use of javafx.beans.property.SimpleStringProperty in project Gargoyle by callakrsos.
the class MacroBaseSkin method start.
/**
* Start 버튼을 클릭하면 결과가 리턴된다. param으로 입력받은 데이터는 textArea에서 적혀져있는 텍스트문자열.
*
* 2016-10-25 Skin클래스안으로 이동처리.
*
* @작성자 : KYJ
* @작성일 : 2016. 10. 25.
* @param tbResult
* @param param
* @throws Exception
*/
public void start(TableView<Map<String, String>> tbResult, String param) throws Exception {
Connection connection = getSkinnable().getConnectionSupplier().get();
tbResult.getItems().clear();
tbResult.getColumns().clear();
// try {
String[] split = param.split(";");
connection.setAutoCommit(false);
try {
for (String sql : split) {
String _sql = sql.trim();
if (_sql.isEmpty())
continue;
boolean dml = DbUtil.isDml(_sql);
if (dml) {
LOGGER.debug("do update : {}", _sql);
DbUtil.update(connection, _sql);
} else {
LOGGER.debug("do select : {}", _sql);
DbUtil.select(connection, _sql, 30, 1000, new BiFunction<ResultSetMetaData, ResultSet, List<Map<String, ObjectProperty<Object>>>>() {
@Override
public List<Map<String, ObjectProperty<Object>>> apply(ResultSetMetaData t, ResultSet rs) {
try {
int columnCount = t.getColumnCount();
for (int i = 1; i <= columnCount; i++) {
String columnName = t.getColumnName(i);
TableColumn<Map<String, String>, String> tbCol = new TableColumn<>(columnName);
tbCol.setCellFactory(new Callback<TableColumn<Map<String, String>, String>, TableCell<Map<String, String>, String>>() {
@Override
public TableCell<Map<String, String>, String> call(TableColumn<Map<String, String>, String> param) {
return new TableCell<Map<String, String>, String>() {
@Override
protected void updateItem(String item, boolean empty) {
super.updateItem(item, empty);
if (empty) {
setGraphic(null);
} else {
setGraphic(new Label(item));
}
}
};
}
});
tbCol.setCellValueFactory(param -> {
return new SimpleStringProperty(param.getValue().get(columnName));
});
tbResult.getColumns().add(tbCol);
}
while (rs.next()) {
Map<String, String> hashMap = new HashMap<>();
for (int i = 1; i <= columnCount; i++) {
String columnName = t.getColumnName(i);
String value = rs.getString(columnName);
hashMap.put(columnName, value);
}
tbResult.getItems().add(hashMap);
}
} catch (SQLException e) {
throw new RuntimeException(e);
}
return Collections.emptyList();
}
});
}
}
connection.commit();
} catch (Exception e) {
connection.rollback();
throw new RuntimeException(e);
} finally {
DbUtil.close(connection);
}
}
use of javafx.beans.property.SimpleStringProperty in project Gargoyle by callakrsos.
the class AbstractTableIndexInformationController method initialize.
/**
* UI 기능 초기화
*
* @작성자 : KYJ
* @작성일 : 2016. 1. 4.
*/
@FXML
public void initialize() {
tcName.setCellValueFactory(param -> {
TableIndexNode value = param.getValue().getValue();
SimpleStringProperty str = new SimpleStringProperty();
if (value instanceof TableIndexLeaf) {
String toString = ((TableIndexLeaf) value).getColumnNane();
str.setValue(toString);
} else {
String constraintName = value.getConstraintName();
str.setValue(constraintName);
}
return str;
});
tcType.setCellValueFactory(param -> {
TableIndexNode value = param.getValue().getValue();
SimpleStringProperty str = new SimpleStringProperty();
if (!(value instanceof TableIndexLeaf)) {
String constraintType = value.getType();
str.setValue(constraintType);
}
return str;
});
tcNoneUnique.setCellValueFactory(param -> {
TableIndexNode value = param.getValue().getValue();
SimpleStringProperty str = new SimpleStringProperty();
if (!(value instanceof TableIndexLeaf)) {
boolean noneUnique = value.isNoneUnique();
str.setValue(noneUnique ? "yes" : "no");
}
return str;
});
}
use of javafx.beans.property.SimpleStringProperty in project bitsquare by bitsquare.
the class BindingTest method start.
@Override
public void start(Stage primaryStage) {
VBox root = new VBox();
root.setSpacing(20);
Label label = new Label();
StringProperty txt = new SimpleStringProperty();
txt.set("-");
label.textProperty().bind(txt);
Button button = new Button("count up");
button.setOnAction(e -> {
txt.set("counter " + counter++);
});
root.getChildren().addAll(label, button);
primaryStage.setScene(new Scene(root, 400, 400));
primaryStage.show();
}
use of javafx.beans.property.SimpleStringProperty in project dolphin-platform by canoo.
the class FXBinderTest method testJavaFXStringUnidirectional.
@Test
public void testJavaFXStringUnidirectional() {
Property<String> stringDolphinProperty = new MockedProperty<>();
StringProperty stringJavaFXProperty = new SimpleStringProperty();
WritableStringValue writableStringValue = new SimpleStringProperty();
stringDolphinProperty.set("Hello");
assertNotEquals(stringJavaFXProperty.get(), "Hello");
Binding binding = FXBinder.bind(stringJavaFXProperty).to(stringDolphinProperty);
assertEquals(stringJavaFXProperty.get(), "Hello");
stringDolphinProperty.set("Hello JavaFX");
assertEquals(stringJavaFXProperty.get(), "Hello JavaFX");
stringDolphinProperty.set(null);
assertEquals(stringJavaFXProperty.get(), null);
binding.unbind();
stringDolphinProperty.set("Hello JavaFX");
assertEquals(stringJavaFXProperty.get(), null);
binding = FXBinder.bind(writableStringValue).to(stringDolphinProperty);
assertEquals(writableStringValue.get(), "Hello JavaFX");
stringDolphinProperty.set("Dolphin Platform");
assertEquals(writableStringValue.get(), "Dolphin Platform");
stringDolphinProperty.set(null);
assertEquals(writableStringValue.get(), null);
binding.unbind();
stringDolphinProperty.set("Dolphin Platform");
assertEquals(writableStringValue.get(), null);
}
use of javafx.beans.property.SimpleStringProperty in project dolphin-platform by canoo.
the class FXBinderTest method testJavaFXStringBidirectional.
@Test
public void testJavaFXStringBidirectional() {
Property<String> stringDolphinProperty = new MockedProperty<>();
StringProperty stringJavaFXProperty = new SimpleStringProperty();
stringDolphinProperty.set("Hello");
assertNotEquals(stringJavaFXProperty.get(), "Hello");
Binding binding = FXBinder.bind(stringJavaFXProperty).bidirectionalTo(stringDolphinProperty);
assertEquals(stringJavaFXProperty.get(), "Hello");
stringDolphinProperty.set("Hello World");
assertEquals(stringJavaFXProperty.get(), "Hello World");
stringDolphinProperty.set(null);
assertEquals(stringJavaFXProperty.get(), null);
stringJavaFXProperty.set("Hello from JavaFX");
assertEquals(stringDolphinProperty.get(), "Hello from JavaFX");
stringJavaFXProperty.setValue(null);
assertEquals(stringDolphinProperty.get(), null);
binding.unbind();
stringDolphinProperty.set("Hello Dolphin");
assertEquals(stringJavaFXProperty.get(), null);
}
Aggregations