Search in sources :

Example 6 with ModuleException

use of com.qcadoo.plugin.api.ModuleException in project qcadoo by qcadoo.

the class ViewTabModule method enable.

@Override
public void enable() {
    addedTabs = ArrayListMultimap.create();
    InternalViewDefinition viewDefinition = viewDefinitionService.getWithoutSession(viewExtension.getPluginName(), viewExtension.getViewName());
    if (viewDefinition == null) {
        throw new ModuleException(pluginIdentifier, "view", String.format("Reference to view which not exists: %s[%s]", viewExtension.getPluginName(), viewExtension.getViewName()));
    }
    try {
        for (Node tabNode : viewDefinitionParser.geElementChildren(viewExtension.getExtesionNode())) {
            WindowComponentPattern window = viewDefinition.getRootWindow();
            ComponentDefinition tabDefinition = viewDefinitionParser.getComponentDefinition(tabNode, window, viewDefinition);
            tabDefinition.setExtensionPluginIdentifier(pluginIdentifier);
            ComponentPattern tabPattern = new WindowTabComponentPattern(tabDefinition);
            try {
                tabPattern.parse(tabNode, viewDefinitionParser);
            } catch (ViewDefinitionParserNodeException e) {
                throw ViewDefinitionParserException.forFileAndNode(fileName, e);
            }
            window.addChild(tabPattern);
            addedTabs.put(window, tabPattern);
            tabPattern.initializeAll();
            tabPattern.registerViews(viewDefinitionService);
        }
    } catch (Exception e) {
        throw new ModuleException(pluginIdentifier, "view-tab", e);
    }
}
Also used : WindowComponentPattern(com.qcadoo.view.internal.components.window.WindowComponentPattern) InternalViewDefinition(com.qcadoo.view.internal.api.InternalViewDefinition) Node(org.w3c.dom.Node) ViewDefinitionParserNodeException(com.qcadoo.view.internal.xml.ViewDefinitionParserNodeException) WindowTabComponentPattern(com.qcadoo.view.internal.components.window.WindowTabComponentPattern) ComponentPattern(com.qcadoo.view.internal.api.ComponentPattern) WindowComponentPattern(com.qcadoo.view.internal.components.window.WindowComponentPattern) ModuleException(com.qcadoo.plugin.api.ModuleException) WindowTabComponentPattern(com.qcadoo.view.internal.components.window.WindowTabComponentPattern) ViewDefinitionParserNodeException(com.qcadoo.view.internal.xml.ViewDefinitionParserNodeException) IOException(java.io.IOException) ModuleException(com.qcadoo.plugin.api.ModuleException) ViewDefinitionParserException(com.qcadoo.view.internal.xml.ViewDefinitionParserException) ComponentDefinition(com.qcadoo.view.internal.ComponentDefinition)

Aggregations

ModuleException (com.qcadoo.plugin.api.ModuleException)6 InternalViewDefinition (com.qcadoo.view.internal.api.InternalViewDefinition)4 ComponentPattern (com.qcadoo.view.internal.api.ComponentPattern)2 WindowComponentPattern (com.qcadoo.view.internal.components.window.WindowComponentPattern)2 ViewDefinitionParserException (com.qcadoo.view.internal.xml.ViewDefinitionParserException)2 ViewDefinitionParserNodeException (com.qcadoo.view.internal.xml.ViewDefinitionParserNodeException)2 IOException (java.io.IOException)2 Node (org.w3c.dom.Node)2 ComponentDefinition (com.qcadoo.view.internal.ComponentDefinition)1 GridComponentPattern (com.qcadoo.view.internal.components.grid.GridComponentPattern)1 WindowTabComponentPattern (com.qcadoo.view.internal.components.window.WindowTabComponentPattern)1 InternalRibbonGroup (com.qcadoo.view.internal.ribbon.model.InternalRibbonGroup)1 RibbonGroupsPack (com.qcadoo.view.internal.ribbon.model.RibbonGroupsPack)1 SingleRibbonGroupPack (com.qcadoo.view.internal.ribbon.model.SingleRibbonGroupPack)1 JasperReport (net.sf.jasperreports.engine.JasperReport)1