use of org.knime.core.node.workflow.NodeID in project knime-core by knime.
the class CheckUpdateMetaNodeLinkAction method runInSWT.
/**
* {@inheritDoc}
*/
@Override
public void runInSWT() {
List<NodeID> candidateList = getMetaNodesToCheck();
final Shell shell = Display.getCurrent().getActiveShell();
IWorkbench wb = PlatformUI.getWorkbench();
IProgressService ps = wb.getProgressService();
LOGGER.debug("Checking for updates for " + candidateList.size() + " node link(s)...");
CheckUpdateRunnableWithProgress runner = new CheckUpdateRunnableWithProgress(getManager(), candidateList);
try {
ps.busyCursorWhile(runner);
} catch (InvocationTargetException e) {
LOGGER.warn("Failed to check for updates: " + e.getMessage(), e);
return;
} catch (InterruptedException e) {
return;
}
List<NodeID> updateList = runner.getUpdateList();
Status status = runner.getStatus();
if (status.getSeverity() == IStatus.ERROR || status.getSeverity() == IStatus.WARNING) {
ErrorDialog.openError(Display.getDefault().getActiveShell(), null, "Errors while checking for " + "updates on node links", status);
if (candidateList.size() == 1) {
/* As only one node is selected and its update failed,
* there is nothing else to do. */
return;
}
}
// find nodes that will be reset as part of the update
int nodesToResetCount = 0;
for (NodeID id : updateList) {
NodeContainerTemplate templateNode = (NodeContainerTemplate) getManager().findNodeContainer(id);
// TODO problematic with through-connections
if (templateNode.containsExecutedNode()) {
nodesToResetCount += 1;
}
}
if (updateList.isEmpty()) {
if (m_showInfoMsgIfNoUpdateAvail) {
MessageDialog.openInformation(shell, "Node Update", "No updates available");
} else {
LOGGER.info("No updates available (" + candidateList.size() + " node link(s))");
}
} else {
boolean isSingle = updateList.size() == 1;
String title = "Update Node" + (isSingle ? "" : "s");
StringBuilder messageBuilder = new StringBuilder();
messageBuilder.append("Update available for ");
if (isSingle && candidateList.size() == 1) {
messageBuilder.append("node \"");
messageBuilder.append(getManager().findNodeContainer(candidateList.get(0)).getNameWithID());
messageBuilder.append("\".");
} else if (isSingle) {
messageBuilder.append("one node.");
} else {
messageBuilder.append(updateList.size());
messageBuilder.append(" nodes.");
}
messageBuilder.append("\n\n");
if (nodesToResetCount > 0) {
messageBuilder.append("Reset nodes and update now?");
} else {
messageBuilder.append("Update now?");
}
String message = messageBuilder.toString();
if (MessageDialog.openQuestion(shell, title, message)) {
LOGGER.debug("Running update for " + updateList.size() + " node(s): " + updateList);
execute(new UpdateMetaNodeLinkCommand(getManager(), updateList.toArray(new NodeID[updateList.size()])));
}
}
}
use of org.knime.core.node.workflow.NodeID in project knime-core by knime.
the class CheckUpdateMetaNodeLinkAction method getMetaNodesToCheck.
protected List<NodeID> getMetaNodesToCheck() {
List<NodeID> list = new ArrayList<NodeID>();
for (NodeContainerEditPart p : getSelectedParts(NodeContainerEditPart.class)) {
NodeContainerUI model = p.getNodeContainer();
if (Wrapper.wraps(model, NodeContainerTemplate.class)) {
NodeContainerTemplate tnc = Wrapper.unwrap(model, NodeContainerTemplate.class);
if (tnc.getTemplateInformation().getRole().equals(Role.Link)) {
if (!getManager().canUpdateMetaNodeLink(tnc.getID())) {
return Collections.emptyList();
}
list.add(tnc.getID());
}
list.addAll(getNCTemplatesToCheck(tnc));
}
}
return list;
}
use of org.knime.core.node.workflow.NodeID in project knime-core by knime.
the class MetaNodeCreationFactory method getNewObject.
/**
* {@inheritDoc}
*/
@Override
public Object getNewObject() {
NodeID id = m_template.getManager().getID();
WorkflowManager sourceManager = WorkflowManager.META_NODE_ROOT;
WorkflowCopyContent.Builder content = WorkflowCopyContent.builder();
content.setNodeIDs(id);
return sourceManager.copy(content.build());
}
use of org.knime.core.node.workflow.NodeID in project knime-core by knime.
the class NodeUsageComposite method createNodeGrid.
private void createNodeGrid(final SubNodeContainer subNodeContainer, @SuppressWarnings("rawtypes") final Map<NodeIDSuffix, WizardNode> viewNodes) {
ScrolledComposite scrollPane = new ScrolledComposite(this, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER);
scrollPane.setExpandHorizontal(true);
scrollPane.setExpandVertical(true);
Composite composite = new Composite(scrollPane, SWT.NONE);
scrollPane.setContent(composite);
scrollPane.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, true));
composite.setLayout(new GridLayout(3, false));
composite.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, false));
// titles
new Composite(composite, SWT.NONE);
/* Placeholder */
Label wizardLabel = new Label(composite, SWT.CENTER);
FontData fontData = wizardLabel.getFont().getFontData()[0];
Font boldFont = new Font(Display.getCurrent(), new FontData(fontData.getName(), fontData.getHeight(), SWT.BOLD));
wizardLabel.setText("WebPortal /\nWrapped Metanode View");
wizardLabel.setFont(boldFont);
Label dialogLabel = new Label(composite, SWT.CENTER);
dialogLabel.setText("\nWrapped Metanode Dialog");
dialogLabel.setFont(boldFont);
// select all checkboxes
Label selectAllLabel = new Label(composite, SWT.LEFT);
selectAllLabel.setText("Enable/Disable");
Button selectAllWizard = createCheckbox(composite);
Button selectAllDialog = createCheckbox(composite);
// individual nodes
for (@SuppressWarnings("rawtypes") Entry<NodeIDSuffix, WizardNode> entry : viewNodes.entrySet()) {
NodeIDSuffix suffix = entry.getKey();
NodeID id = suffix.prependParent(subNodeContainer.getWorkflowManager().getID());
NodeContainer nodeContainer = viewNodes.containsKey(suffix) ? subNodeContainer.getWorkflowManager().getNodeContainer(id) : null;
createNodeLabelComposite(composite, id, nodeContainer);
@SuppressWarnings("rawtypes") WizardNode model = entry.getValue();
Button wizardButton = createCheckbox(composite);
wizardButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(final SelectionEvent e) {
checkAllSelected(m_wizardUsageMap, selectAllWizard);
}
});
wizardButton.setToolTipText("Enable/disable for usage in WebPortal and wizard execution.");
wizardButton.setSelection(!((WizardNode<?, ?>) model).isHideInWizard());
m_wizardUsageMap.put(id, wizardButton);
if (model instanceof DialogNode) {
Button dialogButton = createCheckbox(composite);
dialogButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(final SelectionEvent e) {
checkAllSelected(m_dialogUsageMap, selectAllDialog);
}
});
dialogButton.setToolTipText("Enable/disable for usage in wrapped metanode configure dialog.");
dialogButton.setSelection(!((DialogNode<?, ?>) model).isHideInDialog());
m_dialogUsageMap.put(id, dialogButton);
} else {
new Composite(composite, SWT.NONE);
/* Placeholder */
}
}
checkAllSelected(m_wizardUsageMap, selectAllWizard);
checkAllSelected(m_dialogUsageMap, selectAllDialog);
selectAllWizard.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(final SelectionEvent e) {
selectAllWizard.setGrayed(false);
for (Button b : m_wizardUsageMap.values()) {
b.setSelection(selectAllWizard.getSelection());
}
}
});
if (m_wizardUsageMap.size() < 1) {
selectAllWizard.setEnabled(false);
}
selectAllDialog.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(final SelectionEvent e) {
selectAllDialog.setGrayed(false);
for (Button b : m_dialogUsageMap.values()) {
b.setSelection(selectAllDialog.getSelection());
}
}
});
if (m_dialogUsageMap.size() < 1) {
selectAllDialog.setEnabled(false);
}
}
use of org.knime.core.node.workflow.NodeID in project knime-core by knime.
the class SubnodeLayoutWizard method addPages.
/**
* {@inheritDoc}
*/
@SuppressWarnings("rawtypes")
@Override
public void addPages() {
setWindowTitle("Node Usage and Layout");
setDefaultPageImageDescriptor(ImageRepository.getImageDescriptor(KNIMEEditorPlugin.PLUGIN_ID, "icons/layout_55.png"));
WorkflowManager wfManager = m_subNodeContainer.getWorkflowManager();
// Map<NodeID, SubNodeContainer> nestedSubnodes = wfManager.findNodes(SubNodeContainer.class, false);
Map<NodeID, WizardNode> viewNodes = wfManager.findNodes(WizardNode.class, false);
LinkedHashMap<NodeIDSuffix, WizardNode> resultMap = new LinkedHashMap<>();
for (Map.Entry<NodeID, WizardNode> entry : viewNodes.entrySet()) {
NodeID.NodeIDSuffix idSuffix = NodeID.NodeIDSuffix.create(wfManager.getID(), entry.getKey());
resultMap.put(idSuffix, entry.getValue());
}
List<NodeID> nodeIDs = new ArrayList<NodeID>();
nodeIDs.addAll(viewNodes.keySet());
/*for (NodeID subnodeID : nestedSubnodes.keySet()) {
WorkflowManager nestedWFManager = nestedSubnodes.get(subnodeID).getWorkflowManager();
if (!nestedWFManager.findNodes(WizardNode.class, true).isEmpty()) {
nodeIDs.add(subnodeID);
}
}*/
Collections.sort(nodeIDs);
m_page = new SubnodeLayoutJSONEditorPage("Change the layout configuration");
m_page.setNodes(wfManager, m_subNodeContainer, resultMap);
addPage(m_page);
}
Aggregations