@Override protected String getKey(PluginDefinition item) { return item.getId(); }
/** * Locates a loaded plugin with the specified id. * * @param id Id of plugin to locate. * @return A reference to the loaded plugin, or null if not found. */ public ElementPlugin getLoadedPlugin(String id) { for (ElementPlugin plugin : plugins) { if (id.equals(plugin.getDefinition().getId())) { return plugin; } } return null; }
/** * Locates an activated plugin with the specified id. * * @param id Id of plugin to locate. * @return The requested plugin, or null if not found. */ public ElementPlugin getActivatedPlugin(String id) { for (ElementPlugin plugin : plugins) { if (id.equals(plugin.getDefinition().getId()) && plugin.isActivated()) { return plugin; } } return null; }
/** * Sets the plugin definition the container will use to instantiate the plugin. If there is a * status bean associated with the plugin, it is registered with the container at this time. If * there are style sheet resources associated with the plugin, they will be added to the * container at this time. * * @param definition The plugin definition. */ @Override public void setDefinition(PluginDefinition definition) { super.setDefinition(definition); if (definition != null) { container.addClass("cwf-plugin-" + definition.getId()); shell.registerPlugin(this); } }
/** * Registers the plugin with the specified definition with the specified path. If a tree path is * absent, the plugin is associated with the tab itself. * * @param path Format is <tab name>\<tree node path> * @param def Plugin definition * @param propertySource Optional source for retrieving property values. * @return The newly created plugin. * @throws Exception Unspecified exception. */ public ElementBase register(String path, PluginDefinition def, IPropertyProvider propertySource) throws Exception { if (def.isForbidden()) { log.info("Access to plugin " + def.getName() + " is restricted."); return null; } if (def.isDisabled()) { log.info("Plugin " + def.getName() + " is disabled."); return null; } ElementBase parent = parentFromPath(path); ElementBase plugin = parent == null ? null : def.createElement(parent, propertySource, false); String defPluginId = getDefaultPluginId(); if (plugin instanceof ElementUI && !defPluginId.isEmpty() && (defPluginId.equalsIgnoreCase(def.getId()) || defPluginId.equalsIgnoreCase(def.getName()))) { ((ElementUI) plugin).activate(true); } return plugin; }
/** * Executed once all plugins are loaded. */ public void start() { desktop.activate(true); String initialPlugin = PropertyUtil.getValue("CAREWEB.INITIAL.SECTION", getApplicationName()); if (!StringUtils.isEmpty(initialPlugin)) { for (ElementPlugin plugin : plugins) { if (initialPlugin.equals(plugin.getDefinition().getId())) { plugin.bringToFront(); break; } } } if (startupRoutines == null) { startupRoutines = SpringUtil.getBean("careWebStartup", CareWebStartup.class); } startupRoutines.execute(); }
private void buildDocument(Element node, LayoutNode ele) { if (ele instanceof LayoutElement) { for (LayoutTrigger trigger : ((LayoutElement) ele).getTriggers()) { Element child = createDOMNode(trigger, node); buildDocument(child, trigger); } } for (LayoutNode element : ele.getChildren()) { Element child = createDOMNode(element, node); child.setAttribute("_type", element.getDefinition().getId()); buildDocument(child, element); } }
/** * Returns the info panel associated with the UI element, if there is one. * * @param element The element to examine. * @param activeOnly If true, only active info panels are considered. * @return The associated active info panel, or null if there is none. */ private static IInfoPanel getInfoPanel(UIElementBase element, boolean activeOnly) { if ((element instanceof UIElementPlugin) && (!activeOnly || element.isActivated()) && ((UIElementPlugin) element).getDefinition().getId().equals("infoPanelPlugin")) { PluginContainer container = ((UIElementPlugin) element).getContainer(); container.load(); Component top = container.getFellow("infoPanelRoot"); return (IInfoPanel) FrameworkController.getController(top); } return null; }
if (!StringUtils.isEmpty(plugin.getUrl()) && shell.getLoadedPlugin(plugin.getId()) == null) { plugins.add(plugin);
@Test public void parserTest() throws Exception { String xml = MockTest.getTextFromResource("pluginDefinition.xml"); PluginDefinition def = PluginXmlParser.fromXml(xml); assertEquals("Test1", def.getName()); assertEquals("plugin-test", def.getId()); assertEquals(def.getResources().size(), 4); assertTrue(def.getResources().get(0) instanceof PluginResourceButton); assertTrue(def.getResources().get(1) instanceof PluginResourceButton); assertTrue(def.getResources().get(2) instanceof PluginResourceHelp); assertTrue(def.getResources().get(3) instanceof PluginResourcePropertyGroup); }