Search in sources :

Example 1 with RulerProvider

use of org.eclipse.gef.rulers.RulerProvider in project jbosstools-hibernate by jbosstools.

the class DiagramViewer method initializeGraphicalViewer.

protected void initializeGraphicalViewer() {
    final GraphicalViewer viewer = getGraphicalViewer();
    viewer.setEditPartFactory(new OrmEditPartFactory());
    // 
    viewer.setKeyHandler(new GraphicalViewerKeyHandler(viewer).setParent(getCommonKeyHandler()));
    // 
    List<String> zoomLevels = new ArrayList<String>(3);
    zoomLevels.add(ZoomManager.FIT_ALL);
    zoomLevels.add(ZoomManager.FIT_WIDTH);
    zoomLevels.add(ZoomManager.FIT_HEIGHT);
    gefRootEditPart.getZoomManager().setZoomLevelContributions(zoomLevels);
    IAction zoomIn = new ZoomInAction(gefRootEditPart.getZoomManager());
    IAction zoomOut = new ZoomOutAction(gefRootEditPart.getZoomManager());
    getActionRegistry().registerAction(zoomIn);
    getActionRegistry().registerAction(zoomOut);
    // 
    viewer.setRootEditPart(gefRootEditPart);
    viewer.addDropTargetListener(createTransferDropTargetListener());
    viewer.setContents(getOrmDiagram());
    PopupMenuProvider provider = new PopupMenuProvider(viewer, getActionRegistry());
    viewer.setContextMenu(provider);
    // $NON-NLS-1$
    getSite().registerContextMenu("FlowDiagramContextmenu", provider, viewer);
    // Scroll-wheel Zoom
    viewer.setProperty(MouseWheelHandler.KeyGenerator.getKey(SWT.MOD1), MouseWheelZoomHandler.SINGLETON);
    // Ruler properties
    DiagramRuler ruler = getOrmDiagram().getRuler(PositionConstants.WEST);
    RulerProvider rulerProvider = null;
    if (ruler != null) {
        rulerProvider = new DiagramRulerProvider(ruler);
    }
    getGraphicalViewer().setProperty(RulerProvider.PROPERTY_VERTICAL_RULER, rulerProvider);
    ruler = getOrmDiagram().getRuler(PositionConstants.NORTH);
    rulerProvider = null;
    if (ruler != null) {
        rulerProvider = new DiagramRulerProvider(ruler);
    }
    getGraphicalViewer().setProperty(RulerProvider.PROPERTY_HORIZONTAL_RULER, rulerProvider);
    getGraphicalViewer().setProperty(RulerProvider.PROPERTY_RULER_VISIBILITY, new Boolean(getOrmDiagram().getRulerVisibility()));
    loadProperties();
    updateConnectionRouterActions();
}
Also used : ScrollingGraphicalViewer(org.eclipse.gef.ui.parts.ScrollingGraphicalViewer) GraphicalViewer(org.eclipse.gef.GraphicalViewer) IAction(org.eclipse.jface.action.IAction) ZoomOutAction(org.eclipse.gef.ui.actions.ZoomOutAction) ArrayList(java.util.ArrayList) DiagramRulerProvider(org.jboss.tools.hibernate.ui.diagram.rulers.DiagramRulerProvider) DiagramRulerProvider(org.jboss.tools.hibernate.ui.diagram.rulers.DiagramRulerProvider) RulerProvider(org.eclipse.gef.rulers.RulerProvider) DiagramRuler(org.jboss.tools.hibernate.ui.diagram.rulers.DiagramRuler) GraphicalViewerKeyHandler(org.eclipse.gef.ui.parts.GraphicalViewerKeyHandler) OrmEditPartFactory(org.jboss.tools.hibernate.ui.diagram.editors.parts.OrmEditPartFactory) PopupMenuProvider(org.jboss.tools.hibernate.ui.diagram.editors.popup.PopupMenuProvider) ZoomInAction(org.eclipse.gef.ui.actions.ZoomInAction)

Example 2 with RulerProvider

use of org.eclipse.gef.rulers.RulerProvider in project jbosstools-hibernate by jbosstools.

the class DiagramViewer method loadProperties.

protected boolean loadProperties() {
    if (getOrmDiagram() == null || getGraphicalViewer() == null) {
        return false;
    }
    // Ruler properties
    DiagramRuler ruler = getOrmDiagram().getRuler(PositionConstants.WEST);
    RulerProvider provider = null;
    if (ruler != null) {
        provider = new DiagramRulerProvider(ruler);
    }
    getGraphicalViewer().setProperty(RulerProvider.PROPERTY_VERTICAL_RULER, provider);
    ruler = getOrmDiagram().getRuler(PositionConstants.NORTH);
    provider = null;
    if (ruler != null) {
        provider = new DiagramRulerProvider(ruler);
    }
    getGraphicalViewer().setProperty(RulerProvider.PROPERTY_HORIZONTAL_RULER, provider);
    getGraphicalViewer().setProperty(RulerProvider.PROPERTY_RULER_VISIBILITY, new Boolean(getOrmDiagram().getRulerVisibility()));
    // Snap to Geometry property
    getGraphicalViewer().setProperty(SnapToGeometry.PROPERTY_SNAP_ENABLED, new Boolean(getOrmDiagram().isSnapToGeometryEnabled()));
    // Grid properties
    getGraphicalViewer().setProperty(SnapToGrid.PROPERTY_GRID_ENABLED, new Boolean(getOrmDiagram().isGridEnabled()));
    // We keep grid visibility and enablement in sync
    getGraphicalViewer().setProperty(SnapToGrid.PROPERTY_GRID_VISIBLE, new Boolean(getOrmDiagram().isGridEnabled()));
    // Zoom
    ZoomManager manager = (ZoomManager) getGraphicalViewer().getProperty(ZoomManager.class.toString());
    if (manager != null) {
        manager.setZoom(getOrmDiagram().getZoom());
    }
    return true;
}
Also used : DiagramRulerProvider(org.jboss.tools.hibernate.ui.diagram.rulers.DiagramRulerProvider) RulerProvider(org.eclipse.gef.rulers.RulerProvider) DiagramRuler(org.jboss.tools.hibernate.ui.diagram.rulers.DiagramRuler) ZoomManager(org.eclipse.gef.editparts.ZoomManager) DiagramRulerProvider(org.jboss.tools.hibernate.ui.diagram.rulers.DiagramRulerProvider)

Example 3 with RulerProvider

use of org.eclipse.gef.rulers.RulerProvider in project yamcs-studio by yamcs.

the class OPIEditor method configureRuler.

/**
 * Configure the properties for the rulers.
 */
private void configureRuler() {
    // Ruler properties
    RulerProvider hprovider = new OPIEditorRulerProvider(new RulerModel(true));
    RulerProvider vprovider = new OPIEditorRulerProvider(new RulerModel(false));
    getGraphicalViewer().setProperty(RulerProvider.PROPERTY_HORIZONTAL_RULER, hprovider);
    getGraphicalViewer().setProperty(RulerProvider.PROPERTY_VERTICAL_RULER, vprovider);
}
Also used : RulerProvider(org.eclipse.gef.rulers.RulerProvider) RulerModel(org.csstudio.opibuilder.model.RulerModel)

Example 4 with RulerProvider

use of org.eclipse.gef.rulers.RulerProvider in project archi by archimatetool.

the class RulerEditPart method setParent.

@Override
public void setParent(EditPart parent) {
    super.setParent(parent);
    if (getParent() != null && diagramViewer == null) {
        diagramViewer = (GraphicalViewer) getViewer().getProperty(GraphicalViewer.class.toString());
        RulerProvider hProvider = (RulerProvider) diagramViewer.getProperty(RulerProvider.PROPERTY_HORIZONTAL_RULER);
        if (hProvider != null && hProvider.getRuler() == getModel()) {
            rulerProvider = hProvider;
            horizontal = true;
        } else {
            rulerProvider = (RulerProvider) diagramViewer.getProperty(RulerProvider.PROPERTY_VERTICAL_RULER);
        }
    }
}
Also used : RulerProvider(org.eclipse.gef.rulers.RulerProvider) GraphicalViewer(org.eclipse.gef.GraphicalViewer)

Example 5 with RulerProvider

use of org.eclipse.gef.rulers.RulerProvider in project archi by archimatetool.

the class RulerEditPartFactory method getHorizontalRuler.

protected Object getHorizontalRuler() {
    Object ruler = null;
    RulerProvider provider = (RulerProvider) diagramViewer.getProperty(RulerProvider.PROPERTY_HORIZONTAL_RULER);
    if (provider != null) {
        ruler = provider.getRuler();
    }
    return ruler;
}
Also used : RulerProvider(org.eclipse.gef.rulers.RulerProvider)

Aggregations

RulerProvider (org.eclipse.gef.rulers.RulerProvider)8 GraphicalViewer (org.eclipse.gef.GraphicalViewer)2 DiagramRuler (org.jboss.tools.hibernate.ui.diagram.rulers.DiagramRuler)2 DiagramRulerProvider (org.jboss.tools.hibernate.ui.diagram.rulers.DiagramRulerProvider)2 PropertyChangeEvent (java.beans.PropertyChangeEvent)1 PropertyChangeListener (java.beans.PropertyChangeListener)1 ArrayList (java.util.ArrayList)1 RulerModel (org.csstudio.opibuilder.model.RulerModel)1 ZoomManager (org.eclipse.gef.editparts.ZoomManager)1 RulerEditPart (org.eclipse.gef.internal.ui.rulers.RulerEditPart)1 ZoomInAction (org.eclipse.gef.ui.actions.ZoomInAction)1 ZoomOutAction (org.eclipse.gef.ui.actions.ZoomOutAction)1 GraphicalViewerKeyHandler (org.eclipse.gef.ui.parts.GraphicalViewerKeyHandler)1 ScrollingGraphicalViewer (org.eclipse.gef.ui.parts.ScrollingGraphicalViewer)1 IAction (org.eclipse.jface.action.IAction)1 DisposeEvent (org.eclipse.swt.events.DisposeEvent)1 DisposeListener (org.eclipse.swt.events.DisposeListener)1 FocusEvent (org.eclipse.swt.events.FocusEvent)1 KeyEvent (org.eclipse.swt.events.KeyEvent)1 Event (org.eclipse.swt.widgets.Event)1