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>");
}
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));
}
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();
}
Aggregations