Search in sources :

Example 21 with SimpleObjectProperty

use of javafx.beans.property.SimpleObjectProperty in project org.csstudio.display.builder by kasemir.

the class ColorMapDialog method createContent.

private Node createContent() {
    // Table for selecting a predefined color map
    predefined_table = new TableView<>();
    final TableColumn<PredefinedColorMaps.Predefined, String> name_column = new TableColumn<>(Messages.ColorMapDialog_PredefinedMap);
    name_column.setCellValueFactory(param -> new SimpleStringProperty(param.getValue().getDescription()));
    predefined_table.getColumns().add(name_column);
    predefined_table.getItems().addAll(PredefinedColorMaps.PREDEFINED);
    predefined_table.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
    // Table for viewing/editing color sections
    sections_table = new TableView<>();
    // Value of color section
    final TableColumn<ColorSection, String> value_column = new TableColumn<>(Messages.ColorMapDialog_Value);
    value_column.setCellValueFactory(param -> new SimpleStringProperty(Integer.toString(param.getValue().value)));
    value_column.setCellFactory(TextFieldTableCell.forTableColumn());
    value_column.setOnEditCommit(event -> {
        final int index = event.getTablePosition().getRow();
        try {
            final int value = Math.max(0, Math.min(255, Integer.parseInt(event.getNewValue().trim())));
            color_sections.set(index, new ColorSection(value, color_sections.get(index).color));
            color_sections.sort((sec1, sec2) -> sec1.value - sec2.value);
            updateMapFromSections();
        } catch (NumberFormatException ex) {
        // Ignore, field will reset to original value
        }
    });
    // Color of color section
    final TableColumn<ColorSection, ColorPicker> color_column = new TableColumn<>(Messages.ColorMapDialog_Color);
    color_column.setCellValueFactory(param -> {
        final ColorSection segment = param.getValue();
        return new SimpleObjectProperty<ColorPicker>(createColorPicker(segment));
    });
    color_column.setCellFactory(column -> new ColorTableCell());
    sections_table.getColumns().add(value_column);
    sections_table.getColumns().add(color_column);
    sections_table.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
    sections_table.setItems(color_sections);
    sections_table.setEditable(true);
    add = new Button(Messages.ColorMapDialog_Add, JFXUtil.getIcon("add.png"));
    add.setMaxWidth(Double.MAX_VALUE);
    remove = new Button(Messages.ColorMapDialog_Remove, JFXUtil.getIcon("delete.png"));
    remove.setMaxWidth(Double.MAX_VALUE);
    final VBox buttons = new VBox(10, add, remove);
    // Upper section with tables
    final HBox tables_and_buttons = new HBox(10, predefined_table, sections_table, buttons);
    HBox.setHgrow(predefined_table, Priority.ALWAYS);
    HBox.setHgrow(sections_table, Priority.ALWAYS);
    // Lower section with resulting color map
    final Region fill1 = new Region(), fill2 = new Region(), fill3 = new Region();
    HBox.setHgrow(fill1, Priority.ALWAYS);
    HBox.setHgrow(fill2, Priority.ALWAYS);
    HBox.setHgrow(fill3, Priority.ALWAYS);
    final HBox color_title = new HBox(fill1, new Label(Messages.ColorMapDialog_Result), fill2);
    color_bar = new Region();
    color_bar.setMinHeight(COLOR_BAR_HEIGHT);
    color_bar.setMaxHeight(COLOR_BAR_HEIGHT);
    color_bar.setPrefHeight(COLOR_BAR_HEIGHT);
    final HBox color_legend = new HBox(new Label("0"), fill3, new Label("255"));
    final VBox box = new VBox(10, tables_and_buttons, new Separator(), color_title, color_bar, color_legend);
    VBox.setVgrow(tables_and_buttons, Priority.ALWAYS);
    return box;
}
Also used : HBox(javafx.scene.layout.HBox) ColorPicker(javafx.scene.control.ColorPicker) Label(javafx.scene.control.Label) SimpleStringProperty(javafx.beans.property.SimpleStringProperty) TableColumn(javafx.scene.control.TableColumn) SimpleObjectProperty(javafx.beans.property.SimpleObjectProperty) Button(javafx.scene.control.Button) Region(javafx.scene.layout.Region) VBox(javafx.scene.layout.VBox) Separator(javafx.scene.control.Separator)

Example 22 with SimpleObjectProperty

use of javafx.beans.property.SimpleObjectProperty in project org.csstudio.display.builder by kasemir.

the class ScriptsDialog method createScriptsTable.

/**
 * @return Node for UI elements that edit the scripts
 */
private Region createScriptsTable() {
    scripts_icon_col = new TableColumn<>();
    scripts_icon_col.setCellValueFactory(cdf -> new SimpleObjectProperty<ImageView>(getScriptImage(cdf.getValue())) {

        {
            bind(Bindings.createObjectBinding(() -> getScriptImage(cdf.getValue()), cdf.getValue().fileProperty()));
        }
    });
    scripts_icon_col.setCellFactory(col -> new TableCell<ScriptItem, ImageView>() {

        /* Instance initializer. */
        {
            setAlignment(Pos.CENTER_LEFT);
        }

        @Override
        protected void updateItem(final ImageView item, final boolean empty) {
            super.updateItem(item, empty);
            super.setGraphic(item);
        }
    });
    scripts_icon_col.setEditable(false);
    scripts_icon_col.setSortable(false);
    scripts_icon_col.setMaxWidth(25);
    scripts_icon_col.setMinWidth(25);
    // Create table with editable script 'file' column
    scripts_name_col = new TableColumn<>(Messages.ScriptsDialog_ColScript);
    scripts_name_col.setCellValueFactory(new PropertyValueFactory<ScriptItem, String>("file"));
    scripts_name_col.setCellFactory(col -> new TextFieldTableCell<ScriptItem, String>(new DefaultStringConverter()) {

        private final ChangeListener<? super Boolean> focusedListener = (ob, o, n) -> {
            if (!n)
                cancelEdit();
        };

        @Override
        public void cancelEdit() {
            ((TextField) getGraphic()).focusedProperty().removeListener(focusedListener);
            super.cancelEdit();
        }

        @Override
        public void startEdit() {
            super.startEdit();
            ((TextField) getGraphic()).focusedProperty().addListener(focusedListener);
        }

        @Override
        public void commitEdit(final String newValue) {
            ((TextField) getGraphic()).focusedProperty().removeListener(focusedListener);
            super.commitEdit(newValue);
            Platform.runLater(() -> btn_pv_add.requestFocus());
        }
    });
    scripts_name_col.setOnEditCommit(event -> {
        final int row = event.getTablePosition().getRow();
        script_items.get(row).file.set(event.getNewValue());
        fixupScripts(row);
    });
    scripts_table = new TableView<>(script_items);
    scripts_table.getColumns().add(scripts_icon_col);
    scripts_table.getColumns().add(scripts_name_col);
    scripts_table.setEditable(true);
    scripts_table.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
    scripts_table.setTooltip(new Tooltip(Messages.ScriptsDialog_ScriptsTT));
    scripts_table.setPlaceholder(new Label(Messages.ScriptsDialog_NoScripts));
    // Buttons
    addMenuButton = new MenuButton(Messages.Add, JFXUtil.getIcon("add.png"), new MenuItem(Messages.AddPythonFile, JFXUtil.getIcon("file-python.png")) {

        {
            setOnAction(e -> addPythonFile());
        }
    }, new MenuItem(Messages.AddJavaScriptFile, JFXUtil.getIcon("file-javascript.png")) {

        {
            setOnAction(e -> addJavaScriptFile());
        }
    }, new SeparatorMenuItem(), new MenuItem(Messages.AddEmbeddedPython, JFXUtil.getIcon("python.png")) {

        {
            setOnAction(e -> addEmbeddedJython());
        }
    }, new MenuItem(Messages.AddEmbeddedJavaScript, JFXUtil.getIcon("javascript.png")) {

        {
            setOnAction(e -> addEmbeddedJavaScript());
        }
    });
    addMenuButton.setMaxWidth(Double.MAX_VALUE);
    addMenuButton.setAlignment(Pos.CENTER_LEFT);
    btn_script_remove = new Button(Messages.Remove, JFXUtil.getIcon("delete.png"));
    btn_script_remove.setMaxWidth(Double.MAX_VALUE);
    btn_script_remove.setAlignment(Pos.CENTER_LEFT);
    btn_script_remove.setDisable(true);
    btn_script_remove.setOnAction(event -> {
        final int sel = scripts_table.getSelectionModel().getSelectedIndex();
        if (sel >= 0) {
            script_items.remove(sel);
            fixupScripts(sel);
        }
    });
    btn_edit = new SplitMenuButton(convertToFileMenuItem, new SeparatorMenuItem(), convertToEmbeddedPythonMenuItem, convertToEmbeddedJavaScriptMenuItem);
    btn_edit.setText(Messages.Select);
    btn_edit.setGraphic(JFXUtil.getIcon("select-file.png"));
    btn_edit.setMaxWidth(Double.MAX_VALUE);
    btn_edit.setMinWidth(120);
    btn_edit.setAlignment(Pos.CENTER_LEFT);
    btn_edit.setDisable(true);
    btn_edit.setOnAction(e -> editOrSelect());
    final VBox buttons = new VBox(10, addMenuButton, btn_script_remove, btn_edit);
    final HBox content = new HBox(10, scripts_table, buttons);
    HBox.setHgrow(scripts_table, Priority.ALWAYS);
    HBox.setHgrow(buttons, Priority.NEVER);
    return content;
}
Also used : Button(javafx.scene.control.Button) Pos(javafx.geometry.Pos) ScriptPV(org.csstudio.display.builder.model.properties.ScriptPV) LineNumberTableCellFactory(org.csstudio.javafx.LineNumberTableCellFactory) VBox(javafx.scene.layout.VBox) AutoCompletedTableCell(org.csstudio.display.builder.representation.javafx.PVTableItem.AutoCompletedTableCell) TableHelper(org.csstudio.javafx.TableHelper) ListChangeListener(javafx.collections.ListChangeListener) TableView(javafx.scene.control.TableView) ModelThreadPool(org.csstudio.display.builder.model.util.ModelThreadPool) HBox(javafx.scene.layout.HBox) SplitPane(javafx.scene.control.SplitPane) TextField(javafx.scene.control.TextField) MenuItem(javafx.scene.control.MenuItem) Language(org.csstudio.javafx.SyntaxHighlightedMultiLineInputDialog.Language) PropertyValueFactory(javafx.scene.control.cell.PropertyValueFactory) Collectors(java.util.stream.Collectors) Platform(javafx.application.Platform) SeparatorMenuItem(javafx.scene.control.SeparatorMenuItem) Priority(javafx.scene.layout.Priority) List(java.util.List) Region(javafx.scene.layout.Region) CheckBoxTableCell(javafx.scene.control.cell.CheckBoxTableCell) MenuButton(javafx.scene.control.MenuButton) ObservableList(javafx.collections.ObservableList) DefaultStringConverter(javafx.util.converter.DefaultStringConverter) StringProperty(javafx.beans.property.StringProperty) TableViewSelectionModel(javafx.scene.control.TableView.TableViewSelectionModel) SyntaxHighlightedMultiLineInputDialog(org.csstudio.javafx.SyntaxHighlightedMultiLineInputDialog) SimpleStringProperty(javafx.beans.property.SimpleStringProperty) ButtonType(javafx.scene.control.ButtonType) JFXBaseRepresentation(org.csstudio.display.builder.representation.javafx.widgets.JFXBaseRepresentation) FXCollections(javafx.collections.FXCollections) BackingStoreException(java.util.prefs.BackingStoreException) TextFieldTableCell(javafx.scene.control.cell.TextFieldTableCell) Bindings(javafx.beans.binding.Bindings) ArrayList(java.util.ArrayList) Level(java.util.logging.Level) TableColumn(javafx.scene.control.TableColumn) TableCell(javafx.scene.control.TableCell) Insets(javafx.geometry.Insets) Tooltip(javafx.scene.control.Tooltip) ScriptInfo(org.csstudio.display.builder.model.properties.ScriptInfo) Dialog(javafx.scene.control.Dialog) Label(javafx.scene.control.Label) SplitMenuButton(javafx.scene.control.SplitMenuButton) Node(javafx.scene.Node) CheckBox(javafx.scene.control.CheckBox) Preferences(java.util.prefs.Preferences) ToolkitRepresentation.logger(org.csstudio.display.builder.representation.ToolkitRepresentation.logger) TimeUnit(java.util.concurrent.TimeUnit) SimpleObjectProperty(javafx.beans.property.SimpleObjectProperty) ImageView(javafx.scene.image.ImageView) DialogHelper(org.csstudio.javafx.DialogHelper) Widget(org.csstudio.display.builder.model.Widget) ChangeListener(javafx.beans.value.ChangeListener) HBox(javafx.scene.layout.HBox) SplitMenuButton(javafx.scene.control.SplitMenuButton) Label(javafx.scene.control.Label) MenuButton(javafx.scene.control.MenuButton) SplitMenuButton(javafx.scene.control.SplitMenuButton) Button(javafx.scene.control.Button) MenuButton(javafx.scene.control.MenuButton) SplitMenuButton(javafx.scene.control.SplitMenuButton) TextField(javafx.scene.control.TextField) ImageView(javafx.scene.image.ImageView) Tooltip(javafx.scene.control.Tooltip) MenuItem(javafx.scene.control.MenuItem) SeparatorMenuItem(javafx.scene.control.SeparatorMenuItem) SeparatorMenuItem(javafx.scene.control.SeparatorMenuItem) DefaultStringConverter(javafx.util.converter.DefaultStringConverter) VBox(javafx.scene.layout.VBox)

Example 23 with SimpleObjectProperty

use of javafx.beans.property.SimpleObjectProperty in project JFoenix by jfoenixadmin.

the class PromptLinesWrapper method init.

public void init(Runnable createPromptNodeRunnable, Node... cachedNodes) {
    animatedPromptTextFill = new SimpleObjectProperty<>(promptTextFill.get());
    usePromptText = Bindings.createBooleanBinding(this::usePromptText, valueProperty, promptTextProperty, control.labelFloatProperty(), promptTextFill);
    // draw lines
    line.setManaged(false);
    line.getStyleClass().add("input-line");
    line.setBackground(new Background(new BackgroundFill(control.getUnFocusColor(), CornerRadii.EMPTY, Insets.EMPTY)));
    // focused line
    focusedLine.setManaged(false);
    focusedLine.getStyleClass().add("input-focused-line");
    focusedLine.setBackground(new Background(new BackgroundFill(control.getFocusColor(), CornerRadii.EMPTY, Insets.EMPTY)));
    focusedLine.setOpacity(0);
    focusedLine.getTransforms().add(scale);
    if (usePromptText.get()) {
        createPromptNodeRunnable.run();
    }
    usePromptText.addListener(observable -> {
        createPromptNodeRunnable.run();
        control.requestLayout();
    });
    final Supplier<WritableValue<Number>> promptTargetYSupplier = () -> promptTextSupplier.get() == null ? null : promptTextSupplier.get().translateYProperty();
    final Supplier<WritableValue<Number>> promptTargetXSupplier = () -> promptTextSupplier.get() == null ? null : promptTextSupplier.get().translateXProperty();
    focusTimer = new JFXAnimationTimer(new JFXKeyFrame(Duration.millis(1), JFXKeyValue.builder().setTarget(focusedLine.opacityProperty()).setEndValue(1).setInterpolator(Interpolator.EASE_BOTH).setAnimateCondition(() -> control.isFocused()).build()), new JFXKeyFrame(Duration.millis(160), JFXKeyValue.builder().setTarget(scale.xProperty()).setEndValue(1).setInterpolator(Interpolator.EASE_BOTH).setAnimateCondition(() -> control.isFocused()).build(), JFXKeyValue.builder().setTarget(animatedPromptTextFill).setEndValueSupplier(() -> control.getFocusColor()).setInterpolator(Interpolator.EASE_BOTH).setAnimateCondition(() -> control.isFocused() && control.isLabelFloat()).build(), JFXKeyValue.builder().setTargetSupplier(promptTargetXSupplier).setEndValueSupplier(() -> clip.getX()).setAnimateCondition(() -> control.isLabelFloat()).setInterpolator(Interpolator.EASE_BOTH).build(), JFXKeyValue.builder().setTargetSupplier(promptTargetYSupplier).setEndValueSupplier(() -> -contentHeight).setAnimateCondition(() -> control.isLabelFloat()).setInterpolator(Interpolator.EASE_BOTH).build(), JFXKeyValue.builder().setTarget(promptTextScale.xProperty()).setEndValue(0.85).setAnimateCondition(() -> control.isLabelFloat()).setInterpolator(Interpolator.EASE_BOTH).build(), JFXKeyValue.builder().setTarget(promptTextScale.yProperty()).setEndValue(0.85).setAnimateCondition(() -> control.isLabelFloat()).setInterpolator(Interpolator.EASE_BOTH).build()));
    unfocusTimer = new JFXAnimationTimer(new JFXKeyFrame(Duration.millis(160), JFXKeyValue.builder().setTargetSupplier(promptTargetXSupplier).setEndValue(0).setInterpolator(Interpolator.EASE_BOTH).build(), JFXKeyValue.builder().setTargetSupplier(promptTargetYSupplier).setEndValue(0).setInterpolator(Interpolator.EASE_BOTH).build(), JFXKeyValue.builder().setTarget(promptTextScale.xProperty()).setEndValue(1).setInterpolator(Interpolator.EASE_BOTH).build(), JFXKeyValue.builder().setTarget(promptTextScale.yProperty()).setEndValue(1).setInterpolator(Interpolator.EASE_BOTH).build()));
    promptContainer.getStyleClass().add("prompt-container");
    promptContainer.setManaged(false);
    promptContainer.setMouseTransparent(true);
    // clip prompt container
    clip.setSmooth(false);
    clip.setX(0);
    if (control instanceof JFXTextField) {
        final InvalidationListener leadingListener = obs -> {
            final Node leading = ((JFXTextField) control).getLeadingGraphic();
            if (leading == null) {
                clip.xProperty().unbind();
                clip.setX(0);
            } else {
                clip.xProperty().bind(((Region) leading).widthProperty().negate());
            }
        };
        ((JFXTextField) control).leadingGraphicProperty().addListener(leadingListener);
        leadingListener.invalidated(null);
    }
    clip.widthProperty().bind(promptContainer.widthProperty().add(clip.xProperty().negate()));
    promptContainer.setClip(clip);
    focusTimer.setOnFinished(() -> animating = false);
    unfocusTimer.setOnFinished(() -> animating = false);
    focusTimer.setCacheNodes(cachedNodes);
    unfocusTimer.setCacheNodes(cachedNodes);
    // handle animation on focus gained/lost event
    control.focusedProperty().addListener(observable -> {
        if (control.isFocused()) {
            focus();
        } else {
            unFocus();
        }
    });
    promptTextFill.addListener(observable -> {
        if (!control.isLabelFloat() || !control.isFocused()) {
            animatedPromptTextFill.set(promptTextFill.get());
        }
    });
    updateDisabled();
}
Also used : BooleanBinding(javafx.beans.binding.BooleanBinding) Control(javafx.scene.control.Control) StackPane(javafx.scene.layout.StackPane) Bindings(javafx.beans.binding.Bindings) Supplier(java.util.function.Supplier) JFXKeyFrame(com.jfoenix.transitions.JFXKeyFrame) InvalidationListener(javafx.beans.InvalidationListener) JFXKeyValue(com.jfoenix.transitions.JFXKeyValue) Insets(javafx.geometry.Insets) ComboBox(javafx.scene.control.ComboBox) BorderWidths(javafx.scene.layout.BorderWidths) BackgroundFill(javafx.scene.layout.BackgroundFill) Color(javafx.scene.paint.Color) ObjectProperty(javafx.beans.property.ObjectProperty) Node(javafx.scene.Node) Border(javafx.scene.layout.Border) Rectangle(javafx.scene.shape.Rectangle) JFXAnimationTimer(com.jfoenix.transitions.JFXAnimationTimer) Background(javafx.scene.layout.Background) BorderStrokeStyle(javafx.scene.layout.BorderStrokeStyle) BorderStroke(javafx.scene.layout.BorderStroke) Text(javafx.scene.text.Text) Duration(javafx.util.Duration) Region(javafx.scene.layout.Region) Interpolator(javafx.animation.Interpolator) SimpleObjectProperty(javafx.beans.property.SimpleObjectProperty) Paint(javafx.scene.paint.Paint) IFXLabelFloatControl(com.jfoenix.controls.base.IFXLabelFloatControl) Scale(javafx.scene.transform.Scale) ObservableValue(javafx.beans.value.ObservableValue) WritableValue(javafx.beans.value.WritableValue) JFXTextField(com.jfoenix.controls.JFXTextField) CornerRadii(javafx.scene.layout.CornerRadii) JFXAnimationTimer(com.jfoenix.transitions.JFXAnimationTimer) Background(javafx.scene.layout.Background) JFXKeyFrame(com.jfoenix.transitions.JFXKeyFrame) BackgroundFill(javafx.scene.layout.BackgroundFill) JFXTextField(com.jfoenix.controls.JFXTextField) Node(javafx.scene.Node) InvalidationListener(javafx.beans.InvalidationListener) WritableValue(javafx.beans.value.WritableValue)

Example 24 with SimpleObjectProperty

use of javafx.beans.property.SimpleObjectProperty in project jgnash by ccavanaugh.

the class AbstractTransactionEntryDialog method buildTable.

@SuppressWarnings("unchecked")
private void buildTable() {
    final String[] columnNames = getSplitColumnName();
    final TableColumn<TransactionEntry, String> accountColumn = new TableColumn<>(columnNames[0]);
    accountColumn.setCellValueFactory(param -> new AccountNameWrapper(param.getValue()));
    final TableColumn<TransactionEntry, String> reconciledColumn = new TableColumn<>(columnNames[1]);
    reconciledColumn.setCellValueFactory(param -> new SimpleStringProperty(param.getValue().getReconciled(account.get()).toString()));
    final TableColumn<TransactionEntry, String> memoColumn = new TableColumn<>(columnNames[2]);
    memoColumn.setCellValueFactory(param -> new SimpleStringProperty(param.getValue().getMemo()));
    final Callback<TableColumn<TransactionEntry, BigDecimal>, TableCell<TransactionEntry, BigDecimal>> cellFactory = cell -> new TransactionEntryCommodityFormatTableCell(NumericFormats.getShortCommodityFormat(account.get().getCurrencyNode()));
    final TableColumn<TransactionEntry, BigDecimal> increaseColumn = new TableColumn<>(columnNames[3]);
    increaseColumn.setCellValueFactory(param -> new IncreaseAmountProperty(param.getValue().getAmount(accountProperty().getValue())));
    increaseColumn.setCellFactory(cellFactory);
    final TableColumn<TransactionEntry, BigDecimal> decreaseColumn = new TableColumn<>(columnNames[4]);
    decreaseColumn.setCellValueFactory(param -> new DecreaseAmountProperty(param.getValue().getAmount(accountProperty().getValue())));
    decreaseColumn.setCellFactory(cellFactory);
    final TableColumn<TransactionEntry, BigDecimal> balanceColumn = new TableColumn<>(columnNames[5]);
    balanceColumn.setCellValueFactory(param -> new SimpleObjectProperty<>(getBalanceAt(param.getValue())));
    balanceColumn.setCellFactory(cell -> new TransactionEntryCommodityFormatTableCell(NumericFormats.getFullCommodityFormat(account.get().getCurrencyNode())));
    // do not allow a sort on the balance
    balanceColumn.setSortable(false);
    tableView.getColumns().addAll(memoColumn, accountColumn, reconciledColumn, increaseColumn, decreaseColumn, balanceColumn);
    tableViewManager.setColumnFormatFactory(param -> {
        if (param == balanceColumn) {
            return NumericFormats.getFullCommodityFormat(accountProperty().getValue().getCurrencyNode());
        } else if (param == increaseColumn || param == decreaseColumn) {
            return NumericFormats.getShortCommodityFormat(accountProperty().getValue().getCurrencyNode());
        }
        return null;
    });
}
Also used : Button(javafx.scene.control.Button) SimpleStringProperty(javafx.beans.property.SimpleStringProperty) FXCollections(javafx.collections.FXCollections) TableViewManager(jgnash.uifx.util.TableViewManager) TransactionEntry(jgnash.engine.TransactionEntry) TableColumn(javafx.scene.control.TableColumn) BigDecimal(java.math.BigDecimal) TableCell(javafx.scene.control.TableCell) ResourceBundle(java.util.ResourceBundle) ListChangeListener(javafx.collections.ListChangeListener) WindowEvent(javafx.stage.WindowEvent) TableView(javafx.scene.control.TableView) Callback(javafx.util.Callback) SortedList(javafx.collections.transformation.SortedList) ObjectProperty(javafx.beans.property.ObjectProperty) NotNull(jgnash.util.NotNull) MainView(jgnash.uifx.views.main.MainView) JavaFXUtils(jgnash.uifx.util.JavaFXUtils) FXML(javafx.fxml.FXML) StageUtils(jgnash.uifx.util.StageUtils) Stage(javafx.stage.Stage) SimpleObjectProperty(javafx.beans.property.SimpleObjectProperty) Account(jgnash.engine.Account) ObservableList(javafx.collections.ObservableList) NumericFormats(jgnash.text.NumericFormats) SimpleStringProperty(javafx.beans.property.SimpleStringProperty) TableColumn(javafx.scene.control.TableColumn) BigDecimal(java.math.BigDecimal) TableCell(javafx.scene.control.TableCell) TransactionEntry(jgnash.engine.TransactionEntry)

Example 25 with SimpleObjectProperty

use of javafx.beans.property.SimpleObjectProperty in project jgnash by ccavanaugh.

the class RecurringViewController method initialize.

@FXML
private void initialize() {
    tableView.setClipBoardStringFunction(this::reminderToExcel);
    tableView.setTableMenuButtonVisible(true);
    tableView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
    // hide the horizontal scrollbar and prevent ghosting
    tableView.getStylesheets().addAll(StyleClass.HIDE_HORIZONTAL_CSS);
    final TableColumn<Reminder, String> descriptionColumn = new TableColumn<>(resources.getString("Column.Description"));
    descriptionColumn.setCellValueFactory(param -> new SimpleObjectProperty<>(param.getValue().getDescription()));
    tableView.getColumns().add(descriptionColumn);
    final TableColumn<Reminder, String> accountColumn = new TableColumn<>(resources.getString("Column.Account"));
    accountColumn.setCellValueFactory(param -> new SimpleObjectProperty<>(param.getValue().getDescription()));
    accountColumn.setCellValueFactory(param -> {
        if (param.getValue().getAccount() != null) {
            return new SimpleObjectProperty<>(param.getValue().getAccount().toString());
        }
        return null;
    });
    tableView.getColumns().add(accountColumn);
    final TableColumn<Reminder, BigDecimal> amountColumn = new TableColumn<>(resources.getString("Column.Amount"));
    amountColumn.setCellValueFactory(param -> {
        if (param.getValue().getTransaction() != null) {
            return new SimpleObjectProperty<>(param.getValue().getTransaction().getAmount(param.getValue().getAccount()));
        }
        return null;
    });
    amountColumn.setCellFactory(param -> new ReminderBigDecimalTableCell());
    tableView.getColumns().add(amountColumn);
    final TableColumn<Reminder, String> frequencyColumn = new TableColumn<>(resources.getString("Column.Freq"));
    frequencyColumn.setCellValueFactory(param -> new SimpleObjectProperty<>(param.getValue().getReminderType().toString()));
    tableView.getColumns().add(frequencyColumn);
    final TableColumn<Reminder, Boolean> enabledColumn = new TableColumn<>(resources.getString("Column.Enabled"));
    enabledColumn.setCellValueFactory(param -> new SimpleBooleanProperty(param.getValue().isEnabled()));
    enabledColumn.setCellFactory(CheckBoxTableCell.forTableColumn(enabledColumn));
    tableView.getColumns().add(enabledColumn);
    final TableColumn<Reminder, LocalDate> lastPosted = new TableColumn<>(resources.getString("Column.LastPosted"));
    lastPosted.setCellValueFactory(param -> new SimpleObjectProperty<>(param.getValue().getLastDate()));
    lastPosted.setCellFactory(cell -> new ShortDateTableCell<>());
    tableView.getColumns().add(lastPosted);
    final TableColumn<Reminder, LocalDate> due = new TableColumn<>(resources.getString("Column.Due"));
    due.setCellValueFactory(param -> new SimpleObjectProperty<>(param.getValue().getIterator().next()));
    due.setCellFactory(cell -> new ShortDateTableCell<>());
    tableView.getColumns().add(due);
    sortedReminderList.comparatorProperty().bind(tableView.comparatorProperty());
    tableView.setItems(sortedReminderList);
    selectedReminder.bind(tableView.getSelectionModel().selectedItemProperty());
    // bind enabled state of the buttons to the selected reminder property
    deleteButton.disableProperty().bind(Bindings.isNull(selectedReminder));
    modifyButton.disableProperty().bind(Bindings.isNull(selectedReminder));
    nowButton.disableProperty().bind(Bindings.isNull(selectedReminder));
    MessageBus.getInstance().registerListener(this, MessageChannel.SYSTEM, MessageChannel.REMINDER);
    JavaFXUtils.runLater(this::loadTable);
    startTimer(true);
    // Update the period when the snooze value changes
    snoozePeriodListener = (observable, oldValue, newValue) -> {
        stopTimer();
        // while the dialog is up.
        if (!dialogShowing.get()) {
            startTimer(false);
        }
    };
    Options.reminderSnoozePeriodProperty().addListener(new WeakChangeListener<>(snoozePeriodListener));
}
Also used : SimpleBooleanProperty(javafx.beans.property.SimpleBooleanProperty) PendingReminder(jgnash.engine.recurring.PendingReminder) Reminder(jgnash.engine.recurring.Reminder) TableColumn(javafx.scene.control.TableColumn) LocalDate(java.time.LocalDate) BigDecimal(java.math.BigDecimal) SimpleObjectProperty(javafx.beans.property.SimpleObjectProperty) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) FXML(javafx.fxml.FXML)

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