Search in sources :

Example 1 with com.haulmont.cuba.gui.components.actions

use of com.haulmont.cuba.gui.components.actions in project cuba by cuba-platform.

the class LookupPickerFieldLoader method loadComponent.

@Override
public void loadComponent() {
    super.loadComponent();
    LookupPickerField lookupPickerField = (LookupPickerField) resultComponent;
    String metaClass = element.attributeValue("metaClass");
    if (!StringUtils.isEmpty(metaClass)) {
        lookupPickerField.setMetaClass(getMetadata().getClass(metaClass));
    }
    loadActions(lookupPickerField, element);
    if (lookupPickerField.getActions().isEmpty()) {
        GuiActionSupport guiActionSupport = getGuiActionSupport();
        boolean actionsByMetaAnnotations = guiActionSupport.createActionsByMetaAnnotations(lookupPickerField);
        if (!actionsByMetaAnnotations) {
            if (isLegacyFrame()) {
                lookupPickerField.addLookupAction();
                lookupPickerField.addClearAction();
            } else {
                Actions actions = getActions();
                lookupPickerField.addAction(actions.create(LookupAction.ID));
                lookupPickerField.addAction(actions.create(ClearAction.ID));
            }
        }
    }
    String refreshOptionsOnLookupClose = element.attributeValue("refreshOptionsOnLookupClose");
    if (refreshOptionsOnLookupClose != null) {
        lookupPickerField.setRefreshOptionsOnLookupClose(Boolean.parseBoolean(refreshOptionsOnLookupClose));
    }
}
Also used : LookupPickerField(com.haulmont.cuba.gui.components.LookupPickerField) Actions(com.haulmont.cuba.gui.components.Actions) GuiActionSupport(com.haulmont.cuba.gui.components.actions.GuiActionSupport)

Example 2 with com.haulmont.cuba.gui.components.actions

use of com.haulmont.cuba.gui.components.actions in project cuba by cuba-platform.

the class SuggestionPickerFieldLoader method loadActions.

protected void loadActions(SuggestionPickerField suggestionField) {
    loadActions(suggestionField, element);
    if (suggestionField.getActions().isEmpty()) {
        if (isLegacyFrame()) {
            suggestionField.addLookupAction();
            suggestionField.addOpenAction();
        } else {
            Actions actions = getActions();
            suggestionField.addAction(actions.create(LookupAction.ID));
            suggestionField.addAction(actions.create(OpenAction.ID));
        }
    }
}
Also used : Actions(com.haulmont.cuba.gui.components.Actions)

Example 3 with com.haulmont.cuba.gui.components.actions

use of com.haulmont.cuba.gui.components.actions in project cuba by cuba-platform.

the class ActionsHolderLoader method loadDeclarativeAction.

@Override
protected Action loadDeclarativeAction(ActionsHolder actionsHolder, Element element) {
    String id = element.attributeValue("id");
    if (StringUtils.isEmpty(id)) {
        throw new GuiDevelopmentException("No action id provided", context, "ActionsHolder ID", actionsHolder.getId());
    }
    if (StringUtils.isEmpty(element.attributeValue("invoke"))) {
        // only in legacy frames
        if (context instanceof ComponentContext && ((ComponentContext) context).getFrame().getFrameOwner() instanceof LegacyFrame) {
            // Try to create a standard list action
            for (ListActionType type : ListActionType.values()) {
                if (type.getId().equals(id)) {
                    Action instance = type.createAction((ListComponent) actionsHolder);
                    loadStandardActionProperties(instance, element);
                    loadActionOpenType(instance, element);
                    loadActionConstraint(instance, element);
                    loadShortcut(instance, element);
                    return instance;
                }
            }
        } else {
            String actionTypeId = element.attributeValue("type");
            if (StringUtils.isNotEmpty(actionTypeId)) {
                Actions actions = beanLocator.get(Actions.NAME);
                Action instance = actions.create(actionTypeId, id);
                if (instance instanceof ListAction) {
                    ((ListAction) instance).setTarget((ListComponent) actionsHolder);
                }
                loadStandardActionProperties(instance, element);
                loadActionConstraint(instance, element);
                loadShortcut(instance, element);
                loadCustomProperties(instance, element);
                return instance;
            }
        }
    }
    return super.loadDeclarativeAction(actionsHolder, element);
}
Also used : ListAction(com.haulmont.cuba.gui.components.actions.ListAction) Action(com.haulmont.cuba.gui.components.Action) Actions(com.haulmont.cuba.gui.components.Actions) GuiDevelopmentException(com.haulmont.cuba.gui.GuiDevelopmentException) LegacyFrame(com.haulmont.cuba.gui.screen.compatibility.LegacyFrame) ListActionType(com.haulmont.cuba.gui.components.actions.ListActionType) ListAction(com.haulmont.cuba.gui.components.actions.ListAction)

Aggregations

Actions (com.haulmont.cuba.gui.components.Actions)3 GuiDevelopmentException (com.haulmont.cuba.gui.GuiDevelopmentException)1 Action (com.haulmont.cuba.gui.components.Action)1 LookupPickerField (com.haulmont.cuba.gui.components.LookupPickerField)1 GuiActionSupport (com.haulmont.cuba.gui.components.actions.GuiActionSupport)1 ListAction (com.haulmont.cuba.gui.components.actions.ListAction)1 ListActionType (com.haulmont.cuba.gui.components.actions.ListActionType)1 LegacyFrame (com.haulmont.cuba.gui.screen.compatibility.LegacyFrame)1