use of org.knime.workbench.editor2.editparts.NodeContainerEditPart in project knime-core by knime.
the class ResetAction method internalCalculateEnabled.
/**
* @return <code>true</code> if at least one node is resetable
* @see org.eclipse.gef.ui.actions.WorkbenchPartAction#calculateEnabled()
*/
@Override
protected boolean internalCalculateEnabled() {
NodeContainerEditPart[] parts = getSelectedParts(NodeContainerEditPart.class);
for (int i = 0; i < parts.length; i++) {
NodeContainerEditPart part = parts[i];
NodeContainerUI nc = part.getNodeContainer();
if (getManager().canResetNode(nc.getID())) {
return true;
}
}
return false;
}
use of org.knime.workbench.editor2.editparts.NodeContainerEditPart in project knime-core by knime.
the class OpenFirstOutPortViewAction method runOnNodes.
/**
* This opens the first view of all the selected nodes.
*
* {@inheritDoc}
*/
@Override
public void runOnNodes(final NodeContainerEditPart[] nodeParts) {
LOGGER.debug("Creating open first out-port view job for " + nodeParts.length + " node(s)...");
for (NodeContainerEditPart p : nodeParts) {
final NodeContainerUI cont = p.getNodeContainer();
final java.awt.Rectangle knimeWindowBounds = OpenViewAction.getAppBoundsAsAWTRec();
// first port is flow var port
final OptionalInt portIndex = getPortIndex(cont);
if (portIndex.isPresent()) {
SwingUtilities.invokeLater(new Runnable() {
/**
* {inheritDoc}
*/
@Override
public void run() {
NodeOutPort port = Wrapper.unwrapNC(cont).getOutPort(portIndex.getAsInt());
LOGGER.debug("Open First Out-Port View " + cont.getName() + " on port " + port.getPortName());
port.openPortView(port.getPortName(), knimeWindowBounds);
}
});
}
}
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 PauseLoopExecutionAction method internalCalculateEnabled.
/**
* @return <code>true</code>, if just one loop end node part is selected
* which is executing.
*
* @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 an executing LoopEndNode
NodeContainerUI nc = parts[0].getNodeContainer();
if (Wrapper.wraps(nc, SingleNodeContainer.class)) {
SingleNodeContainer snc = Wrapper.unwrap(nc, SingleNodeContainer.class);
if ((snc.isModelCompatibleTo(LoopEndNode.class)) && (nc.getNodeContainerState().isExecutionInProgress())) {
return true;
}
}
return false;
}
use of org.knime.workbench.editor2.editparts.NodeContainerEditPart in project knime-core by knime.
the class ResumeLoopAction method runOnNodes.
/**
* Resume paused loop.
*
* {@inheritDoc}
*/
@Override
public void runOnNodes(final NodeContainerEditPart[] nodeParts) {
LOGGER.debug("Creating 'Resume Loop Execution' job for " + nodeParts.length + " node(s)...");
WorkflowManager manager = getManager();
for (NodeContainerEditPart p : nodeParts) {
NodeContainerUI nc = p.getNodeContainer();
if (Wrapper.wraps(nc, NativeNodeContainer.class)) {
NativeNodeContainer nnc = Wrapper.unwrap(nc, NativeNodeContainer.class);
if (nnc.isModelCompatibleTo(LoopEndNode.class) && nnc.getLoopStatus().equals(LoopStatus.PAUSED)) {
manager.resumeLoopExecution(nnc, /*oneStep=*/
false);
}
}
}
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 RevealSubNodeTemplateAction method runOnNodes.
/**
* {@inheritDoc}
*/
@Override
public void runOnNodes(final NodeContainerEditPart[] nodes) {
List<NodeID> candidateList = new ArrayList<NodeID>();
List<AbstractExplorerFileStore> templates = new ArrayList<AbstractExplorerFileStore>();
for (NodeContainerEditPart p : nodes) {
Object model = p.getModel();
if (wraps(model, SubNodeContainer.class)) {
NodeContext.pushContext(Wrapper.unwrapNC(p.getNodeContainer()));
try {
SubNodeContainer snc = unwrap((UI) model, SubNodeContainer.class);
MetaNodeTemplateInformation i = snc.getTemplateInformation();
if (Role.Link.equals(i.getRole())) {
candidateList.add(snc.getID());
AbstractExplorerFileStore template = ExplorerFileSystem.INSTANCE.getStore(i.getSourceURI());
if (template != null) {
templates.add(template);
}
}
} finally {
NodeContext.removeLastContext();
}
}
}
List<Object> treeObjects = ContentDelegator.getTreeObjectList(templates);
if (treeObjects != null && treeObjects.size() > 0) {
IViewReference[] views = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getViewReferences();
for (IViewReference view : views) {
if (ExplorerView.ID.equals(view.getId())) {
ExplorerView explorerView = (ExplorerView) view.getView(true);
explorerView.getViewer().setSelection(new StructuredSelection(treeObjects), true);
}
}
}
}
Aggregations