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