use of org.knime.workbench.repository.model.Root in project knime-core by knime.
the class FavoritesView method createPartControl.
/**
* {@inheritDoc}
*/
@Override
public void createPartControl(final Composite parent) {
m_viewer = new TreeViewer(parent, SWT.SINGLE | SWT.V_SCROLL);
this.getSite().setSelectionProvider(m_viewer);
Transfer[] transfers = new Transfer[] { LocalSelectionTransfer.getTransfer() };
m_viewer.addDragSupport(DND.DROP_COPY | DND.DROP_MOVE, transfers, new FavoriteNodesDragSource(this));
m_viewer.addDropSupport(DND.DROP_COPY, transfers, new FavoriteNodesDropTarget(this));
m_viewer.setLabelProvider(new RepositoryLabelProvider());
m_viewer.setContentProvider(new RepositoryContentProvider());
// no sorting
m_viewer.setComparator(null);
m_viewer.setInput("Loading favorite nodes...");
Job treeUpdater = new KNIMEJob("Favorite Nodes Loader", FrameworkUtil.getBundle(getClass())) {
@Override
protected IStatus run(final IProgressMonitor monitor) {
final Root root = FavoriteNodesManager.getInstance().getRoot();
final Object category = root.getChildByID(FavoriteNodesManager.FAV_CAT_ID, false);
if (monitor.isCanceled()) {
return Status.CANCEL_STATUS;
} else {
Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() {
if (!parent.isDisposed()) {
m_viewer.setInput(root);
m_viewer.expandToLevel(category, 1);
}
}
});
}
return Status.OK_STATUS;
}
};
treeUpdater.setSystem(true);
treeUpdater.schedule();
NodeUsageRegistry.addNodeUsageListener(FavoritesView.this);
hookDoubleClickAction();
}
use of org.knime.workbench.repository.model.Root in project knime-core by knime.
the class NodeDescriptionConverter method buildDocumentationFor.
/**
* Gets the {@link RepositoryManager} and transforms all NodeDescriptions
* into HTML files, which are placed into the roots HTML directory.
*
* @param pluginId the id of the plugin for which the help files should be
* generated
* @param destinationDir directory, where the created/modified files should
* be written to. If <code>null</code> they are written directly
* into the plugin's directory.
* @throws Exception if something goes wrong
*/
public synchronized void buildDocumentationFor(final String pluginId, final File destinationDir) throws Exception {
final Root root = RepositoryManager.INSTANCE.getRoot();
if (m_monitor != null) {
Display d = Display.getDefault();
d.syncExec(new Runnable() {
@Override
public void run() {
if (m_monitor.isCanceled()) {
m_canceled = true;
return;
}
if (m_first) {
m_monitor.beginTask("Processing " + m_pluginID, m_nrPlugins * root.getChildren().length);
m_first = false;
} else {
m_monitor.subTask("Processing " + m_pluginID);
}
}
});
}
if (m_canceled) {
return;
}
m_pluginID = pluginId;
if (destinationDir == null) {
m_destinationDir = getPluginDir();
} else {
m_destinationDir = destinationDir;
}
File nodesDir = new File(m_destinationDir, HTML_DIR + File.separator + NODES_DIR);
if (!nodesDir.exists() && !nodesDir.mkdirs()) {
throw new IOException("Could not create directory '" + nodesDir + "'");
}
File tocsDir = new File(m_destinationDir, TOC_DIR);
if (!tocsDir.exists() && !tocsDir.mkdirs()) {
throw new IOException("Could not create directory '" + tocsDir + "'");
}
parsePluginXML();
if (m_dialog != null) {
m_dialog.setCancelable(false);
}
// processing
processAll(root.getChildren(), null);
// at the end -> persist plugin.xml
Document doc = m_pluginXML;
Source src = new DOMSource(doc);
File f = new File(m_destinationDir, m_isFragment ? "fragment.xml" : "plugin.xml");
Result streamResult = new StreamResult(f);
TransformerFactory tf = TransformerFactory.newInstance();
Transformer serializer = tf.newTransformer();
serializer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
serializer.setOutputProperty(OutputKeys.INDENT, "yes");
serializer.transform(src, streamResult);
// at the end add the two dependencies to the manifest file
// org.eclipse.help, org.eclipse.help.ui
updateManifest();
}
use of org.knime.workbench.repository.model.Root 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;
}
Aggregations