use of org.knime.core.node.workflow.WorkflowManager in project knime-core by knime.
the class DropNodeCommand method execute.
/**
* {@inheritDoc}
*/
@Override
public void execute() {
// Add node to workflow and get the container
WorkflowManager hostWFM = getHostWFM();
try {
NodeID id = hostWFM.addNodeAndApplyContext(m_factory, m_dropContext);
m_container = hostWFM.getNodeContainer(id);
// 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);
// Open the dialog. Some times.
if (m_container instanceof SingleNodeContainer && m_container.getNodeContainerState().isIdle() && m_container.hasDialog() && // and has only a variable in port
m_container.getNrInPorts() == 1) {
// if not executable and has a dialog and is fully connected
// This is embedded in a special JFace wrapper dialog
//
Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() {
try {
WrappedNodeDialog dlg = new WrappedNodeDialog(Display.getCurrent().getActiveShell(), m_container);
dlg.open();
} catch (Exception e) {
// they need to open it manually then
}
}
});
}
} 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;
}
}
use of org.knime.core.node.workflow.WorkflowManager in project knime-core by knime.
the class CreateNewConnectedNodeCommand method createNewNode.
/**
* {@inheritDoc}
*/
@Override
protected NodeID createNewNode() {
// Add node to workflow and get the container
NodeID newID = null;
WorkflowManager hostWFM = getHostWFM();
try {
newID = hostWFM.createAndAddNode(m_factory);
NodeTimer.GLOBAL_TIMER.addNodeCreation(hostWFM.getNodeContainer(newID));
} 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 node could not be created " + "due to the following reason:\n" + t.getMessage());
mb.open();
return null;
}
return newID;
}
use of org.knime.core.node.workflow.WorkflowManager in project knime-core by knime.
the class DeleteCommand method undo.
/**
* {@inheritDoc}
*/
@Override
public void undo() {
// select the new ones....
if (m_viewer != null && m_viewer.getRootEditPart().getContents() instanceof WorkflowRootEditPart) {
((WorkflowRootEditPart) m_viewer.getRootEditPart().getContents()).setFutureSelection(m_nodeIDs);
m_viewer.deselectAll();
}
WorkflowManager hostWFM = getHostWFM();
if (m_undoPersitor != null) {
hostWFM.paste(m_undoPersitor);
}
for (ConnectionContainer cc : m_connections) {
ConnectionContainer newCC = hostWFM.addConnection(cc.getSource(), cc.getSourcePort(), cc.getDest(), cc.getDestPort());
newCC.setUIInfo(cc.getUIInfo());
}
}
use of org.knime.core.node.workflow.WorkflowManager in project knime-core by knime.
the class DisconnectSubNodeLinkCommand method execute.
/**
* {@inheritDoc}
*/
@Override
public void execute() {
m_changedIDs = new ArrayList<NodeID>();
m_oldTemplInfos = new ArrayList<MetaNodeTemplateInformation>();
WorkflowManager hostWFM = getHostWFM();
for (NodeID id : m_ids) {
NodeContainer nc = hostWFM.getNodeContainer(id);
if (nc instanceof SubNodeContainer) {
SubNodeContainer snc = (SubNodeContainer) nc;
MetaNodeTemplateInformation lI = snc.getTemplateInformation();
if (Role.Link.equals(lI.getRole())) {
MetaNodeTemplateInformation old = hostWFM.setTemplateInformation(id, MetaNodeTemplateInformation.NONE);
RECENTLY_USED_URIS.put(snc.getID(), old.getSourceURI());
m_changedIDs.add(id);
m_oldTemplInfos.add(old);
}
}
}
}
use of org.knime.core.node.workflow.WorkflowManager in project knime-core by knime.
the class ExpandMetaNodeCommand method undo.
/**
* {@inheritDoc}
*/
@Override
public void undo() {
WorkflowManager hostWFM = getHostWFM();
for (NodeID id : m_pastedNodes) {
hostWFM.removeNode(id);
}
for (WorkflowAnnotation anno : m_pastedAnnotations) {
hostWFM.removeAnnotation(anno);
}
hostWFM.paste(m_undoCopyPersistor);
m_pastedNodes = null;
m_pastedAnnotations = null;
m_undoCopyPersistor = null;
}
Aggregations