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;
}
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;
}
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();
}
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;
});
}
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));
}
Aggregations