@Override public void setDefinition(PluginDefinition definition) { if (definition != null && def == null) { def = new PluginDefinition(definition); layoutName = def.getName(); String category = def.getCategory(); shared = category != null && category.contains("Shared"); super.setDefinition(def); } }
/** * 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; }
private void initDefinition() { if (def != null) { def.setName(layoutName); def.setCategory("Layouts\\" + (shared ? "Shared" : "Private")); } }
public AboutParams(PluginDefinition def) { super(); title = def.getName(); source = def.getSource(); icon = def.getIcon(); description = def.getDescription(); set("name", def.getName()); set("version", def.getVersion()); set("creator", def.getCreator()); set("copyright", def.getCopyright()); set("release", def.getReleased()); }
PluginDefinition definition = new PluginDefinition(); String name = manifest.getValue("client_name"); definition.setId(StrUtil.xlate(manifest.getValue("client_id"), " @", "__")); definition.setName(name); definition.setUrl(manifest.getValue("launch_uri")); definition.setClazz(SmartPlugin.class); definition.setDescription(manifest.getValue("description")); definition.setSource("SMART Platform"); definition.setCreator(manifest.getValue("author")); definition.setVersion(manifest.getValue("version")); definition.setIcon(manifest.getValue("logo_uri")); definition.setCategory("SMART apps"); definition.getResources().add(new SmartResource(manifest)); log.info("Found SMART Manifest for " + name); return definition;
public PluginDefinition fetch(String id) { List<String> tmpl = broker.callRPCList("RGCWFPAR GETTMPL", null, id); PluginDefinition def = new PluginDefinition(); def.setId(id); String entity = null; def.setName(pcs[2]); def.getProperties().add(pi);
@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); }
@Override protected String getKey(PluginDefinition item) { return item.getId(); }
private Treenode addTreenode(PluginDefinition def, Treenode other) { String category = other != null ? favoritesCategory : def.getCategory(); if (ElementPlugin.class.isAssignableFrom(def.getClazz())) { category = StrUtil.getLabel("cwf.shell.plugin.category.default"); } else { String path = category + (category.endsWith("\\") ? "" : "\\") + def.getName(); boolean isFavorite = other != null || (favorites != null && favorites.contains(path)); boolean disabled = def.isDisabled() || def.isForbidden(); Treenode node = TreeUtil.findNode(tree, path, true); node.setData(def); node.setHint(StringUtils.defaultString(def.getDescription(), noDescriptionHint)); node.addEventListener(ClickEvent.TYPE, (event) -> { if (event.getTargetId().endsWith("-img")) {
ElementBase element = null; if (isForbidden()) { log.info("Access to plugin " + getName() + " is restricted."); } else if (isDisabled()) { log.info("Plugin " + getName() + " has been disabled."); } else { Class<? extends ElementBase> clazz = getClazz(); if (isInternal()) { element = parent.getChild(clazz, null); } else { initElement(element, propertyProvider);
/** * 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); }
/** * Synchronizes property values between the proxy and its object. * * @param fromReal If true, property values are copied from the target to the proxy. If false, * property values are copied from the proxy to the target. */ private void syncProperties(boolean fromReal) { PluginDefinition def = getDefinition(); for (PropertyInfo propInfo : def.getProperties()) { if (fromReal) { syncProperty(propInfo, real, this); } else { syncProperty(propInfo, this, real); } } }
public ElementLayout(String layoutName, boolean shared) { this(); this.layoutName = layoutName; this.shared = shared; def = new PluginDefinition(PluginDefinition.getDefinition(getClass())); super.setDefinition(def); initDefinition(); }
/** * Process all associated resources. * * @param register If true, resources will be registered; if false, unregistered. */ private void processResources(boolean register) { CareWebShell shell = CareWebUtil.getShell(); for (IPluginResource resource : getDefinition().getResources()) { resource.register(shell, this, register); } }
if (def.isInternal()) { continue; Class<? extends ElementBase> clazz = def.getClazz(); StrUtil.formatMessage("@cwf.shell.designer.add.component.title", parentElement.getDefinition().getName())); window.setOnCanClose(() -> { if (favoritesChanged) {
/** * Sets the URL of the principal cwf page for the plugin. * * @param url The URL of the principal cwf page. */ public void setUrl(String url) { this.url = url; if (clazz == null && url != null) { setClazz(ElementPlugin.class); } }
PluginDefinition definition = new PluginDefinition(); String name = manifest.getValue("client_name"); definition.setId(StrUtil.xlate(manifest.getValue("client_id"), " @", "__")); definition.setName(name); definition.setUrl(manifest.getValue("launch_uri")); definition.setClazz(SmartPlugin.class); definition.setDescription(manifest.getValue("description")); definition.setSource("SMART Platform"); definition.setCreator(manifest.getValue("author")); definition.setVersion(manifest.getValue("version")); definition.setIcon(manifest.getValue("logo_uri")); definition.setCategory("SMART apps"); definition.getResources().add(new SmartResource(manifest)); log.info("Found SMART Manifest for " + name); return definition;
/** * 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; }