Search in sources :

Example 11 with SimpleStringProperty

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);
    }
}
Also used : ObjectProperty(javafx.beans.property.ObjectProperty) Button(javafx.scene.control.Button) Pos(javafx.geometry.Pos) Connection(java.sql.Connection) DbUtil(com.kyj.fx.voeditor.visual.util.DbUtil) TextArea(javafx.scene.control.TextArea) SimpleStringProperty(javafx.beans.property.SimpleStringProperty) BiFunction(java.util.function.BiFunction) LoggerFactory(org.slf4j.LoggerFactory) HashMap(java.util.HashMap) DialogUtil(com.kyj.fx.voeditor.visual.util.DialogUtil) ArrayList(java.util.ArrayList) TableColumn(javafx.scene.control.TableColumn) BlendMode(javafx.scene.effect.BlendMode) SQLException(java.sql.SQLException) TableCell(javafx.scene.control.TableCell) KeyBinding(com.sun.javafx.scene.control.behavior.KeyBinding) Insets(javafx.geometry.Insets) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) ResultSet(java.sql.ResultSet) Map(java.util.Map) BehaviorSkinBase(com.sun.javafx.scene.control.skin.BehaviorSkinBase) BehaviorBase(com.sun.javafx.scene.control.behavior.BehaviorBase) TableView(javafx.scene.control.TableView) Callback(javafx.util.Callback) Orientation(javafx.geometry.Orientation) KeyCode(javafx.scene.input.KeyCode) HBox(javafx.scene.layout.HBox) NumberTextField(com.kyj.fx.voeditor.visual.component.NumberTextField) ObjectProperty(javafx.beans.property.ObjectProperty) SplitPane(javafx.scene.control.SplitPane) Logger(org.slf4j.Logger) Label(javafx.scene.control.Label) Consumer(java.util.function.Consumer) Platform(javafx.application.Platform) List(java.util.List) BooleanProperty(javafx.beans.property.BooleanProperty) ActionEvent(javafx.event.ActionEvent) SimpleBooleanProperty(javafx.beans.property.SimpleBooleanProperty) SelectionMode(javafx.scene.control.SelectionMode) ValueUtil(kyj.Fx.dao.wizard.core.util.ValueUtil) BorderPane(javafx.scene.layout.BorderPane) Collections(java.util.Collections) ResultSetMetaData(java.sql.ResultSetMetaData) SQLException(java.sql.SQLException) Connection(java.sql.Connection) Label(javafx.scene.control.Label) SimpleStringProperty(javafx.beans.property.SimpleStringProperty) TableColumn(javafx.scene.control.TableColumn) SQLException(java.sql.SQLException) ResultSetMetaData(java.sql.ResultSetMetaData) Callback(javafx.util.Callback) TableCell(javafx.scene.control.TableCell) ResultSet(java.sql.ResultSet) ArrayList(java.util.ArrayList) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map)

Example 12 with SimpleStringProperty

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;
    });
}
Also used : SimpleStringProperty(javafx.beans.property.SimpleStringProperty) FXML(javafx.fxml.FXML)

Example 13 with SimpleStringProperty

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();
}
Also used : Button(javafx.scene.control.Button) Label(javafx.scene.control.Label) SimpleStringProperty(javafx.beans.property.SimpleStringProperty) StringProperty(javafx.beans.property.StringProperty) SimpleStringProperty(javafx.beans.property.SimpleStringProperty) Scene(javafx.scene.Scene) VBox(javafx.scene.layout.VBox)

Example 14 with SimpleStringProperty

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);
}
Also used : Binding(com.canoo.platform.core.functional.Binding) MockedProperty(com.canoo.dp.impl.remoting.MockedProperty) WritableStringValue(javafx.beans.value.WritableStringValue) SimpleStringProperty(javafx.beans.property.SimpleStringProperty) StringProperty(javafx.beans.property.StringProperty) SimpleStringProperty(javafx.beans.property.SimpleStringProperty) Test(org.testng.annotations.Test)

Example 15 with SimpleStringProperty

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);
}
Also used : Binding(com.canoo.platform.core.functional.Binding) MockedProperty(com.canoo.dp.impl.remoting.MockedProperty) SimpleStringProperty(javafx.beans.property.SimpleStringProperty) StringProperty(javafx.beans.property.StringProperty) SimpleStringProperty(javafx.beans.property.SimpleStringProperty) Test(org.testng.annotations.Test)

Aggregations

SimpleStringProperty (javafx.beans.property.SimpleStringProperty)40 StringProperty (javafx.beans.property.StringProperty)14 TableColumn (javafx.scene.control.TableColumn)12 FXML (javafx.fxml.FXML)9 BigDecimal (java.math.BigDecimal)7 Button (javafx.scene.control.Button)7 IOException (java.io.IOException)5 SimpleIntegerProperty (javafx.beans.property.SimpleIntegerProperty)5 SimpleObjectProperty (javafx.beans.property.SimpleObjectProperty)5 ObservableValue (javafx.beans.value.ObservableValue)5 MockedProperty (com.canoo.dp.impl.remoting.MockedProperty)4 Binding (com.canoo.platform.core.functional.Binding)4 List (java.util.List)4 Map (java.util.Map)4 Label (javafx.scene.control.Label)4 CellDataFeatures (javafx.scene.control.TableColumn.CellDataFeatures)4 ImageView (javafx.scene.image.ImageView)4 Test (org.testng.annotations.Test)4 ChunkWrapper (com.kyj.fx.voeditor.visual.diff.ChunkWrapper)3 CompareResult (com.kyj.fx.voeditor.visual.diff.CompareResult)3