use of javafx.scene.control.ButtonBase in project org.csstudio.display.builder by kasemir.
the class ActionButtonRepresentation method makeBaseButton.
// private int calls = 0;
/**
* Create <code>base</code>, either single-action button
* or menu for selecting one out of N actions
*/
private ButtonBase makeBaseButton() {
final ActionInfos actions = model_widget.propActions().getValue();
final ButtonBase result;
if (actions.isExecutedAsOne() || actions.getActions().size() < 2) {
final Button button = new Button();
button.setOnAction(event -> handleActions(actions.getActions()));
result = button;
} else {
final MenuButton button = new MenuButton();
// Experimenting with ways to force update of popup location,
// #226
button.showingProperty().addListener((prop, old, showing) -> {
if (showing) {
// System.out.println("Showing " + model_widget + " menu: " + showing);
// if (++calls > 2)
// {
// System.out.println("Hack!");
// if (button.getPopupSide() == Side.BOTTOM)
// button.setPopupSide(Side.LEFT);
// else
// button.setPopupSide(Side.BOTTOM);
// // button.layout();
// }
}
});
for (final ActionInfo action : actions.getActions()) {
final MenuItem item = new MenuItem(makeActionText(action), new ImageView(new Image(action.getType().getIconStream())));
item.getStyleClass().add("action_button_item");
item.setOnAction(event -> handleAction(action));
button.getItems().add(item);
}
result = button;
}
result.setStyle(background);
result.getStyleClass().add("action_button");
result.setMnemonicParsing(false);
// Model has width/height, but JFX widget has min, pref, max size.
// updateChanges() will set the 'pref' size, so make min use that as well.
result.setMinSize(ButtonBase.USE_PREF_SIZE, ButtonBase.USE_PREF_SIZE);
// Monitor keys that modify the OpenDisplayActionInfo.Target.
// Use filter to capture event that's otherwise already handled.
result.addEventFilter(MouseEvent.MOUSE_PRESSED, this::checkModifiers);
// Need to attach TT to the specific button, not the common jfx_node Pane
TooltipSupport.attach(result, model_widget.propTooltip());
result.setCursor(Cursor.HAND);
return result;
}
use of javafx.scene.control.ButtonBase in project org.csstudio.display.builder by kasemir.
the class ImageToolbarHandler method newItem.
private ButtonBase newItem(final boolean toggle, final ToolIcons icon, final String tool_tip) {
final ButtonBase item = toggle ? new ToggleButton() : new Button();
try {
item.setGraphic(new ImageView(Activator.getIcon(icon.name().toLowerCase())));
} catch (Exception ex) {
logger.log(Level.WARNING, "Cannot get icon" + icon, ex);
item.setText(icon.toString());
}
item.setTooltip(new Tooltip(tool_tip));
toolbar.getItems().add(item);
return item;
}
use of javafx.scene.control.ButtonBase in project org.csstudio.display.builder by kasemir.
the class ToolbarHandler method newItem.
private ButtonBase newItem(final boolean toggle, final ToolIcons icon, final String tool_tip) {
final ButtonBase item = toggle ? new ToggleButton() : new Button();
try {
item.setGraphic(new ImageView(Activator.getIcon(icon.name().toLowerCase())));
} catch (Exception ex) {
logger.log(Level.WARNING, "Cannot get icon" + icon, ex);
item.setText(icon.toString());
}
item.setTooltip(new Tooltip(tool_tip));
toolbar.getItems().add(item);
return item;
}
Aggregations