use of javafx.beans.property.SimpleObjectProperty in project POL-POM-5 by PhoenicisOrg.
the class LibraryFeaturePanelSkin method createContent.
/**
* {@inheritDoc}
*/
@Override
public ObjectExpression<Node> createContent() {
final CombinedListWidget<ShortcutDTO> combinedListWidget = createCombinedListWidget();
final Tab installedApplicationsTab = new Tab(tr("My applications"), combinedListWidget);
installedApplicationsTab.setClosable(false);
final TabPane container = new TabPane();
container.getStyleClass().add("rightPane");
getControl().selectedTabProperty().addListener((Observable invalidation) -> {
final Tab selectedTab = getControl().getSelectedTab();
if (selectedTab != null) {
container.getSelectionModel().select(selectedTab);
} else {
container.getSelectionModel().selectFirst();
}
});
container.getSelectionModel().selectedItemProperty().addListener((Observable invalidation) -> getControl().setSelectedTab(container.getSelectionModel().getSelectedItem()));
Bindings.bindContentBidirectional(container.getTabs(), getControl().getTabs());
container.getTabs().add(installedApplicationsTab);
return new SimpleObjectProperty<>(container);
}
use of javafx.beans.property.SimpleObjectProperty in project Gargoyle by callakrsos.
the class DialogUtil method showInputDialog.
public static Optional<Pair<String, String>> showInputDialog(Window owner, String title, String message, String inputValue, Predicate<String> satisfied) {
BaseDialogComposite composite = new BaseDialogComposite(title, message);
Button btnOk = new Button("OK");
btnOk.setMinWidth(80d);
Button btnCancel = new Button("Cancel");
btnCancel.setMinWidth(80d);
composite.addButton(btnOk);
composite.addButton(btnCancel);
TextField text = new TextField();
composite.setGraphic(text);
Optional<Pair<String, String>> empty = Optional.empty();
SimpleObjectProperty<Optional<Pair<String, String>>> prop = new SimpleObjectProperty<>(empty);
// Modal
composite.show(owner, stage -> {
stage.initModality(Modality.APPLICATION_MODAL);
text.requestFocus();
text.addEventHandler(KeyEvent.KEY_RELEASED, ev -> {
if (ev.getCode() == KeyCode.ENTER) {
Optional<Pair<String, String>> pair = Optional.of(new Pair<>("OK", text.getText()));
prop.set(pair);
if (satisfied != null) {
if (satisfied.test(text.getText())) {
stage.close();
}
}
} else {
if (satisfied != null) {
if (satisfied.test(text.getText())) {
btnOk.setDisable(false);
} else
btnOk.setDisable(true);
}
}
});
btnOk.addEventHandler(MouseEvent.MOUSE_CLICKED, ev -> {
Optional<Pair<String, String>> pair = Optional.of(new Pair<>("OK", text.getText()));
prop.set(pair);
stage.close();
});
btnCancel.addEventHandler(MouseEvent.MOUSE_CLICKED, ev -> {
stage.close();
});
});
return prop.get();
// Create the custom dialog.
// Dialog<Pair<String, String>> dialog = new Dialog<>();
// dialog.setTitle(title);
// dialog.setHeaderText(message);
// TextField text = new TextField();
// text.setFocusTraversable(true);
//
// dialog.setGraphic(text);
// text.requestFocus();
//
// // Set the button types.
// ButtonType okBtn = new ButtonType("OK", ButtonData.OK_DONE);
//
// dialog.getDialogPane().getButtonTypes().add(okBtn);
//
// dialog.setResultConverter(dialogButton -> {
// if (dialogButton == okBtn) {
// return new Pair<>("OK", text.getText());
// } else {
// return null;
// }
// });
//
// if (inputValue != null && inputValue != "") {
// text.setText(inputValue);
// }
//
// dialog.initModality(Modality.APPLICATION_MODAL);
// dialog.initOwner(owner);
// dialog.getGraphic().requestFocus();
// // dialog.initModality(Modality.APPLICATION_MODAL);
// // graphic.setFocusTraversable(true);
//
// Optional<Pair<String, String>> result = dialog.showAndWait();
//
// result.ifPresent(consumer);
//
// return result;
}
use of javafx.beans.property.SimpleObjectProperty in project Gargoyle by callakrsos.
the class DialogUtil method showInputCustomDialog.
/**
* Graphics 부분을 커스텀 처리할 수 있는 InputDialog
*
* @작성자 : KYJ
* @작성일 : 2016. 10. 21.
* @param owner
* @param title
* @param message
* @param customGrahics
* @return
*/
public static <T extends Node, V> Optional<Pair<String, V>> showInputCustomDialog(Window owner, String title, String message, CustomInputDialogAction<T, V> customGrahics) {
BaseDialogComposite composite = new BaseDialogComposite(title, message);
Button btnOk = new Button("OK");
btnOk.setMinWidth(80d);
Button btnCancel = new Button("Cancel");
btnCancel.setMinWidth(80d);
composite.addButton(btnOk);
composite.addButton(btnCancel);
Optional<Pair<String, V>> empty = Optional.empty();
SimpleObjectProperty<Optional<Pair<String, V>>> prop = new SimpleObjectProperty<>(empty);
T node = customGrahics.getNode();
composite.setGraphic(node);
// Modal
composite.show(owner, stage -> {
stage.initModality(Modality.APPLICATION_MODAL);
stage.initStyle(StageStyle.UTILITY);
node.requestFocus();
stage.addEventHandler(KeyEvent.KEY_PRESSED, ev -> {
if (ev.getCode() == KeyCode.ENTER) {
Optional<Pair<String, V>> pair = Optional.of(new Pair<>("OK", customGrahics.okClickValue()));
prop.set(pair);
stage.close();
}
});
btnOk.addEventHandler(MouseEvent.MOUSE_CLICKED, ev -> {
Optional<Pair<String, V>> pair = Optional.of(new Pair<>("OK", customGrahics.okClickValue()));
prop.set(pair);
stage.close();
});
btnCancel.addEventHandler(MouseEvent.MOUSE_CLICKED, ev -> {
Optional<Pair<String, V>> pair = Optional.of(new Pair<>("Cancel", customGrahics.cancelClickValue()));
prop.set(pair);
stage.close();
});
});
return prop.get();
}
use of javafx.beans.property.SimpleObjectProperty in project Gargoyle by callakrsos.
the class DatabaseUrlManagementView method initialize.
@SuppressWarnings({ "rawtypes", "unchecked" })
@FXML
public void initialize() {
// /tbDatabase.getSelectionModel().setSelectionMode(SelectionMode.SINGLE);
colKey.setCellValueFactory(param -> {
Object object = param.getValue().get("seqNum");
return new SimpleObjectProperty<>(object);
});
String property = ResourceLoader.getInstance().get(ResourceLoader.DBMS_SUPPORT);
// 사용되지않은 코드
// String colOrder =
// ResourceLoader.getInstance().get(ResourceLoader.DATABASE_COLUMN_ORDER);
// 2015.11.30 데이터에 []코드를 삭제하면서 아래 코드존재가 불필요해서 주석
// 오류가 발생하여 임시 처리.
// if (colOrder != null) {
// colOrder = colOrder.replace("[", "");
// colOrder = colOrder.replace("]", "");
// }
List<Code> dbms = Stream.of(StringUtils.tokenizeToStringArray(property, ",")).map(t -> new Code(t, t)).collect(Collectors.toList());
colDbms = new ComboBoxTableColumn<>("dbms", FXCollections.observableArrayList(dbms), "code", "codeNm");
tbDatabase.getColumns().add(1, colDbms);
tbDatabase.getColumns().get(1).setText("DBMS");
tbDatabase.getColumns().get(1).setId("colDbms");
colColor = new ColorPickerTableColumn<Map<String, Object>>(colColor, "color");
colColor.setMaxWidth(50);
tbDatabase.getColumns().add(1, colColor);
tbDatabase.getColumns().get(1).setText("Color");
tbDatabase.getColumns().get(1).setId("colColor");
/*********************************************************/
// 파일 DagDrop 이벤트. URL에 새 데이터 add.
tbDatabase.setOnDragDropped(ev -> {
if (ev.getDragboard().hasFiles()) {
List<File> files = ev.getDragboard().getFiles();
files.stream().map(v -> {
return v.getAbsolutePath();
}).forEach(str -> {
Map<String, Object> map = new HashMap<String, Object>();
map.put(ResourceLoader.BASE_KEY_JDBC_URL, str);
tbDatabase.getItems().add(map);
});
ev.setDropCompleted(true);
ev.consume();
}
});
tbDatabase.setOnDragOver(ev -> {
if (ev.getDragboard().hasFiles()) {
ev.acceptTransferModes(TransferMode.LINK);
ev.consume();
}
});
/*********************************************************/
colPopup = new ButtonTableColumn() {
@Override
public void clickHandle(int nRow) {
try {
showSqlPane(nRow);
} catch (Exception e) {
DialogUtil.showExceptionDailog(e);
LOGGER.error(ValueUtil.toString(e));
}
}
};
colPing = new ButtonTableColumn("Ping") {
@Override
public void clickHandle(int nRow) {
try {
ping(nRow);
} catch (Exception e) {
DialogUtil.showExceptionDailog(e);
LOGGER.error(ValueUtil.toString(e));
}
}
};
colPopup.setMaxWidth(50);
tbDatabase.getColumns().add(1, colPopup);
tbDatabase.getColumns().get(1).setText("Popup");
tbDatabase.getColumns().get(1).setId("colPopup");
tbDatabase.getColumns().add(colPing);
setColumnText(colAlias, "alias");
colUrl.setPrefWidth(300);
setColumnText(colUrl, ResourceLoader.BASE_KEY_JDBC_URL);
setColumnText(colUserName, ResourceLoader.BASE_KEY_JDBC_ID);
setColumnText(colUserPassword, ResourceLoader.BASE_KEY_JDBC_PASS, param -> new PasswordTextFieldTableCell());
// colUserPassword.setCellValueFactory(param -> {
// Object initialValue =
// param.getValue().get(ResourceLoader.BASE_KEY_JDBC_PASS);
// SimpleObjectProperty<Object> simpleObjectProperty = new
// SimpleObjectProperty<>(initialValue);
// simpleObjectProperty.addListener((oba, oldval, newval) ->
// param.getValue().put(ResourceLoader.BASE_KEY_JDBC_PASS, newval));
// return simpleObjectProperty;
// });
// colUserPassword.setCellFactory(param -> new
// PasswordTextFieldTableCell());
observableArrayList = loadResource();
tbDatabase.getItems().addAll(observableArrayList);
}
use of javafx.beans.property.SimpleObjectProperty in project Gargoyle by callakrsos.
the class EditableTableView method readByTableName.
private void readByTableName(String sql, String tableName, boolean appendHist) throws Exception {
LOGGER.debug(sql);
getColumns().clear();
getItems().clear();
removedList.clear();
columnMap.clear();
try (Connection connection = connectionSupplier.get()) {
List<String> pks = DbUtil.pks(connection, tableName);
Map<String, Boolean> columnsToMap = DbUtil.columnsToMap(connection, tableName, rs -> {
try {
return rs.getString(4);
} catch (Exception e) {
return null;
}
}, rs -> {
try {
return Boolean.valueOf("YES".equals(rs.getString(18)));
} catch (Exception e) {
return false;
}
});
LOGGER.debug("nullable columns ? {} ", columnsToMap);
DbUtil.select(connection, sql, FETCH_COUNT, LIMIT_ROW_COUNT, new BiFunction<ResultSetMetaData, ResultSet, List<Map<String, Object>>>() {
@Override
public List<Map<String, Object>> apply(ResultSetMetaData t, ResultSet u) {
try {
int columnCount = t.getColumnCount();
for (int i = 1; i <= columnCount; i++) {
String columnName = t.getColumnName(i);
ColumnExpression columnExp = new ColumnExpression(columnName);
columnExp.isPrimaryColumn = pks.contains(columnName);
columnExp.isNullableColumn = columnsToMap.containsKey(columnName) && (columnsToMap.get(columnName) == true);
columnExp.setColumnType(t.getColumnType(i));
TableColumn<Map<ColumnExpression, ObjectProperty<ValueExpression>>, ValueExpression> e = new TableColumn<>(columnName);
e.setUserData(columnExp);
e.setCellValueFactory(DynamicCallback.fromTableColumn(columnExp));
e.setCellFactory(DEFAULT_CELL_FACTORY);
e.setEditable(true);
columnMap.put(columnName, columnExp);
getColumns().add(e);
}
while (u.next()) {
Map<ColumnExpression, ObjectProperty<ValueExpression>> hashMap = new HashMap<>();
for (int i = 1; i <= columnCount; i++) {
String columnName = t.getColumnName(i);
//new ColumnExpression(columnName);
ColumnExpression columnExp = columnMap.get(columnName);
ValueExpression valueExp = new ValueExpression();
valueExp.displayText.set(u.getString(columnName));
valueExp.isPrimaryKey = pks.contains(columnName);
valueExp.realValue.set(u.getObject(columnName));
valueExp.setColumnExpression(columnExp);
hashMap.put(columnExp, new SimpleObjectProperty<>(valueExp));
}
getItems().removeListener(itemChangeListener);
getItems().add(hashMap);
getItems().addListener(itemChangeListener);
}
} catch (SQLException e) {
LOGGER.error(ValueUtil.toString(e));
}
return null;
}
});
if (appendHist) {
if (history.size() >= HISTORY_LIMITED_SIZE) {
history.removeFirst();
}
history.add(sql);
}
this.tableName.set(tableName);
}
}
Aggregations