Search in sources :

Example 1 with ScalableFreeformRootEditPart

use of org.eclipse.gef.editparts.ScalableFreeformRootEditPart 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 ScalableFreeformRootEditPart

use of org.eclipse.gef.editparts.ScalableFreeformRootEditPart in project cubrid-manager by CUBRID.

the class MonitorDashboardEditor method configureGraphicalViewer.

/**
	 * @see org.eclipse.gef.ui.parts.GraphicalEditor.configureGraphicalViewer
	 */
protected void configureGraphicalViewer() {
    super.configureGraphicalViewer();
    GraphicalViewer viewer = getGraphicalViewer();
    ScalableFreeformRootEditPart rootEditPart = new ScalableFreeformRootEditPart();
    viewer.setRootEditPart(rootEditPart);
    viewer.setEditPartFactory(new MonitorEditPartFacotry());
    ZoomManager manager = rootEditPart.getZoomManager();
    double[] zoomLevels = new double[] { 1.0, 1.2, 1.4, 1.6, 1.8, 2.0 };
    manager.setZoomLevels(zoomLevels);
    getActionRegistry().registerAction(new ZoomInAction(manager));
    getActionRegistry().registerAction(new ZoomOutAction(manager));
    KeyHandler keyHandler = new GefViewerKeyHandler(viewer);
    keyHandler.put(KeyStroke.getReleased('', 97, SWT.CONTROL), getActionRegistry().getAction(ActionFactory.SELECT_ALL.getId()));
    keyHandler.put(KeyStroke.getPressed('+', SWT.KEYPAD_ADD, 0), getActionRegistry().getAction(GEFActionConstants.ZOOM_IN));
    keyHandler.put(KeyStroke.getPressed('-', SWT.KEYPAD_SUBTRACT, 0), getActionRegistry().getAction(GEFActionConstants.ZOOM_OUT));
    viewer.setProperty(MouseWheelHandler.KeyGenerator.getKey(SWT.CTRL), MouseWheelZoomHandler.SINGLETON);
    viewer.setKeyHandler(keyHandler);
    //initialize context menu
    MenuManager menuManager = new MenuManager();
    menuManager.setRemoveAllWhenShown(true);
    menuManager.addMenuListener(new IMenuListener() {

        /**
			 * get menus to show.
			 * 
			 * @param manager IMenuManager
			 */
        public void menuAboutToShow(IMenuManager manager) {
            IStructuredSelection selection = (IStructuredSelection) getGraphicalViewer().getSelection();
            String[] ids = new String[] {};
            if (null == selection || selection.isEmpty() || selection.getFirstElement() instanceof DashboardPart) {
                manager.add(getActionRegistry().getAction(ActionFactory.SELECT_ALL.getId()));
                ids = new String[] { AddHostMonitorAction.ID, SEPARATOR, DashboardRefreshAction.ID };
            } else if (selection.getFirstElement() instanceof HostMonitorPart) {
                ids = new String[] { MonitorDetailAction.ID, DeleteHostMonitorAction.ID, EditAliasNameAction.ID, SEPARATOR, //HARoleChangeAction.ID, SEPARATOR,
                HostDashboardHistoryAction.ID, AddDatabaseMonitorAction.ID, AddBrokerMonitorAction.ID, SEPARATOR, HideHostAction.ID, MinimizeFigureAction.ID, DashboardRefreshAction.ID };
            } else if (selection.getFirstElement() instanceof DatabaseMonitorPart) {
                ids = new String[] { MonitorDetailAction.ID, DeleteDatabaseMonitorAction.ID, EditAliasNameAction.ID, SEPARATOR, DbDashboardHistoryAction.ID, OpenApplyLogDBLogAction.ID, OpenCopyLogDBLogAction.ID, OpenDatabaseLogAction.ID, SEPARATOR, ShowHostAction.ID, MinimizeFigureAction.ID, DashboardRefreshAction.ID };
            } else if (selection.getFirstElement() instanceof BrokerMonitorPart) {
                ids = new String[] { MonitorDetailAction.ID, DeleteBrokerMonitorAction.ID, EditAliasNameAction.ID, SEPARATOR, ShowBrokerClientAction.ID, ShowBrokerDabaseAction.ID, SEPARATOR, ShowHostAction.ID, MinimizeFigureAction.ID, DashboardRefreshAction.ID };
            } else if (selection.getFirstElement() instanceof ClientMonitorPart) {
                ids = new String[] { EditAliasNameAction.ID };
            } else if (selection.getFirstElement() instanceof BrokerDBListMonitorPart) {
                ids = new String[] { EditAliasNameAction.ID };
            }
            for (String id : ids) {
                if (id.equals(SEPARATOR)) {
                    manager.add(new Separator());
                } else {
                    IAction action = ActionManager.getInstance().getAction(id);
                    ((ISelectionAction) action).setSelectionProvider(getGraphicalViewer());
                    ActionManager.addActionToManager(manager, action);
                }
            }
            manager.update(true);
        }
    });
    viewer.setContextMenu(menuManager);
}
Also used : GraphicalViewer(org.eclipse.gef.GraphicalViewer) BrokerDBListMonitorPart(com.cubrid.cubridmanager.ui.mondashboard.editor.parts.BrokerDBListMonitorPart) IAction(org.eclipse.jface.action.IAction) ZoomOutAction(org.eclipse.gef.ui.actions.ZoomOutAction) BrokerMonitorPart(com.cubrid.cubridmanager.ui.mondashboard.editor.parts.BrokerMonitorPart) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) HostMonitorPart(com.cubrid.cubridmanager.ui.mondashboard.editor.parts.HostMonitorPart) IMenuListener(org.eclipse.jface.action.IMenuListener) ScalableFreeformRootEditPart(org.eclipse.gef.editparts.ScalableFreeformRootEditPart) ClientMonitorPart(com.cubrid.cubridmanager.ui.mondashboard.editor.parts.ClientMonitorPart) ZoomManager(org.eclipse.gef.editparts.ZoomManager) DashboardPart(com.cubrid.cubridmanager.ui.mondashboard.editor.parts.DashboardPart) MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) DatabaseMonitorPart(com.cubrid.cubridmanager.ui.mondashboard.editor.parts.DatabaseMonitorPart) MonitorEditPartFacotry(com.cubrid.cubridmanager.ui.mondashboard.editor.parts.MonitorEditPartFacotry) KeyHandler(org.eclipse.gef.KeyHandler) ZoomInAction(org.eclipse.gef.ui.actions.ZoomInAction) Separator(org.eclipse.jface.action.Separator)

Example 3 with ScalableFreeformRootEditPart

use of org.eclipse.gef.editparts.ScalableFreeformRootEditPart in project knime-core by knime.

the class WorkflowEditor method toRelative.

private Point toRelative(final Point absLoc) {
    ScalableFreeformRootEditPart rootEditPart = (ScalableFreeformRootEditPart) getViewer().getRootEditPart();
    Viewport viewport = (Viewport) rootEditPart.getFigure();
    Rectangle area = viewport.getClientArea();
    Point loc = absLoc.getCopy();
    double z = getZoomfactor();
    loc.x = (int) Math.round((loc.x - area.x) * z);
    loc.y = (int) Math.round((loc.y - area.y) * z);
    return loc;
}
Also used : ScalableFreeformRootEditPart(org.eclipse.gef.editparts.ScalableFreeformRootEditPart) Viewport(org.eclipse.draw2d.Viewport) Rectangle(org.eclipse.draw2d.geometry.Rectangle) Point(org.eclipse.draw2d.geometry.Point) PrecisionPoint(org.eclipse.draw2d.geometry.PrecisionPoint)

Example 4 with ScalableFreeformRootEditPart

use of org.eclipse.gef.editparts.ScalableFreeformRootEditPart in project knime-core by knime.

the class WorkflowEditor method toAbsolute.

private Point toAbsolute(final Point relLoc) {
    ScalableFreeformRootEditPart rootEditPart = (ScalableFreeformRootEditPart) getViewer().getRootEditPart();
    Viewport viewport = (Viewport) rootEditPart.getFigure();
    Rectangle area = viewport.getClientArea();
    Point loc = relLoc.getCopy();
    loc.x += area.x;
    loc.y += area.y;
    return loc;
}
Also used : ScalableFreeformRootEditPart(org.eclipse.gef.editparts.ScalableFreeformRootEditPart) Viewport(org.eclipse.draw2d.Viewport) Rectangle(org.eclipse.draw2d.geometry.Rectangle) Point(org.eclipse.draw2d.geometry.Point) PrecisionPoint(org.eclipse.draw2d.geometry.PrecisionPoint)

Example 5 with ScalableFreeformRootEditPart

use of org.eclipse.gef.editparts.ScalableFreeformRootEditPart in project dbeaver by dbeaver.

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(UIUtils.getColorRegistry().get(ERDConstants.COLOR_ERD_DIAGRAM_BACKGROUND));
    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)

Aggregations

ScalableFreeformRootEditPart (org.eclipse.gef.editparts.ScalableFreeformRootEditPart)25 Viewport (org.eclipse.draw2d.Viewport)6 Point (org.eclipse.draw2d.geometry.Point)6 Rectangle (org.eclipse.draw2d.geometry.Rectangle)6 RootEditPart (org.eclipse.gef.RootEditPart)6 GraphicalViewerKeyHandler (org.eclipse.gef.ui.parts.GraphicalViewerKeyHandler)5 ScrollingGraphicalViewer (org.eclipse.gef.ui.parts.ScrollingGraphicalViewer)5 ZoomManager (org.eclipse.gef.editparts.ZoomManager)4 IOException (java.io.IOException)3 ArrayList (java.util.ArrayList)3 EditPart (org.eclipse.gef.EditPart)3 ExtendedViewportAutoexposeHelper (com.archimatetool.editor.diagram.util.ExtendedViewportAutoexposeHelper)2 IPath (org.eclipse.core.runtime.IPath)2 IFigure (org.eclipse.draw2d.IFigure)2 Insets (org.eclipse.draw2d.geometry.Insets)2 PrecisionPoint (org.eclipse.draw2d.geometry.PrecisionPoint)2 ContextMenuProvider (org.eclipse.gef.ContextMenuProvider)2 GraphicalViewer (org.eclipse.gef.GraphicalViewer)2 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)2 SaveAsDialog (org.eclipse.ui.dialogs.SaveAsDialog)2