Search in sources :

Example 1 with MenuProvider

use of com.cubrid.common.ui.spi.action.MenuProvider in project cubrid-manager by CUBRID.

the class SchemaInfoEditorPart method createContextMenu.

/**
	 * 
	 * Create the context menu
	 * 
	 * @param control Control
	 */
private void createContextMenu(final Control control) {
    MenuManager contextMenuManager = new MenuManager();
    contextMenuManager.setRemoveAllWhenShown(true);
    contextMenuManager.addMenuListener(new IMenuListener() {

        public void menuAboutToShow(IMenuManager manager) {
            ISelectionProvider provider = ActionManager.getInstance().getSelectionProvider();
            if (!(provider instanceof TreeViewer)) {
                return;
            }
            TreeViewer viewer = (TreeViewer) provider;
            viewer.setSelection(new StructuredSelection(schemaNode), true);
            viewer.getTree().setFocus();
            MenuProvider menuProvider = new MenuProvider();
            String type = schemaNode.getType();
            if (NodeType.SYSTEM_TABLE.equals(type)) {
                menuProvider.buildSystemTableMenu(manager);
            } else if (NodeType.SYSTEM_VIEW.equals(type)) {
                menuProvider.buildSystemViewMenu(manager);
            } else if (NodeType.USER_PARTITIONED_TABLE_FOLDER.equals(type)) {
                menuProvider.buildUserTableMenu(manager, schemaNode);
            } else if (NodeType.USER_PARTITIONED_TABLE.equals(type)) {
                menuProvider.buildPartitionedTableMenu(manager);
            } else if (NodeType.USER_TABLE.equals(type)) {
                menuProvider.buildUserTableMenu(manager, schemaNode);
            } else if (NodeType.USER_VIEW.equals(type)) {
                menuProvider.buildUserViewMenu(manager);
            }
            manager.remove(ShowSchemaEditorAction.ID);
        }
    });
    Menu contextMenu = contextMenuManager.createContextMenu(control);
    control.setMenu(contextMenu);
}
Also used : ISelectionProvider(org.eclipse.jface.viewers.ISelectionProvider) TreeViewer(org.eclipse.jface.viewers.TreeViewer) MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IMenuManager(org.eclipse.jface.action.IMenuManager) Menu(org.eclipse.swt.widgets.Menu) MenuProvider(com.cubrid.common.ui.spi.action.MenuProvider) IMenuListener(org.eclipse.jface.action.IMenuListener)

Aggregations

MenuProvider (com.cubrid.common.ui.spi.action.MenuProvider)1 IMenuListener (org.eclipse.jface.action.IMenuListener)1 IMenuManager (org.eclipse.jface.action.IMenuManager)1 MenuManager (org.eclipse.jface.action.MenuManager)1 ISelectionProvider (org.eclipse.jface.viewers.ISelectionProvider)1 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)1 TreeViewer (org.eclipse.jface.viewers.TreeViewer)1 Menu (org.eclipse.swt.widgets.Menu)1