use of org.knime.workbench.editor2.editparts.WorkflowRootEditPart in project knime-core by knime.
the class WorkflowEditor method createGraphicalViewer.
/**
* Creates the graphical viewer that is hosted in this editor and hooks
* keyhandler and edit domain.
*
* @see org.eclipse.gef.ui.parts.GraphicalEditor
* #createGraphicalViewer(org.eclipse.swt.widgets.Composite)
* @param parent The parent
*/
@Override
protected void createGraphicalViewer(final Composite parent) {
IEditorSite editorSite = getEditorSite();
GraphicalViewer viewer = new WorkflowGraphicalViewerCreator(editorSite, this.getActionRegistry()).createViewer(parent);
// Add a listener to the static node provider
NodeProvider.INSTANCE.addListener(this);
// Configure the key handler
GraphicalViewerKeyHandler keyHandler = new GraphicalViewerKeyHandler(viewer);
KeyHandler parentKeyHandler = keyHandler.setParent(getCommonKeyHandler());
viewer.setKeyHandler(parentKeyHandler);
// hook the viewer into the EditDomain
getEditDomain().addViewer(viewer);
// activate the viewer as selection provider for Eclipse
getSite().setSelectionProvider(viewer);
// remember this viewer
m_graphicalViewer = viewer;
// load properties like grid- or node-connections settings (e.g. width, curved)
// needs to be called before getGraphicalViewer().setContents(m_manager), since
// the node connections are repainted on that setContents-call and the properties need
// to be set by then
loadProperties();
// We already have the model - set it into the viewer
getGraphicalViewer().setContents(m_manager);
// add Help context
WorkbenchHelpSystem.getInstance().setHelp(m_graphicalViewer.getControl(), "org.knime.workbench.help.flow_editor_context");
updateEditorBackgroundColor();
updateJobManagerDisplay();
updateTempRemoteWorkflowMessage();
RootEditPart rep = getGraphicalViewer().getRootEditPart();
((WorkflowRootEditPart) rep.getChildren().get(0)).createToolTipHelper(getSite().getShell());
ZoomManager zm = this.getZoomManager();
zm.setZoomLevels(ZOOM_LEVELS);
m_zoomWheelListener = new ZoomWheelListener(zm, (FigureCanvas) getViewer().getControl());
}
use of org.knime.workbench.editor2.editparts.WorkflowRootEditPart in project knime-core by knime.
the class WorkflowEditor method updateJobManagerDisplay.
private void updateJobManagerDisplay() {
NodeExecutionJobManager jobManager = m_manager.findJobManager();
URL url;
if (jobManager instanceof AbstractNodeExecutionJobManager) {
url = ((AbstractNodeExecutionJobManager) jobManager).getIconForWorkflow();
} else {
url = null;
}
Image image;
if (url != null) {
image = ImageRepository.getUnscaledImage(url);
} else {
image = null;
}
WorkflowFigure workflowFigure = ((WorkflowRootEditPart) getViewer().getRootEditPart().getContents()).getFigure();
workflowFigure.setJobManagerFigure(image);
}
use of org.knime.workbench.editor2.editparts.WorkflowRootEditPart in project knime-core by knime.
the class WorkflowEditor method updateTempRemoteWorkflowMessage.
/**
* Places the message at the top of the editor - above all other contents.
*/
private void updateTempRemoteWorkflowMessage() {
WorkflowFigure workflowFigure = ((WorkflowRootEditPart) getViewer().getRootEditPart().getContents()).getFigure();
if (isTempRemoteWorkflowEditor()) {
URI origRemoteLocation = m_origRemoteLocation;
WorkflowEditor parentEditor = m_parentEditor;
while (origRemoteLocation == null && parentEditor != null) {
origRemoteLocation = parentEditor.m_origRemoteLocation;
parentEditor = parentEditor.m_parentEditor;
}
workflowFigure.setMessage(" This is a temporary copy of \"" + URIUtil.toDecodedString(origRemoteLocation) + "\".\n Use \"Save\" to upload it back to its original location on the server or \"Save As...\" to " + "store it in a different location.");
} else if (!getWorkflowManager().isPresent()) {
workflowFigure.setMessage("This is a remotely opened job workflow. It can neither be stored locally nor edited." + " It also just represents a static snapshot of the job workflow and won't get" + " updated automatically (use context menu to refresh).");
} else {
workflowFigure.setMessage(null);
}
List<IEditorPart> subEditors = getSubEditors();
for (IEditorPart ep : subEditors) {
if (ep instanceof WorkflowEditor) {
((WorkflowEditor) ep).updateTempRemoteWorkflowMessage();
}
}
}
use of org.knime.workbench.editor2.editparts.WorkflowRootEditPart 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.workbench.editor2.editparts.WorkflowRootEditPart in project knime-core by knime.
the class AnnotationEditPart method performEdit.
/**
* Opens the editor to directoy edit the annotation in place.
*/
public void performEdit() {
final EditPart parent = getParent();
if (parent instanceof WorkflowRootEditPart) {
WorkflowRootEditPart wkfRootEdit = (WorkflowRootEditPart) parent;
if (wkfRootEdit.getWorkflowManager().isWriteProtected()) {
return;
}
}
if (m_directEditManager == null) {
m_directEditManager = new AnnotationEditManager(this, new StyledTextEditorLocator((NodeAnnotationFigure) getFigure()));
}
m_directEditManager.show();
}
Aggregations