use of javafx.event.ActionEvent in project Gargoyle by callakrsos.
the class SqlMultiplePane method applySelectScript.
/**
* 테이블의 SELECT문을 리턴.
*
* @param e
*/
public void applySelectScript(ActionEvent e) {
TreeItem<K> selectedItem = schemaTree.getSelectionModel().getSelectedItem();
String tableName = this.getSelectedTreeByTableName(selectedItem);
SqlTab selectedTab = getSelectedSqlTab();
TreeItem<K> schemaTreeItem = selectedItem.getParent();
String schema = schemaTreeItem.getValue().toString();
Connection connection = connectionSupplier.get();
try {
String driver = DbUtil.getDriverNameByConnection(connection);
String sql = ConfigResourceLoader.getInstance().get(ConfigResourceLoader.SQL_TABLE_COLUMNS_WRAPPER, driver);
Map<String, Object> map = new HashMap<>(2);
map.put("databaseName", schema);
map.put("tableName", tableName);
sql = ValueUtil.getVelocityToText(sql, map, true);
List<String> select = DbUtil.select(connection, sql, 10, (RowMapper<String>) (rs, rowNum) -> rs.getString(1));
redueceAction(select, ",", v -> selectedTab.appendTextSql(String.format("select %s \nfrom %s ", v.substring(0, v.length()), tableName)));
} catch (Exception e1) {
LOGGER.error(ValueUtil.toString(e1));
}
}
use of javafx.event.ActionEvent in project Gargoyle by callakrsos.
the class CommonsSqllPan method menuExportInsertScriptOnAction.
@Override
public void menuExportInsertScriptOnAction(ActionEvent e) {
Optional<Pair<String, String[]>> showTableInputDialog = showTableInputDialog(f -> f.getName());
// Optional<Pair<String, String>> showInputDialog = 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);
} else {
tableName = _tableName;
}
List<Map<String, Object>> items = getSelectedTabResultItems();
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 -> {
});
});
}
use of javafx.event.ActionEvent in project Gargoyle by callakrsos.
the class DaoWizardViewController method menuToVoEditorOnAction.
/********************************
* 작성일 : 2016. 2. 27. 작성자 : KYJ
*
* 내용 : VO에티터로 결과내용을 전달처리한다.
*******************************/
public void menuToVoEditorOnAction(ActionEvent e) {
ObservableList<TbpSysDaoColumnsDVO> items = tbMappings.getItems();
if (items.isEmpty())
return;
DatabaseTypeMappingFunction typeConverter = new DatabaseTypeMappingFunction();
try {
FXMLLoader loader = FxUtil.createNewFxmlLoader();
loader.setLocation(getClass().getResource("VoEditorView.fxml"));
BorderPane root = loader.load();
VoEditorController controller = loader.getController();
List<TableModelDVO> resultItems = items.stream().map(m -> {
TableModelDVO dvo = new TableModelDVO();
dvo.setName(ValueUtil.getPrefixLowerTextMyEdit(m.getColumnName()));
String programType = m.getProgramType();
if (programType == null || programType.isEmpty()) {
programType = typeConverter.apply(m.getColumnType());
}
dvo.setType(programType);
return dvo;
}).collect(Collectors.toList());
controller.addItem(resultItems);
SharedMemory.getSystemLayoutViewController().loadNewSystemTab("New VO", root);
} catch (IOException e1) {
LOGGER.error(ValueUtil.toString(e1));
}
}
use of javafx.event.ActionEvent in project bitsquare by bitsquare.
the class CandleStickChart method dataItemRemoved.
@Override
protected void dataItemRemoved(XYChart.Data<Number, Number> item, XYChart.Series<Number, Number> series) {
if (series.getNode() instanceof Path) {
Path seriesPath = (Path) series.getNode();
seriesPath.getElements().clear();
}
final Node node = item.getNode();
if (shouldAnimate()) {
// fade out old candle
FadeTransition ft = new FadeTransition(Duration.millis(500), node);
ft.setToValue(0);
ft.setOnFinished((ActionEvent actionEvent) -> {
getPlotChildren().remove(node);
});
ft.play();
} else {
getPlotChildren().remove(node);
}
}
use of javafx.event.ActionEvent in project bitsquare by bitsquare.
the class VolumeChart method dataItemRemoved.
@Override
protected void dataItemRemoved(XYChart.Data<Number, Number> item, XYChart.Series<Number, Number> series) {
final Node node = item.getNode();
if (shouldAnimate()) {
FadeTransition ft = new FadeTransition(Duration.millis(500), node);
ft.setToValue(0);
ft.setOnFinished((ActionEvent actionEvent) -> getPlotChildren().remove(node));
ft.play();
} else {
getPlotChildren().remove(node);
}
}
Aggregations