/** * Registers the plugin with the specified id and 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 id Unique id of plugin * @param propertySource Optional source for retrieving property values. * @return Container created for the plugin. * @throws Exception Unspecified exception. */ public ElementBase registerFromId(String path, String id, IPropertyProvider propertySource) throws Exception { return register(path, pluginById(id), propertySource); }
shell = (CareWebShellEx) comp; if (shell.getLayout() == null) { shell.setLayout(CWFUtil.getResourcePath(TestHarnessController.class) + "testharness-layout.xml"); if (!StringUtils.isEmpty(plugin.getUrl()) && shell.getLoadedPlugin(plugin.getId()) == null) { plugins.add(plugin); shell.register("Test Harness\\" + plugin.getName(), plugin); shell.registerMenu("Actions\\" + action, action.getScript()).setHint(action.getScript()); shell.start(); } catch (Exception e) { throw MiscUtil.toUnchecked(e);
/** * Returns the parent UI element based on the provided path. * * @param path Format is <tab name>\<tree node path> * @return The parent UI element. * @throws Exception Unspecified exception. */ private ElementUI parentFromPath(String path) throws Exception { if (TOOLBAR_PATH.equalsIgnoreCase(path)) { return getDesktop().getToolbar(); } String[] pieces = path.split(delim, 2); ElementTabPane tabPane = pieces.length == 0 ? null : findTabPane(pieces[0]); ElementUI parent = pieces.length < 2 ? null : getPathResolver().resolvePath(tabPane, pieces[1]); return parent == null ? tabPane : parent; }
/** * 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 * @return The newly created plugin. * @throws Exception Unspecified exception. */ public ElementBase register(String path, PluginDefinition def) throws Exception { return register(path, def, null); }
/** * Register a menu. * * @param path Path for the menu. * @param action Associated action for the menu. * @return Created menu. */ public ElementMenuItem registerMenu(String path, String action) { ElementMenuItem menu = getElement(path, getDesktop().getMenubar(), ElementMenuItem.class); menu.setAction(action); return menu; }
/** * 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; }
/** * Returns the tab view that will receive plug-ins. Searches the UI desktop for the first * occurrence of a tab view that it finds. The result is cached. This may return null if a tab * view is not found. * * @return The target tab view, or null if not found. */ private ElementTabView getTabView() { if (tabView == null) { tabView = getDesktop().findChildElement(ElementTabView.class); } return tabView; }
/** * Registers a layout at the specified path. * * @param path Format is <tab name>\<tree node path> * @param resource Location of the xml layout. * @throws Exception Unspecified exception. */ public void registerLayout(String path, String resource) throws Exception { Layout layout = LayoutParser.parseResource(resource); ElementUI parent = parentFromPath(path); if (parent != null) { layout.materialize(parent); } }
/** * Locate the tab with the corresponding label, or create one if not found. * * @param name Label text of tab to find. * @return Tab corresponding to label text. * @throws Exception Unspecified exception. */ private ElementTabPane findTabPane(String name) throws Exception { ElementTabView tabView = getTabView(); ElementTabPane tabPane = null; while ((tabPane = tabView.getChild(ElementTabPane.class, tabPane)) != null) { if (name.equalsIgnoreCase(tabPane.getLabel())) { return tabPane; } } tabPane = new ElementTabPane(); tabPane.setParent(tabView); tabPane.setLabel(name); return tabPane; }
/** * Register a plugin by specifying a path and a url. * * @param path Format is <tab name>\<tree node path> * @param url Main url of plugin. * @return Container created for the plugin. * @throws Exception Unspecified exception. */ public ElementBase register(String path, String url) throws Exception { return register(path, url, null); }
/** * Register a plugin by specifying a path and a url. * * @param path Format is <tab name>\<tree node path> * @param url Main url of plugin. * @param propertySource Optional source for retrieving property values. * @return Container created for the plugin. * @throws Exception Unspecified exception. */ public ElementBase register(String path, String url, IPropertyProvider propertySource) throws Exception { PluginDefinition def = new PluginDefinition(); def.setUrl(url); return register(path, def, propertySource); }