Search in sources :

Example 11 with IRepositoryObject

use of org.knime.workbench.repository.model.IRepositoryObject 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>");
}
Also used : NodeContainerUI(org.knime.core.ui.node.workflow.NodeContainerUI) SubNodeContainerUI(org.knime.core.ui.node.workflow.SubNodeContainerUI) SingleNodeContainerUI(org.knime.core.ui.node.workflow.SingleNodeContainerUI) Category(org.knime.workbench.repository.model.Category) NodeTemplate(org.knime.workbench.repository.model.NodeTemplate) MetaNodeTemplate(org.knime.workbench.repository.model.MetaNodeTemplate) MetaNodeTemplate(org.knime.workbench.repository.model.MetaNodeTemplate) IRepositoryObject(org.knime.workbench.repository.model.IRepositoryObject)

Example 12 with IRepositoryObject

use of org.knime.workbench.repository.model.IRepositoryObject in project knime-core by knime.

the class RepositoryStyledLabelProvider method update.

@Override
public void update(final ViewerCell cell) {
    Object obj = cell.getElement();
    if (obj instanceof IRepositoryObject) {
        StyledString styledString = new StyledString(m_provider.getText(obj));
        if (m_appendCategory) {
            // receive the category string.
            String categoryString = getCategoryString((IRepositoryObject) obj);
            if (!categoryString.isEmpty()) {
                styledString.append(String.format("\t - %s", categoryString), StyledString.DECORATIONS_STYLER);
            }
        }
        if (m_appendAdditionalInfoKeys.length > 0) {
            if (obj instanceof AbstractRepositoryObject) {
                AbstractRepositoryObject aro = (AbstractRepositoryObject) obj;
                for (String key : m_appendAdditionalInfoKeys) {
                    if (aro.getAdditionalInfo(key) != null) {
                        styledString.append(String.format("\t [%s]", ((AbstractRepositoryObject) obj).getAdditionalInfo(key)), StyledString.QUALIFIER_STYLER);
                    }
                }
            }
        }
        cell.setText(styledString.toString());
        cell.setStyleRanges(styledString.getStyleRanges());
    } else {
        cell.setText(m_provider.getText(obj));
    }
    cell.setImage(m_provider.getImage(obj));
}
Also used : AbstractRepositoryObject(org.knime.workbench.repository.model.AbstractRepositoryObject) IRepositoryObject(org.knime.workbench.repository.model.IRepositoryObject) IContainerObject(org.knime.workbench.repository.model.IContainerObject) StyledString(org.eclipse.jface.viewers.StyledString) StyledString(org.eclipse.jface.viewers.StyledString) AbstractRepositoryObject(org.knime.workbench.repository.model.AbstractRepositoryObject) IRepositoryObject(org.knime.workbench.repository.model.IRepositoryObject)

Example 13 with IRepositoryObject

use of org.knime.workbench.repository.model.IRepositoryObject 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();
}
Also used : NodeTemplate(org.knime.workbench.repository.model.NodeTemplate) Bundle(org.osgi.framework.Bundle) IRepositoryObject(org.knime.workbench.repository.model.IRepositoryObject)

Aggregations

IRepositoryObject (org.knime.workbench.repository.model.IRepositoryObject)13 Category (org.knime.workbench.repository.model.Category)7 MetaNodeTemplate (org.knime.workbench.repository.model.MetaNodeTemplate)5 NodeTemplate (org.knime.workbench.repository.model.NodeTemplate)5 IContainerObject (org.knime.workbench.repository.model.IContainerObject)4 Root (org.knime.workbench.repository.model.Root)4 Image (org.eclipse.swt.graphics.Image)3 BufferedWriter (java.io.BufferedWriter)2 FileWriter (java.io.FileWriter)2 Writer (java.io.Writer)2 NodeFactory (org.knime.core.node.NodeFactory)2 NodeModel (org.knime.core.node.NodeModel)2 AbstractNodeTemplate (org.knime.workbench.repository.model.AbstractNodeTemplate)2 Method (java.lang.reflect.Method)1 URL (java.net.URL)1 ArrayList (java.util.ArrayList)1 StyledString (org.eclipse.jface.viewers.StyledString)1 ImageData (org.eclipse.swt.graphics.ImageData)1 ImageLoader (org.eclipse.swt.graphics.ImageLoader)1 Display (org.eclipse.swt.widgets.Display)1