use of org.eclipse.gef.ui.actions.ZoomOutAction in project tdi-studio-se by Talend.
the class AbstractTalendEditor method configureGraphicalViewer.
@Override
protected void configureGraphicalViewer() {
super.configureGraphicalViewer();
/** * Manage the view in the Outline ** */
ScrollingGraphicalViewer viewer = (ScrollingGraphicalViewer) getGraphicalViewer();
viewer.setSelectionManager(new TalendSelectionManager());
TalendScalableFreeformRootEditPart root = new TalendScalableFreeformRootEditPart(getEditorInput());
List<String> zoomLevels = new ArrayList<String>();
zoomLevels.add(ZoomManager.FIT_ALL);
zoomLevels.add(ZoomManager.FIT_WIDTH);
zoomLevels.add(ZoomManager.FIT_HEIGHT);
root.getZoomManager().setZoomLevelContributions(zoomLevels);
// root.getZoomManager().setZoomAnimationStyle(ZoomManager.ANIMATE_NEVER);
IAction zoomIn = new ZoomInAction(root.getZoomManager());
IAction zoomOut = new ZoomOutAction(root.getZoomManager());
getActionRegistry().registerAction(zoomIn);
getActionRegistry().registerAction(zoomOut);
IHandlerService service = (IHandlerService) getEditorSite().getService(IHandlerService.class);
service.activateHandler(zoomIn.getActionDefinitionId(), new ActionHandler(zoomIn));
service.activateHandler(zoomOut.getActionDefinitionId(), new ActionHandler(zoomOut));
IAction directEditAction = new DirectEditAction(this);
getActionRegistry().registerAction(directEditAction);
getSelectionActions().add(directEditAction.getId());
IAction copyAction = new GEFCopyAction(this);
getActionRegistry().registerAction(copyAction);
getSelectionActions().add(copyAction.getId());
// setAction(copyAction.getId(), copyAction);
IAction pasteAction = new GEFPasteAction(this);
getActionRegistry().registerAction(pasteAction);
getSelectionActions().add(pasteAction.getId());
// setAction(pasteAction.getId(), pasteAction);
IAction deleteAction = new GEFDeleteAction(this);
getActionRegistry().registerAction(deleteAction);
getSelectionActions().add(deleteAction.getId());
// setAction(deleteAction.getId(), deleteAction);
IAction undoAction = new GEFUndoAction(this);
getActionRegistry().registerAction(undoAction);
getSelectionActions().add(undoAction.getId());
IAction redoAction = new GEFRedoAction(this);
getActionRegistry().registerAction(redoAction);
getSelectionActions().add(redoAction.getId());
IAction setRefAction = new ConnectionSetAsMainRef(this);
getActionRegistry().registerAction(setRefAction);
getSelectionActions().add(setRefAction.getId());
IAction modifyMergeAction = new ModifyMergeOrderAction(this);
getActionRegistry().registerAction(modifyMergeAction);
getSelectionActions().add(modifyMergeAction.getId());
IAction modifyOutputOrderAction = new ModifyOutputOrderAction(this);
getActionRegistry().registerAction(modifyOutputOrderAction);
getSelectionActions().add(modifyOutputOrderAction.getId());
List<IAction> calcOrderActions = ModifyConnectionOrderAction.getOrderActions(this);
for (IAction orderAction : calcOrderActions) {
getActionRegistry().registerAction(orderAction);
getSelectionActions().add(orderAction.getId());
}
viewer.setRootEditPart(root);
PartFactory partFactory = new PartFactory();
// set the factory to use for creating EditParts for elements in the model
getGraphicalViewer().setEditPartFactory(partFactory);
getGraphicalViewer().setKeyHandler(new NodePartKeyHander(getGraphicalViewer()).setParent(getCommonKeyHandler()));
// GraphicalViewer graViewer = getGraphicalViewer();
// graViewer.setKeyHandler(new GraphicalViewerKeyHandler(graViewer));
initializeActivationCodeTrigger();
/** * Management of the context menu ** */
ContextMenuProvider cmProvider = new TalendEditorContextMenuProvider(this, viewer, getActionRegistry());
viewer.setContextMenu(cmProvider);
/** * Management of the Zoom ** */
/*
* ZoomManager manager = (ZoomManager) getGraphicalViewer().getProperty(ZoomManager.class.toString()); if
* (manager != null) { manager.setZoom(getProcess().getZoom()); }
*/
// Scroll-wheel Zoom
getGraphicalViewer().setProperty(MouseWheelHandler.KeyGenerator.getKey(SWT.MOD1), MouseWheelZoomHandler.SINGLETON);
/** * Snap To Grid ** */
// Grid properties
getGraphicalViewer().setProperty(SnapToGrid.PROPERTY_GRID_SPACING, new Dimension(AbstractTalendEditor.GRID_SIZE, AbstractTalendEditor.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);
configurationSubJob(viewer);
}
use of org.eclipse.gef.ui.actions.ZoomOutAction 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);
}
use of org.eclipse.gef.ui.actions.ZoomOutAction in project cubrid-manager by CUBRID.
the class ERSchemaEditor method getCommonKeyHandler.
protected KeyHandler getCommonKeyHandler() {
KeyHandler sharedKeyHandler = new KeyHandler();
Action action = new ZoomInAction(zoomManager);
getActionRegistry().registerAction(action);
action = new ZoomOutAction(zoomManager);
getActionRegistry().registerAction(action);
sharedKeyHandler.put(KeyStroke.getPressed('+', SWT.KEYPAD_ADD, 0), getActionRegistry().getAction(GEFActionConstants.ZOOM_IN));
sharedKeyHandler.put(KeyStroke.getPressed('-', SWT.KEYPAD_SUBTRACT, 0), getActionRegistry().getAction(GEFActionConstants.ZOOM_OUT));
sharedKeyHandler.put(KeyStroke.getPressed(SWT.DEL, 127, 0), getActionRegistry().getAction(DeleteAction.ID));
sharedKeyHandler.put(KeyStroke.getPressed(SWT.F2, 0), getActionRegistry().getAction(GEFActionConstants.DIRECT_EDIT));
sharedKeyHandler.put(KeyStroke.getReleased('', 97, SWT.CTRL), getActionRegistry().getAction(ActionFactory.SELECT_ALL.getId()));
getGraphicalViewer().setProperty(MouseWheelHandler.KeyGenerator.getKey(SWT.CTRL), MouseWheelZoomHandler.SINGLETON);
graphicalViewer.setProperty(MouseWheelHandler.KeyGenerator.getKey(SWT.MOD1), MouseWheelZoomHandler.SINGLETON);
getGraphicalViewer().setProperty(SnapToGrid.PROPERTY_GRID_ENABLED, new Boolean(true));
getGraphicalViewer().setProperty(SnapToGrid.PROPERTY_GRID_VISIBLE, true);
getGraphicalViewer().setProperty(SnapToGrid.PROPERTY_GRID_SPACING, new Dimension(10, 10));
return sharedKeyHandler;
}
use of org.eclipse.gef.ui.actions.ZoomOutAction 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