Search in sources :

Example 1 with Action

use of org.controlsfx.control.action.Action in project java-jotasync by trixon.

the class MainApp method initActions.

private void initActions() {
    // DRAWER
    // history
    mHistoryAction = new Action(Dict.HISTORY.toString(), (ActionEvent event) -> {
        mWorkbench.hideNavigationDrawer();
        mWorkbench.openModule(mHistoryModule);
    });
    mHistoryAction.disabledProperty().bind(mManager.connectedProperty().not());
    // options
    mOptionsAction = new Action(Dict.OPTIONS.toString(), (ActionEvent event) -> {
        mWorkbench.hideNavigationDrawer();
        displayOptions();
    });
    // help
    mHelpAction = new Action(Dict.HELP.toString(), (ActionEvent event) -> {
        mWorkbench.hideNavigationDrawer();
        SystemHelper.desktopBrowse("https://trixon.se/projects/jotasync/documentation/");
    });
    // about rsync
    mAboutRsyncAction = new Action(String.format(Dict.ABOUT_S.toString(), "rsync"), (ActionEvent event) -> {
        mWorkbench.hideNavigationDrawer();
        try {
            String aboutRsync = mManager.getServerCommander().getAboutRsync();
            mWorkbench.showInformationDialog(String.format(Dict.ABOUT_S.toString(), "rsync"), aboutRsync, null);
        } catch (RemoteException ex) {
            Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, null, ex);
        }
    });
    mAboutRsyncAction.disabledProperty().bind(mManager.connectedProperty().not());
    // about
    mAboutAction = new Action(Dict.ABOUT.toString(), (ActionEvent event) -> {
        mWorkbench.hideNavigationDrawer();
        PomInfo pomInfo = new PomInfo(MainApp.class, "se.trixon", "jotasync");
        AboutModel aboutModel = new AboutModel(SystemHelper.getBundle(getClass(), "about"), SystemHelperFx.getResourceAsImageView(MainApp.class, "logo.png"));
        aboutModel.setAppVersion(pomInfo.getVersion());
        AboutPane aboutPane = new AboutPane(aboutModel);
        double scaledFontSize = FxHelper.getScaledFontSize();
        Label appLabel = new Label(aboutModel.getAppName());
        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);
        box.setPadding(new Insets(0, 0, 0, 22));
        BorderPane topBorderPane = new BorderPane(box);
        topBorderPane.setLeft(aboutModel.getImageView());
        topBorderPane.setPadding(new Insets(22));
        BorderPane mainBorderPane = new BorderPane(aboutPane);
        mainBorderPane.setTop(topBorderPane);
        WorkbenchDialog dialog = WorkbenchDialog.builder(Dict.ABOUT.toString(), mainBorderPane, ButtonType.CLOSE).build();
        mWorkbench.showDialog(dialog);
    });
}
Also used : Action(org.controlsfx.control.action.Action) BorderPane(javafx.scene.layout.BorderPane) PomInfo(se.trixon.almond.util.PomInfo) AboutPane(se.trixon.almond.util.fx.dialogs.about.AboutPane) Insets(javafx.geometry.Insets) ActionEvent(javafx.event.ActionEvent) Label(javafx.scene.control.Label) AboutModel(se.trixon.almond.util.fx.AboutModel) Font(javafx.scene.text.Font) WorkbenchDialog(com.dlsc.workbenchfx.model.WorkbenchDialog) RemoteException(java.rmi.RemoteException) VBox(javafx.scene.layout.VBox)

Example 2 with Action

use of org.controlsfx.control.action.Action in project selenium_java by sergueik.

the class MainViewController method onAvailableUpdate.

private void onAvailableUpdate(GithubRelease githubRelease) {
    Notifications n = Notifications.create().title("New release available!").text("You are currently running binjr version " + AppEnvironment.getInstance().getVersion() + "\t\t.\nVersion " + githubRelease.getVersion() + " is now available.").hideAfter(Duration.seconds(20)).position(Pos.BOTTOM_RIGHT).owner(root);
    n.action(new Action("Download", actionEvent -> {
        String newReleaseUrl = githubRelease.getHtmlUrl();
        if (newReleaseUrl != null && newReleaseUrl.trim().length() > 0) {
            try {
                Dialogs.launchUrlInExternalBrowser(newReleaseUrl);
            } catch (IOException | URISyntaxException e) {
                logger.error("Failed to launch url in browser " + newReleaseUrl, e);
            }
        }
        n.hideAfter(Duration.seconds(0));
    }));
    n.showInformation();
}
Also used : StageStyle(javafx.stage.StageStyle) DataAdapterException(eu.fthevenet.binjr.data.exceptions.DataAdapterException) HPos(javafx.geometry.HPos) Pos(javafx.geometry.Pos) Initializable(javafx.fxml.Initializable) DoubleBinding(javafx.beans.binding.DoubleBinding) javafx.scene.layout(javafx.scene.layout) Dialogs(eu.fthevenet.binjr.dialogs.Dialogs) javafx.scene.control(javafx.scene.control) URL(java.net.URL) URISyntaxException(java.net.URISyntaxException) ZonedDateTime(java.time.ZonedDateTime) NoAdapterFoundException(eu.fthevenet.binjr.data.exceptions.NoAdapterFoundException) DataAdapterDialog(eu.fthevenet.binjr.dialogs.DataAdapterDialog) Side(javafx.geometry.Side) Application(javafx.application.Application) Parent(javafx.scene.Parent) MaskerPane(org.controlsfx.control.MaskerPane) ListChangeListener(javafx.collections.ListChangeListener) DiagnosticCommand(eu.fthevenet.util.diagnositic.DiagnosticCommand) CannotInitializeDataAdapterException(eu.fthevenet.binjr.data.exceptions.CannotInitializeDataAdapterException) eu.fthevenet.util.javafx.controls(eu.fthevenet.util.javafx.controls) UpdateManager(eu.fthevenet.binjr.preferences.UpdateManager) eu.fthevenet.binjr.data.workspace(eu.fthevenet.binjr.data.workspace) USE_COMPUTED_SIZE(javafx.scene.layout.Region.USE_COMPUTED_SIZE) Event(javafx.event.Event) AsyncTaskManager(eu.fthevenet.binjr.data.async.AsyncTaskManager) AppEnvironment(eu.fthevenet.binjr.preferences.AppEnvironment) JAXBException(javax.xml.bind.JAXBException) Collectors(java.util.stream.Collectors) ZoneId(java.time.ZoneId) Platform(javafx.application.Platform) FXML(javafx.fxml.FXML) DataAdapter(eu.fthevenet.binjr.data.adapters.DataAdapter) Duration(javafx.util.Duration) Logger(org.apache.logging.log4j.Logger) TimeSeriesBinding(eu.fthevenet.binjr.data.adapters.TimeSeriesBinding) Binjr(eu.fthevenet.binjr.Binjr) Notifications(org.controlsfx.control.Notifications) StageAppearanceManager(eu.fthevenet.binjr.dialogs.StageAppearanceManager) Binding(javafx.beans.binding.Binding) java.util(java.util) GithubRelease(eu.fthevenet.util.github.GithubRelease) Action(org.controlsfx.control.action.Action) DiagnosticException(eu.fthevenet.util.diagnositic.DiagnosticException) javafx.animation(javafx.animation) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) DataAdapterFactory(eu.fthevenet.binjr.data.adapters.DataAdapterFactory) DataAdapterInfo(eu.fthevenet.binjr.data.adapters.DataAdapterInfo) Bindings(javafx.beans.binding.Bindings) Supplier(java.util.function.Supplier) VPos(javafx.geometry.VPos) FXMLLoader(javafx.fxml.FXMLLoader) GlobalPreferences(eu.fthevenet.binjr.preferences.GlobalPreferences) StreamSupport(java.util.stream.StreamSupport) Callback(javafx.util.Callback) Color(javafx.scene.paint.Color) javafx.beans.property(javafx.beans.property) javafx.scene.input(javafx.scene.input) Files(java.nio.file.Files) Node(javafx.scene.Node) IOException(java.io.IOException) File(java.io.File) FileChooser(javafx.stage.FileChooser) ActionEvent(javafx.event.ActionEvent) ChronoUnit(java.time.temporal.ChronoUnit) Stage(javafx.stage.Stage) Paths(java.nio.file.Paths) ObservableValue(javafx.beans.value.ObservableValue) LogManager(org.apache.logging.log4j.LogManager) Action(org.controlsfx.control.action.Action) Notifications(org.controlsfx.control.Notifications)

Example 3 with Action

use of org.controlsfx.control.action.Action in project qupath by qupath.

the class QuPathGUI method initializeMainComponent.

private BorderPane initializeMainComponent() {
    pane = new BorderPane();
    // Create a reasonably-sized viewer
    QuPathViewerPlus viewer = new QuPathViewerPlus(null, imageRegionStore, overlayOptions, viewerDisplayOptions);
    // Add analysis panel & viewer to split pane
    viewerManager = new MultiviewManager(viewer);
    viewerProperty.bind(viewerManager.activeViewerProperty());
    // Now that we have a viewer, we can create an undo/redo manager
    undoRedoManager = new UndoRedoManager(this);
    // TODO: MOVE INITIALIZING MANAGERS ELSEWHERE
    actions.addAll(new Menus(this).getActions());
    // Add a recent projects menu
    getMenu("File", true).getItems().add(1, createRecentProjectsMenu());
    // analysisPanel = createAnalysisPanel();
    initializeAnalysisPanel();
    analysisPanel.setMinWidth(300);
    analysisPanel.setPrefWidth(400);
    splitPane.setMinWidth(analysisPanel.getMinWidth() + 200);
    splitPane.setPrefWidth(analysisPanel.getPrefWidth() + 200);
    SplitPane.setResizableWithParent(analysisPanel, Boolean.FALSE);
    // paneCommands.setRight(cbPin);
    mainViewerPane = CommandFinderTools.createCommandFinderPane(this, viewerManager.getNode(), CommandFinderTools.commandBarDisplayProperty());
    // paneViewer.setTop(tfCommands);
    // paneViewer.setCenter(viewerManager.getNode());
    splitPane.getItems().addAll(analysisPanel, mainViewerPane);
    // splitPane.getItems().addAll(viewerManager.getComponent());
    SplitPane.setResizableWithParent(viewerManager.getNode(), Boolean.TRUE);
    pane.setCenter(splitPane);
    toolbar = new ToolBarComponent(this);
    pane.setTop(toolbar.getToolBar());
    setAnalysisPaneVisible(showAnalysisPane.get());
    showAnalysisPane.addListener((v, o, n) -> setAnalysisPaneVisible(n));
    // setInitialLocationAndMagnification(getViewer());
    // Prepare the viewer
    setupViewer(viewerManager.getActiveViewer());
    // Ensure the mode is set
    // Ensure actions are set appropriately
    selectedToolProperty.addListener((v, o, n) -> {
        Action action = toolActions.get(n);
        if (action != null)
            action.setSelected(true);
        activateTools(getViewer());
        if (n == PathTools.POINTS)
            defaultActions.COUNTING_PANEL.handle(null);
        updateCursor();
    });
    setSelectedTool(getSelectedTool());
    return pane;
}
Also used : BorderPane(javafx.scene.layout.BorderPane) Action(org.controlsfx.control.action.Action) QuPathViewerPlus(qupath.lib.gui.viewer.QuPathViewerPlus)

Example 4 with Action

use of org.controlsfx.control.action.Action in project qupath by qupath.

the class LogViewerCommand method createDialog.

private void createDialog() {
    dialog = new Stage();
    dialog.setTitle("Log");
    BorderPane pane = new BorderPane(textPane);
    Action actionCopy = new Action("Copy", e -> {
        String text = textPane.getSelectedText();
        if (text == null || text.isEmpty())
            text = textPane.getText();
        ClipboardContent content = new ClipboardContent();
        content.putString(text);
        Clipboard.getSystemClipboard().setContent(content);
    });
    actionCopy.setAccelerator(new KeyCodeCombination(KeyCode.C, KeyCodeCombination.SHORTCUT_DOWN));
    Action actionClear = new Action("Clear log", e -> textPane.clear());
    CheckMenuItem miLockScroll = new CheckMenuItem("Scroll to end");
    miLockScroll.setSelected(true);
    // Add context menu
    ContextMenu menu = textPane.getContextMenu();
    if (menu == null) {
        menu = new ContextMenu();
        textPane.setContextMenu(menu);
        menu.getItems().add(ActionUtils.createMenuItem(actionCopy));
    // menu.getItems().add(new SeparatorMenuItem());
    } else
        menu.getItems().add(new SeparatorMenuItem());
    menu.getItems().add(ActionUtils.createMenuItem(actionClear));
    menu.getItems().add(miLockScroll);
    menu.getItems().add(createLogLevelMenu());
    // Add actual menubar
    MenuBar menubar = new MenuBar();
    Menu menuFile = new Menu("File");
    MenuItem miSave = new MenuItem("Save log");
    miSave.setAccelerator(new KeyCodeCombination(KeyCode.S, KeyCodeCombination.SHORTCUT_DOWN));
    miSave.setOnAction(e -> {
        File fileOutput = Dialogs.getChooser(dialog).promptToSaveFile("Save log", null, "log.txt", "Log files", ".txt");
        if (fileOutput == null)
            return;
        try {
            PrintWriter writer = new PrintWriter(fileOutput, StandardCharsets.UTF_8);
            writer.print(textPane.getText());
            writer.close();
        } catch (Exception ex) {
            logger.error("Problem writing log", ex);
        }
    });
    MenuItem miCloseWindow = new MenuItem("Close window");
    miCloseWindow.setAccelerator(new KeyCodeCombination(KeyCode.W, KeyCodeCombination.SHORTCUT_DOWN));
    miCloseWindow.setOnAction(e -> dialog.hide());
    menuFile.getItems().addAll(miSave, miCloseWindow);
    Menu menuEdit = new Menu("Edit");
    menuEdit.getItems().addAll(ActionUtils.createMenuItem(actionCopy), ActionUtils.createMenuItem(actionClear), createLogLevelMenu());
    menubar.getMenus().addAll(menuFile, menuEdit);
    pane.setTop(menubar);
    // menubar.setUseSystemMenuBar(true);
    menubar.useSystemMenuBarProperty().bindBidirectional(PathPrefs.useSystemMenubarProperty());
    Scene scene = new Scene(pane, 400, 300);
    dialog.setScene(scene);
    // dialog.getDialogPane().setContent(pane);
    dialog.setResizable(true);
    textPane.setEditable(false);
    // Keep scrolling to the last message
    textPane.textProperty().addListener((v, o, n) -> {
        if (dialog.isShowing() && miLockScroll.isSelected())
            Platform.runLater(() -> textPane.setScrollTop(Double.MAX_VALUE));
    });
    dialog.initModality(Modality.NONE);
    dialog.initOwner(qupath.getStage());
    dialog.setResizable(true);
}
Also used : BorderPane(javafx.scene.layout.BorderPane) Action(org.controlsfx.control.action.Action) ClipboardContent(javafx.scene.input.ClipboardContent) MenuBar(javafx.scene.control.MenuBar) KeyCodeCombination(javafx.scene.input.KeyCodeCombination) ContextMenu(javafx.scene.control.ContextMenu) CheckMenuItem(javafx.scene.control.CheckMenuItem) MenuItem(javafx.scene.control.MenuItem) SeparatorMenuItem(javafx.scene.control.SeparatorMenuItem) SeparatorMenuItem(javafx.scene.control.SeparatorMenuItem) Scene(javafx.scene.Scene) CheckMenuItem(javafx.scene.control.CheckMenuItem) Stage(javafx.stage.Stage) ContextMenu(javafx.scene.control.ContextMenu) Menu(javafx.scene.control.Menu) File(java.io.File) PrintWriter(java.io.PrintWriter)

Example 5 with Action

use of org.controlsfx.control.action.Action in project qupath by qupath.

the class DefaultScriptEditor method createSaveAction.

Action createSaveAction(final String name, final boolean saveAs) {
    Action action = new Action(name, e -> {
        ScriptTab tab = getCurrentScriptObject();
        if (tab == null)
            return;
        save(tab, saveAs);
    });
    if (saveAs)
        action.setAccelerator(new KeyCodeCombination(KeyCode.S, KeyCombination.SHORTCUT_DOWN, KeyCombination.SHIFT_DOWN));
    else
        action.setAccelerator(new KeyCodeCombination(KeyCode.S, KeyCombination.SHORTCUT_DOWN));
    return action;
}
Also used : Action(org.controlsfx.control.action.Action) KeyCodeCombination(javafx.scene.input.KeyCodeCombination)

Aggregations

Action (org.controlsfx.control.action.Action)31 KeyCodeCombination (javafx.scene.input.KeyCodeCombination)13 BorderPane (javafx.scene.layout.BorderPane)10 File (java.io.File)7 MenuItem (javafx.scene.control.MenuItem)7 SeparatorMenuItem (javafx.scene.control.SeparatorMenuItem)7 IOException (java.io.IOException)6 ArrayList (java.util.ArrayList)6 Button (javafx.scene.control.Button)6 KeyCode (javafx.scene.input.KeyCode)6 Stage (javafx.stage.Stage)6 ActionUtils (org.controlsfx.control.action.ActionUtils)6 List (java.util.List)5 Node (javafx.scene.Node)5 ButtonType (javafx.scene.control.ButtonType)5 ContextMenu (javafx.scene.control.ContextMenu)5 Label (javafx.scene.control.Label)5 Menu (javafx.scene.control.Menu)5 Tooltip (javafx.scene.control.Tooltip)5 KeyCombination (javafx.scene.input.KeyCombination)5