use of org.eclipse.gef.ui.parts.ScrollingGraphicalViewer in project tdi-studio-se by Talend.
the class ErdiagramDiagramEditor method configureGraphicalViewer.
//$NON-NLS-1$
@SuppressWarnings("unchecked")
protected void configureGraphicalViewer() {
super.configureGraphicalViewer();
ScrollingGraphicalViewer viewer = (ScrollingGraphicalViewer) getGraphicalViewer();
ErDiagramRootEditPart root = new ErDiagramRootEditPart();
IAction deleteAction = new ErDiagramItemDeleteAction(this);
getActionRegistry().registerAction(deleteAction);
getSelectionActions().add(deleteAction.getId());
viewer.setRootEditPart(root);
ErDiagramPartFactory partFactory = new ErDiagramPartFactory();
// set the factory to use for creating EditParts for elements in the
// model
getGraphicalViewer().setEditPartFactory(partFactory);
getGraphicalViewer().setKeyHandler(new GraphicalViewerKeyHandler(getGraphicalViewer()).setParent(getCommonKeyHandler()));
/** * Management of the context menu ** */
ContextMenuProvider cmProvider = new ErDiagramMenuProvider(this, viewer, getActionRegistry());
viewer.setContextMenu(cmProvider);
/** * Snap To Grid ** */
// Grid properties
getGraphicalViewer().setProperty(SnapToGrid.PROPERTY_GRID_SPACING, new Dimension(GRID_SIZE, GRID_SIZE));
getGraphicalViewer().setProperty(SnapToGrid.PROPERTY_GRID_ENABLED, new Boolean(true));
// We keep grid visibility and enablement in sync
getGraphicalViewer().setProperty(SnapToGrid.PROPERTY_GRID_VISIBLE, new Boolean(true));
IAction showGrid = new ToggleGridAction(getGraphicalViewer());
getActionRegistry().registerAction(showGrid);
/** * Snap To Geometry ** */
getGraphicalViewer().setProperty(SnapToGeometry.PROPERTY_SNAP_ENABLED, new Boolean(false));
IAction snapAction = new ToggleSnapToGeometryAction(getGraphicalViewer());
getActionRegistry().registerAction(snapAction);
}
use of org.eclipse.gef.ui.parts.ScrollingGraphicalViewer in project knime-core by knime.
the class AbstractNodeAction method getAllObjects.
/**
* @return all objects of the selected editor site.
*/
protected List getAllObjects() {
ScrollingGraphicalViewer provider = (ScrollingGraphicalViewer) m_editor.getEditorSite().getSelectionProvider();
if (provider == null) {
return Collections.EMPTY_LIST;
}
// get parent of the node parts
EditPart editorPart = (EditPart) provider.getRootEditPart().getChildren().get(0);
return editorPart.getChildren();
}
use of org.eclipse.gef.ui.parts.ScrollingGraphicalViewer in project knime-core by knime.
the class WorkflowGraphicalViewerCreator method createViewer.
/**
* Creates the viewer control, and connect it to a root edit part Additionally the viewer gets the edit part factory
* and a drop-listener.
*
* @param parent Parent composite
* @return The viewer
*/
protected GraphicalViewer createViewer(final Composite parent) {
ScrollingGraphicalViewer viewer = new ScrollingGraphicalViewer();
viewer.createControl(parent);
// configure the m_viewer
viewer.getControl().setBackground(ColorConstants.white);
ScalableFreeformRootEditPart part = new ConnectionSelectingScalableFreeformRootEditPart();
viewer.setRootEditPart(part);
viewer.setKeyHandler(new GraphicalViewerKeyHandler(viewer));
// Add drop listeners
viewer.addDropTargetListener(new NodeDropTargetListener(viewer));
viewer.addDropTargetListener(new MetaNodeDropTargetListener(viewer));
viewer.addDropTargetListener(new WorkflowEditorFileDropTargetListener(viewer));
viewer.addDropTargetListener(new WorkflowEditorSelectionDropListener(viewer));
// DO NOT Add drag listener
/* Don't add any drag listener here. Processing of drag events seems
* to influence GEF events (resize, node move, create connection).
* See bug 2844 for details (linux only) */
MetaNodeTemplateDropTargetListener metaNodeTemplateDropListener = new MetaNodeTemplateDropTargetListener(viewer);
viewer.addDropTargetListener(metaNodeTemplateDropListener);
// configure context menu
viewer.setContextMenu(new WorkflowContextMenuProvider(m_actionRegistry, viewer));
m_editorSite.registerContextMenu(viewer.getContextMenu(), viewer, false);
// set the factory that is able to create the edit parts to be
// used in the viewer
viewer.setEditPartFactory(new WorkflowEditPartFactory());
return viewer;
}
use of org.eclipse.gef.ui.parts.ScrollingGraphicalViewer in project knime-core by knime.
the class AutoLayoutAction method runOnNodes.
/**
* {@inheritDoc}
*/
@Override
public synchronized void runOnNodes(final NodeContainerEditPart[] parts) {
ScrollingGraphicalViewer provider = (ScrollingGraphicalViewer) getEditor().getEditorSite().getSelectionProvider();
if (provider == null) {
return;
}
ArrayList<NodeContainerUI> nodes = null;
if (parts != null && parts.length > 0) {
nodes = new ArrayList<NodeContainerUI>(parts.length);
for (NodeContainerEditPart p : parts) {
nodes.add(p.getNodeContainer());
}
}
AutoLayoutCommand alc = new AutoLayoutCommand(getManager(), nodes);
// enables undo
getCommandStack().execute(alc);
// update the actions
getEditor().updateActions();
// Give focus to the editor again. Otherwise the actions (selection)
// is not updated correctly.
getWorkbenchPart().getSite().getPage().activate(getWorkbenchPart());
}
use of org.eclipse.gef.ui.parts.ScrollingGraphicalViewer in project webtools.sourceediting by eclipse.
the class RootEditPart method activate.
public void activate() {
super.activate();
// Set up Connection layer with a router, if it doesn't already have one
ConnectionLayer connectionLayer = (ConnectionLayer) getLayer(LayerConstants.CONNECTION_LAYER);
if (connectionLayer != null) {
connectionLayer.setConnectionRouter(new BendpointConnectionRouter());
}
Figure figure = (Figure) getLayer(LayerConstants.FEEDBACK_LAYER);
if (figure != null) {
if (getViewer() instanceof ScrollingGraphicalViewer) {
// ScrollingGraphicalViewer sgv = (ScrollingGraphicalViewer)getViewer();
// IndexFigure indexFigure = new IndexFigure(sgv);
// figure.add(indexFigure);
// getViewer().addPropertyChangeListener(indexFigure);
}
}
refresh();
}
Aggregations