Search in sources :

Example 1 with InternalRibbonGroup

use of com.qcadoo.view.internal.ribbon.model.InternalRibbonGroup in project qcadoo by qcadoo.

the class TemplateRibbonGroupsPackTest method shouldNotCallTemplateFromUpdateInfoPack.

@Test
public final void shouldNotCallTemplateFromUpdateInfoPack() throws Exception {
    // given
    InternalRibbonGroup internalRibbonGroup = mock(InternalRibbonGroup.class);
    given(internalRibbonGroup.getUpdate()).willReturn(internalRibbonGroup);
    stubTemplateGetRibbonGroups(Lists.newArrayList(internalRibbonGroup));
    RibbonGroupsPack ribbonGroupsPackUpdate = templateRibbonGroupsPack.getUpdate();
    // Flush
    template = mock(RibbonTemplate.class);
    // when
    ribbonGroupsPackUpdate.getGroups();
    // then
    verify(template, never()).getRibbonGroups(Mockito.any(RibbonTemplateParameters.class), Mockito.eq(viewDefinition));
}
Also used : RibbonTemplateParameters(com.qcadoo.view.internal.ribbon.templates.RibbonTemplateParameters) RibbonTemplate(com.qcadoo.view.internal.ribbon.templates.model.RibbonTemplate) InternalRibbonGroup(com.qcadoo.view.internal.ribbon.model.InternalRibbonGroup) RibbonGroupsPack(com.qcadoo.view.internal.ribbon.model.RibbonGroupsPack) TemplateRibbonGroupsPack(com.qcadoo.view.internal.ribbon.templates.model.TemplateRibbonGroupsPack) Test(org.junit.Test)

Example 2 with InternalRibbonGroup

use of com.qcadoo.view.internal.ribbon.model.InternalRibbonGroup in project qcadoo by qcadoo.

the class RibbonParserService method parseRibbonGroup.

public InternalRibbonGroup parseRibbonGroup(final Node groupNode, final ViewDefinitionParser parser, final ViewDefinition viewDefinition) throws ViewDefinitionParserNodeException {
    String template = parser.getStringAttribute(groupNode, "template");
    SecurityRole role = parser.getAuthorizationRole(groupNode);
    if (template == null) {
        String groupName = parser.getStringAttribute(groupNode, NAME);
        if (groupName == null) {
            throw new ViewDefinitionParserNodeException(groupNode, "Name attribute cannot be empty");
        }
        InternalRibbonGroup ribbonGroup = new RibbonGroupImpl(groupName, role);
        NodeList childNodes = groupNode.getChildNodes();
        for (int i = 0; i < childNodes.getLength(); i++) {
            Node child = childNodes.item(i);
            if (child.getNodeType() == Node.ELEMENT_NODE) {
                ribbonGroup.addItem(parseRibbonItem(child, parser, viewDefinition));
            }
        }
        return ribbonGroup;
    } else {
        try {
            return ribbonTemplates.getGroupTemplate(template, viewDefinition, role);
        } catch (IllegalStateException e) {
            throw new ViewDefinitionParserNodeException(groupNode, e);
        }
    }
}
Also used : SecurityRole(com.qcadoo.security.api.SecurityRole) RibbonGroupImpl(com.qcadoo.view.internal.ribbon.model.RibbonGroupImpl) NodeList(org.w3c.dom.NodeList) Node(org.w3c.dom.Node) ViewDefinitionParserNodeException(com.qcadoo.view.internal.xml.ViewDefinitionParserNodeException) InternalRibbonGroup(com.qcadoo.view.internal.ribbon.model.InternalRibbonGroup)

Example 3 with InternalRibbonGroup

use of com.qcadoo.view.internal.ribbon.model.InternalRibbonGroup in project qcadoo by qcadoo.

the class RibbonTemplates method createGridNewActionTemplate.

private InternalRibbonGroup createGridNewActionTemplate(final ViewDefinition viewDefinition, final SecurityRole role) {
    InternalRibbonGroup ribbonGroup = new RibbonGroupImpl(ACTIONS, role);
    ribbonGroup.addItem(createGridNewAction(viewDefinition));
    return ribbonGroup;
}
Also used : RibbonGroupImpl(com.qcadoo.view.internal.ribbon.model.RibbonGroupImpl) InternalRibbonGroup(com.qcadoo.view.internal.ribbon.model.InternalRibbonGroup)

Example 4 with InternalRibbonGroup

use of com.qcadoo.view.internal.ribbon.model.InternalRibbonGroup in project qcadoo by qcadoo.

the class RibbonTemplates method createGridNewAndCopyActionsTemplate.

private InternalRibbonGroup createGridNewAndCopyActionsTemplate(final ViewDefinition viewDefinition, final SecurityRole role) {
    InternalRibbonGroup ribbonGroup = new RibbonGroupImpl(ACTIONS, role);
    ribbonGroup.addItem(createGridNewAction(viewDefinition));
    ribbonGroup.addItem(createGridCopyAction(viewDefinition));
    return ribbonGroup;
}
Also used : RibbonGroupImpl(com.qcadoo.view.internal.ribbon.model.RibbonGroupImpl) InternalRibbonGroup(com.qcadoo.view.internal.ribbon.model.InternalRibbonGroup)

Example 5 with InternalRibbonGroup

use of com.qcadoo.view.internal.ribbon.model.InternalRibbonGroup in project qcadoo by qcadoo.

the class RibbonTemplates method createFormSaveActionTemplate.

private InternalRibbonGroup createFormSaveActionTemplate(final ViewDefinition viewDefinition, final SecurityRole role) {
    InternalRibbonActionItem ribbonSaveAction = new RibbonActionItemImpl();
    ribbonSaveAction.setAction(RibbonUtils.translateRibbonAction("#{form}.performSave; #{window}.performBack", viewDefinition));
    ribbonSaveAction.setIcon("saveBackIcon24.png");
    ribbonSaveAction.setName("saveBack");
    ribbonSaveAction.setType(RibbonActionItem.Type.BIG_BUTTON);
    ribbonSaveAction.setEnabled(true);
    InternalRibbonGroup ribbonGroup = new RibbonGroupImpl(ACTIONS, role);
    ribbonGroup.addItem(ribbonSaveAction);
    return ribbonGroup;
}
Also used : RibbonGroupImpl(com.qcadoo.view.internal.ribbon.model.RibbonGroupImpl) RibbonActionItemImpl(com.qcadoo.view.internal.ribbon.model.RibbonActionItemImpl) InternalRibbonActionItem(com.qcadoo.view.internal.ribbon.model.InternalRibbonActionItem) InternalRibbonGroup(com.qcadoo.view.internal.ribbon.model.InternalRibbonGroup)

Aggregations

InternalRibbonGroup (com.qcadoo.view.internal.ribbon.model.InternalRibbonGroup)20 RibbonGroupImpl (com.qcadoo.view.internal.ribbon.model.RibbonGroupImpl)18 InternalRibbonActionItem (com.qcadoo.view.internal.ribbon.model.InternalRibbonActionItem)4 RibbonActionItemImpl (com.qcadoo.view.internal.ribbon.model.RibbonActionItemImpl)2 RibbonGroupsPack (com.qcadoo.view.internal.ribbon.model.RibbonGroupsPack)2 ViewDefinitionParserNodeException (com.qcadoo.view.internal.xml.ViewDefinitionParserNodeException)2 Node (org.w3c.dom.Node)2 ModuleException (com.qcadoo.plugin.api.ModuleException)1 SecurityRole (com.qcadoo.security.api.SecurityRole)1 RibbonActionItem (com.qcadoo.view.api.ribbon.RibbonActionItem)1 InternalViewDefinition (com.qcadoo.view.internal.api.InternalViewDefinition)1 WindowComponentPattern (com.qcadoo.view.internal.components.window.WindowComponentPattern)1 SingleRibbonGroupPack (com.qcadoo.view.internal.ribbon.model.SingleRibbonGroupPack)1 RibbonTemplateParameters (com.qcadoo.view.internal.ribbon.templates.RibbonTemplateParameters)1 RibbonTemplate (com.qcadoo.view.internal.ribbon.templates.model.RibbonTemplate)1 TemplateRibbonGroupsPack (com.qcadoo.view.internal.ribbon.templates.model.TemplateRibbonGroupsPack)1 ViewDefinitionParserException (com.qcadoo.view.internal.xml.ViewDefinitionParserException)1 IOException (java.io.IOException)1 Test (org.junit.Test)1 NodeList (org.w3c.dom.NodeList)1