Search in sources :

Example 1 with DeclarativeAction

use of com.haulmont.cuba.gui.xml.DeclarativeAction in project cuba by cuba-platform.

the class AbstractComponentLoader method loadDeclarativeActionDefault.

protected Action loadDeclarativeActionDefault(Component.ActionsHolder actionsHolder, Element element) {
    String id = element.attributeValue("id");
    if (id == null) {
        Element component = element;
        for (int i = 0; i < 2; i++) {
            if (component.getParent() != null)
                component = component.getParent();
            else
                throw new GuiDevelopmentException("No action ID provided", context.getFullFrameId());
        }
        throw new GuiDevelopmentException("No action ID provided", context.getFullFrameId(), "Component ID", component.attributeValue("id"));
    }
    String trackSelection = element.attributeValue("trackSelection");
    String shortcut = StringUtils.trimToNull(element.attributeValue("shortcut"));
    shortcut = loadShortcut(shortcut);
    if (Boolean.parseBoolean(trackSelection)) {
        DeclarativeTrackingAction action = new DeclarativeTrackingAction(id, loadResourceString(element.attributeValue("caption")), loadResourceString(element.attributeValue("description")), getIconPath(element.attributeValue("icon")), element.attributeValue("enable"), element.attributeValue("visible"), element.attributeValue("invoke"), shortcut, actionsHolder);
        loadActionConstraint(action, element);
        return action;
    } else {
        return new DeclarativeAction(id, loadResourceString(element.attributeValue("caption")), loadResourceString(element.attributeValue("description")), getIconPath(element.attributeValue("icon")), element.attributeValue("enable"), element.attributeValue("visible"), element.attributeValue("invoke"), shortcut, actionsHolder);
    }
}
Also used : Element(org.dom4j.Element) GuiDevelopmentException(com.haulmont.cuba.gui.GuiDevelopmentException) DeclarativeTrackingAction(com.haulmont.cuba.gui.xml.DeclarativeTrackingAction) DeclarativeAction(com.haulmont.cuba.gui.xml.DeclarativeAction)

Example 2 with DeclarativeAction

use of com.haulmont.cuba.gui.xml.DeclarativeAction in project cuba by cuba-platform.

the class ButtonLoader method loadInvoke.

protected void loadInvoke(Button component, boolean enabled, boolean visible, Element element) {
    if (!StringUtils.isBlank(element.attributeValue("action"))) {
        return;
    }
    final String methodName = element.attributeValue("invoke");
    if (StringUtils.isBlank(methodName)) {
        return;
    }
    String actionBaseId = component.getId();
    if (StringUtils.isEmpty(actionBaseId)) {
        actionBaseId = methodName;
    }
    DeclarativeAction action = new DeclarativeAction(actionBaseId + "_invoke", component.getCaption(), component.getDescription(), component.getIcon(), enabled, visible, methodName, component.getFrame());
    component.setAction(action);
}
Also used : DeclarativeAction(com.haulmont.cuba.gui.xml.DeclarativeAction)

Aggregations

DeclarativeAction (com.haulmont.cuba.gui.xml.DeclarativeAction)2 GuiDevelopmentException (com.haulmont.cuba.gui.GuiDevelopmentException)1 DeclarativeTrackingAction (com.haulmont.cuba.gui.xml.DeclarativeTrackingAction)1 Element (org.dom4j.Element)1