org.eclipse.gef.ui.actions.ZoomInAction Java Examples

The following examples show how to use org.eclipse.gef.ui.actions.ZoomInAction. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GraphicalEditorWithFlyoutPalette.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
protected void hookZoom( ScalableFreeformRootEditPart root )
{
	List zoomLevels = new ArrayList( 3 );
	zoomLevels.add( ZoomManager.FIT_ALL );
	zoomLevels.add( ZoomManager.FIT_WIDTH );
	zoomLevels.add( ZoomManager.FIT_HEIGHT );
	root.getZoomManager( ).setZoomLevelContributions( zoomLevels );

	IAction zoomIn = new ZoomInAction( root.getZoomManager( ) );
	IAction zoomOut = new ZoomOutAction( root.getZoomManager( ) );
	getActionRegistry( ).registerAction( zoomIn );
	getActionRegistry( ).registerAction( zoomOut );
	getSite( ).getKeyBindingService( ).registerAction( zoomIn );
	getSite( ).getKeyBindingService( ).registerAction( zoomOut );
}
 
Example #2
Source File: ZoomInCommandHandler.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
public Object execute(ExecutionEvent event) throws ExecutionException {
	DiagramEditor editor = (DiagramEditor) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor() ;
	ZoomManager zm = ((DiagramRootEditPart)editor.getDiagramEditPart().getRoot()).getZoomManager() ; 
	ZoomInAction action = new ZoomInAction(zm) ;
	action.run() ;
	return null;
}
 
Example #3
Source File: ZoomInCommandHandler.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Override
public boolean isEnabled() {
	DiagramEditor editor = (DiagramEditor) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor() ;
	ZoomManager zm = ((DiagramRootEditPart)editor.getDiagramEditPart().getRoot()).getZoomManager() ; 
	ZoomInAction action = new ZoomInAction(zm) ;
	return action.isEnabled();
}
 
Example #4
Source File: GraphConfig.java    From olca-app with Mozilla Public License 2.0 5 votes vote down vote up
private void registerStaticActions() {
	final ProductSystemGraphEditor editor = model.editor;
	actionRegistry.registerAction(ActionFactory.buildSupplyChainMenu(editor));
	actionRegistry.registerAction(ActionFactory.removeSupplyChain(editor));
	actionRegistry.registerAction(ActionFactory.removeAllConnections(editor));
	actionRegistry.registerAction(ActionFactory.mark(editor));
	actionRegistry.registerAction(ActionFactory.unmark(editor));
	actionRegistry.registerAction(ActionFactory.saveImage(editor));
	actionRegistry.registerAction(ActionFactory.expandAll(editor));
	actionRegistry.registerAction(ActionFactory.collapseAll(editor));
	actionRegistry.registerAction(ActionFactory.maximizeAll(editor));
	actionRegistry.registerAction(ActionFactory.minimizeAll(editor));
	actionRegistry.registerAction(ActionFactory.layoutMenu(editor));
	actionRegistry.registerAction(ActionFactory.searchProviders(editor));
	actionRegistry.registerAction(ActionFactory.searchRecipients(editor));
	actionRegistry.registerAction(ActionFactory.open(editor));
	actionRegistry.registerAction(ActionFactory.openMiniatureView(editor));
	actionRegistry.registerAction(ActionFactory.showOutline());
	actionRegistry.registerAction(new ZoomInAction(getZoomManager()));
	actionRegistry.registerAction(new ZoomOutAction(getZoomManager()));
	DeleteAction delAction = new DeleteAction((IWorkbenchPart) editor) {
		@Override
		protected ISelection getSelection() {
			return editor.getSite().getWorkbenchWindow().getSelectionService().getSelection();
		}
	};
	actionRegistry.registerAction(delAction);
}
 
Example #5
Source File: SankeyDiagram.java    From olca-app with Mozilla Public License 2.0 5 votes vote down vote up
@Override
protected void configureGraphicalViewer() {
	super.configureGraphicalViewer();

	MenuManager menu = SankeyMenu.create(this);
	getGraphicalViewer().setContextMenu(menu);

	GraphicalViewer viewer = getGraphicalViewer();
	viewer.setEditPartFactory(new SankeyEditPartFactory());
	ScalableRootEditPart root = new ScalableRootEditPart();
	viewer.setRootEditPart(root);

	// append zoom actions to action registry
	ZoomManager zoom = root.getZoomManager();
	getActionRegistry().registerAction(new ZoomInAction(zoom));
	getActionRegistry().registerAction(new ZoomOutAction(zoom));
	zoom.setZoomLevelContributions(Arrays.asList(
			ZoomManager.FIT_ALL,
			ZoomManager.FIT_HEIGHT,
			ZoomManager.FIT_WIDTH));

	// create key handler
	KeyHandler keyHandler = new KeyHandler();
	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.setKeyHandler(keyHandler);

	viewer.setProperty(MouseWheelHandler.KeyGenerator.getKey(SWT.NONE),
			MouseWheelZoomHandler.SINGLETON);
}
 
Example #6
Source File: ERDiagramEditor.java    From ermasterr with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
private void initViewerAction(final GraphicalViewer viewer) {
    final ScalableFreeformRootEditPart rootEditPart = new PagableFreeformRootEditPart(diagram);
    viewer.setRootEditPart(rootEditPart);

    final ZoomManager manager = rootEditPart.getZoomManager();

    final double[] zoomLevels = new double[] {0.1, 0.25, 0.5, 0.75, 0.8, 1.0, 1.5, 2.0, 2.5, 3.0, 4.0, 5.0, 10.0, 20.0};
    manager.setZoomLevels(zoomLevels);

    final List<String> zoomContributions = new ArrayList<String>();
    zoomContributions.add(ZoomManager.FIT_ALL);
    zoomContributions.add(ZoomManager.FIT_HEIGHT);
    zoomContributions.add(ZoomManager.FIT_WIDTH);
    manager.setZoomLevelContributions(zoomContributions);

    final ZoomInAction zoomInAction = new ZoomInAction(manager);
    final ZoomOutAction zoomOutAction = new ZoomOutAction(manager);
    final ZoomAdjustAction zoomAdjustAction = new ZoomAdjustAction(manager);

    getActionRegistry().registerAction(zoomInAction);
    getActionRegistry().registerAction(zoomOutAction);
    getActionRegistry().registerAction(zoomAdjustAction);

    addKeyHandler(zoomInAction);
    addKeyHandler(zoomOutAction);

    final IFigure gridLayer = rootEditPart.getLayer(LayerConstants.GRID_LAYER);
    gridLayer.setForegroundColor(Resources.GRID_COLOR);

    IAction action = new ToggleGridAction(viewer);
    getActionRegistry().registerAction(action);

    action = new ToggleSnapToGeometryAction(viewer);
    getActionRegistry().registerAction(action);

    action = new ChangeBackgroundColorAction(this, diagram);
    getActionRegistry().registerAction(action);
    getSelectionActions().add(action.getId());

    action = new TooltipAction(this);
    getActionRegistry().registerAction(action);

    action = new LockEditAction(this);
    getActionRegistry().registerAction(action);

    action = new ExportToDBAction(this);
    getActionRegistry().registerAction(action);

    actionBarContributor = new ERDiagramActionBarContributor();
    actionBarContributor.init(getEditorSite().getActionBars(), getSite().getPage());
    // action = new ToggleRulerVisibilityAction(viewer);
    // this.getActionRegistry().registerAction(action);
}
 
Example #7
Source File: MainDiagramEditor.java    From erflute with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
protected void initViewerAction(GraphicalViewer viewer) {
    final ScalableFreeformRootEditPart rootEditPart = new PagableFreeformRootEditPart(diagram);
    viewer.setRootEditPart(rootEditPart);

    final ZoomManager manager = rootEditPart.getZoomManager();

    final double[] zoomLevels = new double[] { 0.1, 0.25, 0.5, 0.75, 0.8, 1.0, 1.5, 2.0, 2.5, 3.0, 4.0, 5.0, 10.0, 20.0 };
    manager.setZoomLevels(zoomLevels);

    final List<String> zoomContributions = new ArrayList<>();
    zoomContributions.add(ZoomManager.FIT_ALL);
    zoomContributions.add(ZoomManager.FIT_HEIGHT);
    zoomContributions.add(ZoomManager.FIT_WIDTH);
    manager.setZoomLevelContributions(zoomContributions);

    final ZoomInAction zoomInAction = new ZoomInAction(manager);
    final ZoomOutAction zoomOutAction = new ZoomOutAction(manager);
    final ZoomAdjustAction zoomAdjustAction = new ZoomAdjustAction(manager);

    getActionRegistry().registerAction(zoomInAction);
    getActionRegistry().registerAction(zoomOutAction);
    getActionRegistry().registerAction(zoomAdjustAction);

    addKeyHandler(zoomInAction);
    addKeyHandler(zoomOutAction);

    final IFigure gridLayer = rootEditPart.getLayer(LayerConstants.GRID_LAYER);
    gridLayer.setForegroundColor(DesignResources.GRID_COLOR);

    IAction action = new ToggleGridAction(viewer);
    getActionRegistry().registerAction(action);

    action = new ChangeBackgroundColorAction(this, diagram);
    getActionRegistry().registerAction(action);
    getSelectionActions().add(action.getId());

    action = new ToggleMainColumnAction(this);
    getActionRegistry().registerAction(action);

    action = new LockEditAction(this);
    getActionRegistry().registerAction(action);

    action = new ExportToDBAction(this);
    getActionRegistry().registerAction(action);

    this.actionBarContributor = new ERDiagramActionBarContributor(zoomComboContributionItem);
}
 
Example #8
Source File: ERDiagramEditor.java    From ermaster-b with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
protected void initViewerAction(GraphicalViewer viewer) {
	ScalableFreeformRootEditPart rootEditPart = new PagableFreeformRootEditPart(
			this.diagram);
	viewer.setRootEditPart(rootEditPart);

	ZoomManager manager = rootEditPart.getZoomManager();

	double[] zoomLevels = new double[] { 0.1, 0.25, 0.5, 0.75, 0.8, 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);

	ZoomInAction zoomInAction = new ZoomInAction(manager);
	ZoomOutAction zoomOutAction = new ZoomOutAction(manager);
	ZoomAdjustAction zoomAdjustAction = new ZoomAdjustAction(manager);

	this.getActionRegistry().registerAction(zoomInAction);
	this.getActionRegistry().registerAction(zoomOutAction);
	this.getActionRegistry().registerAction(zoomAdjustAction);

	this.addKeyHandler(zoomInAction);
	this.addKeyHandler(zoomOutAction);

	IFigure gridLayer = rootEditPart.getLayer(LayerConstants.GRID_LAYER);
	gridLayer.setForegroundColor(Resources.GRID_COLOR);

	IAction action = new ToggleGridAction(viewer);
	this.getActionRegistry().registerAction(action);

	action = new ChangeBackgroundColorAction(this, this.diagram);
	this.getActionRegistry().registerAction(action);
	this.getSelectionActions().add(action.getId());

	action = new EditExcelAction(this, this.diagram);
	this.getActionRegistry().registerAction(action);
	this.getSelectionActions().add(action.getId());

	action = new ToggleMainColumnAction(this);
	this.getActionRegistry().registerAction(action);

	action = new LockEditAction(this);
	this.getActionRegistry().registerAction(action);

	action = new ExportToDBAction(this);
	this.getActionRegistry().registerAction(action);

	this.actionBarContributor = new ERDiagramActionBarContributor(
			this.zoomComboContributionItem);

	// action = new ToggleRulerVisibilityAction(viewer);
	// this.getActionRegistry().registerAction(action);
	//
	// action = new ToggleSnapToGeometryAction(viewer);
	// this.getActionRegistry().registerAction(action);
}