use of org.knime.core.ui.node.workflow.WorkflowManagerUI in project knime-core by knime.
the class WorkflowEditorDropTargetListener method dragOver.
/**
* {@inheritDoc}
*
* Marks nodes or edges if a new node should replace an old node or should be inserted on an edge.
*/
@Override
public void dragOver(final DropTargetEvent event) {
WorkflowManagerUI wfm = ((WorkflowRootEditPart) getViewer().getRootEditPart().getContents()).getWorkflowManager();
m_node = null;
m_edge = null;
m_nodeCount = 0;
m_edgeCount = 0;
// edge-/nodedist
double edgedist = Integer.MAX_VALUE;
double nodedist = Integer.MAX_VALUE;
Point dropLocation = getDropLocation(event);
EditPart ep = getViewer().findObjectAt(dropLocation.getTranslated(0, 0));
if (ep instanceof NodeContainerEditPart) {
double temp = dropLocation.getDistance(dropLocation.getTranslated(0, 0));
// choose nearest node to mouse position
if (nodedist >= temp) {
m_node = (NodeContainerEditPart) ep;
nodedist = temp;
}
m_nodeCount++;
} else if (ep instanceof ConnectionContainerEditPart) {
double temp = dropLocation.getDistance(dropLocation.getTranslated(0, 0));
// choose nearest edge to mouse-position
if (edgedist >= temp) {
m_edge = (ConnectionContainerEditPart) ep;
edgedist = temp;
}
m_edgeCount++;
}
unmark(wfm);
if (m_node != null && m_nodeCount >= m_edgeCount) {
m_markedNode = m_node;
m_markedNode.mark();
// workaround for eclipse bug 393868 (https://bugs.eclipse.org/bugs/show_bug.cgi?id=393868)
WindowsDNDHelper.hideDragImage();
} else if (m_edge != null) {
m_edgeColor = m_edge.getFigure().getForegroundColor();
m_edgeWidth = ((ProgressPolylineConnection) m_edge.getFigure()).getLineWidth();
m_markedEdge = m_edge;
((ProgressPolylineConnection) m_markedEdge.getFigure()).setLineWidth(m_edgeWidth + 3);
m_markedEdge.getFigure().setForegroundColor(RED);
// workaround for eclipse bug 393868 (https://bugs.eclipse.org/bugs/show_bug.cgi?id=393868)
WindowsDNDHelper.hideDragImage();
}
}
use of org.knime.core.ui.node.workflow.WorkflowManagerUI in project knime-core by knime.
the class WorkflowOutPortBarEditPart method getModelChildren.
/**
* {@inheritDoc}
*/
@Override
protected List<NodePortUI> getModelChildren() {
WorkflowManagerUI manager = ((WorkflowPortBar) getModel()).getWorkflowManager();
List<NodePortUI> ports = new ArrayList<NodePortUI>();
for (int i = 0; i < manager.getNrWorkflowOutgoingPorts(); i++) {
ports.add(manager.getOutPort(i));
}
return ports;
}
use of org.knime.core.ui.node.workflow.WorkflowManagerUI in project knime-core by knime.
the class WorkflowRootEditPart method getModelChildren.
/**
* Returns the model chidlren, that is, the <code>NodeConatiner</code>s that
* are stored in the workflow manager.
*
* {@inheritDoc}
*/
@Override
@SuppressWarnings("unchecked")
protected List getModelChildren() {
List modelChildren = new ArrayList();
WorkflowManagerUI wfm = getWorkflowManager();
// Add them first so they appear behind everything else
for (Annotation anno : wfm.getWorkflowAnnotations()) {
modelChildren.add(anno);
}
// workflow annotations so they appear above them)
for (NodeAnnotation nodeAnno : wfm.getNodeAnnotations()) {
modelChildren.add(nodeAnno);
}
modelChildren.addAll(wfm.getNodeContainers());
if (wfm.getNrWorkflowIncomingPorts() > 0) {
if (m_inBar == null) {
m_inBar = new WorkflowPortBar(wfm, true);
NodeUIInformation uiInfo = wfm.getInPortsBarUIInfo();
if (uiInfo != null) {
m_inBar.setUIInfo(wfm.getInPortsBarUIInfo());
}
}
modelChildren.add(m_inBar);
}
if (wfm.getNrWorkflowOutgoingPorts() > 0) {
if (m_outBar == null) {
m_outBar = new WorkflowPortBar(wfm, false);
NodeUIInformation uiInfo = wfm.getOutPortsBarUIInfo();
if (uiInfo != null) {
m_outBar.setUIInfo(wfm.getOutPortsBarUIInfo());
}
}
modelChildren.add(m_outBar);
}
return modelChildren;
}
use of org.knime.core.ui.node.workflow.WorkflowManagerUI in project knime-core by knime.
the class LockMetaNodeAction method internalCalculateEnabled.
/**
* @return true, if underlying model instance of
* <code>WorkflowManager</code>, otherwise false
*/
@Override
protected boolean internalCalculateEnabled() {
if (getManager().isWriteProtected()) {
return false;
}
NodeContainerEditPart[] nodes = getSelectedParts(NodeContainerEditPart.class);
if (nodes.length != 1) {
return false;
}
Object model = nodes[0].getModel();
if (model instanceof WorkflowManagerUI) {
WorkflowManagerUI metaNode = (WorkflowManagerUI) model;
if (metaNode.isWriteProtected()) {
return false;
}
return true;
} else {
return false;
}
}
use of org.knime.core.ui.node.workflow.WorkflowManagerUI in project knime-core by knime.
the class KnimeResourceContentProvider method getChildren.
/**
* {@inheritDoc}
*/
@Override
public Object[] getChildren(final Object element) {
if (element instanceof IFile) {
return EMPTY_ARRAY;
}
if (isKNIMEWorkflow(element)) {
IContainer project = (IContainer) element;
NodeContainerUI workflow = ProjectWorkflowMap.getWorkflowUI(project.getLocationURI());
if (workflow != null) {
// the number of contained nodes is returned
return getSortedNodeContainers(((WorkflowManagerUI) workflow).getNodeContainers());
}
} else if (element instanceof WorkflowManager) {
return getSortedNodeContainers(((WorkflowManagerUI) element).getNodeContainers());
}
return getFolders(element);
}
Aggregations