use of org.knime.workbench.editor2.editparts.NodeContainerEditPart in project knime-core by knime.
the class SelectLoopAction method runOnNodes.
/**
* {@inheritDoc}
*/
@Override
public void runOnNodes(final NodeContainerEditPart[] nodeParts) {
WorkflowManager wfm = getManager();
for (NodeContainerEditPart selNode : nodeParts) {
NodeContainerUI selNC = selNode.getNodeContainer();
if (selNC instanceof SingleNodeContainerUI) {
EditPartViewer viewer = selNode.getViewer();
List<NodeContainer> loopNodes = wfm.getNodesInScope(Wrapper.unwrap(selNC, SingleNodeContainer.class));
for (NodeContainer nc : loopNodes) {
NodeContainerEditPart sel = (NodeContainerEditPart) viewer.getEditPartRegistry().get(NodeContainerWrapper.wrap(nc));
viewer.appendSelection(sel);
}
}
}
try {
// Give focus to the editor again. Otherwise the actions (selection)
// is not updated correctly.
getWorkbenchPart().getSite().getPage().activate(getWorkbenchPart());
} catch (Exception e) {
// ignore
}
}
use of org.knime.workbench.editor2.editparts.NodeContainerEditPart in project knime-core by knime.
the class ShowNodeIdsAction method runOnNodes.
/**
* {@inheritDoc}
*/
@Override
public synchronized void runOnNodes(final NodeContainerEditPart[] parts) {
ScrollingGraphicalViewer provider = (ScrollingGraphicalViewer) getEditor().getEditorSite().getSelectionProvider();
if (provider == null) {
return;
}
// get parent of the node parts
WorkflowRootEditPart editorPart = (WorkflowRootEditPart) provider.getRootEditPart().getChildren().get(0);
editorPart.changeShowNodeID();
for (NodeContainerEditPart edit : getAllParts(NodeContainerEditPart.class)) {
edit.updateHeaderField();
}
}
use of org.knime.workbench.editor2.editparts.NodeContainerEditPart in project knime-core by knime.
the class AbstractEditorAction method selectionChanged.
/**
* {@inheritDoc}
*/
@Override
public final void selectionChanged(final IAction action, final ISelection selection) {
if (m_decoratedAction != null) {
m_decoratedAction.dispose();
m_decoratedAction = null;
// and unregister from old selection
for (NodeContainerEditPart cont : m_currentSelection) {
cont.getNodeContainer().removeNodeStateChangeListener(this);
}
m_currentSelection.clear();
}
if (m_editor != null) {
m_decoratedAction = createAction(m_editor);
StructuredSelection sel = ((StructuredSelection) selection);
if (sel != null) {
// register to new selection
for (Iterator itr = sel.iterator(); itr.hasNext(); ) {
Object o = itr.next();
if (o instanceof NodeContainerEditPart) {
NodeContainerEditPart ncEP = (NodeContainerEditPart) o;
m_currentSelection.add(ncEP);
ncEP.getNodeContainer().addNodeStateChangeListener(this);
}
}
}
action.setEnabled(m_decoratedAction.isEnabled());
action.setChecked(m_decoratedAction.isChecked());
}
}
use of org.knime.workbench.editor2.editparts.NodeContainerEditPart in project knime-core by knime.
the class StepLoopAction method internalCalculateEnabled.
/**
* @return <code>true</code>, if just one loop end node part is selected
* which is executable and a loop is in progress.
*
* @see org.eclipse.gef.ui.actions.WorkbenchPartAction#calculateEnabled()
*/
@Override
protected boolean internalCalculateEnabled() {
NodeContainerEditPart[] parts = getSelectedParts(NodeContainerEditPart.class);
if (parts.length != 1) {
return false;
}
// enabled if the one selected node is a configured and "in progress"
// LoopEndNode
NodeContainerUI nc = parts[0].getNodeContainer();
if (Wrapper.wraps(nc, NativeNodeContainer.class)) {
NativeNodeContainer nnc = Wrapper.unwrap(nc, NativeNodeContainer.class);
if (nnc.isModelCompatibleTo(LoopEndNode.class) && nnc.getLoopStatus().equals(LoopStatus.PAUSED)) {
// either the node is paused...
return true;
}
WorkflowManager wm = getEditor().getWorkflowManager().get();
if (wm.canExecuteNodeDirectly(nc.getID())) {
// ...or we can execute it (then this will be the first step)
return true;
}
}
return false;
}
use of org.knime.workbench.editor2.editparts.NodeContainerEditPart in project knime-core by knime.
the class ToggleGridAction method runOnNodes.
/**
* {@inheritDoc}
*/
@Override
public void runOnNodes(final NodeContainerEditPart[] nodeParts) {
final WorkflowEditor editor = getEditor();
EditorUIInformation settings = editor.getCurrentEditorSettings();
EditorUIInformation newSet = EditorUIInformation.builder().setSnapToGrid(!settings.getSnapToGrid()).build();
editor.applyEditorSettings(newSet);
editor.markDirty();
}
Aggregations