Search in sources :

Example 1 with DesignViewContextMenuProvider

use of org.eclipse.wst.xsd.ui.internal.adt.design.DesignViewContextMenuProvider in project webtools.sourceediting by eclipse.

the class ADTContentOutlinePage method createControl.

public void createControl(Composite parent) {
    super.createControl(parent);
    getTreeViewer().setContentProvider(contentProvider);
    getTreeViewer().setLabelProvider(labelProvider);
    getTreeViewer().setInput(model);
    getTreeViewer().addSelectionChangedListener(this);
    // $NON-NLS-1$
    MenuManager menuManager = new MenuManager("#popup");
    menuManager.setRemoveAllWhenShown(true);
    Menu menu = menuManager.createContextMenu(getTreeViewer().getControl());
    getTreeViewer().getControl().setMenu(menu);
    setSelectionManager(editor.getSelectionManager());
    // Create menu...for now reuse graph's.  Note edit part viewer = null
    DesignViewContextMenuProvider menuProvider = new DesignViewContextMenuProvider(editor, null, editor.getSelectionManager());
    menuManager.addMenuListener(menuProvider);
    // $NON-NLS-1$
    getSite().registerContextMenu("org.eclipse.wst.xsd.ui.popup.outline", menuManager, editor.getSelectionManager());
    // enable popupMenus extension
    // getSite().registerContextMenu("org.eclipse.wst.xsdeditor.ui.popup.outline",
    // menuManager, xsdEditor.getSelectionManager());
    // drill down from outline view
    getTreeViewer().getControl().addMouseListener(new MouseAdapter() {

        public void mouseDoubleClick(MouseEvent e) {
            ISelection iSelection = getTreeViewer().getSelection();
            if (iSelection instanceof StructuredSelection) {
                StructuredSelection selection = (StructuredSelection) iSelection;
                Object obj = selection.getFirstElement();
                if (obj instanceof XSDConcreteComponent) {
                    XSDConcreteComponent comp = (XSDConcreteComponent) obj;
                    if (comp.getContainer() instanceof XSDSchema) {
                    // getXSDEditor().getGraphViewer().setInput(obj);
                    }
                }
            }
        }
    });
}
Also used : MouseEvent(org.eclipse.swt.events.MouseEvent) XSDConcreteComponent(org.eclipse.xsd.XSDConcreteComponent) MenuManager(org.eclipse.jface.action.MenuManager) MouseAdapter(org.eclipse.swt.events.MouseAdapter) ISelection(org.eclipse.jface.viewers.ISelection) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) Menu(org.eclipse.swt.widgets.Menu) DesignViewContextMenuProvider(org.eclipse.wst.xsd.ui.internal.adt.design.DesignViewContextMenuProvider) XSDSchema(org.eclipse.xsd.XSDSchema)

Aggregations

MenuManager (org.eclipse.jface.action.MenuManager)1 ISelection (org.eclipse.jface.viewers.ISelection)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)1 MouseAdapter (org.eclipse.swt.events.MouseAdapter)1 MouseEvent (org.eclipse.swt.events.MouseEvent)1 Menu (org.eclipse.swt.widgets.Menu)1 DesignViewContextMenuProvider (org.eclipse.wst.xsd.ui.internal.adt.design.DesignViewContextMenuProvider)1 XSDConcreteComponent (org.eclipse.xsd.XSDConcreteComponent)1 XSDSchema (org.eclipse.xsd.XSDSchema)1