use of org.knime.core.node.workflow.NodeID in project knime-core by knime.
the class CreateNodeCommand method execute.
/**
* {@inheritDoc}
*/
@Override
public void execute() {
WorkflowManager hostWFM = getHostWFM();
// Add node to workflow and get the container
try {
NodeID id = hostWFM.createAndAddNode(m_factory);
m_container = hostWFM.getNodeContainer(id);
NodeTimer.GLOBAL_TIMER.addNodeCreation(m_container);
} catch (Throwable t) {
// if fails notify the user
LOGGER.debug("Node cannot be created.", t);
MessageBox mb = new MessageBox(Display.getDefault().getActiveShell(), SWT.ICON_WARNING | SWT.OK);
mb.setText("Node cannot be created.");
mb.setMessage("The selected node could not be created " + "due to the following reason:\n" + t.getMessage());
mb.open();
return;
}
// create extra info and set it
NodeUIInformation info = NodeUIInformation.builder().setNodeLocation(m_location.x, m_location.y, -1, -1).setHasAbsoluteCoordinates(false).setSnapToGrid(m_snapToGrid).setIsDropLocation(true).build();
m_container.setUIInformation(info);
}
use of org.knime.core.node.workflow.NodeID in project knime-core by knime.
the class DisconnectMetaNodeLinkCommand method canExecute.
/**
* We can execute, if all components were 'non-null' in the constructor.
* {@inheritDoc}
*/
@Override
public boolean canExecute() {
if (!super.canExecute()) {
return false;
}
if (m_ids == null) {
return false;
}
for (NodeID id : m_ids) {
NodeContainer nc = getHostWFM().getNodeContainer(id);
if (nc instanceof WorkflowManager) {
WorkflowManager wm = (WorkflowManager) nc;
MetaNodeTemplateInformation lI = wm.getTemplateInformation();
if (Role.Link.equals(lI.getRole())) {
return true;
}
}
}
return false;
}
use of org.knime.core.node.workflow.NodeID in project knime-core by knime.
the class DisconnectMetaNodeLinkCommand method undo.
/**
* {@inheritDoc}
*/
@Override
public void undo() {
LOGGER.debug("Undo: Reconnecting metanode links (" + m_changedIDs.size() + " metanode(s))");
for (int i = 0; i < m_changedIDs.size(); i++) {
NodeID id = m_changedIDs.get(i);
MetaNodeTemplateInformation old = m_oldTemplInfos.get(i);
getHostWFM().setTemplateInformation(id, old);
}
m_changedIDs = null;
m_oldTemplInfos = null;
}
use of org.knime.core.node.workflow.NodeID in project knime-core by knime.
the class ExpandSubNodeCommand method execute.
/**
* {@inheritDoc}
*/
@Override
public void execute() {
try {
WorkflowManager hostWFM = getHostWFM();
// close editor of subnode and children
NodeID wfmID = ((SubNodeContainer) hostWFM.getNodeContainer(m_id)).getWorkflowManager().getID();
for (IEditorPart child : m_editor.getSubEditors(m_id)) {
child.getEditorSite().getPage().closeEditor(child, false);
}
m_expandResult = hostWFM.expandSubWorkflow(m_id);
WorkflowAnnotation[] annotations = m_expandResult.getExpandedCopyContent().getAnnotations();
NodeID[] nodeIDs = m_expandResult.getExpandedCopyContent().getNodeIDs();
EditPartViewer partViewer = m_editor.getViewer();
partViewer.deselectAll();
// select the new ones....
if (partViewer.getRootEditPart().getContents() != null && partViewer.getRootEditPart().getContents() instanceof WorkflowRootEditPart) {
WorkflowRootEditPart rootEditPart = (WorkflowRootEditPart) partViewer.getRootEditPart().getContents();
rootEditPart.setFutureSelection(nodeIDs);
rootEditPart.setFutureAnnotationSelection(Arrays.asList(annotations));
}
} catch (Exception e) {
String error = "Expanding Wrapped Metanode failed: " + e.getMessage();
LOGGER.error(error, e);
MessageDialog.openError(Display.getCurrent().getActiveShell(), "Expand failed", error);
}
}
use of org.knime.core.node.workflow.NodeID in project knime-core by knime.
the class DeleteCommand method canExecute.
/**
* {@inheritDoc}
*/
@Override
public boolean canExecute() {
if (!super.canExecute()) {
return false;
}
boolean foundValid = false;
WorkflowManager hostWFM = getHostWFM();
for (NodeID id : m_nodeIDs) {
foundValid = true;
if (!hostWFM.canRemoveNode(id)) {
return false;
}
}
for (ConnectionContainer cc : m_connections) {
foundValid = true;
if (!hostWFM.canRemoveConnection(cc)) {
return false;
}
}
return foundValid || m_annotations.length > 0;
}
Aggregations