Search in sources :

Example 1 with PopupMenuProvider

use of org.jboss.tools.hibernate.ui.diagram.editors.popup.PopupMenuProvider in project jbosstools-hibernate by jbosstools.

the class DiagramContentOutlinePage method configureOutlineViewer.

/**
 * Outline viewer configuration
 */
protected void configureOutlineViewer() {
    getViewer().setEditDomain(editor.getDefaultEditDomain());
    getViewer().setEditPartFactory(new TreePartFactory());
    MenuManager provider = new PopupMenuProvider(getViewer(), getActionRegistry());
    // getViewer().setContextMenu(provider);
    getViewer().setContextMenu(provider);
    getSite().registerContextMenu(// $NON-NLS-1$
    "org.jboss.tools.hibernate.ui.diagram.editors.popup.outline.contextmenu", provider, getSite().getSelectionProvider());
    IToolBarManager tbm = getSite().getActionBars().getToolBarManager();
    tbm.add(editor.getLexicalSortingAction());
    showOutlineAction = new Action() {

        public void run() {
            showPage(ID_OUTLINE);
        }
    };
    showOutlineAction.setToolTipText(DiagramViewerMessages.DiagramContentOutlinePage_Outline);
    showOutlineAction.setImageDescriptor(ImageDescriptor.createFromFile(DiagramViewer.class, // $NON-NLS-1$
    "icons/outline.gif"));
    tbm.add(showOutlineAction);
    showOverviewAction = new Action() {

        public void run() {
            showPage(ID_OVERVIEW);
        }
    };
    showOverviewAction.setToolTipText(DiagramViewerMessages.DiagramContentOutlinePage_Overview);
    showOverviewAction.setImageDescriptor(ImageDescriptor.createFromFile(DiagramViewer.class, // $NON-NLS-1$
    "icons/overview.gif"));
    tbm.add(showOverviewAction);
    showPage(ID_OVERVIEW);
}
Also used : TreePartFactory(org.jboss.tools.hibernate.ui.diagram.editors.parts.TreePartFactory) IAction(org.eclipse.jface.action.IAction) ToggleShapeVisibleStateAction(org.jboss.tools.hibernate.ui.diagram.editors.actions.ToggleShapeVisibleStateAction) AutoLayoutAction(org.jboss.tools.hibernate.ui.diagram.editors.actions.AutoLayoutAction) ToggleConnectionsAction(org.jboss.tools.hibernate.ui.diagram.editors.actions.ToggleConnectionsAction) LexicalSortingAction(org.jboss.tools.hibernate.ui.diagram.editors.actions.LexicalSortingAction) ToggleShapeExpandStateAction(org.jboss.tools.hibernate.ui.diagram.editors.actions.ToggleShapeExpandStateAction) Action(org.eclipse.jface.action.Action) IToolBarManager(org.eclipse.jface.action.IToolBarManager) MenuManager(org.eclipse.jface.action.MenuManager) PopupMenuProvider(org.jboss.tools.hibernate.ui.diagram.editors.popup.PopupMenuProvider)

Example 2 with PopupMenuProvider

use of org.jboss.tools.hibernate.ui.diagram.editors.popup.PopupMenuProvider 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)

Aggregations

IAction (org.eclipse.jface.action.IAction)2 PopupMenuProvider (org.jboss.tools.hibernate.ui.diagram.editors.popup.PopupMenuProvider)2 ArrayList (java.util.ArrayList)1 GraphicalViewer (org.eclipse.gef.GraphicalViewer)1 RulerProvider (org.eclipse.gef.rulers.RulerProvider)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 Action (org.eclipse.jface.action.Action)1 IToolBarManager (org.eclipse.jface.action.IToolBarManager)1 MenuManager (org.eclipse.jface.action.MenuManager)1 AutoLayoutAction (org.jboss.tools.hibernate.ui.diagram.editors.actions.AutoLayoutAction)1 LexicalSortingAction (org.jboss.tools.hibernate.ui.diagram.editors.actions.LexicalSortingAction)1 ToggleConnectionsAction (org.jboss.tools.hibernate.ui.diagram.editors.actions.ToggleConnectionsAction)1 ToggleShapeExpandStateAction (org.jboss.tools.hibernate.ui.diagram.editors.actions.ToggleShapeExpandStateAction)1 ToggleShapeVisibleStateAction (org.jboss.tools.hibernate.ui.diagram.editors.actions.ToggleShapeVisibleStateAction)1 OrmEditPartFactory (org.jboss.tools.hibernate.ui.diagram.editors.parts.OrmEditPartFactory)1 TreePartFactory (org.jboss.tools.hibernate.ui.diagram.editors.parts.TreePartFactory)1 DiagramRuler (org.jboss.tools.hibernate.ui.diagram.rulers.DiagramRuler)1