Search in sources :

Example 36 with ZoomManager

use of org.eclipse.gef.editparts.ZoomManager in project yamcs-studio by yamcs.

the class PartZoomAction method setPart.

/**
 * @param part a part which must have a ZoomManager Adapter.
 */
public void setPart(IWorkbenchPart part) {
    if (this.part == part)
        return;
    this.part = part;
    if (zoomManager != null)
        zoomManager.removeZoomListener(this);
    ZoomManager newZoomManager = part.getAdapter(ZoomManager.class);
    if (newZoomManager != null) {
        newZoomManager.addZoomListener(this);
        zoomManager = newZoomManager;
    }
}
Also used : ZoomManager(org.eclipse.gef.editparts.ZoomManager)

Example 37 with ZoomManager

use of org.eclipse.gef.editparts.ZoomManager in project yamcs-studio by yamcs.

the class PartZoomComboContributionItem method setPart.

/**
 * @param part a part which must have a ZoomManager Adapter.
 */
public void setPart(IWorkbenchPart part) {
    if (this.part == part)
        return;
    this.part = part;
    ZoomManager newZoomManager = part.getAdapter(ZoomManager.class);
    if (newZoomManager != null) {
        setZoomManager(newZoomManager);
    }
}
Also used : ZoomManager(org.eclipse.gef.editparts.ZoomManager)

Example 38 with ZoomManager

use of org.eclipse.gef.editparts.ZoomManager in project webtools.sourceediting by eclipse.

the class CommonMultiPageEditor method configureGraphicalViewer.

protected void configureGraphicalViewer() {
    graphicalViewer.getControl().setBackground(ColorConstants.listBackground);
    // Set the root edit part
    // ScalableFreeformRootEditPart root = new ScalableFreeformRootEditPart();
    RootEditPart root = new RootEditPart();
    ZoomManager zoomManager = root.getZoomManager();
    List zoomLevelContributions = new ArrayList(3);
    zoomLevelContributions.add(ZoomManager.FIT_ALL);
    zoomLevelContributions.add(ZoomManager.FIT_WIDTH);
    zoomLevelContributions.add(ZoomManager.FIT_HEIGHT);
    zoomManager.setZoomLevelContributions(zoomLevelContributions);
    double[] zoomLevels = { .10, .25, .5, .75, 1.0, 1.25, 1.5, 2.0, 2.5, 3, 4, 5 };
    zoomManager.setZoomLevels(zoomLevels);
    IAction zoomIn = new ZoomInAction(zoomManager);
    IAction zoomOut = new ZoomOutAction(zoomManager);
    getActionRegistry().registerAction(zoomIn);
    getActionRegistry().registerAction(zoomOut);
    getSite().getKeyBindingService().registerAction(zoomIn);
    getSite().getKeyBindingService().registerAction(zoomOut);
    // ConnectionLayer connectionLayer = (ConnectionLayer) root.getLayer(LayerConstants.CONNECTION_LAYER);
    // connectionLayer.setConnectionRouter(new BendpointConnectionRouter());
    // connectionLayer.setConnectionRouter(new ShortestPathConnectionRouter(connectionLayer));
    // connectionLayer.setVisible(false);
    // Zoom
    zoomManager.setZoom(1.0);
    // Scroll-wheel Zoom
    graphicalViewer.setProperty(MouseWheelHandler.KeyGenerator.getKey(SWT.CTRL), MouseWheelZoomHandler.SINGLETON);
    graphicalViewer.setRootEditPart(root);
    graphicalViewer.setEditPartFactory(getEditPartFactory());
}
Also used : IAction(org.eclipse.jface.action.IAction) ZoomOutAction(org.eclipse.gef.ui.actions.ZoomOutAction) ZoomManager(org.eclipse.gef.editparts.ZoomManager) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) ZoomInAction(org.eclipse.gef.ui.actions.ZoomInAction) RootEditPart(org.eclipse.wst.xsd.ui.internal.adt.design.editparts.RootEditPart)

Example 39 with ZoomManager

use of org.eclipse.gef.editparts.ZoomManager in project whole by wholeplatform.

the class E4GraphicalViewer method createRootEditPart.

protected RootEditPart createRootEditPart() {
    RootEditPart rootEditPart = new RootEditPart();
    List<String> levels = new ArrayList<String>(3);
    levels.add(ZoomManager.FIT_ALL);
    levels.add(ZoomManager.FIT_WIDTH);
    levels.add(ZoomManager.FIT_HEIGHT);
    ZoomManager zoomManager = rootEditPart.getZoomManager();
    zoomManager.setZoomLevelContributions(levels);
    zoomManager.setZoomAnimationStyle(ZoomManager.ANIMATE_ZOOM_IN_OUT);
    return rootEditPart;
}
Also used : ZoomManager(org.eclipse.gef.editparts.ZoomManager) ArrayList(java.util.ArrayList) RootEditPart(org.whole.lang.e4.ui.editparts.RootEditPart) IScalableRootEditPart(org.whole.lang.e4.ui.editparts.IScalableRootEditPart)

Example 40 with ZoomManager

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

the class ERDEditorPart method configureGraphicalViewer.

@Override
protected void configureGraphicalViewer() {
    super.configureGraphicalViewer();
    this.getGraphicalViewer().getControl().setBackground(UIUtils.getColorRegistry().get(ERDUIConstants.COLOR_ERD_DIAGRAM_BACKGROUND));
    GraphicalViewer graphicalViewer = getGraphicalViewer();
    /*
        MenuManager manager = new MenuManager(getClass().getName(), getClass().getName());
        manager.setRemoveAllWhenShown(true);
        getEditorSite().registerContextMenu(getClass().getName() + ".EditorContext", manager, graphicalViewer, true); //$NON-NLS-1$
*/
    DBPPreferenceStore store = ERDUIActivator.getDefault().getPreferences();
    graphicalViewer.setProperty(SnapToGrid.PROPERTY_GRID_ENABLED, store.getBoolean(ERDUIConstants.PREF_GRID_ENABLED));
    graphicalViewer.setProperty(SnapToGrid.PROPERTY_GRID_VISIBLE, store.getBoolean(ERDUIConstants.PREF_GRID_ENABLED));
    graphicalViewer.setProperty(SnapToGrid.PROPERTY_GRID_SPACING, new Dimension(store.getInt(ERDUIConstants.PREF_GRID_WIDTH), store.getInt(ERDUIConstants.PREF_GRID_HEIGHT)));
    // initialize actions
    createActions();
    // Setup zoom manager
    ZoomManager zoomManager = rootPart.getZoomManager();
    List<String> zoomLevels = new ArrayList<>(3);
    zoomLevels.add(ZoomManager.FIT_ALL);
    zoomLevels.add(ZoomManager.FIT_WIDTH);
    zoomLevels.add(ZoomManager.FIT_HEIGHT);
    zoomManager.setZoomLevelContributions(zoomLevels);
    zoomManager.setZoomLevels(new double[] { .1, .1, .2, .3, .5, .6, .7, .8, .9, 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0, 2.5, 3, 4 });
    IAction zoomIn = new ZoomInAction(zoomManager);
    IAction zoomOut = new ZoomOutAction(zoomManager);
    addAction(zoomIn);
    addAction(zoomOut);
    graphicalViewer.addSelectionChangedListener(event -> {
        String status;
        IStructuredSelection selection = (IStructuredSelection) event.getSelection();
        if (selection.isEmpty()) {
            status = "";
        } else if (selection.size() == 1) {
            status = CommonUtils.toString(selection.getFirstElement());
        } else {
            status = selection.size() + " objects";
        }
        if (progressControl != null) {
            progressControl.setInfo(status);
        }
        updateActions(editPartActionIDs);
    });
}
Also used : ZoomManager(org.eclipse.gef.editparts.ZoomManager) ArrayList(java.util.ArrayList) Dimension(org.eclipse.draw2d.geometry.Dimension) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) DBPPreferenceStore(org.jkiss.dbeaver.model.preferences.DBPPreferenceStore)

Aggregations

ZoomManager (org.eclipse.gef.editparts.ZoomManager)46 Point (org.eclipse.draw2d.geometry.Point)14 ArrayList (java.util.ArrayList)7 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)5 Dimension (org.eclipse.draw2d.geometry.Dimension)4 ScalableFreeformRootEditPart (org.eclipse.gef.editparts.ScalableFreeformRootEditPart)4 ZoomInAction (org.eclipse.gef.ui.actions.ZoomInAction)4 ZoomOutAction (org.eclipse.gef.ui.actions.ZoomOutAction)4 Iterator (java.util.Iterator)3 Rectangle (org.eclipse.draw2d.geometry.Rectangle)3 GraphicalViewer (org.eclipse.gef.GraphicalViewer)3 IAction (org.eclipse.jface.action.IAction)3 ConnectionContainerEditPart (org.knime.workbench.editor2.editparts.ConnectionContainerEditPart)3 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 Method (java.lang.reflect.Method)2 AbsoluteBendpoint (org.eclipse.draw2d.AbsoluteBendpoint)2 Bendpoint (org.eclipse.draw2d.Bendpoint)2 FigureCanvas (org.eclipse.draw2d.FigureCanvas)2 Viewport (org.eclipse.draw2d.Viewport)2 KeyHandler (org.eclipse.gef.KeyHandler)2