use of com.cubrid.cubridmanager.ui.replication.editor.parts.PartFactory 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);
}
Aggregations