Search in sources :

Example 6 with Action

use of org.controlsfx.control.action.Action in project mapton by trixon.

the class LocalGridsView method createUI.

private void createUI() {
    mPlotCheckBox = new CheckBox(Dict.LOCAL.toString());
    mPlotCheckBox.setStyle("-fx-font-weight: bold; -fx-font-size: 1.3em");
    mPlotCheckBox.setPadding(new Insets(0, 0, 0, 8));
    var addAction = new Action(Dict.ADD.toString(), actionEvent -> {
        mLocalGridEditor.edit(null);
    });
    addAction.setGraphic(MaterialIcon._Content.ADD.getImageView(getIconSizeToolBarInt()));
    var editAction = new Action(Dict.EDIT.toString(), actionEvent -> {
        if (getSelected() != null) {
            mLocalGridEditor.edit(getSelected());
        }
    });
    editAction.setGraphic(MaterialIcon._Editor.MODE_EDIT.getImageView(getIconSizeToolBarInt()));
    var remAction = new Action(Dict.REMOVE.toString(), actionEvent -> {
        if (getSelected() != null) {
            mLocalGridEditor.remove(getSelected());
        }
    });
    remAction.setGraphic(MaterialIcon._Content.REMOVE.getImageView(getIconSizeToolBarInt()));
    Collection<? extends Action> actions = Arrays.asList(new FileImportAction().getAction(this), new FileExportAction().getAction(this), addAction, remAction, editAction);
    var toolBar = ActionUtils.createToolBar(actions, ActionUtils.ActionTextBehavior.HIDE);
    FxHelper.adjustButtonWidth(toolBar.getItems().stream(), getIconSizeToolBarInt());
    toolBar.getItems().stream().filter((item) -> (item instanceof ButtonBase)).map((item) -> (ButtonBase) item).forEachOrdered((buttonBase) -> {
        FxHelper.undecorateButton(buttonBase);
    });
    FxHelper.slimToolBar(toolBar);
    setTop(new VBox(8, mPlotCheckBox, toolBar));
    setCenter(mListView);
    toolBar.disableProperty().bind(mPlotCheckBox.selectedProperty().not());
    mListView.disableProperty().bind(mPlotCheckBox.selectedProperty().not());
    mListView.setPrefHeight(FxHelper.getUIScaled(150.0));
    mListView.setItems(mManager.getItems());
}
Also used : Arrays(java.util.Arrays) MouseButton(javafx.scene.input.MouseButton) ButtonBase(javafx.scene.control.ButtonBase) Collection(java.util.Collection) Action(org.controlsfx.control.action.Action) CheckBox(javafx.scene.control.CheckBox) ActionUtils(org.controlsfx.control.action.ActionUtils) MaterialIcon(se.trixon.almond.util.icons.material.MaterialIcon) VBox(javafx.scene.layout.VBox) MLocalGridManager(org.mapton.api.MLocalGridManager) Platform(javafx.application.Platform) CheckListView(org.controlsfx.control.CheckListView) MLocalGrid(org.mapton.api.MLocalGrid) Insets(javafx.geometry.Insets) Dict(se.trixon.almond.util.Dict) ListChangeListener(javafx.collections.ListChangeListener) MOptions(org.mapton.api.MOptions) Mapton.getIconSizeToolBarInt(org.mapton.api.Mapton.getIconSizeToolBarInt) BorderPane(javafx.scene.layout.BorderPane) FxHelper(se.trixon.almond.util.fx.FxHelper) Action(org.controlsfx.control.action.Action) Insets(javafx.geometry.Insets) CheckBox(javafx.scene.control.CheckBox) ButtonBase(javafx.scene.control.ButtonBase) VBox(javafx.scene.layout.VBox)

Example 7 with Action

use of org.controlsfx.control.action.Action in project mapton by trixon.

the class UpdaterTopComponent method createScene.

private Scene createScene() {
    UpdaterView updaterView = new UpdaterView();
    Action updateAction = new Action(Dict.UPDATE.toString(), event -> {
        updaterView.update();
    });
    updateAction.setGraphic(MaterialIcon._Action.SYSTEM_UPDATE_ALT.getImageView(getIconSizeToolBarInt()));
    Action refreshAction = new Action(Dict.REFRESH.toString(), event -> {
        updaterView.refreshUpdaters();
    });
    refreshAction.setGraphic(MaterialIcon._Navigation.REFRESH.getImageView(getIconSizeToolBarInt()));
    Action clearAction = new Action(Dict.CLEAR.toString(), event -> {
        updaterView.clear();
    });
    clearAction.setGraphic(MaterialIcon._Content.CLEAR.getImageView(getIconSizeToolBarInt()));
    List<Action> actions = Arrays.asList(updateAction, refreshAction, clearAction);
    ToolBar toolBar = ActionUtils.createToolBar(actions, ActionUtils.ActionTextBehavior.SHOW);
    toolBar.getItems().stream().filter((item) -> (item instanceof ButtonBase)).map((item) -> (ButtonBase) item).forEachOrdered((buttonBase) -> {
        FxHelper.undecorateButton(buttonBase);
    });
    toolBar.setStyle("-fx-spacing: 0px;");
    toolBar.setPadding(Insets.EMPTY);
    updateAction.disabledProperty().bind(updaterView.runningProperty().or(updaterView.selectedProperty().not()));
    refreshAction.disabledProperty().bind(updaterView.runningProperty());
    BorderPane root = new BorderPane(updaterView.getLogPanel());
    root.setLeft(updaterView.getListNode());
    root.setTop(toolBar);
    return new Scene(root);
}
Also used : TopComponent(org.openide.windows.TopComponent) Scene(javafx.scene.Scene) Arrays(java.util.Arrays) ActionID(org.openide.awt.ActionID) ConvertAsProperties(org.netbeans.api.settings.ConvertAsProperties) ToolBar(javafx.scene.control.ToolBar) ButtonBase(javafx.scene.control.ButtonBase) Action(org.controlsfx.control.action.Action) ActionUtils(org.controlsfx.control.action.ActionUtils) MTopComponent(org.mapton.core.api.MTopComponent) MaterialIcon(se.trixon.almond.util.icons.material.MaterialIcon) ActionReference(org.openide.awt.ActionReference) UpdaterView(org.mapton.base.ui.updater.UpdaterView) List(java.util.List) ActionReferences(org.openide.awt.ActionReferences) Insets(javafx.geometry.Insets) Dict(se.trixon.almond.util.Dict) Mapton.getIconSizeToolBarInt(org.mapton.api.Mapton.getIconSizeToolBarInt) BorderPane(javafx.scene.layout.BorderPane) NbBundle(org.openide.util.NbBundle) FxHelper(se.trixon.almond.util.fx.FxHelper) Action(org.controlsfx.control.action.Action) BorderPane(javafx.scene.layout.BorderPane) UpdaterView(org.mapton.base.ui.updater.UpdaterView) ToolBar(javafx.scene.control.ToolBar) ButtonBase(javafx.scene.control.ButtonBase) Scene(javafx.scene.Scene)

Example 8 with Action

use of org.controlsfx.control.action.Action in project mapton by trixon.

the class FilesPane method createUI.

private void createUI() {
    var closeAction = new Action(Dict.CLOSE.toString(), event -> {
        if (getSelected() != null) {
            remove();
        }
    });
    closeAction.setGraphic(MaterialIcon._Content.REMOVE.getImageView(getIconSizeToolBarInt()));
    var closeAllAction = new Action(Dict.CLOSE_ALL.toString(), event -> {
        if (!mListView.getItems().isEmpty()) {
            removeAll();
        }
    });
    closeAllAction.setGraphic(MaterialIcon._Content.CLEAR.getImageView(getIconSizeToolBarInt()));
    mRefreshAction = new Action(Dict.REFRESH.toString(), event -> {
        mManager.refresh();
    });
    mRefreshAction.setGraphic(MaterialIcon._Navigation.REFRESH.getImageView(getIconSizeToolBarInt()));
    var optionsPopOver = new MOptionsPopOver();
    optionsPopOver.getAction().setDisabled(true);
    mActions = Arrays.asList(closeAction, closeAllAction, ActionUtils.ACTION_SPAN, mRefreshAction, optionsPopOver.getAction());
    var toolBar = ActionUtils.createToolBar(mActions, ActionUtils.ActionTextBehavior.HIDE);
    FxHelper.adjustButtonWidth(toolBar.getItems().stream(), getIconSizeToolBarInt());
    FxHelper.undecorateButtons(toolBar.getItems().stream());
    FxHelper.slimToolBar(toolBar);
    setTop(toolBar);
    setCenter(mListView);
    mListView.itemsProperty().bind(mManager.itemsProperty());
}
Also used : Arrays(java.util.Arrays) MCoordinateFile(org.mapton.api.MCoordinateFile) Action(org.controlsfx.control.action.Action) ActionUtils(org.controlsfx.control.action.ActionUtils) MaterialIcon(se.trixon.almond.util.icons.material.MaterialIcon) IOException(java.io.IOException) DialogDisplayer(org.openide.DialogDisplayer) Platform(javafx.application.Platform) CheckListView(org.controlsfx.control.CheckListView) List(java.util.List) SwingUtilities(javax.swing.SwingUtilities) NotifyDescriptor(org.openide.NotifyDescriptor) Dict(se.trixon.almond.util.Dict) ListChangeListener(javafx.collections.ListChangeListener) Exceptions(org.openide.util.Exceptions) Mapton.getIconSizeToolBarInt(org.mapton.api.Mapton.getIconSizeToolBarInt) MOptionsPopOver(org.mapton.api.ui.MOptionsPopOver) IndexedCheckModel(org.controlsfx.control.IndexedCheckModel) MCoordinateFileManager(org.mapton.api.MCoordinateFileManager) BorderPane(javafx.scene.layout.BorderPane) FxHelper(se.trixon.almond.util.fx.FxHelper) Action(org.controlsfx.control.action.Action) MOptionsPopOver(org.mapton.api.ui.MOptionsPopOver)

Example 9 with Action

use of org.controlsfx.control.action.Action in project mapton by trixon.

the class FileExportAction method getAction.

@Override
public Action getAction(Node owner) {
    FxActionSwing action = new FxActionSwing(Dict.EXPORT.toString(), () -> {
        ArrayList<MLocalGrid> selectedGrids = new ArrayList<>();
        mManager.getItems().stream().filter((grid) -> (grid.isVisible())).forEachOrdered((grid) -> {
            selectedGrids.add(grid);
        });
        if (!selectedGrids.isEmpty()) {
            SimpleDialog.clearFilters();
            SimpleDialog.addFilters("grid");
            SimpleDialog.setFilter("grid");
            final String dialogTitle = String.format("%s %s", Dict.EXPORT.toString(), mTitle.toLowerCase());
            SimpleDialog.setTitle(dialogTitle);
            if (mFile == null) {
                SimpleDialog.setPath(FileUtils.getUserDirectory());
            } else {
                SimpleDialog.setPath(mFile.getParentFile());
                SimpleDialog.setSelectedFile(new File(""));
            }
            if (SimpleDialog.saveFile(new String[] { "grid" })) {
                new Thread(() -> {
                    mFile = SimpleDialog.getPath();
                    try {
                        mManager.gridExport(mFile, selectedGrids);
                        NotificationDisplayer.getDefault().notify(Dict.OPERATION_COMPLETED.toString(), MNotificationIcons.getInformationIcon(), dialogTitle, null, NotificationDisplayer.Priority.LOW);
                    } catch (IOException ex) {
                        Exceptions.printStackTrace(ex);
                    }
                }).start();
            }
        }
    });
    action.setGraphic(MaterialIcon._Content.SAVE.getImageView(getIconSizeToolBarInt()));
    return action;
}
Also used : NotificationDisplayer(org.openide.awt.NotificationDisplayer) SimpleDialog(se.trixon.almond.util.swing.dialogs.SimpleDialog) Node(javafx.scene.Node) Action(org.controlsfx.control.action.Action) MaterialIcon(se.trixon.almond.util.icons.material.MaterialIcon) IOException(java.io.IOException) FileUtils(org.apache.commons.io.FileUtils) File(java.io.File) ArrayList(java.util.ArrayList) MLocalGrid(org.mapton.api.MLocalGrid) MNotificationIcons(org.mapton.api.MNotificationIcons) Dict(se.trixon.almond.util.Dict) Exceptions(org.openide.util.Exceptions) Mapton.getIconSizeToolBarInt(org.mapton.api.Mapton.getIconSizeToolBarInt) FxActionSwing(se.trixon.almond.util.fx.FxActionSwing) FxActionSwing(se.trixon.almond.util.fx.FxActionSwing) ArrayList(java.util.ArrayList) MLocalGrid(org.mapton.api.MLocalGrid) IOException(java.io.IOException) File(java.io.File)

Example 10 with Action

use of org.controlsfx.control.action.Action in project mapton by trixon.

the class BaseToolBar method setTextFromActions.

protected void setTextFromActions() {
    for (Map.Entry<Action, Double> entry : mButtonWidths.entrySet()) {
        ButtonBase b = getButtonForAction(entry.getKey());
        b.setPrefWidth(entry.getValue());
        b.textProperty().bind(entry.getKey().textProperty());
    }
}
Also used : Action(org.controlsfx.control.action.Action) ButtonBase(javafx.scene.control.ButtonBase) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

Action (org.controlsfx.control.action.Action)48 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 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 ContextMenu (javafx.scene.control.ContextMenu)11 List (java.util.List)10 File (java.io.File)9 IOException (java.io.IOException)9 Label (javafx.scene.control.Label)9 SeparatorMenuItem (javafx.scene.control.SeparatorMenuItem)9 ObservableValue (javafx.beans.value.ObservableValue)8 ActionEvent (javafx.event.ActionEvent)8