Search in sources :

Example 31 with MenuItem

use of org.eclipse.swt.widgets.MenuItem in project cubrid-manager by CUBRID.

the class PstmtSQLDialog method registerContextMenu.

private void registerContextMenu() {
    parameterTable.getTable().addFocusListener(new FocusAdapter() {

        @Override
        public void focusGained(FocusEvent event) {
            ActionManager.getInstance().changeFocusProvider(parameterTable.getTable());
        }
    });
    MenuManager menuManager = new MenuManager();
    menuManager.setRemoveAllWhenShown(true);
    Menu contextMenu = menuManager.createContextMenu(parameterTable.getTable());
    parameterTable.getTable().setMenu(contextMenu);
    Menu menu = new Menu(getShell(), SWT.POP_UP);
    final MenuItem itemShowMuchValue = new MenuItem(menu, SWT.PUSH);
    itemShowMuchValue.setText(Messages.pstmtSQLMuchItem);
    itemShowMuchValue.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            //seems like MenuEvent can't get the mouse click Point
            //so use the point which table MouseDown event marked
            Point pt = clickPoint;
            int selectIndex = parameterTable.getTable().getSelectionIndex();
            final TableItem item = parameterTable.getTable().getItem(selectIndex);
            if (item == null) {
                return;
            }
            for (int i = 1; i < parameterTable.getTable().getColumnCount(); i++) {
                Rectangle rect = item.getBounds(i);
                if (rect.contains(pt)) {
                    String type = parameterTypeTable.getItem(0).getText(i);
                    SetPstmtValueDialog dialog = new SetPstmtValueDialog(getShell(), item, database, i, type);
                    if (IDialogConstants.OK_ID == dialog.open()) {
                        charSet = (String) item.getData(SetPstmtValueDialog.FILE_CHARSET);
                        valueList.get(selectIndex).getValue().set(i, item.getText(i));
                        packTable();
                        addTableItemToLast(selectIndex, item);
                    }
                    validate();
                }
            }
        }
    });
    menu.addMenuListener(new MenuAdapter() {

        public void menuShown(MenuEvent event) {
            //seems like MenuEvent can't get the mouse click Point
            //so use the point which table MouseDown event marked
            Point pt = clickPoint;
            int selectIndex = parameterTable.getTable().getSelectionIndex();
            if (selectIndex < 0) {
                itemShowMuchValue.setEnabled(false);
                return;
            }
            final TableItem item = parameterTable.getTable().getItem(selectIndex);
            if (item == null) {
                itemShowMuchValue.setEnabled(false);
                return;
            }
            for (int i = 1; i < parameterTable.getTable().getColumnCount(); i++) {
                Rectangle rect = item.getBounds(i);
                if (rect.contains(pt)) {
                    String type = parameterTypeTable.getItem(0).getText(i);
                    //if type is nut much value type ,set the menu disable
                    if (DBAttrTypeFormatter.isMuchValueType(type)) {
                        itemShowMuchValue.setEnabled(true);
                    } else {
                        itemShowMuchValue.setEnabled(false);
                    }
                }
            }
        }
    });
    parameterTable.getTable().setMenu(menu);
}
Also used : FocusAdapter(org.eclipse.swt.events.FocusAdapter) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) TableItem(org.eclipse.swt.widgets.TableItem) Rectangle(org.eclipse.swt.graphics.Rectangle) MenuAdapter(org.eclipse.swt.events.MenuAdapter) MenuItem(org.eclipse.swt.widgets.MenuItem) Point(org.eclipse.swt.graphics.Point) FocusEvent(org.eclipse.swt.events.FocusEvent) MenuManager(org.eclipse.jface.action.MenuManager) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Menu(org.eclipse.swt.widgets.Menu) MenuEvent(org.eclipse.swt.events.MenuEvent)

Example 32 with MenuItem

use of org.eclipse.swt.widgets.MenuItem in project cubrid-manager by CUBRID.

the class DBAuthComparator method registerContextMenu.

/**
	 * register context menu
	 */
private void registerContextMenu() {
    userTableViewer.getTable().addFocusListener(new FocusAdapter() {

        public void focusGained(FocusEvent event) {
            ActionManager.getInstance().changeFocusProvider(userTableViewer.getTable());
        }
    });
    MenuManager menuManager = new MenuManager();
    menuManager.setRemoveAllWhenShown(true);
    Menu contextMenu = menuManager.createContextMenu(userTableViewer.getTable());
    userTableViewer.getTable().setMenu(contextMenu);
    Menu menu = new Menu(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), SWT.POP_UP);
    final MenuItem editSerialItem = new MenuItem(menu, SWT.PUSH);
    editSerialItem.setText(Messages.itemEditUser);
    editSerialItem.setImage(CommonUIPlugin.getImage("icons/action/user_edit.png"));
    editSerialItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            editUser();
        }
    });
    final MenuItem dropSerialItem = new MenuItem(menu, SWT.PUSH);
    dropSerialItem.setText(Messages.itemDropUser);
    dropSerialItem.setImage(CommonUIPlugin.getImage("icons/action/user_delete.png"));
    dropSerialItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            dropUser();
        }
    });
    new MenuItem(menu, SWT.SEPARATOR);
    final MenuItem addSerialItem = new MenuItem(menu, SWT.PUSH);
    addSerialItem.setText(Messages.itemAddUser);
    addSerialItem.setImage(CommonUIPlugin.getImage("icons/action/user_add.png"));
    addSerialItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            addUser();
        }
    });
    userTableViewer.getTable().setMenu(menu);
}
Also used : FocusAdapter(org.eclipse.swt.events.FocusAdapter) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) MenuManager(org.eclipse.jface.action.MenuManager) SelectionEvent(org.eclipse.swt.events.SelectionEvent) MenuItem(org.eclipse.swt.widgets.MenuItem) Menu(org.eclipse.swt.widgets.Menu) FocusEvent(org.eclipse.swt.events.FocusEvent)

Example 33 with MenuItem

use of org.eclipse.swt.widgets.MenuItem in project cubrid-manager by CUBRID.

the class EditVirtualTableDialog method buildColumnTableMenu.

private void buildColumnTableMenu() {
    Menu menu = new Menu(columnsTable.getShell(), SWT.POP_UP);
    columnsTable.setMenu(menu);
    final MenuItem deleteItem = new MenuItem(menu, SWT.PUSH);
    deleteItem.setText(Messages.itemDeleteColumn);
    deleteItem.setImage(CommonUIPlugin.getImageDescriptor("icons/action/table_record_delete.png").createImage());
    deleteItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            deleteColumn();
        }
    });
    menu.addMenuListener(new MenuListener() {

        public void menuShown(MenuEvent e) {
            TableItem[] tblItems = columnsTable.getSelection();
            if (tblItems.length > 0) {
                DBAttribute attr = (DBAttribute) tblItems[0].getData();
                List<DBAttribute> items = getNewSchemaInfo().getAttributes();
                if (!items.contains(attr)) {
                    deleteItem.setEnabled(false);
                } else {
                    deleteItem.setEnabled(true);
                }
            }
        }

        public void menuHidden(MenuEvent e) {
        }
    });
}
Also used : MenuListener(org.eclipse.swt.events.MenuListener) DBAttribute(com.cubrid.common.core.common.model.DBAttribute) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SelectionEvent(org.eclipse.swt.events.SelectionEvent) MenuItem(org.eclipse.swt.widgets.MenuItem) ArrayList(java.util.ArrayList) List(java.util.List) Menu(org.eclipse.swt.widgets.Menu) MenuEvent(org.eclipse.swt.events.MenuEvent)

Example 34 with MenuItem

use of org.eclipse.swt.widgets.MenuItem in project cubrid-manager by CUBRID.

the class ViewDashboardEditorPart method registerContextMenu.

private void registerContextMenu() {
    viewsDetailInfoTable.getTable().addFocusListener(new FocusAdapter() {

        public void focusGained(FocusEvent event) {
            ActionManager.getInstance().changeFocusProvider(viewsDetailInfoTable.getTable());
        }
    });
    MenuManager menuManager = new MenuManager();
    menuManager.setRemoveAllWhenShown(true);
    Menu contextMenu = menuManager.createContextMenu(viewsDetailInfoTable.getTable());
    viewsDetailInfoTable.getTable().setMenu(contextMenu);
    Menu menu = new Menu(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), SWT.POP_UP);
    final MenuItem editViewItem = new MenuItem(menu, SWT.PUSH);
    editViewItem.setText(Messages.viewDetailInfoPartTableEditViewBtn);
    editViewItem.setImage(CommonUIPlugin.getImage("icons/action/schema_view_edit.png"));
    editViewItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            editView();
        }
    });
    final MenuItem dropViewItem = new MenuItem(menu, SWT.PUSH);
    dropViewItem.setText(Messages.viewDetailInfoPartTableDropViewBtn);
    dropViewItem.setImage(CommonUIPlugin.getImage("icons/action/schema_view_delete.png"));
    dropViewItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            dropView();
        }
    });
    new MenuItem(menu, SWT.SEPARATOR);
    final MenuItem addViewItem = new MenuItem(menu, SWT.PUSH);
    addViewItem.setText(Messages.viewDetailInfoPartTableCreateViewBtn);
    addViewItem.setImage(CommonUIPlugin.getImage("icons/action/schema_view_add.png"));
    addViewItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            addView();
        }
    });
    viewsDetailInfoTable.getTable().setMenu(menu);
}
Also used : FocusAdapter(org.eclipse.swt.events.FocusAdapter) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) MenuManager(org.eclipse.jface.action.MenuManager) SelectionEvent(org.eclipse.swt.events.SelectionEvent) MenuItem(org.eclipse.swt.widgets.MenuItem) Menu(org.eclipse.swt.widgets.Menu) FocusEvent(org.eclipse.swt.events.FocusEvent)

Example 35 with MenuItem

use of org.eclipse.swt.widgets.MenuItem in project cubrid-manager by CUBRID.

the class ViewDashboardEditorPart method createTabFolder.

public void createTabFolder(Composite parent) {
    tabFolder = new CTabFolder(parent, SWT.TOP);
    tabFolder.setLayout(new FillLayout());
    tabFolder.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    tabFolder.setSimple(false);
    tabFolder.setUnselectedImageVisible(true);
    tabFolder.setUnselectedCloseVisible(true);
    tabFolder.setBorderVisible(true);
    tabFolder.setSelectionBackground(ResourceManager.getColor(136, 161, 227));
    tabFolder.setSelectionForeground(ResourceManager.getColor(SWT.COLOR_BLACK));
    Menu menu = new Menu(tabFolder.getShell(), SWT.POP_UP);
    tabFolder.setMenu(menu);
    MenuItem closeItem = new MenuItem(menu, SWT.PUSH);
    closeItem.setText(Messages.tablesDetailInfoPartCloseMenu);
    closeItem.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            widgetDefaultSelected(e);
        }

        public void widgetDefaultSelected(SelectionEvent e) {
            CTabItem item = tabFolder.getSelection();
            item.dispose();
        }
    });
    MenuItem closeOthersItem = new MenuItem(menu, SWT.PUSH);
    closeOthersItem.setText(Messages.tablesDetailInfoPartCloseOthersMenu);
    closeOthersItem.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            widgetDefaultSelected(e);
        }

        public void widgetDefaultSelected(SelectionEvent e) {
            CTabItem[] items = tabFolder.getItems();
            CTabItem selectedItem = tabFolder.getSelection();
            for (CTabItem item : items) {
                if (!item.equals(selectedItem)) {
                    item.dispose();
                }
            }
        }
    });
    MenuItem closeAllItem = new MenuItem(menu, SWT.PUSH);
    closeAllItem.setText(Messages.tablesDetailInfoPartCloseAllMenu);
    closeAllItem.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            widgetDefaultSelected(e);
        }

        public void widgetDefaultSelected(SelectionEvent e) {
            CTabItem[] items = tabFolder.getItems();
            for (CTabItem item : items) {
                item.dispose();
            }
        }
    });
}
Also used : CTabFolder(org.eclipse.swt.custom.CTabFolder) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) MenuItem(org.eclipse.swt.widgets.MenuItem) FillLayout(org.eclipse.swt.layout.FillLayout) Menu(org.eclipse.swt.widgets.Menu) ViewsDetailInfoCTabItem(com.cubrid.common.ui.cubrid.view.editor.ViewDashboardComposite.ViewsDetailInfoCTabItem) CTabItem(org.eclipse.swt.custom.CTabItem) SelectionListener(org.eclipse.swt.events.SelectionListener)

Aggregations

MenuItem (org.eclipse.swt.widgets.MenuItem)181 Menu (org.eclipse.swt.widgets.Menu)138 SelectionEvent (org.eclipse.swt.events.SelectionEvent)100 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)81 ArrayList (java.util.ArrayList)38 GridData (org.eclipse.swt.layout.GridData)37 Point (org.eclipse.swt.graphics.Point)35 SelectionListener (org.eclipse.swt.events.SelectionListener)34 Composite (org.eclipse.swt.widgets.Composite)33 GridLayout (org.eclipse.swt.layout.GridLayout)31 Rectangle (org.eclipse.swt.graphics.Rectangle)27 Table (org.eclipse.swt.widgets.Table)26 Label (org.eclipse.swt.widgets.Label)25 List (java.util.List)23 MenuManager (org.eclipse.jface.action.MenuManager)23 Image (org.eclipse.swt.graphics.Image)23 FillLayout (org.eclipse.swt.layout.FillLayout)23 Button (org.eclipse.swt.widgets.Button)23 FileDialog (org.eclipse.swt.widgets.FileDialog)22 Shell (org.eclipse.swt.widgets.Shell)22