Search in sources :

Example 41 with MenuItem

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

the class FavoriteQueryNavigatorView method createContextMenu.

private void createContextMenu() {
    final MenuManager menuManager = new MenuManager();
    menuManager.setRemoveAllWhenShown(true);
    final Menu contextMenu = menuManager.createContextMenu(tv.getTable());
    tv.getTable().setMenu(contextMenu);
    final Menu popupMenu = new Menu(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), SWT.POP_UP);
    tv.getTable().setMenu(popupMenu);
    final MenuItem openMenuItem = new MenuItem(popupMenu, SWT.PUSH);
    openMenuItem.setText(com.cubrid.common.ui.query.Messages.lblOpenSqlFavorite);
    openMenuItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            ISelection selection = tv.getSelection();
            openSelectedFile(selection);
        }
    });
    final MenuItem runMenuItem = new MenuItem(popupMenu, SWT.PUSH);
    runMenuItem.setText(com.cubrid.common.ui.query.Messages.lblRunSqlFavorite);
    runMenuItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            executeSql();
        }
    });
    new MenuItem(popupMenu, SWT.SEPARATOR);
    final MenuItem addMenuItem = new MenuItem(popupMenu, SWT.PUSH);
    addMenuItem.setText(Messages.btnAdd);
    addMenuItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            addFile();
        }
    });
    new MenuItem(popupMenu, SWT.SEPARATOR);
    final MenuItem removeMenuItem = new MenuItem(popupMenu, SWT.PUSH);
    removeMenuItem.setText(com.cubrid.common.ui.query.Messages.lblRemoveFromSqlFavorite);
    removeMenuItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            if (!CommonUITool.openConfirmBox(com.cubrid.common.ui.query.Messages.errBatchRunDel)) {
                return;
            }
            removeFavorite();
        }
    });
    final MenuItem delMenuItem = new MenuItem(popupMenu, SWT.PUSH);
    delMenuItem.setText(com.cubrid.common.ui.query.Messages.lblDeleteFromSqlFavorite);
    delMenuItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            if (!CommonUITool.openConfirmBox(com.cubrid.common.ui.query.Messages.errBatchRunDelWithFile)) {
                return;
            }
            removeFavoriteWithFileDeletion();
        }
    });
    popupMenu.addMenuListener(new MenuListener() {

        public void menuShown(MenuEvent e) {
            if (tv.getTable().getSelection().length == 0) {
                openMenuItem.setEnabled(false);
                runMenuItem.setEnabled(false);
                removeMenuItem.setEnabled(false);
                delMenuItem.setEnabled(false);
            } else {
                openMenuItem.setEnabled(true);
                runMenuItem.setEnabled(true);
                removeMenuItem.setEnabled(true);
                delMenuItem.setEnabled(true);
            }
        }

        public void menuHidden(MenuEvent e) {
        }
    });
}
Also used : MenuListener(org.eclipse.swt.events.MenuListener) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) MenuManager(org.eclipse.jface.action.MenuManager) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ISelection(org.eclipse.jface.viewers.ISelection) MenuItem(org.eclipse.swt.widgets.MenuItem) Menu(org.eclipse.swt.widgets.Menu) MenuEvent(org.eclipse.swt.events.MenuEvent)

Example 42 with MenuItem

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

the class CubridColumnNavigatorView method createPartControl.

public void createPartControl(Composite parent) {
    Composite comp = new Composite(parent, SWT.NONE);
    {
        GridLayout gl = new GridLayout(1, false);
        comp.setLayout(gl);
        GridData gd = new GridData(GridData.FILL_HORIZONTAL);
        comp.setLayoutData(gd);
    }
    lblSchemaName = new Label(comp, SWT.NONE);
    lblSchemaName.setText(com.cubrid.common.ui.common.Messages.lblQuickViewColInfo);
    {
        GridData gd = new GridData(GridData.FILL_HORIZONTAL);
        lblSchemaName.setLayoutData(gd);
    }
    tableColTableViewer = new TableViewer(comp, SWT.FULL_SELECTION | SWT.MULTI | SWT.BORDER);
    {
        GridData gd = new GridData(GridData.FILL_BOTH);
        tableColTableViewer.getTable().setLayoutData(gd);
        tableColTableViewer.getTable().setToolTipText(com.cubrid.common.ui.common.Messages.miniSchemaCopyColumnTooltip);
        final MenuManager menuManager = new MenuManager();
        menuManager.setRemoveAllWhenShown(true);
        final Menu contextMenu = menuManager.createContextMenu(tableColTableViewer.getTable());
        tableColTableViewer.getTable().setMenu(contextMenu);
        final Menu copyMenu = new Menu(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), SWT.POP_UP);
        tableColTableViewer.getTable().setMenu(copyMenu);
        tableColTableViewer.getTable().addKeyListener(new org.eclipse.swt.events.KeyAdapter() {

            public void keyPressed(org.eclipse.swt.events.KeyEvent event) {
                if ((event.stateMask & SWT.CTRL) != 0 && (event.stateMask & SWT.SHIFT) == 0 && event.keyCode == 'c') {
                    copyColumnListToClipboard(",");
                }
            }
        });
        final MenuItem copyMenuItem = new MenuItem(copyMenu, SWT.PUSH);
        copyMenuItem.setText(com.cubrid.common.ui.common.Messages.miniSchemaCopyColumnWithComma);
        copyMenuItem.setAccelerator(SWT.CTRL + 'C');
        copyMenuItem.addSelectionListener(new SelectionAdapter() {

            public void widgetSelected(SelectionEvent event) {
                copyColumnListToClipboard(",");
            }
        });
        final MenuItem copyMenuItem2 = new MenuItem(copyMenu, SWT.PUSH);
        copyMenuItem2.setText(com.cubrid.common.ui.common.Messages.miniSchemaCopyColumnWithNewline);
        copyMenuItem2.addSelectionListener(new SelectionAdapter() {

            public void widgetSelected(SelectionEvent event) {
                copyColumnListToClipboard(StringUtil.NEWLINE);
            }
        });
        new MenuItem(copyMenu, SWT.SEPARATOR);
        final MenuItem copyMenuItem3 = new MenuItem(copyMenu, SWT.PUSH);
        copyMenuItem3.setText(com.cubrid.common.ui.common.Messages.miniSchemaCopySelectQuery);
        copyMenuItem3.addSelectionListener(new SelectionAdapter() {

            public void widgetSelected(SelectionEvent event) {
                copySelectSQLToClipboard();
            }
        });
        final MenuItem copyMenuItem4 = new MenuItem(copyMenu, SWT.PUSH);
        copyMenuItem4.setText(com.cubrid.common.ui.common.Messages.miniSchemaCopyInsertQuery);
        copyMenuItem4.addSelectionListener(new SelectionAdapter() {

            public void widgetSelected(SelectionEvent event) {
                copyInsertSQLToClipboard();
            }
        });
        final MenuItem copyMenuItem5 = new MenuItem(copyMenu, SWT.PUSH);
        copyMenuItem5.setText(com.cubrid.common.ui.common.Messages.miniSchemaCopyUpdateQuery);
        copyMenuItem5.addSelectionListener(new SelectionAdapter() {

            public void widgetSelected(SelectionEvent event) {
                copyUpdateSQLToClipboard();
            }
        });
    }
    Table columnsTable = tableColTableViewer.getTable();
    columnsTable.setLinesVisible(true);
    columnsTable.setHeaderVisible(true);
    final TableColumn pkColumn = new TableColumn(columnsTable, SWT.NONE);
    pkColumn.setAlignment(SWT.CENTER);
    pkColumn.setWidth(30);
    pkColumn.setText(Messages.tblColumnPK);
    final TableColumn nameColumn = new TableColumn(columnsTable, SWT.NONE);
    nameColumn.setWidth(90);
    nameColumn.setText(Messages.tblColumnName);
    final TableColumn dataTypeColumn = new TableColumn(columnsTable, SWT.NONE);
    dataTypeColumn.setWidth(120);
    dataTypeColumn.setText(Messages.tblColumnDataType);
    final TableColumn defaultColumn = new TableColumn(columnsTable, SWT.NONE);
    defaultColumn.setWidth(98);
    defaultColumn.setText(Messages.tblColumnDefault);
    final TableColumn autoIncrTableColumn = new TableColumn(columnsTable, SWT.NONE);
    autoIncrTableColumn.setAlignment(SWT.CENTER);
    autoIncrTableColumn.setWidth(100);
    autoIncrTableColumn.setText(Messages.tblColumnAutoIncr);
    final TableColumn notNullColumn = new TableColumn(columnsTable, SWT.NONE);
    notNullColumn.setWidth(70);
    notNullColumn.setText(Messages.tblColumnNotNull);
    notNullColumn.setAlignment(SWT.CENTER);
    final TableColumn uniqueColumn = new TableColumn(columnsTable, SWT.NONE);
    uniqueColumn.setWidth(70);
    uniqueColumn.setText(Messages.tblColumnUnique);
    uniqueColumn.setAlignment(SWT.CENTER);
    final TableColumn sharedColumn = new TableColumn(columnsTable, SWT.NONE);
    sharedColumn.setWidth(60);
    sharedColumn.setResizable(false);
    sharedColumn.setText(Messages.tblColumnShared);
    sharedColumn.setAlignment(SWT.CENTER);
    final TableColumn inheritColumn = new TableColumn(columnsTable, SWT.NONE);
    inheritColumn.setAlignment(SWT.CENTER);
    inheritColumn.setWidth(90);
    inheritColumn.setResizable(false);
    inheritColumn.setText(Messages.tblColumnInherit);
    final TableColumn classColumn = new TableColumn(columnsTable, SWT.NONE);
    classColumn.setWidth(90);
    classColumn.setResizable(false);
    classColumn.setText(Messages.tblColumnClass);
    classColumn.setAlignment(SWT.CENTER);
}
Also used : Table(org.eclipse.swt.widgets.Table) Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) MenuItem(org.eclipse.swt.widgets.MenuItem) TableColumn(org.eclipse.swt.widgets.TableColumn) GridLayout(org.eclipse.swt.layout.GridLayout) GridData(org.eclipse.swt.layout.GridData) MenuManager(org.eclipse.jface.action.MenuManager) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Menu(org.eclipse.swt.widgets.Menu) TableViewer(org.eclipse.jface.viewers.TableViewer)

Example 43 with MenuItem

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

the class SelectColorCombo method buildColorMenuItem.

/**
	 * Create the menuitem which would be used on the host type.
	 *
	 * @param menu
	 * @param colorIndex
	 * @param message
	 * @return
	 */
private MenuItem buildColorMenuItem(final Menu menu, final int colorIndex, final String message) {
    MenuItem menuItem = new MenuItem(menu, SWT.PUSH);
    menuItem.setText(message);
    menuItem.setImage(CommonUIPlugin.getImage("icons/control/color_" + colorIndex + ".GIF"));
    menuItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            selectedColor = EditorConstance.getAvaliableBackground().get(colorIndex);
            serverTypeLabel.setBackground(ResourceManager.getColor(selectedColor));
            serverTypeLabel.setText(message);
        }
    });
    return menuItem;
}
Also used : SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SelectionEvent(org.eclipse.swt.events.SelectionEvent) MenuItem(org.eclipse.swt.widgets.MenuItem)

Example 44 with MenuItem

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

the class DatabaseDashboardEditor method createBrokerComposite.

/**
	 * craete broker composite
	 *
	 * @param bar
	 * @param bar index
	 *
	 */
public void createBrokerComposite(ExpandBar bar, int index) {
    ExpandItem brokerItem = new ExpandItem(bar, SWT.NONE, index);
    brokerItem.setText(Messages.exportDashboardBrokerTableTitle);
    Composite brokerComposite = new Composite(bar, SWT.None);
    brokerComposite.setLayout(new FillLayout());
    brokerInfoTableViewer = new TableViewer(brokerComposite, SWT.BORDER | SWT.FULL_SELECTION);
    brokerInfoTable = brokerInfoTableViewer.getTable();
    brokerInfoTable.setHeaderVisible(true);
    brokerInfoTable.setLinesVisible(true);
    final TableViewerColumn columnVolumn = new TableViewerColumn(brokerInfoTableViewer, SWT.CENTER);
    columnVolumn.getColumn().setWidth(100);
    columnVolumn.getColumn().setText("Broker");
    columnVolumn.getColumn().setToolTipText(com.cubrid.cubridmanager.ui.host.Messages.tipBrokerName);
    final TableViewerColumn columnType = new TableViewerColumn(brokerInfoTableViewer, SWT.CENTER);
    columnType.getColumn().setWidth(80);
    columnType.getColumn().setText("ID");
    columnType.getColumn().setToolTipText(Messages.brokerTableIDColumnTip);
    final TableViewerColumn columnSize = new TableViewerColumn(brokerInfoTableViewer, SWT.CENTER);
    columnSize.getColumn().setWidth(100);
    columnSize.getColumn().setText("PID");
    columnSize.getColumn().setToolTipText(Messages.brokerTablePIDColumnTip);
    final TableViewerColumn columnQPS = new TableViewerColumn(brokerInfoTableViewer, SWT.CENTER);
    columnQPS.getColumn().setWidth(100);
    columnQPS.getColumn().setText("QPS");
    columnQPS.getColumn().setToolTipText(com.cubrid.cubridmanager.ui.host.Messages.tipQps);
    final TableViewerColumn columnFreeSize = new TableViewerColumn(brokerInfoTableViewer, SWT.CENTER);
    columnFreeSize.getColumn().setWidth(100);
    columnFreeSize.getColumn().setText("LQS");
    columnFreeSize.getColumn().setToolTipText(Messages.brokerTableLQSColumnTip);
    final TableViewerColumn columnTotalSize = new TableViewerColumn(brokerInfoTableViewer, SWT.CENTER);
    columnTotalSize.getColumn().setWidth(80);
    columnTotalSize.getColumn().setText(Messages.multiDatabaseLoginDialogColumnStatus);
    columnTotalSize.getColumn().setToolTipText(Messages.multiDatabaseLoginDialogColumnStatus);
    final TableViewerColumn columnLocation = new TableViewerColumn(brokerInfoTableViewer, SWT.CENTER);
    columnLocation.getColumn().setWidth(140);
    columnLocation.getColumn().setText(Messages.brokerTableLastConnectTimeColumnLabel);
    columnLocation.getColumn().setToolTipText(Messages.brokerTableLastConnectTimeColumnLabel);
    brokerInfoTableViewer.setContentProvider(new TableContentProvider());
    brokerInfoTableViewer.setLabelProvider(new TableLabelProvider());
    brokerInfoTableViewer.setInput(brokerInfoListData);
    brokerItem.setControl(brokerComposite);
    brokerItem.setHeight(140);
    brokerItem.setExpanded(true);
    Menu menu = new Menu(this.getSite().getShell(), SWT.POP_UP);
    final MenuItem itemRestartCAS = new MenuItem(menu, SWT.PUSH);
    itemRestartCAS.setText(Messages.exportDashboardMenuRestartServer);
    itemRestartCAS.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            int i = brokerInfoTable.getSelectionIndex();
            if (i < 0) {
                return;
            }
            String brokerName = brokerInfoTable.getItem(i).getText(0);
            String serverId = brokerInfoTable.getItem(i).getText(1);
            if (!CommonUITool.openConfirmBox(Messages.bind(com.cubrid.cubridmanager.ui.broker.Messages.restartBrokerServerMsg, serverId))) {
                return;
            }
            ServerInfo serverInfo = database.getServer().getServerInfo();
            RestartBrokerTask restartTask = new RestartBrokerTask(serverInfo);
            restartTask.setBrokerName(brokerName);
            restartTask.setApplyServerNum(serverId);
            TaskExecutor taskExecutor = new CommonTaskExec(Messages.bind(com.cubrid.cubridmanager.ui.broker.Messages.restartBrokerServerTaskName, serverId));
            taskExecutor.addTask(restartTask);
            new ExecTaskWithProgress(taskExecutor).exec();
            if (taskExecutor.isSuccess()) {
                // refresh
                brokerInfoListData.clear();
                asinfoLst.clear();
                brokerInfoTable.remove(i);
                loadBrokerInfo();
                //recompute database's qps
                long qps = 0;
                for (HashMap<String, ApplyServerInfo> brokerValueMap : asinfoLst) {
                    for (Entry<String, ApplyServerInfo> entry : brokerValueMap.entrySet()) {
                        ApplyServerInfo applyServerInfo = entry.getValue();
                        qps += Long.valueOf(applyServerInfo.getAs_num_query());
                    }
                }
                Map<String, String> dbInfoMap = brokerInfoListData.get(0);
                dbInfoMap.put("2", Long.toString(qps));
                if (CompatibleUtil.isSupportGetCPUAndMemoryInfo(database.getDatabaseInfo())) {
                    dbInfoTableViewer.refresh();
                }
                brokerInfoTableViewer.refresh();
            }
        }
    });
    final MenuItem itemShowSqlLog = new MenuItem(menu, SWT.PUSH);
    itemShowSqlLog.setText(Messages.exportDashboardMenuShowSQLLog);
    itemShowSqlLog.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            showLogView("sql");
        }
    });
    final MenuItem itemShowSlowQueryLog = new MenuItem(menu, SWT.PUSH);
    itemShowSlowQueryLog.setText(Messages.exportDashboardMenuShowSlowQueryLog);
    itemShowSlowQueryLog.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            showLogView("slow");
        }
    });
    menu.addMenuListener(new MenuListener() {

        public void menuHidden(MenuEvent e) {
        }

        public void menuShown(MenuEvent e) {
            int i = brokerInfoTable.getSelectionIndex();
            if (i < 0) {
                Menu menu = (Menu) e.getSource();
                menu.setVisible(false);
            }
        }
    });
    brokerInfoTable.setMenu(menu);
    tableViewOnBarIndexMap.put(brokerInfoTableViewer, index);
}
Also used : CommonTaskExec(com.cubrid.common.ui.spi.progress.CommonTaskExec) Composite(org.eclipse.swt.widgets.Composite) HashMap(java.util.HashMap) ApplyServerInfo(com.cubrid.cubridmanager.core.broker.model.ApplyServerInfo) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) MenuListener(org.eclipse.swt.events.MenuListener) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) MenuItem(org.eclipse.swt.widgets.MenuItem) FillLayout(org.eclipse.swt.layout.FillLayout) TableLabelProvider(com.cubrid.common.ui.spi.TableLabelProvider) ApplyServerInfo(com.cubrid.cubridmanager.core.broker.model.ApplyServerInfo) TaskExecutor(com.cubrid.common.ui.spi.progress.TaskExecutor) DbLotEntry(com.cubrid.cubridmanager.core.cubrid.database.model.lock.DbLotEntry) Entry(java.util.Map.Entry) ExpandItem(org.eclipse.swt.widgets.ExpandItem) TableContentProvider(com.cubrid.common.ui.spi.TableContentProvider) SelectionEvent(org.eclipse.swt.events.SelectionEvent) RestartBrokerTask(com.cubrid.cubridmanager.core.broker.task.RestartBrokerTask) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress) Menu(org.eclipse.swt.widgets.Menu) TableViewer(org.eclipse.jface.viewers.TableViewer) Map(java.util.Map) TreeMap(java.util.TreeMap) HashMap(java.util.HashMap) TableViewerColumn(org.eclipse.jface.viewers.TableViewerColumn) MenuEvent(org.eclipse.swt.events.MenuEvent)

Example 45 with MenuItem

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

the class DatabaseDashboardEditor method createLockAndTransactionComposite.

/**
	 * create lock and transaction composite
	 *
	 * @param bar ExpandBar
	 * @param bar index
	 *
	 */
public void createLockAndTransactionComposite(ExpandBar bar, int index) {
    ExpandItem lockAndTransactionItem = new ExpandItem(bar, SWT.NONE, index);
    lockAndTransactionItem.setText(Messages.exportDashboardLockTableTitle);
    Composite lockAndTransactionComposite = new Composite(bar, SWT.NONE);
    lockAndTransactionComposite.setLayout(new FillLayout());
    lockAndTransactionTableViewer = new TableViewer(lockAndTransactionComposite, SWT.BORDER | SWT.FULL_SELECTION);
    lockAndTransactionTable = lockAndTransactionTableViewer.getTable();
    lockAndTransactionTable.setHeaderVisible(true);
    lockAndTransactionTable.setLinesVisible(true);
    final TableViewerColumn columnTranIndex = new TableViewerColumn(lockAndTransactionTableViewer, SWT.CENTER);
    columnTranIndex.getColumn().setWidth(80);
    columnTranIndex.getColumn().setText(Messages.tblColTranInfoTranIndex);
    columnTranIndex.getColumn().setToolTipText(Messages.tblColTranInfoTranIndex);
    final TableViewerColumn columnUserName = new TableViewerColumn(lockAndTransactionTableViewer, SWT.CENTER);
    columnUserName.getColumn().setWidth(80);
    columnUserName.getColumn().setText(Messages.tblColTranInfoUserName);
    columnUserName.getColumn().setToolTipText(Messages.tblColTranInfoUserName);
    final TableViewerColumn columnHost = new TableViewerColumn(lockAndTransactionTableViewer, SWT.CENTER);
    columnHost.getColumn().setWidth(130);
    columnHost.getColumn().setText(Messages.tblColTranInfoHost);
    columnHost.getColumn().setToolTipText(Messages.tblColTranInfoHost);
    final TableViewerColumn columnPid = new TableViewerColumn(lockAndTransactionTableViewer, SWT.CENTER);
    columnPid.getColumn().setWidth(80);
    columnPid.getColumn().setText(Messages.tblColTranInfoProcessId);
    columnPid.getColumn().setToolTipText(Messages.tblColTranInfoProcessId);
    final TableViewerColumn columnType = new TableViewerColumn(lockAndTransactionTableViewer, SWT.BEGINNING);
    columnType.getColumn().setWidth(320);
    columnType.getColumn().setText(Messages.tblColLockInfoObjectType);
    columnType.getColumn().setToolTipText(Messages.tblColLockInfoObjectType);
    columnPid.getColumn().setAlignment(SWT.CENTER);
    final TableViewerColumn columnMode = new TableViewerColumn(lockAndTransactionTableViewer, SWT.CENTER);
    columnMode.getColumn().setWidth(100);
    columnMode.getColumn().setText(Messages.tblColLockInfoMode);
    columnMode.getColumn().setToolTipText(Messages.tblColLockInfoMode);
    lockAndTransactionTableViewer.setContentProvider(new TableContentProvider());
    lockAndTransactionTableViewer.setLabelProvider(new TableLabelProvider());
    lockAndTransactionTableViewer.setInput(lockAndTransactionListData);
    lockAndTransactionItem.setControl(lockAndTransactionComposite);
    lockAndTransactionItem.setHeight(140);
    lockAndTransactionItem.setExpanded(true);
    Menu menu = new Menu(this.getSite().getShell(), SWT.POP_UP);
    final MenuItem itemKillTran = new MenuItem(menu, SWT.PUSH);
    itemKillTran.setText(Messages.menuKillTransaction);
    itemKillTran.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            int i = lockAndTransactionTable.getSelectionIndex();
            if (i < 0) {
                return;
            }
            String pid = lockAndTransactionTable.getItem(i).getText(3);
            if (i >= 0 && dbTransactionList != null && dbTransactionList.getTransationInfo() != null && dbTransactionList.getTransationInfo().getTransactionList() != null) {
                KillTransactionDialog dlg = new KillTransactionDialog(Display.getCurrent().getActiveShell());
                Transaction bean = null;
                for (Transaction t : dbTransactionList.getTransationInfo().getTransactionList()) {
                    if (pid.equals(t.getPid())) {
                        bean = t;
                    }
                }
                dlg.setTransationInfo(bean);
                dlg.setDatabase(database);
                if (dlg.open() == IDialogConstants.CANCEL_ID) {
                    return;
                }
                dbTransactionList.getTransationInfo().setTransactionList(dlg.getKillTransactionList().getTransationInfo().getTransactionList());
                lockAndTransactionListData.clear();
                lockAndTransactionTableViewer.getTable().clearAll();
                loadTransactionInfo();
                lockAndTransactionTableViewer.refresh();
            }
        }
    });
    menu.addMenuListener(new MenuListener() {

        public void menuHidden(MenuEvent e) {
        }

        public void menuShown(MenuEvent e) {
            int i = lockAndTransactionTableViewer.getTable().getSelectionIndex();
            if (i < 0) {
                Menu menu = (Menu) e.getSource();
                menu.setVisible(false);
            }
        }
    });
    lockAndTransactionTable.setMenu(menu);
    tableViewOnBarIndexMap.put(lockAndTransactionTableViewer, index);
}
Also used : Composite(org.eclipse.swt.widgets.Composite) MenuListener(org.eclipse.swt.events.MenuListener) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) MenuItem(org.eclipse.swt.widgets.MenuItem) FillLayout(org.eclipse.swt.layout.FillLayout) TableLabelProvider(com.cubrid.common.ui.spi.TableLabelProvider) KillTransactionDialog(com.cubrid.cubridmanager.ui.cubrid.database.dialog.KillTransactionDialog) DatabaseTransaction(com.cubrid.cubridmanager.core.cubrid.database.model.lock.DatabaseTransaction) Transaction(com.cubrid.cubridmanager.core.cubrid.database.model.transaction.Transaction) ExpandItem(org.eclipse.swt.widgets.ExpandItem) TableContentProvider(com.cubrid.common.ui.spi.TableContentProvider) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Menu(org.eclipse.swt.widgets.Menu) TableViewer(org.eclipse.jface.viewers.TableViewer) TableViewerColumn(org.eclipse.jface.viewers.TableViewerColumn) MenuEvent(org.eclipse.swt.events.MenuEvent)

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