use of org.knime.core.node.workflow.WorkflowManager 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;
}
use of org.knime.core.node.workflow.WorkflowManager in project knime-core by knime.
the class DeleteCommand method execute.
/**
* {@inheritDoc}
*/
@Override
public void execute() {
WorkflowManager hostWFM = getHostWFM();
// removed.
if (m_nodeIDs.length > 0 || m_annotations.length > 0) {
WorkflowCopyContent.Builder content = WorkflowCopyContent.builder();
content.setNodeIDs(m_nodeIDs);
content.setAnnotation(m_annotations);
m_undoPersitor = hostWFM.copy(true, content.build());
}
for (WorkflowAnnotation anno : m_annotations) {
hostWFM.removeAnnotation(anno);
}
for (NodeID id : m_nodeIDs) {
hostWFM.removeNode(id);
}
for (ConnectionContainer cc : m_connections) {
hostWFM.removeConnection(cc);
}
}
use of org.knime.core.node.workflow.WorkflowManager in project knime-core by knime.
the class ExpandMetaNodeCommand method execute.
/**
* {@inheritDoc}
*/
@Override
public void execute() {
try {
WorkflowManager hostWFM = getHostWFM();
// close editor of metanode and children
for (IEditorPart child : m_editor.getSubEditors(m_id)) {
child.getEditorSite().getPage().closeEditor(child, false);
}
WorkflowCopyContent.Builder cnt = WorkflowCopyContent.builder();
cnt.setNodeIDs(m_id);
cnt.setIncludeInOutConnections(true);
m_undoCopyPersistor = hostWFM.copy(true, cnt.build());
WorkflowCopyContent wcc = hostWFM.expandMetaNode(m_id);
m_pastedNodes = wcc.getNodeIDs();
m_pastedAnnotations = wcc.getAnnotations();
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(m_pastedNodes);
rootEditPart.setFutureAnnotationSelection(Arrays.asList(m_pastedAnnotations));
}
} catch (Exception e) {
String error = "Expanding Metanode failed: " + e.getMessage();
LOGGER.error(error, e);
MessageDialog.openError(Display.getCurrent().getActiveShell(), "Expand failed", error);
}
}
use of org.knime.core.node.workflow.WorkflowManager in project knime-core by knime.
the class NodeOutputView method selectionChanged.
/**
* The method updating the content of the monitor.
*
* {@inheritDoc}
*/
@Override
public void selectionChanged(final IWorkbenchPart part, final ISelection selection) {
if (!(selection instanceof IStructuredSelection)) {
// showErrorAndClear("");
return;
}
IStructuredSelection structSel = (IStructuredSelection) selection;
if (m_pinned) {
m_lastSelectionWhilePinned = structSel;
if (m_branchLocked && m_selectionWhenLocked == null) {
m_selectionWhenLocked = structSel;
}
return;
}
if (structSel.equals(m_lastSelection)) {
// selection hasn't changed - return.
return;
}
m_lastSelection = structSel;
if (structSel.size() < 1) {
// Nothing selected
showErrorAndClear("No node selected");
return;
}
if (structSel.size() > 1) {
// too many selected items
showErrorAndClear("Multiple elements selected");
return;
}
// retrieve first (and only!) selection:
Iterator<?> selIt = structSel.iterator();
Object sel = selIt.next();
//
if (sel instanceof NodeContainerEditPart) {
// a NodeContainer was selected, display it's name and status
NodeContainer nc = Wrapper.unwrapNC(((NodeContainerEditPart) sel).getNodeContainer());
WorkflowManager wfm = nc.getParent();
checkWorkflowManagerListener(wfm);
updateNodeContainerInfo(nc.getID());
} else if (sel instanceof WorkflowInPortBarEditPart) {
WorkflowManager wfm = Wrapper.unwrapWFM(((WorkflowInPortBarEditPart) sel).getNodeContainer());
checkWorkflowManagerListener(wfm);
} else {
// unsupported selection
showErrorAndClear("No info available for this selection");
return;
}
}
use of org.knime.core.node.workflow.WorkflowManager in project knime-core by knime.
the class ReconfigureMetaNodeCommand method canExecute.
/**
* {@inheritDoc}
*/
@Override
public boolean canExecute() {
if (!super.canExecute()) {
return false;
}
if (m_metanodeID == null) {
return false;
}
NodeContainer nc = getHostWFM().getNodeContainer(m_metanodeID);
boolean isWriteProtected;
if (nc instanceof WorkflowManager) {
isWriteProtected = ((WorkflowManager) nc).isWriteProtected();
} else if (nc instanceof SubNodeContainer) {
isWriteProtected = ((SubNodeContainer) nc).isWriteProtected();
} else {
return false;
}
if (!(nc instanceof WorkflowManager) && !(nc instanceof SubNodeContainer)) {
return false;
}
if (isWriteProtected) {
return false;
}
// at least one thing to change should be set
return (m_inPorts != null || m_outPorts != null || m_name != null);
}
Aggregations