use of org.knime.workbench.repository.model.NodeTemplate in project knime-core by knime.
the class NodeDescriptionConverter method processAll.
private boolean processAll(final IRepositoryObject[] elements, final Document nodeToc) throws Exception {
boolean nodeCreated = false;
for (IRepositoryObject o : elements) {
if (o instanceof Category) {
Category c = (Category) o;
if (c.getParent() instanceof Root && m_monitor != null) {
Display d = Display.getDefault();
d.asyncExec(new Runnable() {
@Override
public void run() {
m_monitor.worked(2);
}
});
}
// create toc file
Document topicFile = createNodeTocFile(c);
boolean hasNodes = processAll(((Category) o).getChildren(), topicFile);
if (c.getContributingPlugin().equals(m_pluginID)) {
writeCategoryTocFile(c);
}
if (hasNodes) {
// write toc file
writeNodeTocFile(topicFile, fileName(getFullPath(c) + NODES));
writeTocToPluginXML(c, true);
}
// TODO: why is nodeToc null?
} else if (o instanceof NodeTemplate && nodeToc != null) {
nodeCreated |= processNode((NodeTemplate) o, nodeToc);
} else if (o instanceof MetaNodeTemplate && nodeToc != null) {
nodeCreated |= processMetaNode((MetaNodeTemplate) o, nodeToc);
}
}
return nodeCreated;
}
use of org.knime.workbench.repository.model.NodeTemplate in project knime-core by knime.
the class NodeUsageRegistry method loadLastUsedNodes.
/**
* Loads the last used nodes from XML memento. Called from
* FavoriteNodesManager#loadFavoriteNodes.
*
* @see #saveLastUsedNodes(IMemento)
* @param lastUsedNodes the XML memento to load the last used nodes from
*/
public static void loadLastUsedNodes(final IMemento lastUsedNodes) {
for (IMemento lastNode : lastUsedNodes.getChildren(TAG_FAVORITE)) {
String id = lastNode.getString(TAG_NODE_ID);
NodeTemplate node = RepositoryManager.INSTANCE.getNodeTemplate(id);
if (node != null) {
addToLastUsedNodes(node);
}
}
}
use of org.knime.workbench.repository.model.NodeTemplate in project knime-core by knime.
the class DynamicNodeDescriptionCreator method addDescription.
/**
* Adds the single line description for all nodes contained in the category
* (and all sub categories) to the StringBuilder. It will separate the lines
* by a HTML new line tag.
*
* @param cat the category to add the descriptions for.
* @param bld the buffer to add the one line strings to.
* @param idsDisplayed a set of IDs of categories and templates already
* displayed. Items appearing twice will be skipped.
*/
public void addDescription(final Category cat, final StringBuilder bld, final Set<String> idsDisplayed) {
bld.append("<dl>");
bld.append("<dt><h2>In <b>");
bld.append(htmlString(cat.getName()));
bld.append("</b>:</h2></dt> \n");
if (!cat.hasChildren()) {
bld.append("<dd> - contains no nodes - </dd>");
} else {
bld.append("<dd><dl>");
for (IRepositoryObject child : cat.getChildren()) {
if (child instanceof Category) {
Category childCat = (Category) child;
if (!idsDisplayed.contains(childCat.getID())) {
idsDisplayed.add(childCat.getID());
addDescription(childCat, bld, idsDisplayed);
}
} else if (child instanceof NodeTemplate) {
NodeTemplate templ = (NodeTemplate) child;
if (!idsDisplayed.contains(templ.getID())) {
idsDisplayed.add(templ.getID());
addDescription(templ, /* useSingleLine */
true, bld);
}
} else if (child instanceof MetaNodeTemplate) {
MetaNodeTemplate templ = (MetaNodeTemplate) child;
if (!idsDisplayed.contains(templ.getID())) {
idsDisplayed.add(templ.getID());
NodeContainerUI manager = ((MetaNodeTemplate) child).getManager();
addDescription(manager, /* useSingleLine */
true, bld);
}
} else {
bld.append(" - contains unknown object (internal err!) -");
}
}
bld.append("</dl></dd>");
}
bld.append("</dl>");
}
use of org.knime.workbench.repository.model.NodeTemplate in project knime-core by knime.
the class RepositoryStyledLabelProvider method getVendorAndBundle.
/**
* @param robj
* @return
*/
private static String getVendorAndBundle(final Object robj) {
StringBuilder toReturn = new StringBuilder();
if (robj instanceof NodeTemplate) {
@SuppressWarnings("rawtypes") final Class<? extends NodeFactory> facClass = ((NodeTemplate) robj).getFactory();
Bundle bundle = OSGIHelper.getBundle(facClass);
if (bundle != null) {
toReturn.append("Vendor: ");
toReturn.append(bundle.getHeaders().get(Constants.BUNDLE_VENDOR));
toReturn.append(" - ");
}
((NodeTemplate) robj).getContributingPlugin();
}
if (robj instanceof IRepositoryObject) {
toReturn.append("Plugin: ");
toReturn.append(((IRepositoryObject) robj).getContributingPlugin());
}
return toReturn.toString();
}
use of org.knime.workbench.repository.model.NodeTemplate in project knime-core by knime.
the class WorkflowCoachView method hookDoubleClickAction.
/**
* Inserts a node on double click into the workflow editor.
*/
private void hookDoubleClickAction() {
m_viewer.addDoubleClickListener(event -> {
Object o = ((IStructuredSelection) event.getSelection()).getFirstElement();
if (o instanceof NodeRecommendation[]) {
NodeRecommendation[] nrs = (NodeRecommendation[]) o;
NodeTemplate tmplt = getNonNullEntry(nrs).getNodeTemplate();
NodeFactory<? extends NodeModel> nodeFact;
try {
nodeFact = tmplt.createFactoryInstance();
} catch (Exception e) {
NodeLogger.getLogger(WorkflowCoachView.class).error("Unable to instantiate the selected node " + tmplt.getFactory().getName(), e);
return;
}
boolean added = NodeProvider.INSTANCE.addNode(nodeFact);
if (added) {
Display.getDefault().asyncExec(() -> setFocus());
}
}
});
}
Aggregations