Search in sources :

Example 1 with GraphicalViewerKeyHandler

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;
}
Also used : DataEditDropTargetListener(org.jkiss.dbeaver.ext.erd.dnd.DataEditDropTargetListener) StatusLineValidationMessageHandler(org.jkiss.dbeaver.ext.erd.directedit.StatusLineValidationMessageHandler) NodeDropTargetListener(org.jkiss.dbeaver.ext.erd.dnd.NodeDropTargetListener) ScalableFreeformRootEditPart(org.eclipse.gef.editparts.ScalableFreeformRootEditPart) GraphicalViewerKeyHandler(org.eclipse.gef.ui.parts.GraphicalViewerKeyHandler)

Example 2 with GraphicalViewerKeyHandler

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;
}
Also used : ScrollingGraphicalViewer(org.eclipse.gef.ui.parts.ScrollingGraphicalViewer) ValidationGraphicalViewer(com.cubrid.common.ui.er.ValidationGraphicalViewer) StatusLineValidationMessageHandler(com.cubrid.common.ui.er.directedit.StatusLineValidationMessageHandler) PartFactory(com.cubrid.common.ui.er.part.PartFactory) GraphicalViewerKeyHandler(org.eclipse.gef.ui.parts.GraphicalViewerKeyHandler) Dimension(org.eclipse.draw2d.geometry.Dimension) Point(org.eclipse.draw2d.geometry.Point)

Example 3 with GraphicalViewerKeyHandler

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();
}
Also used : ScrollingGraphicalViewer(org.eclipse.gef.ui.parts.ScrollingGraphicalViewer) ScalableFreeformRootEditPart(org.eclipse.gef.editparts.ScalableFreeformRootEditPart) GraphicalViewerKeyHandler(org.eclipse.gef.ui.parts.GraphicalViewerKeyHandler) GraphicalViewerKeyHandler(org.eclipse.gef.ui.parts.GraphicalViewerKeyHandler) KeyHandler(org.eclipse.gef.KeyHandler) IEditorSite(org.eclipse.ui.IEditorSite) ContextMenuProvider(org.eclipse.gef.ContextMenuProvider) SchemaContextMenuProvider(com.cubrid.common.ui.er.SchemaContextMenuProvider) SchemaContextMenuProvider(com.cubrid.common.ui.er.SchemaContextMenuProvider)

Example 4 with GraphicalViewerKeyHandler

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);
}
Also used : ScrollingGraphicalViewer(org.eclipse.gef.ui.parts.ScrollingGraphicalViewer) ToggleSnapToGeometryAction(org.eclipse.gef.ui.actions.ToggleSnapToGeometryAction) IAction(org.eclipse.jface.action.IAction) ErDiagramItemDeleteAction(org.talend.sqlbuilder.erdiagram.ui.actions.ErDiagramItemDeleteAction) ToggleGridAction(org.eclipse.gef.ui.actions.ToggleGridAction) GraphicalViewerKeyHandler(org.eclipse.gef.ui.parts.GraphicalViewerKeyHandler) Dimension(org.eclipse.draw2d.geometry.Dimension) ContextMenuProvider(org.eclipse.gef.ContextMenuProvider)

Aggregations

GraphicalViewerKeyHandler (org.eclipse.gef.ui.parts.GraphicalViewerKeyHandler)4 ScrollingGraphicalViewer (org.eclipse.gef.ui.parts.ScrollingGraphicalViewer)3 Dimension (org.eclipse.draw2d.geometry.Dimension)2 ContextMenuProvider (org.eclipse.gef.ContextMenuProvider)2 ScalableFreeformRootEditPart (org.eclipse.gef.editparts.ScalableFreeformRootEditPart)2 SchemaContextMenuProvider (com.cubrid.common.ui.er.SchemaContextMenuProvider)1 ValidationGraphicalViewer (com.cubrid.common.ui.er.ValidationGraphicalViewer)1 StatusLineValidationMessageHandler (com.cubrid.common.ui.er.directedit.StatusLineValidationMessageHandler)1 PartFactory (com.cubrid.common.ui.er.part.PartFactory)1 Point (org.eclipse.draw2d.geometry.Point)1 KeyHandler (org.eclipse.gef.KeyHandler)1 ToggleGridAction (org.eclipse.gef.ui.actions.ToggleGridAction)1 ToggleSnapToGeometryAction (org.eclipse.gef.ui.actions.ToggleSnapToGeometryAction)1 IAction (org.eclipse.jface.action.IAction)1 IEditorSite (org.eclipse.ui.IEditorSite)1 StatusLineValidationMessageHandler (org.jkiss.dbeaver.ext.erd.directedit.StatusLineValidationMessageHandler)1 DataEditDropTargetListener (org.jkiss.dbeaver.ext.erd.dnd.DataEditDropTargetListener)1 NodeDropTargetListener (org.jkiss.dbeaver.ext.erd.dnd.NodeDropTargetListener)1 ErDiagramItemDeleteAction (org.talend.sqlbuilder.erdiagram.ui.actions.ErDiagramItemDeleteAction)1