Search in sources :

Example 16 with SimpleObjectProperty

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);
}
Also used : TabPane(javafx.scene.control.TabPane) SimpleObjectProperty(javafx.beans.property.SimpleObjectProperty) Tab(javafx.scene.control.Tab) ShortcutDTO(org.phoenicis.library.dto.ShortcutDTO) Observable(javafx.beans.Observable)

Example 17 with SimpleObjectProperty

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;
}
Also used : BaseDialogComposite(com.kyj.fx.voeditor.visual.component.popup.BaseDialogComposite) SimpleObjectProperty(javafx.beans.property.SimpleObjectProperty) Optional(java.util.Optional) Button(javafx.scene.control.Button) TextField(javafx.scene.control.TextField) Pair(javafx.util.Pair)

Example 18 with SimpleObjectProperty

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();
}
Also used : BaseDialogComposite(com.kyj.fx.voeditor.visual.component.popup.BaseDialogComposite) SimpleObjectProperty(javafx.beans.property.SimpleObjectProperty) Optional(java.util.Optional) Button(javafx.scene.control.Button) Pair(javafx.util.Pair)

Example 19 with SimpleObjectProperty

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);
}
Also used : Button(javafx.scene.control.Button) DbUtil(com.kyj.fx.voeditor.visual.util.DbUtil) Enumeration(java.util.Enumeration) LoggerFactory(org.slf4j.LoggerFactory) PoolProperties(org.apache.tomcat.jdbc.pool.PoolProperties) EncrypUtil(com.kyj.fx.voeditor.visual.util.EncrypUtil) Map(java.util.Map) CommonsSqllPan(com.kyj.fx.voeditor.visual.component.sql.view.CommonsSqllPan) ColorPickerTableColumn(com.kyj.fx.voeditor.visual.component.ColorPickerTableColumn) TableView(javafx.scene.control.TableView) ButtonTableColumn(com.kyj.fx.voeditor.visual.component.ButtonTableColumn) RuntimeException(com.sun.star.uno.RuntimeException) FXMLController(com.kyj.fx.voeditor.visual.framework.annotation.FXMLController) ConfigResourceLoader(com.kyj.fx.voeditor.visual.momory.ConfigResourceLoader) Collectors(java.util.stream.Collectors) FXML(javafx.fxml.FXML) FxUtil(com.kyj.fx.voeditor.visual.util.FxUtil) List(java.util.List) ResourceLoader(com.kyj.fx.voeditor.visual.momory.ResourceLoader) Stream(java.util.stream.Stream) JSONObject(org.json.simple.JSONObject) ComboBoxTableColumn(com.kyj.fx.voeditor.visual.component.ComboBoxTableColumn) Optional(java.util.Optional) ObservableList(javafx.collections.ObservableList) BorderPane(javafx.scene.layout.BorderPane) Code(com.kyj.fx.voeditor.visual.main.model.vo.Code) MouseEvent(javafx.scene.input.MouseEvent) FXCollections(javafx.collections.FXCollections) HashMap(java.util.HashMap) TextFieldTableCell(javafx.scene.control.cell.TextFieldTableCell) DockNode(com.kyj.fx.voeditor.visual.component.dock.pane.DockNode) DialogUtil(com.kyj.fx.voeditor.visual.util.DialogUtil) TransferMode(javafx.scene.input.TransferMode) ArrayList(java.util.ArrayList) TableColumn(javafx.scene.control.TableColumn) TableCell(javafx.scene.control.TableCell) Callback(javafx.util.Callback) Color(javafx.scene.paint.Color) Logger(org.slf4j.Logger) FileOutputStream(java.io.FileOutputStream) IOException(java.io.IOException) ValueUtil(com.kyj.fx.voeditor.visual.util.ValueUtil) StringConverter(javafx.util.StringConverter) File(java.io.File) SimpleObjectProperty(javafx.beans.property.SimpleObjectProperty) NotYetSupportException(com.kyj.fx.voeditor.visual.exceptions.NotYetSupportException) PasswordTextFieldTableCell(com.kyj.fx.voeditor.visual.component.PasswordTextFieldTableCell) ChangeListener(javafx.beans.value.ChangeListener) StringUtils(org.springframework.util.StringUtils) HashMap(java.util.HashMap) Code(com.kyj.fx.voeditor.visual.main.model.vo.Code) RuntimeException(com.sun.star.uno.RuntimeException) IOException(java.io.IOException) NotYetSupportException(com.kyj.fx.voeditor.visual.exceptions.NotYetSupportException) SimpleObjectProperty(javafx.beans.property.SimpleObjectProperty) JSONObject(org.json.simple.JSONObject) PasswordTextFieldTableCell(com.kyj.fx.voeditor.visual.component.PasswordTextFieldTableCell) Map(java.util.Map) HashMap(java.util.HashMap) File(java.io.File) ButtonTableColumn(com.kyj.fx.voeditor.visual.component.ButtonTableColumn) FXML(javafx.fxml.FXML)

Example 20 with SimpleObjectProperty

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);
    }
}
Also used : ObjectProperty(javafx.beans.property.ObjectProperty) SimpleObjectProperty(javafx.beans.property.SimpleObjectProperty) SQLException(java.sql.SQLException) Connection(java.sql.Connection) TableColumn(javafx.scene.control.TableColumn) SQLException(java.sql.SQLException) ResultSetMetaData(java.sql.ResultSetMetaData) SimpleObjectProperty(javafx.beans.property.SimpleObjectProperty) ColumnExpression(com.kyj.fx.voeditor.visual.component.grid.EditableTableView.ColumnExpression) ValueExpression(com.kyj.fx.voeditor.visual.component.grid.EditableTableView.ValueExpression) ResultSet(java.sql.ResultSet) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) List(java.util.List) ObservableList(javafx.collections.ObservableList) HashMap(java.util.HashMap) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap)

Aggregations

SimpleObjectProperty (javafx.beans.property.SimpleObjectProperty)37 TableColumn (javafx.scene.control.TableColumn)12 MappedList (org.phoenicis.javafx.collections.MappedList)10 JavaFxSettingsManager (org.phoenicis.javafx.settings.JavaFxSettingsManager)10 BigDecimal (java.math.BigDecimal)9 None (org.phoenicis.javafx.components.common.panelstates.None)8 CombinedListWidget (org.phoenicis.javafx.components.common.widgets.control.CombinedListWidget)8 ListWidgetElement (org.phoenicis.javafx.components.common.widgets.utils.ListWidgetElement)8 Bindings (javafx.beans.binding.Bindings)7 Button (javafx.scene.control.Button)7 SimpleStringProperty (javafx.beans.property.SimpleStringProperty)6 LocalDate (java.time.LocalDate)5 Optional (java.util.Optional)5 ObjectProperty (javafx.beans.property.ObjectProperty)5 ObservableList (javafx.collections.ObservableList)5 FXML (javafx.fxml.FXML)5 Scene (javafx.scene.Scene)5 TableCell (javafx.scene.control.TableCell)5 ArrayList (java.util.ArrayList)4 List (java.util.List)4