use of javafx.event.ActionEvent in project Gargoyle by callakrsos.
the class CodeAreaHelper method codeAreaKeyClick.
/**
* 키클릭 이벤트 처리
*
* @작성자 : KYJ
* @작성일 : 2015. 12. 14.
* @param e
*/
public void codeAreaKeyClick(KeyEvent e) {
//CTRL + F
if (KeyCode.F == e.getCode() && e.isControlDown() && !e.isShiftDown() && !e.isAltDown()) {
if (!e.isConsumed()) {
findAndReplaceHelper.findReplaceEvent(new ActionEvent());
e.consume();
}
} else //CTRL + L
if (KeyCode.L == e.getCode() && e.isControlDown() && !e.isShiftDown() && !e.isAltDown()) {
if (!e.isConsumed()) {
moveToLineEvent(new ActionEvent());
e.consume();
}
} else // CTRL + U
if (KeyCode.U == e.getCode() && e.isControlDown() && e.isShiftDown() && !e.isAltDown()) {
if (!e.isConsumed()) {
toUppercaseEvent(new ActionEvent());
e.consume();
}
} else //CTRL + L
if (KeyCode.L == e.getCode() && e.isControlDown() && e.isShiftDown() && !e.isAltDown()) {
if (!e.isConsumed()) {
toLowercaseEvent(new ActionEvent());
e.consume();
}
} else //Tab
if (e.getCode() == KeyCode.TAB && (!e.isControlDown() && !e.isShiftDown())) {
if (e.isConsumed())
return;
String selectedText = codeArea.getSelectedText();
IndexRange selection = codeArea.getSelection();
int start = selection.getStart();
if (ValueUtil.isEmpty(selectedText))
return;
String tabbing = ValueUtil.tapping(selectedText);
replaceSelection(tabbing);
IndexRange selection2 = codeArea.getSelection();
int end = selection2.getEnd();
codeArea.selectRange(start, end);
e.consume();
} else //Shift + Tab
if (e.getCode() == KeyCode.TAB && (!e.isControlDown() && e.isShiftDown())) {
if (e.isConsumed())
return;
String selectedText = codeArea.getSelectedText();
IndexRange selection = codeArea.getSelection();
if (selection.getStart() == selection.getEnd()) {
codeArea.selectLine();
selectedText = codeArea.getSelectedText();
selection = codeArea.getSelection();
String tabbing = ValueUtil.reverseTapping(selectedText);
replaceSelection(tabbing);
codeArea.selectRange(selection.getStart(), selection.getStart());
} else {
String tabbing = ValueUtil.reverseTapping(selectedText);
replaceSelection(tabbing);
codeArea.selectRange(selection.getStart(), selection.getEnd());
}
e.consume();
} else //////////////////////////////////////////////////////////////////////////////////////
{
codeArea.getUndoManager().mark();
}
}
use of javafx.event.ActionEvent in project Gargoyle by callakrsos.
the class SqlPane method menuExportJsonOnAction.
/**
* Export JSON Script.
*
* @작성자 : KYJ
* @작성일 : 2016. 6. 13.
* @param e
*/
public void menuExportJsonOnAction(ActionEvent e) {
ObservableList<Map<String, Object>> items = tbResult.getItems();
if (items.isEmpty())
return;
Map<String, Object> map = items.get(0);
if (map == null)
return;
// 클립보드 복사
StringBuilder clip = new StringBuilder();
List<String> valueList = items.stream().map(v -> {
return ValueUtil.toJSONString(v);
}).collect(Collectors.toList());
valueList.forEach(str -> {
clip.append(str).append(System.lineSeparator());
});
try {
SimpleTextView parent = new SimpleTextView(clip.toString());
parent.setWrapText(false);
FxUtil.createStageAndShow(parent, stage -> {
});
} catch (Exception e1) {
LOGGER.error(ValueUtil.toString(e1));
}
}
use of javafx.event.ActionEvent 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...");
}
use of javafx.event.ActionEvent 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 -> {
});
});
}
use of javafx.event.ActionEvent in project Gargoyle by callakrsos.
the class SystemLayoutViewController method treeProjectFileOnKeyPressed.
/********************************
* 작성일 : 2016. 6. 11. 작성자 : KYJ
*
* 트리 키 클릭 이벤트
*
* @param event
********************************/
public void treeProjectFileOnKeyPressed(KeyEvent event) {
if (event.getCode() == KeyCode.R && event.isControlDown() && event.isShiftDown() && !event.isAltDown()) {
try {
GagoyleWorkspaceOpenResourceView resourceView = new GagoyleWorkspaceOpenResourceView();
ResultDialog<File> show = resourceView.show();
File data = show.getData();
if (data != null && data.exists()) {
TreeItem<FileWrapper> search = search(data);
treeProjectFile.getSelectionModel().select(search);
treeProjectFile.getFocusModel().focus(treeProjectFile.getSelectionModel().getSelectedIndex());
treeProjectFile.scrollTo(treeProjectFile.getSelectionModel().getSelectedIndex());
openFile(data);
}
} catch (Exception e) {
LOGGER.error(ValueUtil.toString(e));
}
} else if (event.getCode() == KeyCode.DELETE && !event.isControlDown() && !event.isShiftDown() && !event.isAltDown()) {
//이벤트 발생시킴.
ActionEvent.fireEvent(tail -> tail.append((event1, tail1) -> {
deleteFileMenuItemOnAction((ActionEvent) event1);
return event1;
}), new ActionEvent());
} else if (KeyCode.F5 == event.getCode()) {
TreeItem<FileWrapper> selectedItem = treeProjectFile.getSelectionModel().getSelectedItem();
if (selectedItem != null)
refleshWorkspaceTreeItem(selectedItem);
}
}
Aggregations