use of org.eclipse.gef.ui.parts.GraphicalViewerKeyHandler in project dbeaver by serge-rider.
the class ERDEditorPart method createViewer.
private GraphicalViewer createViewer(Composite parent) {
StatusLineValidationMessageHandler validationMessageHandler = new StatusLineValidationMessageHandler(getEditorSite());
GraphicalViewer viewer = new ERDGraphicalViewer(this, validationMessageHandler);
viewer.createControl(parent);
// configure the viewer
viewer.getControl().setBackground(ColorConstants.white);
rootPart = new ScalableFreeformRootEditPart();
viewer.setRootEditPart(rootPart);
viewer.setKeyHandler(new GraphicalViewerKeyHandler(viewer));
viewer.addDropTargetListener(new DataEditDropTargetListener(viewer));
viewer.addDropTargetListener(new NodeDropTargetListener(viewer));
// initialize the viewer with input
viewer.setEditPartFactory(new ERDEditPartFactory());
return viewer;
}
use of org.eclipse.gef.ui.parts.GraphicalViewerKeyHandler in project cubrid-manager by CUBRID.
the class ERSchemaEditor method createGraphicalViewer.
private ScrollingGraphicalViewer createGraphicalViewer(IEditorSite editorSite, Composite parent) {
StatusLineValidationMessageHandler messageHandler = new StatusLineValidationMessageHandler(editorSite);
ScrollingGraphicalViewer viewer = new ValidationGraphicalViewer(messageHandler);
viewer.createControl(parent);
viewer.getControl().setBackground(ColorConstants.white);
viewer.setRootEditPart(new ERScalableFreeformRootEditPart());
viewer.setEditPartFactory(new PartFactory());
viewer.setKeyHandler(new GraphicalViewerKeyHandler(viewer));
viewer.setProperty(SnapToGrid.PROPERTY_GRID_VISIBLE, true);
viewer.setProperty(SnapToGrid.PROPERTY_GRID_ENABLED, true);
viewer.setProperty(SnapToGrid.PROPERTY_GRID_SPACING, new Dimension(10, 10));
viewer.setProperty(SnapToGrid.PROPERTY_GRID_ORIGIN, new Point(5, 5));
return viewer;
}
use of org.eclipse.gef.ui.parts.GraphicalViewerKeyHandler in project cubrid-manager by CUBRID.
the class ERSchemaEditor method createGraphicalViewer.
/**
* Creates a new <code>GraphicalViewer</code>, configures, registers and
* initializes it.
*
* @param parent the parent composite
* @return a new <code>GraphicalViewer</code>
*/
protected void createGraphicalViewer(Composite parent) {
IEditorSite editorSite = getEditorSite();
ScrollingGraphicalViewer viewer = createGraphicalViewer(editorSite, parent);
ScalableFreeformRootEditPart rootEditPart = (ScalableFreeformRootEditPart) viewer.getRootEditPart();
zoomManager = rootEditPart.getZoomManager();
zoomManager.setZoomLevels(ZOOM_LEVELS);
// hook the viewer into the EditDomain
getEditDomain().addViewer(viewer);
// acticate the viewer as selection provider for Eclipse
getSite().setSelectionProvider(viewer);
viewer.setContents(erSchema);
ContextMenuProvider provider = new SchemaContextMenuProvider(viewer, getActionRegistry());
viewer.setContextMenu(provider);
getSite().registerContextMenu(provider.getId(), provider, viewer);
graphicalViewer = viewer;
// key handler
GraphicalViewerKeyHandler graphicalViewerKeyHandler = new GraphicalViewerKeyHandler(viewer);
KeyHandler parentKeyHandler = graphicalViewerKeyHandler.setParent(getCommonKeyHandler());
viewer.setKeyHandler(parentKeyHandler);
registDropTarget();
}
use of org.eclipse.gef.ui.parts.GraphicalViewerKeyHandler 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);
}
Aggregations