use of io.jmix.ui.action.Action in project jmix by jmix-framework.
the class EntityInspectorBrowser method addSelectionListener.
private void addSelectionListener() {
entitiesTable.addSelectionListener(event -> {
Table.SelectionEvent selectionEvent = (Table.SelectionEvent) event;
boolean removeEnabled = true;
boolean restoreEnabled = true;
if (!selectionEvent.getSelected().isEmpty()) {
for (Object o : selectionEvent.getSelected()) {
if (o instanceof Entity) {
if (EntityValues.isSoftDeleted(o)) {
removeEnabled = false;
} else {
restoreEnabled = false;
}
if (!removeEnabled && !restoreEnabled) {
break;
}
}
}
}
Action removeAction = entitiesTable.getAction(RemoveAction.ID);
if (removeAction != null) {
removeAction.setEnabled(removeEnabled);
}
Action restoreAction = entitiesTable.getAction(RESTORE_ACTION_ID);
if (restoreAction != null) {
restoreAction.setEnabled(restoreEnabled);
}
});
}
use of io.jmix.ui.action.Action in project jmix by jmix-framework.
the class InputDialog method initActions.
protected void initActions(List<Action> actions) {
for (Action action : actions) {
Button button = uiComponents.create(Button.NAME);
button.setAction(action);
if (action instanceof DialogAction) {
DialogAction.Type type = ((DialogAction) action).getType();
button.setCaption(messages.getMessage(type.getMsgKey()));
String iconPath = icons.get(type.getIconKey());
button.setIcon(iconPath);
}
actionsLayout.add(button);
}
}
use of io.jmix.ui.action.Action in project jmix by jmix-framework.
the class StandardEditor method addDefaultCommitAndCloseAction.
protected Action addDefaultCommitAndCloseAction(Messages messages, Icons icons) {
String commitShortcut = getApplicationContext().getBean(UiScreenProperties.class).getCommitShortcut();
Action action = new BaseAction(WINDOW_COMMIT_AND_CLOSE).withCaption(messages.getMessage("actions.Ok")).withIcon(icons.get(JmixIcon.EDITOR_OK)).withPrimary(true).withShortcut(commitShortcut);
getWindow().addAction(action);
return action;
}
use of io.jmix.ui.action.Action in project jmix by jmix-framework.
the class StandardLookup method addDefaultCancelAction.
protected Action addDefaultCancelAction(Messages messages, Icons icons) {
Action action = new BaseAction(LOOKUP_CANCEL_ACTION_ID).withCaption(messages.getMessage("actions.Cancel")).withIcon(icons.get(JmixIcon.LOOKUP_CANCEL));
getWindow().addAction(action);
return action;
}
use of io.jmix.ui.action.Action in project jmix by jmix-framework.
the class AbstractDataGrid method createShortcutsDelegate.
protected ShortcutsDelegate<ShortcutListener> createShortcutsDelegate() {
return new ShortcutsDelegate<ShortcutListener>() {
@Override
protected ShortcutListener attachShortcut(String actionId, KeyCombination keyCombination) {
ShortcutListener shortcut = new ShortcutListenerDelegate(actionId, keyCombination.getKey().getCode(), KeyCombination.Modifier.codes(keyCombination.getModifiers())).withHandler((sender, target) -> {
if (sender == componentComposition) {
Action action = getAction(actionId);
if (action != null && action.isEnabled() && action.isVisible()) {
action.actionPerform(AbstractDataGrid.this);
}
}
});
componentComposition.addShortcutListener(shortcut);
return shortcut;
}
@Override
protected void detachShortcut(Action action, ShortcutListener shortcutDescriptor) {
componentComposition.removeShortcutListener(shortcutDescriptor);
}
@Override
protected Collection<Action> getActions() {
return AbstractDataGrid.this.getActions();
}
};
}
Aggregations