use of javafx.collections.ObservableList in project Gargoyle by callakrsos.
the class CrudBaseColumnMapper method commboBox.
private CommboBoxTableColumn<T, Object> commboBox(Class<?> classType, String columnName, IOptions naming) {
CommboInfo<?> comboBox = naming.comboBox(columnName);
ObservableList codeList = (ObservableList) comboBox.getCodeList();
String code = comboBox.getCode();
String codeNm = comboBox.getCodeNm();
Supplier<ChoiceBoxTableCell<T, Object>> supplier = () -> {
ChoiceBoxTableCell<T, Object> choiceBoxTableCell = new ChoiceBoxTableCell<T, Object>(codeList) {
@Override
public void startEdit() {
Object vo = tableViewProperty().get().getItems().get(super.getIndex());
if (vo instanceof AbstractDVO) {
AbstractDVO _abstractvo = (AbstractDVO) vo;
if (Objects.equals(CommonConst._STATUS_CREATE, _abstractvo.get_status())) {
boolean editable = naming.editable(columnName);
if (!editable)
return;
super.startEdit();
} else if (Objects.equals(CommonConst._STATUS_UPDATE, _abstractvo.get_status())) {
boolean editable = naming.editable(columnName);
if (!editable)
return;
NonEditable annotationClass = getAnnotationClass(_abstractvo.getClass(), NonEditable.class, columnName);
if (annotationClass != null) {
LOGGER.debug("non start Edit");
} else {
super.startEdit();
LOGGER.debug("start Edit");
}
}
}
}
};
EventDispatcher originalDispatcher = choiceBoxTableCell.getEventDispatcher();
choiceBoxTableCell.setEventDispatcher((event, tail) -> {
return choiceBoxTableCellCellEventDispatcher(choiceBoxTableCell, originalDispatcher, event, tail);
});
// 아직까지는 codeList가 쓰일일이 없어서 주석처리함.. 과연 필요한 케이스가 생길지...?
choiceBoxTableCell.setConverter(new CommboBoxStringConverter<Object>(/* codeList, */
code, codeNm));
return choiceBoxTableCell;
};
CommboBoxTableColumn<T, Object> combobox = new CommboBoxTableColumn<T, Object>(supplier, columnName, codeList, code, codeNm);
return combobox;
}
use of javafx.collections.ObservableList 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.collections.ObservableList 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.collections.ObservableList 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.collections.ObservableList in project Gargoyle by callakrsos.
the class LogViewController method onAfter.
@FxPostInitialize
public void onAfter() throws IOException {
File monitoringFile = composite.getMonitoringFile();
fileChannel = FileChannel.open(monitoringFile.toPath(), StandardOpenOption.READ);
buffer = ByteBuffer.allocate(seekSize);
String encoding = ResourceLoader.loadCharset();
if (Charset.isSupported(encoding)) {
charset.set(Charset.forName(encoding));
} else {
LOGGER.info("does not supported encoding {} , default utf-8 setting. ", encoding);
encoding = "UTF-8";
charset.set(Charset.forName(encoding));
}
//설정에 저장된 인코딩셋을 불러와 디폴트로 선택되게함.
ObservableList<Toggle> toggles = ENCODING.getToggles();
toggles.stream().map(tg -> {
if (tg instanceof RadioMenuItem) {
RadioMenuItem r = (RadioMenuItem) tg;
if (r.getText().toUpperCase().equals(charset.get().name().toUpperCase())) {
return r;
}
}
return null;
}).filter(v -> v != null).findFirst().ifPresent(rmi -> {
rmi.setSelected(true);
});
//캐릭터셋이 변경될때 환경변수에 등록하는 과정
this.charset.addListener((oba, o, newCharset) -> {
String name = newCharset.name();
if (ValueUtil.isEmpty(name)) {
return;
}
ResourceLoader.saveCharset(name);
});
}
Aggregations