Search in sources :

Example 36 with Action

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

the class TMASummaryViewer method getCustomizeTablePane.

private Pane getCustomizeTablePane() {
    TableView<TreeTableColumn<TMAEntry, ?>> tableColumns = new TableView<>();
    tableColumns.setPlaceholder(new Text("No columns available"));
    tableColumns.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
    tableColumns.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
    SortedList<TreeTableColumn<TMAEntry, ?>> sortedColumns = new SortedList<>(table.getColumns().filtered(p -> !p.getText().trim().isEmpty()));
    sortedColumns.setComparator((c1, c2) -> c1.getText().compareTo(c2.getText()));
    tableColumns.setItems(sortedColumns);
    sortedColumns.comparatorProperty().bind(tableColumns.comparatorProperty());
    // sortedColumns.comparatorProperty().bind(tableColumns.comparatorProperty());
    TableColumn<TreeTableColumn<TMAEntry, ?>, String> columnName = new TableColumn<>("Column");
    columnName.setCellValueFactory(v -> v.getValue().textProperty());
    TableColumn<TreeTableColumn<TMAEntry, ?>, Boolean> columnVisible = new TableColumn<>("Visible");
    columnVisible.setCellValueFactory(v -> v.getValue().visibleProperty());
    // columnVisible.setCellValueFactory(col -> {
    // SimpleBooleanProperty prop = new SimpleBooleanProperty(col.getValue().isVisible());
    // prop.addListener((v, o, n) -> col.getValue().setVisible(n));
    // return prop;
    // });
    tableColumns.setEditable(true);
    columnVisible.setCellFactory(v -> new CheckBoxTableCell<>());
    tableColumns.getColumns().add(columnName);
    tableColumns.getColumns().add(columnVisible);
    ContextMenu contextMenu = new ContextMenu();
    Action actionShowSelected = new Action("Show selected", e -> {
        for (TreeTableColumn<?, ?> col : tableColumns.getSelectionModel().getSelectedItems()) {
            if (col != null)
                col.setVisible(true);
            else {
                // Not sure why this happens...?
                logger.trace("Selected column is null!");
            }
        }
    });
    Action actionHideSelected = new Action("Hide selected", e -> {
        for (TreeTableColumn<?, ?> col : tableColumns.getSelectionModel().getSelectedItems()) {
            if (col != null)
                col.setVisible(false);
            else {
                // Not sure why this happens...?
                logger.trace("Selected column is null!");
            }
        }
    });
    contextMenu.getItems().addAll(ActionUtils.createMenuItem(actionShowSelected), ActionUtils.createMenuItem(actionHideSelected));
    tableColumns.setContextMenu(contextMenu);
    tableColumns.setTooltip(new Tooltip("Show or hide table columns - right-click to change multiple columns at once"));
    BorderPane paneColumns = new BorderPane(tableColumns);
    paneColumns.setBottom(PaneTools.createColumnGridControls(ActionUtils.createButton(actionShowSelected), ActionUtils.createButton(actionHideSelected)));
    VBox paneRows = new VBox();
    // Create a box to filter on some metadata text
    ComboBox<String> comboMetadata = new ComboBox<>();
    comboMetadata.setItems(metadataNames);
    comboMetadata.getSelectionModel().getSelectedItem();
    comboMetadata.setPromptText("Select column");
    TextField tfFilter = new TextField();
    CheckBox cbExact = new CheckBox("Exact");
    // Set listeners
    cbExact.selectedProperty().addListener((v, o, n) -> setMetadataTextPredicate(comboMetadata.getSelectionModel().getSelectedItem(), tfFilter.getText(), cbExact.isSelected(), !cbExact.isSelected()));
    tfFilter.textProperty().addListener((v, o, n) -> setMetadataTextPredicate(comboMetadata.getSelectionModel().getSelectedItem(), tfFilter.getText(), cbExact.isSelected(), !cbExact.isSelected()));
    comboMetadata.getSelectionModel().selectedItemProperty().addListener((v, o, n) -> setMetadataTextPredicate(comboMetadata.getSelectionModel().getSelectedItem(), tfFilter.getText(), cbExact.isSelected(), !cbExact.isSelected()));
    GridPane paneMetadata = new GridPane();
    paneMetadata.add(comboMetadata, 0, 0);
    paneMetadata.add(tfFilter, 1, 0);
    paneMetadata.add(cbExact, 2, 0);
    paneMetadata.setPadding(new Insets(10, 10, 10, 10));
    paneMetadata.setVgap(2);
    paneMetadata.setHgap(5);
    comboMetadata.setMaxWidth(Double.MAX_VALUE);
    GridPane.setHgrow(tfFilter, Priority.ALWAYS);
    GridPane.setFillWidth(comboMetadata, Boolean.TRUE);
    GridPane.setFillWidth(tfFilter, Boolean.TRUE);
    TitledPane tpMetadata = new TitledPane("Metadata filter", paneMetadata);
    tpMetadata.setExpanded(false);
    // tpMetadata.setCollapsible(false);
    Tooltip tooltipMetadata = new Tooltip("Enter text to filter entries according to a selected metadata column");
    Tooltip.install(paneMetadata, tooltipMetadata);
    tpMetadata.setTooltip(tooltipMetadata);
    paneRows.getChildren().add(tpMetadata);
    // Add measurement predicate
    TextField tfCommand = new TextField();
    tfCommand.setTooltip(new Tooltip("Predicate used to filter entries for inclusion"));
    TextFields.bindAutoCompletion(tfCommand, e -> {
        int ind = tfCommand.getText().lastIndexOf("\"");
        if (ind < 0)
            return Collections.emptyList();
        String part = tfCommand.getText().substring(ind + 1);
        return measurementNames.stream().filter(n -> n.startsWith(part)).map(n -> "\"" + n + "\" ").collect(Collectors.toList());
    });
    String instructions = "Enter a predicate to filter entries.\n" + "Only entries passing the test will be included in any results.\n" + "Examples of predicates include:\n" + "    \"Num Tumor\" > 200\n" + "    \"Num Tumor\" > 100 && \"Num Stroma\" < 1000";
    // labelInstructions.setTooltip(new Tooltip("Note: measurement names must be in \"inverted commands\" and\n" +
    // "&& indicates 'and', while || indicates 'or'."));
    BorderPane paneMeasurementFilter = new BorderPane(tfCommand);
    Label label = new Label("Predicate: ");
    label.setAlignment(Pos.CENTER);
    label.setMaxHeight(Double.MAX_VALUE);
    paneMeasurementFilter.setLeft(label);
    Button btnApply = new Button("Apply");
    btnApply.setOnAction(e -> {
        TablePredicate predicateNew = new TablePredicate(tfCommand.getText());
        if (predicateNew.isValid()) {
            predicateMeasurements.set(predicateNew);
        } else {
            Dialogs.showErrorMessage("Invalid predicate", "Current predicate '" + tfCommand.getText() + "' is invalid!");
        }
        e.consume();
    });
    TitledPane tpMeasurementFilter = new TitledPane("Measurement filter", paneMeasurementFilter);
    tpMeasurementFilter.setExpanded(false);
    Tooltip tooltipInstructions = new Tooltip(instructions);
    tpMeasurementFilter.setTooltip(tooltipInstructions);
    Tooltip.install(paneMeasurementFilter, tooltipInstructions);
    paneMeasurementFilter.setRight(btnApply);
    paneRows.getChildren().add(tpMeasurementFilter);
    logger.info("Predicate set to: {}", predicateMeasurements.get());
    VBox pane = new VBox();
    // TitledPane tpColumns = new TitledPane("Select column", paneColumns);
    // tpColumns.setMaxHeight(Double.MAX_VALUE);
    // tpColumns.setCollapsible(false);
    pane.getChildren().addAll(paneColumns, new Separator(), paneRows);
    VBox.setVgrow(paneColumns, Priority.ALWAYS);
    return pane;
}
Also used : Arrays(java.util.Arrays) Change(javafx.collections.ListChangeListener.Change) ServerTools(qupath.lib.images.servers.ServerTools) ActionUtils(org.controlsfx.control.action.ActionUtils) HistogramDisplay(qupath.lib.gui.charts.HistogramDisplay) PathTableData(qupath.lib.gui.measure.PathTableData) MasterDetailPane(org.controlsfx.control.MasterDetailPane) ScrollPane(javafx.scene.control.ScrollPane) TabPane(javafx.scene.control.TabPane) ListChangeListener(javafx.collections.ListChangeListener) SpearmansCorrelation(org.apache.commons.math3.stat.correlation.SpearmansCorrelation) Map(java.util.Map) SimpleIntegerProperty(javafx.beans.property.SimpleIntegerProperty) ScriptException(javax.script.ScriptException) Set(java.util.Set) KeyEvent(javafx.scene.input.KeyEvent) Executors(java.util.concurrent.Executors) Platform(javafx.application.Platform) Separator(javafx.scene.control.Separator) BooleanProperty(javafx.beans.property.BooleanProperty) Project(qupath.lib.projects.Project) Clipboard(javafx.scene.input.Clipboard) ScrollBarPolicy(javafx.scene.control.ScrollPane.ScrollBarPolicy) CheckBoxTableCell(javafx.scene.control.cell.CheckBoxTableCell) SimpleDoubleProperty(javafx.beans.property.SimpleDoubleProperty) SummaryMeasurementTableCommand(qupath.lib.gui.commands.SummaryMeasurementTableCommand) ObservableList(javafx.collections.ObservableList) BorderPane(javafx.scene.layout.BorderPane) TMAObjectEntry(qupath.lib.gui.tma.TMAEntries.TMAObjectEntry) WeakChangeListener(javafx.beans.value.WeakChangeListener) TreeItem(javafx.scene.control.TreeItem) FXCollections(javafx.collections.FXCollections) PathObjectHierarchy(qupath.lib.objects.hierarchy.PathObjectHierarchy) Bindings(javafx.beans.binding.Bindings) IntegerProperty(javafx.beans.property.IntegerProperty) ArrayList(java.util.ArrayList) MeasurementList(qupath.lib.measurements.MeasurementList) LinkedHashMap(java.util.LinkedHashMap) TabClosingPolicy(javafx.scene.control.TabPane.TabClosingPolicy) TextFields(org.controlsfx.control.textfield.TextFields) TreeTableView(javafx.scene.control.TreeTableView) TextAlignment(javafx.scene.text.TextAlignment) LinkedHashSet(java.util.LinkedHashSet) GridPane(javafx.scene.layout.GridPane) TitledPane(javafx.scene.control.TitledPane) ToolBar(javafx.scene.control.ToolBar) GeneralTools(qupath.lib.common.GeneralTools) Node(javafx.scene.Node) CheckBox(javafx.scene.control.CheckBox) IOException(java.io.IOException) ChartTools(qupath.lib.gui.charts.ChartTools) File(java.io.File) Menu(javafx.scene.control.Menu) DefaultTMAGrid(qupath.lib.objects.hierarchy.DefaultTMAGrid) KeyCodeCombination(javafx.scene.input.KeyCodeCombination) SelectionMode(javafx.scene.control.SelectionMode) TreeMap(java.util.TreeMap) SimpleObjectProperty(javafx.beans.property.SimpleObjectProperty) Tab(javafx.scene.control.Tab) ObservableValue(javafx.beans.value.ObservableValue) TMAGrid(qupath.lib.objects.hierarchy.TMAGrid) PathPrefs(qupath.lib.gui.prefs.PathPrefs) PaneTools(qupath.lib.gui.tools.PaneTools) PathIO(qupath.lib.io.PathIO) Button(javafx.scene.control.Button) Pos(javafx.geometry.Pos) LoggerFactory(org.slf4j.LoggerFactory) Scanner(java.util.Scanner) XYChart(javafx.scene.chart.XYChart) VBox(javafx.scene.layout.VBox) Side(javafx.geometry.Side) KeyCombination(javafx.scene.input.KeyCombination) ObservableMeasurementTableData(qupath.lib.gui.measure.ObservableMeasurementTableData) ComboBox(javafx.scene.control.ComboBox) ContextMenu(javafx.scene.control.ContextMenu) TableView(javafx.scene.control.TableView) QuPathGUI(qupath.lib.gui.QuPathGUI) SortedList(javafx.collections.transformation.SortedList) Pane(javafx.scene.layout.Pane) Orientation(javafx.geometry.Orientation) TextField(javafx.scene.control.TextField) MenuItem(javafx.scene.control.MenuItem) BufferedImage(java.awt.image.BufferedImage) Predicate(java.util.function.Predicate) Collection(java.util.Collection) FilteredList(javafx.collections.transformation.FilteredList) Collectors(java.util.stream.Collectors) SeparatorMenuItem(javafx.scene.control.SeparatorMenuItem) Text(javafx.scene.text.Text) SimpleBindings(javax.script.SimpleBindings) Priority(javafx.scene.layout.Priority) List(java.util.List) Entry(java.util.Map.Entry) Optional(java.util.Optional) NumberAxis(javafx.scene.chart.NumberAxis) Scene(javafx.scene.Scene) ListView(javafx.scene.control.ListView) ReadOnlyObjectProperty(javafx.beans.property.ReadOnlyObjectProperty) SimpleStringProperty(javafx.beans.property.SimpleStringProperty) Action(org.controlsfx.control.action.Action) HashMap(java.util.HashMap) DoubleProperty(javafx.beans.property.DoubleProperty) TMAScoreImporter(qupath.lib.io.TMAScoreImporter) TreeTableRow(javafx.scene.control.TreeTableRow) TableColumn(javafx.scene.control.TableColumn) HashSet(java.util.HashSet) Dialogs(qupath.lib.gui.dialogs.Dialogs) ScatterChart(javafx.scene.chart.ScatterChart) Insets(javafx.geometry.Insets) Callback(javafx.util.Callback) Tooltip(javafx.scene.control.Tooltip) ExecutorService(java.util.concurrent.ExecutorService) ImageData(qupath.lib.images.ImageData) KeyCode(javafx.scene.input.KeyCode) ObjectProperty(javafx.beans.property.ObjectProperty) Logger(org.slf4j.Logger) Label(javafx.scene.control.Label) MenuBar(javafx.scene.control.MenuBar) CellDataFeatures(javafx.scene.control.TreeTableColumn.CellDataFeatures) ProjectImageEntry(qupath.lib.projects.ProjectImageEntry) ScriptEngineManager(javax.script.ScriptEngineManager) TMACoreObject(qupath.lib.objects.TMACoreObject) PearsonsCorrelation(org.apache.commons.math3.stat.correlation.PearsonsCorrelation) DropShadow(javafx.scene.effect.DropShadow) MenuTools(qupath.lib.gui.tools.MenuTools) ScriptContext(javax.script.ScriptContext) TMAEntry(qupath.lib.gui.tma.TMAEntries.TMAEntry) TreeTableColumn(javafx.scene.control.TreeTableColumn) SimpleBooleanProperty(javafx.beans.property.SimpleBooleanProperty) Stage(javafx.stage.Stage) ScriptEngine(javax.script.ScriptEngine) ChangeListener(javafx.beans.value.ChangeListener) Collections(java.util.Collections) Action(org.controlsfx.control.action.Action) BorderPane(javafx.scene.layout.BorderPane) Insets(javafx.geometry.Insets) SortedList(javafx.collections.transformation.SortedList) Label(javafx.scene.control.Label) ContextMenu(javafx.scene.control.ContextMenu) Button(javafx.scene.control.Button) TextField(javafx.scene.control.TextField) TreeTableView(javafx.scene.control.TreeTableView) TableView(javafx.scene.control.TableView) TitledPane(javafx.scene.control.TitledPane) GridPane(javafx.scene.layout.GridPane) ComboBox(javafx.scene.control.ComboBox) Tooltip(javafx.scene.control.Tooltip) Text(javafx.scene.text.Text) TableColumn(javafx.scene.control.TableColumn) TreeTableColumn(javafx.scene.control.TreeTableColumn) TreeTableColumn(javafx.scene.control.TreeTableColumn) CheckBox(javafx.scene.control.CheckBox) VBox(javafx.scene.layout.VBox) Separator(javafx.scene.control.Separator)

Example 37 with Action

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

the class DefaultScriptEditor method createInsertAction.

Action createInsertAction(final String name) {
    Action action = new Action(name, e -> {
        var control = getCurrentTextComponent();
        String join = "," + System.lineSeparator() + "  ";
        String listFormat = "[" + System.lineSeparator() + "  %s" + System.lineSeparator() + "]";
        if (name.toLowerCase().equals("pixel classifiers")) {
            try {
                String classifiers = qupath.getProject().getPixelClassifiers().getNames().stream().map(classifierName -> "\"" + classifierName + "\"").collect(Collectors.joining(join));
                String s = classifiers.isEmpty() ? "[]" : String.format(listFormat, classifiers);
                control.paste(s);
            } catch (IOException ex) {
                logger.error("Could not fetch classifiers", ex.getLocalizedMessage());
            }
        } else if (name.toLowerCase().equals("object classifiers")) {
            try {
                String classifiers = qupath.getProject().getObjectClassifiers().getNames().stream().map(classifierName -> "\"" + classifierName + "\"").collect(Collectors.joining(join));
                String s = classifiers.isEmpty() ? "[]" : String.format(listFormat, classifiers);
                control.paste(s);
            } catch (IOException ex) {
                logger.error("Could not fetch classifiers", ex.getLocalizedMessage());
            }
        } else if (name.toLowerCase().equals("detection")) {
            var imageData = qupath.getImageData();
            String measurements = "";
            if (imageData != null) {
                measurements = imageData.getHierarchy().getDetectionObjects().stream().flatMap(d -> d.getMeasurementList().getMeasurementNames().stream()).distinct().map(m -> "\"" + m + "\"").collect(Collectors.joining(join));
            }
            String s = measurements.isEmpty() ? "[]" : String.format(listFormat, measurements);
            control.paste(s);
        } else if (name.toLowerCase().equals(GeneralTools.SYMBOL_MU + ""))
            control.paste(GeneralTools.SYMBOL_MU + "");
        else {
        // TODO: fix
        // // Imports (end with a new line)
        // if (name.toLowerCase().equals("qpex"))
        // control.insertText(0, "import static qupath.lib.gui.scripting.QPEx.*");
        // else if (name.toLowerCase().equals("qp"))
        // control.insertText(0, "import static qupath.lib.gui.scripting.QP.*");
        // else if (name.toLowerCase().equals("all default"))
        // control.insertText(0, QPEx.getDefaultImports(false));
        // currentLanguage.get().getSyntax().handleNewLine(control, smartEditing.get());
        }
        e.consume();
    });
    if (name.equals(GeneralTools.SYMBOL_MU + ""))
        action.setAccelerator(new KeyCodeCombination(KeyCode.M, KeyCombination.SHORTCUT_DOWN, KeyCombination.SHIFT_DOWN));
    else if (name.toLowerCase().equals("pixel classifiers") || name.toLowerCase().equals("object classifiers"))
        action.disabledProperty().bind(qupath.projectProperty().isNull());
    else if (name.toLowerCase().equals("detection"))
        action.disabledProperty().bind(qupath.imageDataProperty().isNull());
    return action;
}
Also used : StringBinding(javafx.beans.binding.StringBinding) BooleanBinding(javafx.beans.binding.BooleanBinding) Date(java.util.Date) ListCell(javafx.scene.control.ListCell) LoggerFactory(org.slf4j.LoggerFactory) KeyCombination(javafx.scene.input.KeyCombination) Future(java.util.concurrent.Future) Task(javafx.concurrent.Task) QuPathGUI(qupath.lib.gui.QuPathGUI) ScriptException(javax.script.ScriptException) PrintWriter(java.io.PrintWriter) Orientation(javafx.geometry.Orientation) SplitPane(javafx.scene.control.SplitPane) BufferedImage(java.awt.image.BufferedImage) Collection(java.util.Collection) Font(javafx.scene.text.Font) KeyEvent(javafx.scene.input.KeyEvent) GroovyLanguage(qupath.lib.gui.scripting.languages.GroovyLanguage) Collectors(java.util.stream.Collectors) RunnableLanguage(qupath.lib.gui.scripting.languages.RunnableLanguage) Objects(java.util.Objects) Platform(javafx.application.Platform) SeparatorMenuItem(javafx.scene.control.SeparatorMenuItem) List(java.util.List) BooleanProperty(javafx.beans.property.BooleanProperty) Project(qupath.lib.projects.Project) Clipboard(javafx.scene.input.Clipboard) Writer(java.io.Writer) Optional(java.util.Optional) Toggle(javafx.scene.control.Toggle) Pattern(java.util.regex.Pattern) BorderPane(javafx.scene.layout.BorderPane) LogManager(qupath.lib.gui.logging.LogManager) Scene(javafx.scene.Scene) RadioMenuItem(javafx.scene.control.RadioMenuItem) ListView(javafx.scene.control.ListView) TextArea(javafx.scene.control.TextArea) ButtonType(javafx.scene.control.ButtonType) Action(org.controlsfx.control.action.Action) ProgressDialog(org.controlsfx.dialog.ProgressDialog) SimpleScriptContext(javax.script.SimpleScriptContext) Bindings(javafx.beans.binding.Bindings) ProjectDialogs(qupath.lib.gui.dialogs.ProjectDialogs) TransferMode(javafx.scene.input.TransferMode) Projects(qupath.lib.projects.Projects) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) Dialogs(qupath.lib.gui.dialogs.Dialogs) ScriptLanguage(qupath.lib.gui.scripting.languages.ScriptLanguage) ActionTools(qupath.lib.gui.ActionTools) Callback(javafx.util.Callback) Tooltip(javafx.scene.control.Tooltip) LinkedHashSet(java.util.LinkedHashSet) ImageData(qupath.lib.images.ImageData) KeyCode(javafx.scene.input.KeyCode) ObjectProperty(javafx.beans.property.ObjectProperty) Modality(javafx.stage.Modality) Logger(org.slf4j.Logger) Dialog(javafx.scene.control.Dialog) MenuBar(javafx.scene.control.MenuBar) TitledPane(javafx.scene.control.TitledPane) ProjectImageEntry(qupath.lib.projects.ProjectImageEntry) GeneralTools(qupath.lib.common.GeneralTools) Node(javafx.scene.Node) IOException(java.io.IOException) StringEscapeUtils(org.apache.commons.text.StringEscapeUtils) MenuTools(qupath.lib.gui.tools.MenuTools) File(java.io.File) ScriptContext(javax.script.ScriptContext) Menu(javafx.scene.control.Menu) KeyCodeCombination(javafx.scene.input.KeyCodeCombination) ScriptLanguageProvider(qupath.lib.gui.scripting.languages.ScriptLanguageProvider) ActionEvent(javafx.event.ActionEvent) ToggleGroup(javafx.scene.control.ToggleGroup) Stage(javafx.stage.Stage) SimpleObjectProperty(javafx.beans.property.SimpleObjectProperty) ObservableValue(javafx.beans.value.ObservableValue) PlainLanguage(qupath.lib.gui.scripting.languages.PlainLanguage) PathPrefs(qupath.lib.gui.prefs.PathPrefs) DialogButton(qupath.lib.gui.dialogs.Dialogs.DialogButton) Action(org.controlsfx.control.action.Action) KeyCodeCombination(javafx.scene.input.KeyCodeCombination) IOException(java.io.IOException)

Example 38 with Action

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

the class DefaultScriptEditor method createOpenAction.

Action createOpenAction(final String name) {
    Action action = new Action(name, e -> {
        String dirPath = PathPrefs.scriptsPathProperty().get();
        File dir = null;
        if (dirPath != null)
            dir = new File(dirPath);
        // File file = Dialogs.promptForFile("Choose script file", dir, "Known script files", SCRIPT_EXTENSIONS);
        File file = Dialogs.promptForFile("Choose script file", dir, "Groovy script", ".groovy");
        if (file == null)
            return;
        try {
            addScript(file, true);
            PathPrefs.scriptsPathProperty().set(file.getParent());
        } catch (Exception ex) {
            logger.error("Unable to open script file: {}", ex);
            ex.printStackTrace();
        }
    });
    action.setAccelerator(new KeyCodeCombination(KeyCode.O, KeyCombination.SHORTCUT_DOWN));
    return action;
}
Also used : Action(org.controlsfx.control.action.Action) KeyCodeCombination(javafx.scene.input.KeyCodeCombination) File(java.io.File) ScriptException(javax.script.ScriptException) IOException(java.io.IOException)

Example 39 with Action

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

the class DefaultScriptEditor method createFindAction.

Action createFindAction(final String name) {
    ScriptFindCommand findCommand = new ScriptFindCommand(this);
    Action action = new Action(name, e -> {
        findCommand.run();
        e.consume();
    });
    action.setAccelerator(new KeyCodeCombination(KeyCode.F, KeyCombination.SHORTCUT_DOWN));
    return action;
}
Also used : Action(org.controlsfx.control.action.Action) KeyCodeCombination(javafx.scene.input.KeyCodeCombination)

Example 40 with Action

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

the class DefaultScriptEditor method createRevertAction.

Action createRevertAction(final String name) {
    Action action = new Action(name, e -> {
        ScriptTab tab = getCurrentScriptObject();
        if (tab != null) {
            tab.refreshFileContents();
            setToggle(tab.getLanguage());
        }
    });
    return action;
}
Also used : Action(org.controlsfx.control.action.Action)

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