use of org.controlsfx.control.action.Action in project controlsfx by controlsfx.
the class HelloNotificationPane method getPanel.
@Override
public Node getPanel(Stage stage) {
notificationPane = new NotificationPane();
String imagePath = HelloNotificationPane.class.getResource("notification-pane-warning.png").toExternalForm();
ImageView image = new ImageView(imagePath);
notificationPane.setGraphic(image);
notificationPane.getActions().addAll(new Action("Sync", ae -> {
// do sync
// then hide...
notificationPane.hide();
}));
Button showBtn = new Button("Show / Hide");
showBtn.setOnAction(e -> {
if (notificationPane.isShowing()) {
notificationPane.hide();
} else {
notificationPane.show();
}
});
CheckBox cbSlideFromTop = new CheckBox("Slide from top");
cbSlideFromTop.setSelected(true);
notificationPane.showFromTopProperty().bind(cbSlideFromTop.selectedProperty());
cbUseDarkTheme = new CheckBox("Use dark theme");
cbUseDarkTheme.setSelected(false);
cbUseDarkTheme.setOnAction(e -> updateBar());
cbHideCloseBtn = new CheckBox("Hide close button");
cbHideCloseBtn.setSelected(false);
cbHideCloseBtn.setOnAction(e -> notificationPane.setCloseButtonVisible(!cbHideCloseBtn.isSelected()));
textField = new TextField();
textField.setPromptText("Type text to display and press Enter");
textField.setOnAction(e -> notificationPane.show(textField.getText()));
VBox root = new VBox(10);
root.setPadding(new Insets(50, 0, 0, 10));
root.getChildren().addAll(showBtn, cbSlideFromTop, cbUseDarkTheme, cbHideCloseBtn, textField);
notificationPane.setContent(root);
updateBar();
return notificationPane;
}
use of org.controlsfx.control.action.Action in project controlsfx by controlsfx.
the class HelloActionGroup method getControlPanel.
@Override
public Node getControlPanel() {
GridPane grid = new GridPane();
grid.setVgap(10);
grid.setHgap(10);
grid.setPadding(new Insets(30, 30, 0, 30));
int row = 0;
// Dynamically enable/disable action
Label lblAddCrumb = new Label("Dynamically enable/disable action: ");
lblAddCrumb.getStyleClass().add("property");
grid.add(lblAddCrumb, 0, row);
final ComboBox<Action> cbActions = new ComboBox<>(flatten(actions, FXCollections.<Action>observableArrayList()));
cbActions.getSelectionModel().select(0);
grid.add(cbActions, 1, row);
Action toggleAction = new Action("Enable/Disable") {
{
setEventHandler(this::handleAction);
}
private void handleAction(ActionEvent ae) {
Action action = cbActions.getSelectionModel().getSelectedItem();
if (action != null) {
BooleanProperty p = action.disabledProperty();
p.set(!p.get());
}
}
};
grid.add(ActionUtils.createButton(toggleAction), 2, row++);
return grid;
}
use of org.controlsfx.control.action.Action in project binjr by binjr.
the class UpdateManager method showUpdateReadyNotification.
private void showUpdateReadyNotification(Node root) {
Notifications n = Notifications.create().title("binjr is now ready to be updated!").text("The update package has been downloaded successfully.").hideAfter(Duration.seconds(20)).position(Pos.BOTTOM_RIGHT).owner(root);
n.action(new Action("Restart & update now", event -> restartApp(root)), new Action("Update when I exit", event -> {
Dialogs.dismissParentNotificationPopup((Node) event.getSource());
}));
n.showInformation();
}
use of org.controlsfx.control.action.Action in project almond by trixon.
the class AboutPane method getAction.
public static Action getAction(Stage stage, AboutModel aboutModel) {
AboutPane aboutPane = new AboutPane(aboutModel);
Action action = new Action(Dict.ABOUT.toString(), (ActionEvent event) -> {
aboutPane.reset();
Alert alert = new Alert(Alert.AlertType.NONE);
alert.initOwner(stage);
alert.setTitle(String.format(Dict.ABOUT_S.toString(), aboutModel.getAppName()));
ButtonType closeButtonType = new ButtonType(Dict.CLOSE.toString(), ButtonData.OK_DONE);
alert.getButtonTypes().setAll(closeButtonType);
alert.setGraphic((ImageView) aboutModel.getLogo());
alert.setHeaderText(" ");
alert.setResizable(true);
DialogPane dialogPane = alert.getDialogPane();
dialogPane.setContent(aboutPane);
double scale = SwingHelper.getUIScale();
dialogPane.setPrefSize(520 * scale, 400 * scale);
for (Node node : dialogPane.getChildren()) {
if (node instanceof GridPane) {
GridPane gridPane = (GridPane) node;
Label appLabel = new Label(aboutModel.getAppName());
double scaledFontSize = FxHelper.getScaledFontSize();
appLabel.setFont(new Font(scaledFontSize * 1.8));
Label verLabel = new Label(String.format("%s %s", Dict.VERSION.toString(), aboutModel.getAppVersion()));
verLabel.setFont(new Font(scaledFontSize * 1.2));
Label dateLabel = new Label(aboutModel.getAppDate());
dateLabel.setFont(new Font(scaledFontSize * 1.2));
VBox box = new VBox(appLabel, verLabel, dateLabel);
box.setAlignment(Pos.CENTER_LEFT);
gridPane.add(box, 0, 0);
break;
}
}
FxHelper.showAndWait(alert, stage);
});
return action;
}
Aggregations