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);
});
}
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();
}
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;
}
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);
}
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;
}
Aggregations