Search in sources :

Example 1 with Pair

use of javafx.util.Pair in project Gargoyle by callakrsos.

the class SystemLayoutViewController method newDirOnAction.

/********************************
	 * 작성일 : 2016. 8. 29. 작성자 : KYJ
	 *
	 * 디렉토리를 새로 생성한다.
	 *
	 * @param e
	 ********************************/
public void newDirOnAction(ActionEvent e) {
    TreeItem<FileWrapper> selectedItem = treeProjectFile.getSelectionModel().getSelectedItem();
    if (selectedItem != null) {
        FileWrapper value = selectedItem.getValue();
        File file = value.getFile();
        if (file.isDirectory()) {
            Optional<Pair<String, String>> showInputDialog = DialogUtil.showInputDialog("Directory Name", "Input New Dir Name");
            showInputDialog.ifPresent(v -> {
                String newFileName = v.getValue();
                File createdNewFile = new File(file, newFileName);
                boolean mkdir = createdNewFile.mkdir();
                if (mkdir) {
                    TreeItem<FileWrapper> createDefaultNode = projectFileTreeCreator.createDefaultNode(new FileWrapper(createdNewFile));
                    createDefaultNode.setExpanded(true);
                    selectedItem.getChildren().add(createDefaultNode);
                }
            });
        }
    }
}
Also used : FileWrapper(com.kyj.fx.voeditor.visual.component.FileWrapper) File(java.io.File) Pair(javafx.util.Pair)

Example 2 with Pair

use of javafx.util.Pair in project Gargoyle by callakrsos.

the class VoEditorController method btnGenerateOnMouseClick.

/********************************
	 * 작성일 : 2016. 6. 6. 작성자 : KYJ
	 *
	 * 생성 마우스 클릭
	 *
	 * @param me
	 ********************************/
public void btnGenerateOnMouseClick(MouseEvent me) {
    try {
        checkValidation();
        String className = txtClassName.getText();
        String location = txtLocation.getText();
        String packageName = txtPackageName.getText();
        String extendsBaseClass = ConfigResourceLoader.getInstance().get(ConfigResourceLoader.VOEDITOR_DEFAULT_EXTENDS_CLASS);
        ObservableList<TableModelDVO> items = tbVoEditor.getItems();
        ClassMeta classMeta = EditorUtil.extractedClassMeta(className, packageName, extendsBaseClass);
        VoEditorConverter converter = new VoEditorConverter(classMeta, items);
        VoEditor voEditor = converter.convert();
        if (location != null && !location.isEmpty()) {
            Optional<Pair<String, String>> showYesOrNoDialog = DialogUtil.showYesOrNoDialog("파일생성여부", "파일도 만드시겠습니까? ");
            showYesOrNoDialog.ifPresent(string -> {
                if ("Y".equals(string.getValue())) {
                    try {
                        voEditor.toFile(location);
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            });
        }
        JavaTextView simpleTextView = new JavaTextView(voEditor.toText());
        simpleTextView.show();
    } catch (Exception e) {
        DialogUtil.showExceptionDailog(e);
        return;
    }
}
Also used : VoEditorConverter(com.kyj.fx.voeditor.visual.util.VoEditorConverter) JavaTextView(com.kyj.fx.voeditor.visual.component.popup.JavaTextView) ClassMeta(com.kyj.fx.voeditor.core.model.meta.ClassMeta) TableModelDVO(kyj.Fx.dao.wizard.core.model.vo.TableModelDVO) FileNotFoundException(java.io.FileNotFoundException) GargoyleFileAlreadyExistException(com.kyj.fx.voeditor.visual.exceptions.GargoyleFileAlreadyExistException) ParseException(com.github.javaparser.ParseException) IOException(java.io.IOException) VoEditor(com.kyj.fx.voeditor.core.VoEditor) Pair(javafx.util.Pair)

Example 3 with Pair

use of javafx.util.Pair in project Gargoyle by callakrsos.

the class DaoWizardViewController method btnGenerateOnMouseClick.

/**
	 * DAO Wizard 생성 버튼 이벤트
	 *
	 * @작성자 : KYJ
	 * @작성일 : 2015. 10. 28.
	 */
@FXML
public void btnGenerateOnMouseClick(MouseEvent event) {
    try {
        int checkValidation = checkValidation();
        String className = txtClassName.getText();
        String location = txtDaoLocation.getText();
        String packageName = txtPackageName.getText();
        String desc = txtAreaDaoDesc.getText();
        // 저장처리전 검증 및 위자드로 한번 확인
        String extendsBaseClass = ConfigResourceLoader.getInstance().get(ConfigResourceLoader.DAO_WIZARD_DEFAULT_EXTENDS_CLASS);
        ClassMeta classMeta = EditorUtil.extractedClassMeta(className, packageName, extendsBaseClass);
        classMeta.setDesc(desc);
        // TbmSysDaoDVO tbmSysDaoDVO = tbmSysDaoDVOProperty.get();
        // tbmSysDaoDVO.setClassName(className);
        // tbmSysDaoDVO.setLocation(location);
        // tbmSysDaoDVO.setPackageName(packageName);
        // tbmSysDaoDVO.setDesc(desc);
        // tbmSysDaoDVO.setExtendClassNameStr(extendsBaseClass);
        DaoWizardConverter converter = new DaoWizardConverter(classMeta, tbmSysDaoDVOProperty.get());
        converter.createWizard(Wizardtype.meerkatbase);
        DaoWizard<ClassMeta, TbpSysDaoMethodsDVO, FieldMeta> daowizard = converter.convert();
        if (location != null && !location.isEmpty()) {
            Optional<Pair<String, String>> showYesOrNoDialog = DialogUtil.showYesOrNoDialog("파일생성여부", "파일도 만드시겠습니까? ");
            showYesOrNoDialog.ifPresent(string -> {
                if ("Y".equals(string.getValue())) {
                    try {
                        daowizard.toFile(ValueUtil.appendBaseDir(location));
                    } catch (Exception e) {
                        DialogUtil.showExceptionDailog(e);
                    }
                }
            });
        }
        // 위의 검증작업에서 이상없을시 데이터베이스 저장작업
        if (checkValidation == MESSAGE_CODES.indexOf(MSG_NOMAL)) {
            JavaTextView simpleTextView = new JavaTextView(daowizard.toText());
            simpleTextView.show();
            Optional<Pair<String, String>> showYesOrNoDialog = DialogUtil.showYesOrNoDialog(MESSAGE_CODES.get(checkValidation), "Code : [" + checkValidation + "]\n" + MESSAGE_CODES.get(checkValidation) + "\nDo you want save. ?");
            showYesOrNoDialog.ifPresent(option -> {
                if ("Y".equals(option.getValue())) {
                    TbmSysDaoDVO saveTbmSysDaoDVO = this.tbmSysDaoDVOProperty.get();
                    saveTbmSysDaoDVO.setClassName(className);
                    saveTbmSysDaoDVO.setLocation(location);
                    saveTbmSysDaoDVO.setPackageName(packageName);
                    saveTbmSysDaoDVO.setClassDesc(desc);
                    saveTbmSysDaoDVO.setExtendsClassName(extendsBaseClass);
                    save(saveTbmSysDaoDVO);
                }
            });
        } else {
            DialogUtil.showMessageDialog("Error Code[" + checkValidation + "]\n" + MESSAGE_CODES.get(checkValidation));
        }
    // if (checkValidation == MESSAGE_CODES.indexOf(MSG_NOMAL)) {
    //
    // } else {
    // DialogUtil.showMessageDialog(MESSAGE_CODES.get(checkValidation));
    // }
    } catch (Exception e) {
        DialogUtil.showExceptionDailog(e, e.getMessage());
    }
}
Also used : TbpSysDaoMethodsDVO(kyj.Fx.dao.wizard.core.model.vo.TbpSysDaoMethodsDVO) TbmSysDaoDVO(kyj.Fx.dao.wizard.core.model.vo.TbmSysDaoDVO) DaoWizardConverter(com.kyj.fx.voeditor.visual.util.DaoWizardConverter) JavaTextView(com.kyj.fx.voeditor.visual.component.popup.JavaTextView) ClassMeta(com.kyj.fx.voeditor.core.model.meta.ClassMeta) FieldMeta(com.kyj.fx.voeditor.core.model.meta.FieldMeta) IOException(java.io.IOException) Pair(javafx.util.Pair) FXML(javafx.fxml.FXML)

Example 4 with Pair

use of javafx.util.Pair in project Gargoyle by callakrsos.

the class SqlPane method menuExportExcelOnAction.

/**
	 * Excel Export.
	 *
	 * @param e
	 */
public void menuExportExcelOnAction(ActionEvent e) {
    File saveFile = DialogUtil.showFileSaveDialog(SharedMemory.getPrimaryStage().getOwner(), option -> {
        option.setInitialFileName(DateUtil.getCurrentDateString(DateUtil.SYSTEM_DATEFORMAT_YYYYMMDDHHMMSS));
        option.getExtensionFilters().add(new ExtensionFilter("Excel files (*.xlsx)", "*.xlsx"));
        option.getExtensionFilters().add(new ExtensionFilter("Excel files (*.xls)", "*.xls"));
        option.getExtensionFilters().add(new ExtensionFilter("All files", "*.*"));
        option.setTitle("Save Excel");
        option.setInitialDirectory(new File(SystemUtils.USER_HOME));
    });
    if (saveFile == null) {
        return;
    }
    if (saveFile.exists()) {
        Optional<Pair<String, String>> showYesOrNoDialog = DialogUtil.showYesOrNoDialog("overwrite ?? ", FILE_OVERWIRTE_MESSAGE);
        showYesOrNoDialog.ifPresent(consume -> {
            String key = consume.getKey();
            String value = consume.getValue();
            if (!("RESULT".equals(key) && "Y".equals(value))) {
                return;
            }
        });
    }
    ObservableList<Map<String, Object>> items = this.tbResult.getItems();
    ToExcelFileFunction toExcelFileFunction = new ToExcelFileFunction();
    List<String> columns = this.tbResult.getColumns().stream().map(col -> col.getText()).collect(Collectors.toList());
    toExcelFileFunction.generate0(saveFile, columns, items);
    DialogUtil.showMessageDialog("complete...");
}
Also used : SystemLayoutViewController(com.kyj.fx.voeditor.visual.main.layout.SystemLayoutViewController) Arrays(java.util.Arrays) CheckComboBox(org.controlsfx.control.CheckComboBox) Application(javafx.application.Application) TabPane(javafx.scene.control.TabPane) ListChangeListener(javafx.collections.ListChangeListener) MacroControl(com.kyj.fx.voeditor.visual.component.macro.MacroControl) Map(java.util.Map) SQLPaneMotionable(com.kyj.fx.voeditor.visual.component.sql.functions.SQLPaneMotionable) SimpleIntegerProperty(javafx.beans.property.SimpleIntegerProperty) VariableMappingView(com.kyj.fx.voeditor.visual.component.popup.VariableMappingView) DockPane(com.kyj.fx.voeditor.visual.component.dock.pane.DockPane) SystemUtils(org.apache.commons.lang.SystemUtils) Strings(com.sun.btrace.BTraceUtils.Strings) ColumnExpression(com.kyj.fx.voeditor.visual.component.grid.EditableTableView.ColumnExpression) SplitPane(javafx.scene.control.SplitPane) Pair(javafx.util.Pair) EditableTableViewComposite(com.kyj.fx.voeditor.visual.component.grid.EditableTableViewComposite) KeyEvent(javafx.scene.input.KeyEvent) ValueExpression(com.kyj.fx.voeditor.visual.component.grid.EditableTableView.ValueExpression) FxUtil(com.kyj.fx.voeditor.visual.util.FxUtil) ResourceLoader(com.kyj.fx.voeditor.visual.momory.ResourceLoader) CustomInputDialogAction(com.kyj.fx.voeditor.visual.util.DialogUtil.CustomInputDialogAction) ObservableList(javafx.collections.ObservableList) BorderPane(javafx.scene.layout.BorderPane) TitledBorderPane(com.kyj.fx.voeditor.visual.component.TitledBorderPane) TableViewSelectionModel(javafx.scene.control.TableView.TableViewSelectionModel) MouseButton(javafx.scene.input.MouseButton) ASTSqlCodeAreaHelper(com.kyj.fx.voeditor.visual.component.text.ASTSqlCodeAreaHelper) TreeItem(javafx.scene.control.TreeItem) FXCollections(javafx.collections.FXCollections) GagoyleTabProxy(com.kyj.fx.voeditor.visual.main.layout.GagoyleTabProxy) DialogUtil(com.kyj.fx.voeditor.visual.util.DialogUtil) Supplier(java.util.function.Supplier) IntegerProperty(javafx.beans.property.IntegerProperty) ArrayList(java.util.ArrayList) TableItemTree(com.kyj.fx.voeditor.visual.component.sql.dbtree.commons.TableItemTree) Color(javafx.scene.paint.Color) Node(javafx.scene.Node) TableOpenResourceView(com.kyj.fx.voeditor.visual.component.popup.TableOpenResourceView) StringConverter(javafx.util.StringConverter) SchoolMgrerSpreadSheetView(com.kyj.fx.voeditor.visual.main.layout.SchoolMgrerSpreadSheetView) GridPane(jfxtras.scene.layout.GridPane) File(java.io.File) SqlTabPane(com.kyj.fx.voeditor.visual.component.sql.tab.SqlTabPane) Menu(javafx.scene.control.Menu) KeyCodeCombination(javafx.scene.input.KeyCodeCombination) SelectionMode(javafx.scene.control.SelectionMode) TreeMap(java.util.TreeMap) SimpleObjectProperty(javafx.beans.property.SimpleObjectProperty) Tab(javafx.scene.control.Tab) ResultDialog(com.kyj.fx.voeditor.visual.component.ResultDialog) Button(javafx.scene.control.Button) Connection(java.sql.Connection) DbUtil(com.kyj.fx.voeditor.visual.util.DbUtil) LoggerFactory(org.slf4j.LoggerFactory) ToExcelFileFunction(com.kyj.fx.voeditor.visual.functions.ToExcelFileFunction) EncrypUtil(com.kyj.fx.voeditor.visual.util.EncrypUtil) ContextMenu(javafx.scene.control.ContextMenu) WindowEvent(javafx.stage.WindowEvent) TableView(javafx.scene.control.TableView) SqlKeywords(com.kyj.fx.voeditor.visual.component.text.SqlKeywords) Orientation(javafx.geometry.Orientation) HBox(javafx.scene.layout.HBox) TextField(javafx.scene.control.TextField) Main(com.kyj.fx.voeditor.visual.main.Main) MenuItem(javafx.scene.control.MenuItem) SimpleTextView(com.kyj.fx.voeditor.visual.component.text.SimpleTextView) ConfigResourceLoader(com.kyj.fx.voeditor.visual.momory.ConfigResourceLoader) Collectors(java.util.stream.Collectors) TreeView(javafx.scene.control.TreeView) ISchemaTreeItem(com.kyj.fx.voeditor.visual.component.sql.functions.ISchemaTreeItem) SeparatorMenuItem(javafx.scene.control.SeparatorMenuItem) List(java.util.List) SqlTab(com.kyj.fx.voeditor.visual.component.sql.tab.SqlTab) Entry(java.util.Map.Entry) RowMapper(org.springframework.jdbc.core.RowMapper) Optional(java.util.Optional) DateUtil(com.kyj.fx.voeditor.visual.util.DateUtil) MouseEvent(javafx.scene.input.MouseEvent) HashMap(java.util.HashMap) TextFieldTableCell(javafx.scene.control.cell.TextFieldTableCell) Function(java.util.function.Function) BigDataDVO(com.kyj.fx.voeditor.visual.framework.BigDataDVO) TableColumn(javafx.scene.control.TableColumn) Insets(javafx.geometry.Insets) FxCollectors(com.kyj.fx.voeditor.visual.util.FxCollectors) Tooltip(javafx.scene.control.Tooltip) KeyCode(javafx.scene.input.KeyCode) ObjectProperty(javafx.beans.property.ObjectProperty) Modality(javafx.stage.Modality) Logger(org.slf4j.Logger) Label(javafx.scene.control.Label) Iterator(java.util.Iterator) ValueUtil(com.kyj.fx.voeditor.visual.util.ValueUtil) Consumer(java.util.function.Consumer) ActionEvent(javafx.event.ActionEvent) Stage(javafx.stage.Stage) ExtensionFilter(javafx.stage.FileChooser.ExtensionFilter) Collections(java.util.Collections) SharedMemory(com.kyj.fx.voeditor.visual.momory.SharedMemory) ExtensionFilter(javafx.stage.FileChooser.ExtensionFilter) ToExcelFileFunction(com.kyj.fx.voeditor.visual.functions.ToExcelFileFunction) File(java.io.File) Map(java.util.Map) TreeMap(java.util.TreeMap) HashMap(java.util.HashMap) Pair(javafx.util.Pair)

Example 5 with Pair

use of javafx.util.Pair in project Gargoyle by callakrsos.

the class MysqlPane method menuExportInsertScriptOnAction.

@Override
public void menuExportInsertScriptOnAction(ActionEvent e) {
    Optional<Pair<String, String[]>> showTableInputDialog = showTableInputDialog(f -> f.getName());
    // DialogUtil.showInputDialog("table Name", "테이블명을 입력하세요.");
    if (showTableInputDialog == null)
        return;
    showTableInputDialog.ifPresent(op -> {
        if (op == null || op.getValue() == null)
            return;
        String schemaName = op.getValue()[0];
        String _tableName = op.getValue()[1];
        String tableName = "";
        if (ValueUtil.isNotEmpty(schemaName)) {
            tableName = String.format("`%s`.%s", schemaName, _tableName);
        }
        ObservableList<Map<String, Object>> items = getTbResult().getItems();
        Map<String, Object> map = items.get(0);
        final Set<String> keySet = map.keySet();
        StringBuilder clip = new StringBuilder();
        String insertPreffix = "insert into " + tableName;
        String collect = keySet.stream().collect(Collectors.joining(",", "(", ")"));
        String insertMiddle = " values ";
        List<String> valueList = items.stream().map(v -> {
            return ValueUtil.toJSONObject(v);
        }).map(v -> {
            Iterator<String> iterator = keySet.iterator();
            List<Object> values = new ArrayList<>();
            while (iterator.hasNext()) {
                String columnName = iterator.next();
                Object value = v.get(columnName);
                values.add(value);
            }
            return values;
        }).map(list -> {
            return list.stream().map(str -> {
                if (str == null)
                    return null;
                else {
                    String convert = str.toString();
                    convert = convert.substring(1, convert.length() - 1);
                    if (convert.indexOf("'") >= 0) {
                        try {
                            convert = StringUtils.replace(convert, "'", "''");
                        } catch (Exception e1) {
                            e1.printStackTrace();
                        }
                    }
                    return "'".concat(convert).concat("'");
                }
            }).collect(Collectors.joining(",", "(", ")"));
        }).map(str -> {
            return new StringBuilder().append(insertPreffix).append(collect).append(insertMiddle).append(str).append(";\n").toString();
        }).collect(Collectors.toList());
        valueList.forEach(str -> {
            clip.append(str);
        });
        SimpleTextView parent = new SimpleTextView(clip.toString());
        parent.setWrapText(false);
        FxUtil.createStageAndShow(String.format("[InsertScript] Table : %s", tableName), parent, stage -> {
        });
    });
}
Also used : Connection(java.sql.Connection) TreeItem(javafx.scene.control.TreeItem) DialogUtil(com.kyj.fx.voeditor.visual.util.DialogUtil) Supplier(java.util.function.Supplier) StringUtils(org.apache.commons.lang3.StringUtils) ArrayList(java.util.ArrayList) TableItemTree(com.kyj.fx.voeditor.visual.component.sql.dbtree.commons.TableItemTree) Map(java.util.Map) MySQLDatabaseItemTree(com.kyj.fx.voeditor.visual.component.sql.dbtree.mysql.MySQLDatabaseItemTree) Pair(javafx.util.Pair) Iterator(java.util.Iterator) DatabaseTreeNode(com.kyj.fx.voeditor.visual.component.sql.dbtree.DatabaseTreeNode) Set(java.util.Set) ValueUtil(com.kyj.fx.voeditor.visual.util.ValueUtil) SimpleTextView(com.kyj.fx.voeditor.visual.component.text.SimpleTextView) ConfigResourceLoader(com.kyj.fx.voeditor.visual.momory.ConfigResourceLoader) Collectors(java.util.stream.Collectors) FxUtil(com.kyj.fx.voeditor.visual.util.FxUtil) List(java.util.List) ResourceLoader(com.kyj.fx.voeditor.visual.momory.ResourceLoader) ActionEvent(javafx.event.ActionEvent) Stage(javafx.stage.Stage) DatabaseItemTree(com.kyj.fx.voeditor.visual.component.sql.dbtree.commons.DatabaseItemTree) Optional(java.util.Optional) ObservableList(javafx.collections.ObservableList) Iterator(java.util.Iterator) SimpleTextView(com.kyj.fx.voeditor.visual.component.text.SimpleTextView) ArrayList(java.util.ArrayList) List(java.util.List) ObservableList(javafx.collections.ObservableList) Map(java.util.Map) Pair(javafx.util.Pair)

Aggregations

Pair (javafx.util.Pair)49 TextField (javafx.scene.control.TextField)12 Optional (java.util.Optional)11 Label (javafx.scene.control.Label)11 File (java.io.File)10 ArrayList (java.util.ArrayList)10 List (java.util.List)10 TextInputDialog (javafx.scene.control.TextInputDialog)10 Insets (javafx.geometry.Insets)9 Dialog (javafx.scene.control.Dialog)9 GridPane (javafx.scene.layout.GridPane)8 IOException (java.io.IOException)7 Map (java.util.Map)7 Collectors (java.util.stream.Collectors)7 ObservableList (javafx.collections.ObservableList)7 ActionEvent (javafx.event.ActionEvent)7 Node (javafx.scene.Node)7 ButtonType (javafx.scene.control.ButtonType)7 InputDialog (com.kendy.util.InputDialog)6 ResourceLoader (com.kyj.fx.voeditor.visual.momory.ResourceLoader)6