Search in sources :

Example 51 with Action

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;
}
Also used : Button(javafx.scene.control.Button) TextField(javafx.scene.control.TextField) Insets(javafx.geometry.Insets) Stage(javafx.stage.Stage) ImageView(javafx.scene.image.ImageView) Node(javafx.scene.Node) Action(org.controlsfx.control.action.Action) CheckBox(javafx.scene.control.CheckBox) ControlsFXSample(org.controlsfx.ControlsFXSample) VBox(javafx.scene.layout.VBox) NotificationPane(org.controlsfx.control.NotificationPane) Action(org.controlsfx.control.action.Action) NotificationPane(org.controlsfx.control.NotificationPane) Insets(javafx.geometry.Insets) Button(javafx.scene.control.Button) CheckBox(javafx.scene.control.CheckBox) TextField(javafx.scene.control.TextField) ImageView(javafx.scene.image.ImageView) VBox(javafx.scene.layout.VBox)

Example 52 with Action

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;
}
Also used : Action(org.controlsfx.control.action.Action) GridPane(javafx.scene.layout.GridPane) Insets(javafx.geometry.Insets) ComboBox(javafx.scene.control.ComboBox) ActionEvent(javafx.event.ActionEvent) BooleanProperty(javafx.beans.property.BooleanProperty) Label(javafx.scene.control.Label)

Example 53 with Action

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();
}
Also used : GithubRelease(eu.binjr.common.github.GithubRelease) Pos(javafx.geometry.Pos) java.util(java.util) URL(java.net.URL) Action(org.controlsfx.control.action.Action) URISyntaxException(java.net.URISyntaxException) LocalDateTime(java.time.LocalDateTime) Security(java.security.Security) Task(javafx.concurrent.Task) UserPreferences(eu.binjr.core.preferences.UserPreferences) Version(eu.binjr.common.version.Version) org.bouncycastle.openpgp(org.bouncycastle.openpgp) JcaPGPContentVerifierBuilderProvider(org.bouncycastle.openpgp.operator.jcajce.JcaPGPContentVerifierBuilderProvider) WindowEvent(javafx.stage.WindowEvent) URI(java.net.URI) Logger(eu.binjr.common.logging.Logger) Path(java.nio.file.Path) JcaKeyFingerprintCalculator(org.bouncycastle.openpgp.operator.jcajce.JcaKeyFingerprintCalculator) Dialogs(eu.binjr.core.dialogs.Dialogs) Files(java.nio.file.Files) ProxyConfiguration(eu.binjr.common.io.ProxyConfiguration) NodeUtils(eu.binjr.common.javafx.controls.NodeUtils) AppEnvironment(eu.binjr.core.preferences.AppEnvironment) Node(javafx.scene.Node) StandardOpenOption(java.nio.file.StandardOpenOption) IOException(java.io.IOException) AsyncTaskManager(eu.binjr.core.data.async.AsyncTaskManager) Consumer(java.util.function.Consumer) GithubApiHelper(eu.binjr.common.github.GithubApiHelper) Duration(javafx.util.Duration) ChronoUnit(java.time.temporal.ChronoUnit) JcaPGPObjectFactory(org.bouncycastle.openpgp.jcajce.JcaPGPObjectFactory) Notifications(org.controlsfx.control.Notifications) InputStream(java.io.InputStream) Action(org.controlsfx.control.action.Action) Node(javafx.scene.Node) Notifications(org.controlsfx.control.Notifications)

Example 54 with Action

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;
}
Also used : DialogPane(javafx.scene.control.DialogPane) Action(org.controlsfx.control.action.Action) GridPane(javafx.scene.layout.GridPane) ActionEvent(javafx.event.ActionEvent) Node(javafx.scene.Node) Label(javafx.scene.control.Label) Alert(javafx.scene.control.Alert) ButtonType(javafx.scene.control.ButtonType) VBox(javafx.scene.layout.VBox) Font(javafx.scene.text.Font)

Aggregations

Action (org.controlsfx.control.action.Action)54 BorderPane (javafx.scene.layout.BorderPane)21 ActionUtils (org.controlsfx.control.action.ActionUtils)16 KeyCodeCombination (javafx.scene.input.KeyCodeCombination)15 Arrays (java.util.Arrays)14 Dict (se.trixon.almond.util.Dict)14 MaterialIcon (se.trixon.almond.util.icons.material.MaterialIcon)14 ArrayList (java.util.ArrayList)13 IOException (java.io.IOException)12 MenuItem (javafx.scene.control.MenuItem)12 Mapton.getIconSizeToolBarInt (org.mapton.api.Mapton.getIconSizeToolBarInt)12 FxHelper (se.trixon.almond.util.fx.FxHelper)12 Platform (javafx.application.Platform)11 Node (javafx.scene.Node)11 ContextMenu (javafx.scene.control.ContextMenu)11 Label (javafx.scene.control.Label)11 List (java.util.List)10 Insets (javafx.geometry.Insets)10 File (java.io.File)9 ActionEvent (javafx.event.ActionEvent)9