use of org.knime.core.ui.node.workflow.WorkflowManagerUI in project knime-core by knime.
the class SaveAsMetaNodeTemplateAction method internalCalculateEnabled.
/**
* @return true, if underlying model instance of
* <code>WorkflowManager</code> and there is no link associated
* with it, otherwise false
*/
@Override
protected boolean internalCalculateEnabled() {
if (getManager().isWriteProtected()) {
return false;
}
NodeContainerEditPart[] nodes = getSelectedParts(NodeContainerEditPart.class);
if (nodes.length != 1) {
return false;
}
Object model = nodes[0].getModel();
if (model instanceof WorkflowManagerUI) {
WorkflowManagerUI wm = (WorkflowManagerUI) model;
switch(Wrapper.unwrapWFM(wm).getTemplateInformation().getRole()) {
case None:
break;
default:
return false;
}
for (AbstractContentProvider p : ExplorerMountTable.getMountedContent().values()) {
if (p.canHostMetaNodeTemplates()) {
return true;
}
}
}
return false;
}
use of org.knime.core.ui.node.workflow.WorkflowManagerUI in project knime-core by knime.
the class AbstractCreateNewConnectedNodeCommand method getMatchingPorts.
private Map<Integer, Integer> getMatchingPorts(final NodeContainer left, final NodeContainer right) {
// don't auto connect to flow var ports - start with port index 1
int leftFirst = (left instanceof WorkflowManagerUI) ? 0 : 1;
int rightFirst = (right instanceof WorkflowManagerUI) ? 0 : 1;
Map<Integer, Integer> matchingPorts = new TreeMap<Integer, Integer>();
Map<Integer, Integer> possibleMatches = new TreeMap<Integer, Integer>();
Set<Integer> assignedRight = new HashSet<Integer>();
for (int rightPidx = rightFirst; rightPidx < right.getNrInPorts(); rightPidx++) {
for (int leftPidx = leftFirst; leftPidx < left.getNrOutPorts(); leftPidx++) {
NodeOutPort leftPort = left.getOutPort(leftPidx);
NodeInPort rightPort = right.getInPort(rightPidx);
PortType leftPortType = leftPort.getPortType();
PortType rightPortType = rightPort.getPortType();
if (leftPortType.isSuperTypeOf(rightPortType)) {
if (getHostWFM().getOutgoingConnectionsFor(left.getID(), leftPidx).size() == 0) {
if (!matchingPorts.containsKey(leftPidx) && !assignedRight.contains(rightPidx)) {
// output not connected: use it.
matchingPorts.put(leftPidx, rightPidx);
assignedRight.add(rightPidx);
}
} else {
// port already connected - we MAY use it
if (!possibleMatches.containsKey(leftPidx) && !assignedRight.contains(rightPidx)) {
possibleMatches.put(leftPidx, rightPidx);
}
}
}
}
}
for (Map.Entry<Integer, Integer> entry : possibleMatches.entrySet()) {
Integer pl = entry.getKey();
Integer pr = entry.getValue();
if (!matchingPorts.containsKey(pl) && !assignedRight.contains(pr)) {
matchingPorts.put(pl, pr);
assignedRight.add(pr);
}
}
return matchingPorts;
}
use of org.knime.core.ui.node.workflow.WorkflowManagerUI in project knime-core by knime.
the class RepositoryFactory method createMetaNode.
/**
* @param configuration content of the extension
* @return a meta node template
*/
public static MetaNodeTemplate createMetaNode(final IConfigurationElement configuration) {
String id = configuration.getAttribute("id");
String name = configuration.getAttribute("name");
String workflowDir = configuration.getAttribute("workflowDir");
String after = configuration.getAttribute("after");
String iconPath = configuration.getAttribute("icon");
String categoryPath = configuration.getAttribute("category-path");
String pluginId = configuration.getDeclaringExtension().getNamespaceIdentifier();
String description = configuration.getAttribute("description");
WorkflowManagerUI manager = loadMetaNode(pluginId, workflowDir);
if (manager == null) {
LOGGER.error("MetaNode " + name + " could not be loaded. " + "Skipped.");
return null;
}
MetaNodeTemplate template = new MetaNodeTemplate(id, name, categoryPath, configuration.getContributor().getName(), manager);
if (after != null && !after.isEmpty()) {
template.setAfterID(after);
}
if (description != null) {
template.setDescription(description);
}
if (!Boolean.getBoolean("java.awt.headless")) {
// Load images from declaring plugin
Image icon = null;
if (iconPath != null) {
icon = ImageRepository.getIconImage(pluginId, iconPath);
}
if (icon == null) {
LOGGER.coding("Icon '" + iconPath + "' for metanode " + categoryPath + "/" + name + " does not exist");
icon = ImageRepository.getIconImage(SharedImages.DefaultMetaNodeIcon);
}
template.setIcon(icon);
}
return template;
}
use of org.knime.core.ui.node.workflow.WorkflowManagerUI in project knime-core by knime.
the class DynamicNodeDescriptionCreator method addSubWorkflowDescription.
private void addSubWorkflowDescription(final NodeContainerUI nc, final boolean useSingleLine, final StringBuilder bld) {
WorkflowManagerUI wfm;
if (nc instanceof SubNodeContainerUI) {
wfm = ((SubNodeContainerUI) nc).getWorkflowManager();
} else {
wfm = (WorkflowManagerUI) nc;
}
if (!useSingleLine) {
bld.append(getHeader());
bld.append("<h1>");
bld.append(nc.getName());
bld.append("</h1>");
if (nc.getCustomDescription() != null) {
bld.append("<h2>Description:</h2>");
bld.append("<p>" + nc.getCustomDescription() + "</p>");
}
bld.append("<h2>Contained nodes: </h2>");
for (NodeContainerUI child : wfm.getNodeContainers()) {
addDescription(child, true, bld);
}
bld.append("</body></html>");
} else {
bld.append("<dt><b>");
bld.append(nc.getName() + " contained nodes:");
bld.append("</b></dt>");
bld.append("<dd>");
bld.append("<dl>");
for (NodeContainerUI child : wfm.getNodeContainers()) {
addDescription(child, true, bld);
}
bld.append("</dl>");
bld.append("</dd>");
}
}
use of org.knime.core.ui.node.workflow.WorkflowManagerUI in project knime-core by knime.
the class ShiftConnectionCommand method getLastConnectedPort.
/**
* @return the lowest index of a port that is not connected.
*/
private int getLastConnectedPort() {
NodeContainerUI nc = m_node.getNodeContainer();
int startIdx = 1;
if (nc instanceof WorkflowManagerUI) {
startIdx = 0;
}
int lastConnPort = -1;
for (int p = startIdx; p < nc.getNrInPorts(); p++) {
if (getHostWFM().getIncomingConnectionFor(m_nodeID, p) != null) {
lastConnPort = p;
}
}
if ((lastConnPort < 0) && (startIdx > 0) && (getHostWFM().getIncomingConnectionFor(m_nodeID, 0) != null)) {
// test the implicit flow var port, if it is the only connected port
lastConnPort = 0;
}
return lastConnPort;
}
Aggregations