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;
}
});
}
Aggregations