Search in sources :

Example 31 with MenuManager

use of org.eclipse.jface.action.MenuManager 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)

Example 32 with MenuManager

use of org.eclipse.jface.action.MenuManager in project cubrid-manager by CUBRID.

the class QueryPlanCompositeWithHistory method setupContextMenu.

private void setupContextMenu(final Tree tree) {
    MenuManager menuManager = new MenuManager();
    menuManager.setRemoveAllWhenShown(true);
    menuManager.addMenuListener(new IMenuListener() {

        public void menuAboutToShow(IMenuManager manager) {
        //				IAction showSchemaAction = ActionManager.getInstance().getAction(ShowSchemaAction.ID);
        //				if (showSchemaAction != null) {
        //					manager.add(showSchemaAction);
        //
        //					showSchemaAction.setEnabled(false);
        //					if (DatabaseNavigatorMenu.SELF_DATABASE_ID.equals(editor.getSelectedDatabase().getId())) {
        //						return;
        //					}
        //
        //					if (editor.getSelectedDatabase().getDatabaseInfo() == null) {
        //						return;
        //					}
        //
        //					if (tree.getSelection() != null && tree.getSelection().length > 0) {
        //						String tname = tree.getSelection()[0].getText(1);
        //						if (tname == null || tname.length() == 0) {
        //							return;
        //						}
        //
        //						int ep = tname.indexOf(' ');
        //						if (ep != -1) {
        //							tname = tname.substring(0, ep);
        //						}
        //						editor.setCurrentSchemaName(tname);
        //						if (tname != null) {
        //							showSchemaAction.setEnabled(true);
        //						}
        //					}
        //				}
        }
    });
    Menu contextMenu = menuManager.createContextMenu(tree);
    tree.setMenu(contextMenu);
}
Also used : MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) TabContextMenuManager(com.cubrid.common.ui.spi.util.TabContextMenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) Menu(org.eclipse.swt.widgets.Menu) IMenuListener(org.eclipse.jface.action.IMenuListener)

Example 33 with MenuManager

use of org.eclipse.jface.action.MenuManager in project cubrid-manager by CUBRID.

the class MenuProvider method buildUserTableMenu.

/**
	 * Construct user table related actions
	 *
	 * @param manager the parent IMenuManager
	 * @param node The ICubridNode object
	 */
public void buildUserTableMenu(IMenuManager manager, ICubridNode node) {
    DatabaseInfo dbInfo = ((ISchemaNode) node).getDatabase().getDatabaseInfo();
    // SELECT GROUP
    IMenuManager selectSqlMenu = new MenuManager(Messages.lblMakeSelectQueryGrp);
    manager.add(selectSqlMenu);
    // SELECT
    addActionToManager(selectSqlMenu, getAction(MakeSelectQueryAction.ID));
    // Parameterized SELECT
    addActionToManager(selectSqlMenu, getAction(MakeSelectPstmtQueryAction.ID));
    // Parameterized INSERT
    addActionToManager(manager, getAction(MakeInsertQueryAction.ID));
    // Parameterized UPDATE
    addActionToManager(manager, getAction(MakeUpdateQueryAction.ID));
    // Parameterized DELETE
    addActionToManager(manager, getAction(MakeDeleteQueryAction.ID));
    // CREATE GROUP
    IMenuManager createSqlMenu = new MenuManager(Messages.lblMakeCreateQueryGrp);
    manager.add(createSqlMenu);
    addActionToManager(createSqlMenu, getAction(MakeCreateQueryAction.ID));
    addActionToManager(createSqlMenu, getAction(MakeCloneQueryAction.ID));
    manager.add(new Separator());
    // Schema to Code Actions
    addActionToManager(manager, getAction(TableToJavaCodeAction.ID));
    addActionToManager(manager, getAction(TableToPhpCodeAction.ID));
    addActionToManager(manager, getAction(ExportTableDefinitionAction.ID));
    manager.add(new Separator());
    // Install Schema Comment
    addActionToManager(manager, getAction(SchemaCommentInstallAction.ID));
    manager.add(new Separator());
    // View data
    IMenuManager viewDataMenu = new MenuManager(Messages.viewDataMenuName);
    manager.add(viewDataMenu);
    addActionToManager(viewDataMenu, getAction(TableSelectAllAction.ID));
    addActionToManager(viewDataMenu, getAction(SelectByOnePstmtDataAction.ID));
    addActionToManager(viewDataMenu, getAction(SelectByMultiPstmtDataAction.ID));
    viewDataMenu.add(new Separator());
    addActionToManager(viewDataMenu, getAction(TableSelectCountAction.ID));
    // Input data
    IMenuManager inputDataMenu = new MenuManager(Messages.inputDataMenuName);
    manager.add(inputDataMenu);
    addActionToManager(inputDataMenu, getAction(InsertOneByPstmtAction.ID));
    addActionToManager(inputDataMenu, getAction(ImportDataFromFileAction.ID));
    //		addActionToManager(manager, getAction(RunSQLFileAction.ID));
    manager.add(new Separator());
    // Export & Import Actions
    addActionToManager(manager, getAction(ExportWizardAction.ID));
    addActionToManager(manager, getAction(ImportWizardAction.ID));
    manager.add(new Separator());
    // Manage table
    addActionToManager(manager, getAction(EditTableAction.ID));
    IAction renameTableAction = getAction(RenameTableAction.ID);
    renameTableAction.setText(com.cubrid.common.ui.spi.Messages.tableRenameActionName);
    renameTableAction.setImageDescriptor(CommonUIPlugin.getImageDescriptor("icons/action/table_rename.png"));
    addActionToManager(manager, renameTableAction);
    IMenuManager moreMenu = new MenuManager(Messages.tableMoreName);
    addActionToManager(moreMenu, getAction(DeleteTableAction.ID));
    IAction action = getAction(DeleteTableAction.ID);
    if (CompatibleUtil.isSupportTruncateTable(dbInfo)) {
        if (action != null) {
            action.setText(Messages.deleteAllRecordsActionName);
        }
        addActionToManager(moreMenu, getAction(TruncateTableAction.ID));
    } else {
        if (action != null) {
            action.setText(Messages.tableDeleteAllActionName);
        }
    }
    IAction tableDropAction = getAction(DropTableAction.ID);
    addActionToManager(moreMenu, tableDropAction);
    moreMenu.add(new Separator());
    if (CompatibleUtil.isSupportCreateTableLike(dbInfo)) {
        addActionToManager(moreMenu, getAction(CreateLikeTableAction.ID));
    }
    manager.add(moreMenu);
}
Also used : IAction(org.eclipse.jface.action.IAction) DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) Separator(org.eclipse.jface.action.Separator)

Example 34 with MenuManager

use of org.eclipse.jface.action.MenuManager in project translationstudio8 by heartsome.

the class TermDbManagerDialog method initTreePopMenu.

/**
	 * 初始化树右键菜单 ;
	 */
private void initTreePopMenu() {
    MenuManager menuManager = new MenuManager("");
    menuManager.add(new Action(Messages.getString("dialog.TermDbManagerDialog.deleteAction")) {

        @Override
        public void run() {
            ISelection selection = getTreeViewer().getSelection();
            if (selection.isEmpty()) {
                return;
            }
            IStructuredSelection structuredSelection = (IStructuredSelection) selection;
            Object obj = structuredSelection.getFirstElement();
            if (obj instanceof DatabaseModelBean) {
                List<DatabaseModelBean> currDbTypeServers = treeInputMap.get(currDbType);
                configer.deleteServerById(((DatabaseModelBean) obj).getId());
                int i = currDbTypeServers.indexOf(obj);
                currDbTypeServers.remove(i);
                getTreeViewer().refresh();
                if (currDbTypeServers.size() != 0) {
                    if (i > currDbTypeServers.size() - 1) {
                        setLastSelectedServer(currDbTypeServers.get(i - 1).getId());
                    } else {
                        setLastSelectedServer(currDbTypeServers.get(i).getId());
                    }
                    initUI(false);
                } else {
                    setLastSelectedServer(null);
                    initUI(true);
                }
                selectSaveItem();
            }
        }
    });
    Tree tree = treeViewer.getTree();
    this.treePopMenu = menuManager.createContextMenu(tree);
}
Also used : Action(org.eclipse.jface.action.Action) DatabaseModelBean(net.heartsome.cat.common.bean.DatabaseModelBean) MenuManager(org.eclipse.jface.action.MenuManager) ISelection(org.eclipse.jface.viewers.ISelection) Tree(org.eclipse.swt.widgets.Tree) WritableList(org.eclipse.core.databinding.observable.list.WritableList) List(java.util.List) ArrayList(java.util.ArrayList) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

Example 35 with MenuManager

use of org.eclipse.jface.action.MenuManager in project translationstudio8 by heartsome.

the class TableHierarchicalExample method createControls.

/**
     * Create the controls that compose the console test.
     * 
     */
protected void createControls(IHierarchicalJaretTableModel hierarchicalModel) {
    GridLayout gl = new GridLayout();
    gl.numColumns = 1;
    _shell.setLayout(gl);
    GridData gd = new GridData(GridData.FILL_BOTH);
    _jt = new JaretTable(_shell, SWT.V_SCROLL | SWT.H_SCROLL);
    _jt.setLayoutData(gd);
    IHierarchicalJaretTableModel hmodel = hierarchicalModel;
    if (hierarchicalModel == null) {
        ITableNode root = new DummyTableNode("tn1", "tn1", "Root", "This the root node");
        ITableNode r1 = new DummyTableNode("tn11", "tn12", "1", "Child 1 of the root");
        ITableNode r2 = new DummyTableNode("tn12", "tn12", "2", "Child 2 of the root");
        ITableNode r3 = new DummyTableNode("tn13", "tn13", "3", "Child 3 of the root");
        root.addNode(r1);
        root.addNode(r2);
        root.addNode(r3);
        r1.addNode(new DummyTableNode("tn111", "tn111", "1", "A second level child"));
        r1.addNode(new DummyTableNode("tn112", "tn112", "2", "Another second level child"));
        ITableNode n1 = new DummyTableNode("tn131", "tn131", "1", "A second level child");
        r3.addNode(n1);
        ITableNode n2 = new DummyTableNode("tn132", "tn132", "2", "Another second level child");
        r3.addNode(n2);
        n1.addNode(new DummyTableNode("tn1311", "tn1311", "1", "A third level child"));
        n1.addNode(new DummyTableNode("tn1312", "tn1312", "2", "Another third level child"));
        DefaultHierarchicalTableModel dhmodel = new DefaultHierarchicalTableModel(root);
        hmodel = dhmodel;
        if (SUPPORT_DND) {
            // init the simple drag and drop handling
            initDND(_jt, _shell);
        }
    }
    _jt.setTableModel(hmodel);
    StdHierarchicalTableModel model = (StdHierarchicalTableModel) _jt.getTableModel();
    IColumn hcol = new HierarchyColumn();
    // create and setup hierarchy renderer
    final TableHierarchyRenderer hierarchyRenderer = new TableHierarchyRenderer();
    hierarchyRenderer.setLabelProvider(new LabelProvider());
    hierarchyRenderer.setDrawIcons(true);
    hierarchyRenderer.setDrawLabels(true);
    _jt.registerCellRenderer(hcol, hierarchyRenderer);
    model.addColumn(hcol);
    model.addColumn(new PropCol("b1", "column 1", "B1"));
    model.addColumn(new PropCol("t1", "column 2", "T1"));
    model.addColumn(new PropCol("t2", "column 3", "T2"));
    model.addColumn(new PropCol("t3", "column 4", "T3"));
    JaretTableActionFactory af = new JaretTableActionFactory();
    MenuManager mm = new MenuManager();
    mm.add(af.createStdAction(_jt, JaretTableActionFactory.ACTION_CONFIGURECOLUMNS));
    _jt.setHeaderContextMenu(mm.createContextMenu(_jt));
    MenuManager rm = new MenuManager();
    rm.add(af.createStdAction(_jt, JaretTableActionFactory.ACTION_OPTROWHEIGHT));
    rm.add(af.createStdAction(_jt, JaretTableActionFactory.ACTION_OPTALLROWHEIGHTS));
    _jt.setRowContextMenu(rm.createContextMenu(_jt));
    TableControlPanel ctrlPanel = new TableControlPanel(_shell, SWT.NULL, _jt);
    Label l = new Label(_shell, SWT.NONE);
    l.setText("Level width:");
    final Scale levelWidthScale = new Scale(_shell, SWT.HORIZONTAL);
    levelWidthScale.setMaximum(40);
    levelWidthScale.setMinimum(0);
    levelWidthScale.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent ev) {
            int val = levelWidthScale.getSelection();
            hierarchyRenderer.setLevelWidth(val);
            _jt.redraw();
        }
    });
}
Also used : JaretTable(de.jaret.util.ui.table.JaretTable) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) JaretTableActionFactory(de.jaret.util.ui.table.util.action.JaretTableActionFactory) Scale(org.eclipse.swt.widgets.Scale) DefaultHierarchicalTableModel(de.jaret.util.ui.table.model.DefaultHierarchicalTableModel) TableHierarchyRenderer(de.jaret.util.ui.table.renderer.TableHierarchyRenderer) GridLayout(org.eclipse.swt.layout.GridLayout) IColumn(de.jaret.util.ui.table.model.IColumn) HierarchyColumn(de.jaret.util.ui.table.model.HierarchyColumn) PropCol(de.jaret.util.ui.table.model.PropCol) GridData(org.eclipse.swt.layout.GridData) MenuManager(org.eclipse.jface.action.MenuManager) SelectionEvent(org.eclipse.swt.events.SelectionEvent) IHierarchicalJaretTableModel(de.jaret.util.ui.table.model.IHierarchicalJaretTableModel) StdHierarchicalTableModel(de.jaret.util.ui.table.model.StdHierarchicalTableModel) ITableNode(de.jaret.util.ui.table.model.ITableNode) ILabelProvider(org.eclipse.jface.viewers.ILabelProvider)

Aggregations

MenuManager (org.eclipse.jface.action.MenuManager)657 IMenuManager (org.eclipse.jface.action.IMenuManager)498 Menu (org.eclipse.swt.widgets.Menu)303 IMenuListener (org.eclipse.jface.action.IMenuListener)246 Separator (org.eclipse.jface.action.Separator)220 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)65 Point (org.eclipse.swt.graphics.Point)63 Action (org.eclipse.jface.action.Action)55 Composite (org.eclipse.swt.widgets.Composite)49 IAction (org.eclipse.jface.action.IAction)48 SelectionEvent (org.eclipse.swt.events.SelectionEvent)44 GridData (org.eclipse.swt.layout.GridData)44 GroupMarker (org.eclipse.jface.action.GroupMarker)43 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)43 Transfer (org.eclipse.swt.dnd.Transfer)35 GridLayout (org.eclipse.swt.layout.GridLayout)32 List (java.util.List)30 EditingDomainViewerDropAdapter (org.eclipse.emf.edit.ui.dnd.EditingDomainViewerDropAdapter)30 LocalTransfer (org.eclipse.emf.edit.ui.dnd.LocalTransfer)30 ViewerDragAdapter (org.eclipse.emf.edit.ui.dnd.ViewerDragAdapter)30