Search in sources :

Example 1 with GridPane

use of jfxtras.scene.layout.GridPane in project Gargoyle by callakrsos.

the class SqlPane method showTableInputDialog.

public Optional<Pair<String, String[]>> showTableInputDialog(Function<K, String> stringConverter) {
    final List<String> schemaList = getSchemaTree().getRoot().getChildren().stream().map(v -> {
        return stringConverter.apply(v.getValue());
    }).collect(Collectors.toList());
    String defaultSchema = "";
    try (Connection con = connectionSupplier.get()) {
        //
        //			String catalog = con.getCatalog();
        //			String schema = con.getSchema();
        //			ResultSet schemas = con.getMetaData().getCatalogs();
        //			if (schemas.next()) {
        //				String string = schemas.getString(1);
        //				System.out.println(string);
        //			}
        Map<String, Object> findOne = DbUtil.findOne(con, "select current_schema() as currentschema");
        if (findOne != null && !findOne.isEmpty()) {
            defaultSchema = ValueUtil.decode(findOne.get("currentschema"), "").toString();
        }
    } catch (Exception e4) {
        LOGGER.error(ValueUtil.toString(e4));
    }
    final String _defaultSchema = defaultSchema;
    if (tbResult.getItems().isEmpty())
        return Optional.empty();
    return DialogUtil.showInputCustomDialog(tbResult.getScene().getWindow(), "table Name", "테이블명을 입력하세요.", new CustomInputDialogAction<GridPane, String[]>() {

        TextField txtSchema;

        TextField txtTable;

        @Override
        public GridPane getNode() {
            GridPane gridPane = new GridPane();
            txtSchema = new TextField();
            txtTable = new TextField();
            FxUtil.installAutoTextFieldBinding(txtSchema, () -> {
                return schemaList;
            });
            FxUtil.installAutoTextFieldBinding(txtTable, () -> {
                return searchPattern(txtSchema.getText(), txtTable.getText()).stream().map(v -> stringConverter.apply(v.getValue())).collect(Collectors.toList());
            });
            txtSchema.setText(_defaultSchema);
            // Default TableName
            TreeItem<K> selectedItem = getSchemaTree().getSelectionModel().getSelectedItem();
            if (null != selectedItem) {
                K value = selectedItem.getValue();
                if (value instanceof TableItemTree) {
                    txtTable.setText(stringConverter.apply(value));
                }
            }
            Label label = new Label("Schema : ");
            Label label2 = new Label("Table : ");
            gridPane.add(label, 0, 0);
            gridPane.add(label2, 1, 0);
            gridPane.add(txtSchema, 0, 1);
            gridPane.add(txtTable, 1, 1);
            return gridPane;
        }

        @Override
        public String[] okClickValue() {
            String schema = txtSchema.getText().trim();
            String table = txtTable.getText().trim();
            String[] okValue = new String[2];
            okValue[0] = schema;
            okValue[1] = table;
            return okValue;
        }

        @Override
        public String[] cancelClickValue() {
            return null;
        }
    });
}
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) TableItemTree(com.kyj.fx.voeditor.visual.component.sql.dbtree.commons.TableItemTree) GridPane(jfxtras.scene.layout.GridPane) TreeItem(javafx.scene.control.TreeItem) ISchemaTreeItem(com.kyj.fx.voeditor.visual.component.sql.functions.ISchemaTreeItem) Connection(java.sql.Connection) Label(javafx.scene.control.Label) TextField(javafx.scene.control.TextField)

Aggregations

ResultDialog (com.kyj.fx.voeditor.visual.component.ResultDialog)1 TitledBorderPane (com.kyj.fx.voeditor.visual.component.TitledBorderPane)1 DockPane (com.kyj.fx.voeditor.visual.component.dock.pane.DockPane)1 ColumnExpression (com.kyj.fx.voeditor.visual.component.grid.EditableTableView.ColumnExpression)1 ValueExpression (com.kyj.fx.voeditor.visual.component.grid.EditableTableView.ValueExpression)1 EditableTableViewComposite (com.kyj.fx.voeditor.visual.component.grid.EditableTableViewComposite)1 MacroControl (com.kyj.fx.voeditor.visual.component.macro.MacroControl)1 TableOpenResourceView (com.kyj.fx.voeditor.visual.component.popup.TableOpenResourceView)1 VariableMappingView (com.kyj.fx.voeditor.visual.component.popup.VariableMappingView)1 TableItemTree (com.kyj.fx.voeditor.visual.component.sql.dbtree.commons.TableItemTree)1 ISchemaTreeItem (com.kyj.fx.voeditor.visual.component.sql.functions.ISchemaTreeItem)1 SQLPaneMotionable (com.kyj.fx.voeditor.visual.component.sql.functions.SQLPaneMotionable)1 SqlTab (com.kyj.fx.voeditor.visual.component.sql.tab.SqlTab)1 SqlTabPane (com.kyj.fx.voeditor.visual.component.sql.tab.SqlTabPane)1 ASTSqlCodeAreaHelper (com.kyj.fx.voeditor.visual.component.text.ASTSqlCodeAreaHelper)1 SimpleTextView (com.kyj.fx.voeditor.visual.component.text.SimpleTextView)1 SqlKeywords (com.kyj.fx.voeditor.visual.component.text.SqlKeywords)1 BigDataDVO (com.kyj.fx.voeditor.visual.framework.BigDataDVO)1 ToExcelFileFunction (com.kyj.fx.voeditor.visual.functions.ToExcelFileFunction)1 Main (com.kyj.fx.voeditor.visual.main.Main)1