Search in sources :

Example 1 with ScalableRootEditPart

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

the class ReplicationEditor method configureGraphicalViewer.

/**
	 * @see org.eclipse.gef.ui.parts.GraphicalEditor#configureGraphicalViewer()
	 */
protected void configureGraphicalViewer() {
    super.configureGraphicalViewer();
    GraphicalViewer viewer = getGraphicalViewer();
    ScalableRootEditPart rootEditPart = new ScalableRootEditPart();
    viewer.setRootEditPart(rootEditPart);
    viewer.setEditPartFactory(new PartFactory(this));
    ZoomManager manager = rootEditPart.getZoomManager();
    getActionRegistry().registerAction(new ZoomInAction(manager));
    getActionRegistry().registerAction(new ZoomOutAction(manager));
    double[] zoomLevels = new double[] { 0.25, 0.5, 0.75, 1.0, 1.5, 2.0, 2.5, 3.0, 4.0, 5.0, 10.0, 20.0 };
    manager.setZoomLevels(zoomLevels);
    List<String> zoomContributions = new ArrayList<String>();
    zoomContributions.add(ZoomManager.FIT_ALL);
    zoomContributions.add(ZoomManager.FIT_HEIGHT);
    zoomContributions.add(ZoomManager.FIT_WIDTH);
    manager.setZoomLevelContributions(zoomContributions);
    KeyHandler keyHandler = new KeyHandler();
    if (isEditable) {
        keyHandler.put(KeyStroke.getPressed(SWT.DEL, 127, 0), getActionRegistry().getAction(ActionFactory.DELETE.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));
    keyHandler.put(KeyStroke.getPressed('a', 97, 0), getActionRegistry().getAction(ActionFactory.SELECT_ALL.getId()));
    viewer.setProperty(MouseWheelHandler.KeyGenerator.getKey(SWT.NONE), MouseWheelZoomHandler.SINGLETON);
    viewer.setKeyHandler(keyHandler);
    ContextMenuProvider provider = new ReplEditorContextMenuProvider(viewer, getActionRegistry());
    viewer.setContextMenu(provider);
}
Also used : GraphicalViewer(org.eclipse.gef.GraphicalViewer) ZoomOutAction(org.eclipse.gef.ui.actions.ZoomOutAction) PartFactory(com.cubrid.cubridmanager.ui.replication.editor.parts.PartFactory) ScalableRootEditPart(org.eclipse.gef.editparts.ScalableRootEditPart) ArrayList(java.util.ArrayList) ContextMenuProvider(org.eclipse.gef.ContextMenuProvider) ZoomManager(org.eclipse.gef.editparts.ZoomManager) KeyHandler(org.eclipse.gef.KeyHandler) ZoomInAction(org.eclipse.gef.ui.actions.ZoomInAction)

Aggregations

PartFactory (com.cubrid.cubridmanager.ui.replication.editor.parts.PartFactory)1 ArrayList (java.util.ArrayList)1 ContextMenuProvider (org.eclipse.gef.ContextMenuProvider)1 GraphicalViewer (org.eclipse.gef.GraphicalViewer)1 KeyHandler (org.eclipse.gef.KeyHandler)1 ScalableRootEditPart (org.eclipse.gef.editparts.ScalableRootEditPart)1 ZoomManager (org.eclipse.gef.editparts.ZoomManager)1 ZoomInAction (org.eclipse.gef.ui.actions.ZoomInAction)1 ZoomOutAction (org.eclipse.gef.ui.actions.ZoomOutAction)1