Search in sources :

Example 1 with Icons

use of io.jmix.ui.icon.Icons in project jmix by jmix-framework.

the class AbstractComponentLoader method getIconPath.

@Nullable
protected String getIconPath(@Nullable String icon) {
    if (icon == null || icon.isEmpty()) {
        return null;
    }
    String iconPath = null;
    if (ICON_NAME_REGEX.matcher(icon).matches()) {
        Icons icons = applicationContext.getBean(Icons.class);
        iconPath = icons.get(icon);
    }
    if (StringUtils.isEmpty(iconPath)) {
        String themeValue = loadThemeString(icon);
        iconPath = loadResourceString(themeValue);
    }
    return iconPath;
}
Also used : Icons(io.jmix.ui.icon.Icons) Nullable(javax.annotation.Nullable)

Example 2 with Icons

use of io.jmix.ui.icon.Icons in project jmix by jmix-framework.

the class RoleAssignmentScreen method initScreenActions.

protected void initScreenActions() {
    Window window = getWindow();
    Messages messages = getApplicationContext().getBean(Messages.class);
    Icons icons = getApplicationContext().getBean(Icons.class);
    String commitShortcut = getApplicationContext().getBean(UiScreenProperties.class).getCommitShortcut();
    Action commitAndCloseAction = new BaseAction(Window.COMMIT_ACTION_ID).withCaption(messages.getMessage("actions.Ok")).withIcon(icons.get(JmixIcon.EDITOR_OK)).withPrimary(true).withShortcut(commitShortcut).withHandler(actionPerformedEvent -> {
        // noinspection ConstantConditions
        getScreenData().getDataContext().commit();
        close(new StandardCloseAction(Window.COMMIT_ACTION_ID));
    });
    window.addAction(commitAndCloseAction);
    Action closeAction = new BaseAction(Window.CLOSE_ACTION_ID).withIcon(icons.get(JmixIcon.EDITOR_CANCEL)).withCaption(messages.getMessage("actions.Cancel")).withHandler(actionPerformedEvent -> {
        if (dataContext.hasChanges()) {
            screenValidation.showUnsavedChangesDialog(this, WINDOW_CLOSE_ACTION).onDiscard(() -> close(WINDOW_CLOSE_ACTION));
        } else {
            close(WINDOW_CLOSE_ACTION);
        }
    });
    window.addAction(closeAction);
}
Also used : Window(io.jmix.ui.component.Window) Action(io.jmix.ui.action.Action) BaseAction(io.jmix.ui.action.BaseAction) Messages(io.jmix.core.Messages) UiScreenProperties(io.jmix.ui.UiScreenProperties) Icons(io.jmix.ui.icon.Icons) BaseAction(io.jmix.ui.action.BaseAction)

Example 3 with Icons

use of io.jmix.ui.icon.Icons in project jmix by jmix-framework.

the class StandardEditor method initActions.

protected void initActions(@SuppressWarnings("unused") InitEvent event) {
    Messages messages = getApplicationContext().getBean(Messages.class);
    Icons icons = getApplicationContext().getBean(Icons.class);
    BaseAction commitAndCloseAction = (BaseAction) getWindowActionOptional(WINDOW_COMMIT_AND_CLOSE).orElseGet(() -> addDefaultCommitAndCloseAction(messages, icons));
    commitAndCloseAction.addActionPerformedListener(this::commitAndClose);
    BaseAction commitAction = (BaseAction) getWindowActionOptional(WINDOW_COMMIT).orElseGet(() -> addDefaultCommitAction(messages, icons));
    commitAction.addActionPerformedListener(this::commit);
    BaseAction closeAction = (BaseAction) getWindowActionOptional(WINDOW_CLOSE).orElseGet(() -> addDefaultCloseAction(messages, icons));
    closeAction.addActionPerformedListener(this::cancel);
    BaseAction enableEditingAction = (BaseAction) getWindowActionOptional(ENABLE_EDITING).orElseGet(() -> addDefaultEnableEditingAction(messages, icons));
    enableEditingAction.addActionPerformedListener(this::enableEditing);
}
Also used : Icons(io.jmix.ui.icon.Icons) BaseAction(io.jmix.ui.action.BaseAction)

Example 4 with Icons

use of io.jmix.ui.icon.Icons in project jmix by jmix-framework.

the class StandardLookup method initActions.

protected void initActions(@SuppressWarnings("unused") InitEvent event) {
    Messages messages = getApplicationContext().getBean(Messages.class);
    Icons icons = getApplicationContext().getBean(Icons.class);
    BaseAction selectAction = (BaseAction) getWindowActionOptional(LOOKUP_SELECT_ACTION_ID).orElseGet(() -> addDefaultSelectAction(messages, icons));
    selectAction.addActionPerformedListener(this::select);
    BaseAction cancelAction = (BaseAction) getWindowActionOptional(LOOKUP_CANCEL_ACTION_ID).orElseGet(() -> addDefaultCancelAction(messages, icons));
    cancelAction.addActionPerformedListener(this::cancel);
}
Also used : Messages(io.jmix.core.Messages) Icons(io.jmix.ui.icon.Icons) BaseAction(io.jmix.ui.action.BaseAction)

Example 5 with Icons

use of io.jmix.ui.icon.Icons in project jmix by jmix-framework.

the class ScriptEditorDialog method initAction.

protected void initAction() {
    Icons icons = getApplicationContext().getBean(Icons.class);
    UiScreenProperties screenProperties = getApplicationContext().getBean(UiScreenProperties.class);
    Action commitAction = new BaseAction("commit").withCaption(messages.getMessage("actions.Ok")).withIcon(icons.get(JmixIcon.OK)).withPrimary(true).withShortcut(screenProperties.getCommitShortcut()).withHandler(this::commit);
    getWindow().addAction(commitAction);
    Action cancelAction = new BaseAction("cancel").withCaption(messages.getMessage("actions.Cancel")).withIcon(icons.get(JmixIcon.CANCEL)).withShortcut(screenProperties.getCloseShortcut()).withHandler(this::cancel);
    getWindow().addAction(cancelAction);
}
Also used : Action(io.jmix.ui.action.Action) BaseAction(io.jmix.ui.action.BaseAction) UiScreenProperties(io.jmix.ui.UiScreenProperties) Icons(io.jmix.ui.icon.Icons) BaseAction(io.jmix.ui.action.BaseAction)

Aggregations

Icons (io.jmix.ui.icon.Icons)8 BaseAction (io.jmix.ui.action.BaseAction)7 Messages (io.jmix.core.Messages)4 Action (io.jmix.ui.action.Action)4 UiScreenProperties (io.jmix.ui.UiScreenProperties)3 Window (io.jmix.ui.component.Window)2 DialogAction (io.jmix.ui.action.DialogAction)1 EntityLookupAction (io.jmix.ui.action.entitypicker.EntityLookupAction)1 RootWindow (io.jmix.ui.component.RootWindow)1 ValidationErrors (io.jmix.ui.component.ValidationErrors)1 IllegalConcurrentAccessException (io.jmix.ui.executor.IllegalConcurrentAccessException)1 StandardCloseAction (io.jmix.ui.screen.StandardCloseAction)1 UnknownOperationResult (io.jmix.ui.util.UnknownOperationResult)1 Nullable (javax.annotation.Nullable)1