use of javafx.beans.InvalidationListener in project org.csstudio.display.builder by kasemir.
the class ActionsDialog method createWritePVDetails.
/**
* @return Sub-pane for WritePV action
*/
private GridPane createWritePVDetails() {
final InvalidationListener update = whatever -> {
if (updating || selected_action_index < 0)
return;
actions.set(selected_action_index, getWritePVAction());
};
final GridPane write_pv_details = new GridPane();
write_pv_details.setHgap(10);
write_pv_details.setVgap(10);
write_pv_details.add(new Label(Messages.ActionsDialog_Description), 0, 0);
write_pv_description = new TextField();
write_pv_description.textProperty().addListener(update);
write_pv_details.add(write_pv_description, 1, 0);
GridPane.setHgrow(write_pv_description, Priority.ALWAYS);
write_pv_details.add(new Label(Messages.ActionsDialog_PVName), 0, 1);
write_pv_name = new TextField();
menu.attachField(write_pv_name);
setOnHidden((event) -> menu.removeField(write_pv_name));
write_pv_name.textProperty().addListener(update);
write_pv_details.add(write_pv_name, 1, 1);
write_pv_details.add(new Label(Messages.ActionsDialog_Value), 0, 2);
write_pv_value = new TextField();
write_pv_value.textProperty().addListener(update);
write_pv_details.add(write_pv_value, 1, 2);
return write_pv_details;
}
use of javafx.beans.InvalidationListener in project org.csstudio.display.builder by kasemir.
the class ActionsDialog method createOpenWebDetails.
/**
* @return Sub-pane for OpenWeb action
*/
private GridPane createOpenWebDetails() {
final InvalidationListener update = whatever -> {
if (updating || selected_action_index < 0)
return;
actions.set(selected_action_index, getOpenWebAction());
};
final GridPane open_web_details = new GridPane();
open_web_details.setHgap(10);
open_web_details.setVgap(10);
open_web_details.add(new Label(Messages.ActionsDialog_Description), 0, 0);
open_web_description = new TextField();
open_web_description.textProperty().addListener(update);
open_web_details.add(open_web_description, 1, 0);
GridPane.setHgrow(open_web_description, Priority.ALWAYS);
open_web_details.add(new Label(Messages.ActionsDialog_URL), 0, 1);
open_web_url = new TextField();
open_web_url.textProperty().addListener(update);
open_web_details.add(open_web_url, 1, 1);
return open_web_details;
}
use of javafx.beans.InvalidationListener in project org.csstudio.display.builder by kasemir.
the class ActionsDialog method createOpenDisplayDetails.
/**
* @return Sub-pane for OpenDisplay action
*/
private GridPane createOpenDisplayDetails() {
final InvalidationListener update = whatever -> {
if (updating || selected_action_index < 0)
return;
actions.set(selected_action_index, getOpenDisplayAction());
};
final GridPane open_display_details = new GridPane();
// open_display_details.setGridLinesVisible(true);
open_display_details.setHgap(10);
open_display_details.setVgap(10);
open_display_details.add(new Label(Messages.ActionsDialog_Description), 0, 0);
open_display_description = new TextField();
open_display_description.textProperty().addListener(update);
open_display_details.add(open_display_description, 1, 0);
GridPane.setHgrow(open_display_description, Priority.ALWAYS);
open_display_details.add(new Label(Messages.ActionsDialog_DisplayPath), 0, 1);
open_display_path = new TextField();
open_display_path.textProperty().addListener(update);
final Button select = new Button("...");
select.setOnAction(event -> {
try {
final String path = FilenameSupport.promptForRelativePath(widget, open_display_path.getText());
if (path != null)
open_display_path.setText(path);
FilenameSupport.performMostAwfulTerribleNoGoodHack(action_list);
} catch (Exception ex) {
logger.log(Level.WARNING, "Cannot prompt for filename", ex);
}
});
final HBox path_box = new HBox(open_display_path, select);
HBox.setHgrow(open_display_path, Priority.ALWAYS);
open_display_details.add(path_box, 1, 1);
final HBox modes_box = new HBox(10);
open_display_targets = new ToggleGroup();
final Target[] modes = Target.values();
for (int i = 0; i < modes.length; ++i) {
final RadioButton target = new RadioButton(modes[i].toString());
target.setToggleGroup(open_display_targets);
target.selectedProperty().addListener(update);
if (modes[i] == Target.STANDALONE && !Preferences.isStandaloneWindowSupported())
target.setDisable(true);
modes_box.getChildren().add(target);
}
open_display_details.add(modes_box, 0, 2, 2, 1);
open_display_macros = new MacrosTable(new Macros());
open_display_macros.addListener(update);
open_display_details.add(open_display_macros.getNode(), 0, 3, 2, 1);
GridPane.setHgrow(open_display_macros.getNode(), Priority.ALWAYS);
GridPane.setVgrow(open_display_macros.getNode(), Priority.ALWAYS);
return open_display_details;
}
use of javafx.beans.InvalidationListener in project org.csstudio.display.builder by kasemir.
the class PopupDemo method start.
@Override
public void start(final Stage stage) {
final Popup popup = new Popup();
final BorderPane content = new BorderPane(new Label("Center"), new Label("Top"), new Label("Right"), new Label("Bottom"), new Label("Left"));
final Rectangle background = new Rectangle(100, 100, Color.LIGHTGRAY);
final InvalidationListener resize_background = p -> {
background.setWidth(content.getWidth());
background.setHeight(content.getHeight());
};
content.widthProperty().addListener(resize_background);
content.heightProperty().addListener(resize_background);
final StackPane stack = new StackPane(background, content);
popup.getContent().addAll(stack);
final Button toggle_popup = new Button("Popup");
final ChangeListener<Number> track_moves = (p, old, current) -> {
// Position popup just below button
final Bounds bounds = toggle_popup.localToScreen(toggle_popup.getBoundsInLocal());
popup.setX(bounds.getMinX());
popup.setY(bounds.getMaxY());
};
toggle_popup.setOnAction(event -> {
if (popup.isShowing()) {
popup.hide();
toggle_popup.getScene().getWindow().xProperty().removeListener(track_moves);
toggle_popup.getScene().getWindow().yProperty().removeListener(track_moves);
} else {
toggle_popup.getScene().getWindow().xProperty().addListener(track_moves);
toggle_popup.getScene().getWindow().yProperty().addListener(track_moves);
track_moves.changed(null, null, null);
popup.show(stage);
}
});
final BorderPane layout = new BorderPane(toggle_popup);
stage.setScene(new Scene(layout));
stage.show();
}
use of javafx.beans.InvalidationListener in project org.csstudio.display.builder by kasemir.
the class ColorMapDialog method hookListeners.
private void hookListeners() {
predefined_table.getSelectionModel().selectedItemProperty().addListener((p, old, selected_map) -> {
if (selected_map != null)
updateUIfromMap(selected_map);
});
// Assert that at least 2 sections are left
remove.setOnAction(event -> {
if (color_sections.size() <= 2)
return;
final int index = sections_table.getSelectionModel().getSelectedIndex();
if (index < 0)
return;
color_sections.remove(index);
updateMapFromSections();
});
final InvalidationListener check_sections = observable -> remove.setDisable(color_sections.size() < 3);
color_sections.addListener(check_sections);
check_sections.invalidated(color_sections);
// Try to interpolate new section between existing sections
add.setOnAction(event -> {
final int size = color_sections.size();
final int index = Math.max(0, sections_table.getSelectionModel().getSelectedIndex());
final ColorSection before = color_sections.get(index);
if (index + 1 < size) {
// Add new color in 'middle'
final ColorSection after = (index + 1) < size ? color_sections.get(index + 1) : null;
final int mid_value = (before.value + after.value) / 2;
final Color color_mix = before.color.interpolate(after.color, 0.5);
color_sections.add(index + 1, new ColorSection(mid_value, color_mix));
} else
color_sections.add(new ColorSection(255, before.color));
updateMapFromSections();
});
}
Aggregations