Search in sources :

Example 46 with IDoubleClickListener

use of org.eclipse.jface.viewers.IDoubleClickListener in project cubrid-manager by CUBRID.

the class SqlmapNavigatorView method createParamView.

private void createParamView(Composite parent) {
    String[] columnNames = { Messages.lblSqlmapName, Messages.lblSqlmapValue, Messages.lblSqlmapType };
    Label lblCondTitle = new Label(parent, SWT.NONE);
    lblCondTitle.setText(Messages.lblSqlmapParameters);
    paramView = CommonUITool.createCommonTableViewer(parent, null, columnNames, CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, 120));
    paramView.setColumnProperties(columnNames);
    paramView.setContentProvider(new TableContentProvider());
    paramView.setLabelProvider(new TableLabelProvider());
    TableLayout tableLayout = new TableLayout();
    tableLayout.addColumnData(new ColumnPixelData(100));
    tableLayout.addColumnData(new ColumnPixelData(80));
    tableLayout.addColumnData(new ColumnPixelData(70));
    paramView.getTable().setLayout(tableLayout);
    paramView.addDoubleClickListener(new IDoubleClickListener() {

        @SuppressWarnings("unchecked")
        public void doubleClick(DoubleClickEvent event) {
            StructuredSelection sel = (StructuredSelection) event.getSelection();
            Map<String, String> data = (Map<String, String>) sel.getFirstElement();
            modifyParam(data);
        }
    });
    Menu menu = new Menu(paramView.getTable().getShell(), SWT.POP_UP);
    paramView.getTable().setMenu(menu);
    final MenuItem addMenuItem = new MenuItem(menu, SWT.PUSH);
    addMenuItem.setText(Messages.mnuSqlmapAdd);
    addMenuItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            addParameter();
        }
    });
    final MenuItem modifyMenuItem = new MenuItem(menu, SWT.PUSH);
    modifyMenuItem.setText(Messages.mnuSqlmapModify);
    modifyMenuItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            modifyParameterByCurrentSelected();
        }
    });
    final MenuItem delMenuItem = new MenuItem(menu, SWT.PUSH);
    delMenuItem.setText(Messages.mnuSqlmapRemove);
    delMenuItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            if (CommonUITool.openConfirmBox(Messages.msgSqlmapRemove)) {
                removeParameterByCurrentSelected();
            }
        }
    });
}
Also used : SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) ColumnPixelData(org.eclipse.jface.viewers.ColumnPixelData) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) MenuItem(org.eclipse.swt.widgets.MenuItem) TableLabelProvider(com.cubrid.common.ui.spi.TableLabelProvider) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) TableContentProvider(com.cubrid.common.ui.spi.TableContentProvider) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Menu(org.eclipse.swt.widgets.Menu) TableLayout(org.eclipse.jface.viewers.TableLayout) Map(java.util.Map) HashMap(java.util.HashMap)

Example 47 with IDoubleClickListener

use of org.eclipse.jface.viewers.IDoubleClickListener in project dbeaver by serge-rider.

the class PostgresRolePrivilegesEditor method createPartControl.

@Override
public void createPartControl(Composite parent) {
    this.boldFont = UIUtils.makeBoldFont(parent.getFont());
    parent.addDisposeListener(new DisposeListener() {

        @Override
        public void widgetDisposed(DisposeEvent e) {
            UIUtils.dispose(boldFont);
        }
    });
    this.pageControl = new PageControl(parent);
    this.pageControl.createOrSubstituteProgressPanel(getSite());
    this.pageControl.setDoubleClickHandler(new IDoubleClickListener() {

        @Override
        public void doubleClick(DoubleClickEvent event) {
            final ISelection selection = pageControl.getSelectionProvider().getSelection();
            if (!selection.isEmpty() && selection instanceof IStructuredSelection) {
                final PostgrePermission element = (PostgrePermission) ((IStructuredSelection) selection).getFirstElement();
                new AbstractJob("Open target object") {

                    @Override
                    protected IStatus run(DBRProgressMonitor monitor) {
                        try {
                            final PostgreObject targetObject = element.getTargetObject(monitor);
                            if (targetObject != null) {
                                DBeaverUI.syncExec(new Runnable() {

                                    @Override
                                    public void run() {
                                        NavigatorHandlerObjectOpen.openEntityEditor(targetObject);
                                    }
                                });
                            }
                        } catch (DBException e) {
                            return GeneralUtils.makeExceptionStatus(e);
                        }
                        return Status.OK_STATUS;
                    }
                }.schedule();
            }
        }
    });
}
Also used : DisposeListener(org.eclipse.swt.events.DisposeListener) DBException(org.jkiss.dbeaver.DBException) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) DisposeEvent(org.eclipse.swt.events.DisposeEvent) AbstractJob(org.jkiss.dbeaver.model.runtime.AbstractJob) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) ISelection(org.eclipse.jface.viewers.ISelection) DBRProgressMonitor(org.jkiss.dbeaver.model.runtime.DBRProgressMonitor)

Example 48 with IDoubleClickListener

use of org.eclipse.jface.viewers.IDoubleClickListener in project cubrid-manager by CUBRID.

the class ViewDashboardEditorPart method createViewsDetailInfoTable.

public void createViewsDetailInfoTable(Composite parent) {
    final Composite tableComposite = new Composite(parent, SWT.NONE);
    {
        tableComposite.setLayout(new FillLayout());
        tableComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    }
    viewsDetailInfoTable = new TableViewer(tableComposite, SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.MULTI | SWT.BORDER);
    viewsDetailInfoTable.getTable().setHeaderVisible(true);
    viewsDetailInfoTable.getTable().setLinesVisible(true);
    final TableViewerColumn columnViewName = new TableViewerColumn(viewsDetailInfoTable, SWT.LEFT);
    columnViewName.getColumn().setWidth(150);
    columnViewName.getColumn().setText(Messages.viewDetailInfoPartColViewName);
    final TableViewerColumn scriptDescColumn = new TableViewerColumn(viewsDetailInfoTable, SWT.LEFT);
    scriptDescColumn.getColumn().setWidth(200);
    scriptDescColumn.getColumn().setText(Messages.viewDetailInfoPartTableDefColumn);
    final TableViewerColumn ownerColumn = new TableViewerColumn(viewsDetailInfoTable, SWT.LEFT);
    ownerColumn.getColumn().setWidth(80);
    ownerColumn.getColumn().setText(Messages.viewDetailInfoPartTableOwnerColumn);
    viewsDetailInfoTable.setContentProvider(new ViewsDetailTableViewerContentProvider());
    viewsDetailInfoTable.setLabelProvider(new ViewsDetailTableViewerLabelProvider());
    viewsDetailInfoTable.addDoubleClickListener(new IDoubleClickListener() {

        public void doubleClick(DoubleClickEvent event) {
            IStructuredSelection selection = (IStructuredSelection) event.getSelection();
            ViewDetailInfo oneViewDetail = (ViewDetailInfo) selection.getFirstElement();
            //if had opend,set it selection
            for (CTabItem tabItem : tabFolder.getItems()) {
                if (tabItem.getText().equals(oneViewDetail.getViewName())) {
                    tabFolder.setSelection(tabItem);
                    return;
                }
            }
            //if a new view info,create a new tab
            ViewDashboardComposite viewComp = new ViewDashboardComposite(tabFolder, SWT.NONE);
            viewComp.initialize();
            SchemaInfo schemaInfo = database.getDatabaseInfo().getSchemaInfo(oneViewDetail.getViewName());
            viewComp.setInput(schemaInfo);
        }
    });
    viewsDetailInfoTable.getTable().addKeyListener(new KeyAdapter() {

        public void keyPressed(KeyEvent event) {
            if ((event.stateMask & SWT.CTRL) != 0 && event.keyCode == 'c') {
            }
        }
    });
    registerContextMenu();
}
Also used : Composite(org.eclipse.swt.widgets.Composite) KeyAdapter(org.eclipse.swt.events.KeyAdapter) ViewDetailInfo(com.cubrid.common.core.common.model.ViewDetailInfo) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) FillLayout(org.eclipse.swt.layout.FillLayout) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ViewsDetailInfoCTabItem(com.cubrid.common.ui.cubrid.view.editor.ViewDashboardComposite.ViewsDetailInfoCTabItem) CTabItem(org.eclipse.swt.custom.CTabItem) KeyEvent(org.eclipse.swt.events.KeyEvent) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) GridData(org.eclipse.swt.layout.GridData) TableViewer(org.eclipse.jface.viewers.TableViewer) TableViewerColumn(org.eclipse.jface.viewers.TableViewerColumn) SchemaInfo(com.cubrid.common.core.common.model.SchemaInfo)

Example 49 with IDoubleClickListener

use of org.eclipse.jface.viewers.IDoubleClickListener in project azure-tools-for-java by Microsoft.

the class ServiceExplorerView method hookMouseActions.

private void hookMouseActions() {
    viewer.addDoubleClickListener(new IDoubleClickListener() {

        public void doubleClick(DoubleClickEvent event) {
            doubleClickAction.run();
        }
    });
    Tree tree = (Tree) viewer.getControl();
    tree.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseUp(MouseEvent e) {
            if (e.button == 1) {
                // left button
                TreeItem[] selection = ((Tree) e.widget).getSelection();
                if (selection.length > 0) {
                    TreeItem item = ((Tree) e.widget).getSelection()[0];
                    Node node = ((TreeNode) item.getData()).node;
                    // we do not propagate the click event to it
                    if (!node.isLoading()) {
                        node.getClickAction().fireNodeActionEvent();
                    }
                }
            }
        }
    });
}
Also used : MouseEvent(org.eclipse.swt.events.MouseEvent) TreeItem(org.eclipse.swt.widgets.TreeItem) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) Node(com.microsoft.tooling.msservices.serviceexplorer.Node) MouseAdapter(org.eclipse.swt.events.MouseAdapter) Tree(org.eclipse.swt.widgets.Tree) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent)

Example 50 with IDoubleClickListener

use of org.eclipse.jface.viewers.IDoubleClickListener in project cubrid-manager by CUBRID.

the class MultiDatabaseLoginFailedDialog method createDialogArea.

protected Control createDialogArea(Composite parent) {
    getShell().setText(Messages.multiDatabaseLoginDialogTitle);
    Composite parentComp = (Composite) super.createDialogArea(parent);
    setTitle(Messages.multiDatabaseLoginDialogTitle);
    setMessage(Messages.multiDatabaseLoginDialogMessages);
    databaseTable = new TableViewer(parentComp, SWT.SINGLE | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION);
    GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1);
    databaseTable.getTable().setLayoutData(gridData);
    databaseTable.getTable().setHeaderVisible(true);
    databaseTable.getTable().setLinesVisible(true);
    final TableViewerColumn columnHost = new TableViewerColumn(databaseTable, SWT.CENTER);
    columnHost.getColumn().setWidth(120);
    columnHost.getColumn().setText(Messages.multiDatabaseLoginDialogColumnHostAddress);
    final TableViewerColumn columnDatabase = new TableViewerColumn(databaseTable, SWT.CENTER);
    columnDatabase.getColumn().setWidth(150);
    columnDatabase.getColumn().setText(Messages.multiDatabaseLoginDialogColumnDbName);
    final TableViewerColumn columnUser = new TableViewerColumn(databaseTable, SWT.CENTER);
    columnUser.getColumn().setWidth(100);
    columnUser.getColumn().setText(Messages.multiDatabaseLoginDialogColumnUser);
    final TableViewerColumn columnErrMsg = new TableViewerColumn(databaseTable, SWT.CENTER);
    columnErrMsg.getColumn().setWidth(200);
    columnErrMsg.getColumn().setText(Messages.multiDatabaseLoginDialogColumnErrMsg);
    final TableViewerColumn columnStatus = new TableViewerColumn(databaseTable, SWT.CENTER);
    columnStatus.getColumn().setWidth(100);
    columnStatus.getColumn().setText(Messages.multiDatabaseLoginDialogColumnStatus);
    databaseTable.setContentProvider(new ServerListContentProvider());
    databaseTable.setLabelProvider(new ServerListLabelProvider());
    databaseTable.addDoubleClickListener(new IDoubleClickListener() {

        public void doubleClick(DoubleClickEvent event) {
            IStructuredSelection selection = (IStructuredSelection) event.getSelection();
            MultiDatabaseloginFailedInfo multiDatabaseloginFailedInfo = (MultiDatabaseloginFailedInfo) selection.getFirstElement();
            editHost(multiDatabaseloginFailedInfo);
            //if all database login , close this dialog
            if (checkAllDatabaseLogin()) {
                close();
            }
        }
    });
    databaseTable.setInput(failedDatabaseList);
    MenuManager menuManager = new MenuManager();
    Menu contextMenu = menuManager.createContextMenu(databaseTable.getTable());
    databaseTable.getTable().setMenu(contextMenu);
    Menu menu = new Menu(getShell(), SWT.POP_UP);
    final MenuItem itemEdit = new MenuItem(menu, SWT.PUSH);
    itemEdit.setText(Messages.multiDatabaseLoginDialogEditLabel);
    itemEdit.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            IStructuredSelection selection = (StructuredSelection) databaseTable.getSelection();
            MultiDatabaseloginFailedInfo multiDatabaseloginFailedInfo = (MultiDatabaseloginFailedInfo) selection.getFirstElement();
            editHost(multiDatabaseloginFailedInfo);
        }
    });
    menu.addMenuListener(new MenuAdapter() {

        public void menuShown(MenuEvent event) {
            IStructuredSelection selection = (IStructuredSelection) databaseTable.getSelection();
            MultiDatabaseloginFailedInfo multiDatabaseloginFailedInfo = (MultiDatabaseloginFailedInfo) selection.getFirstElement();
            if (multiDatabaseloginFailedInfo.getCubridDatabase().isLogined()) {
                itemEdit.setEnabled(false);
            } else {
                itemEdit.setEnabled(true);
            }
        }
    });
    databaseTable.getTable().setMenu(menu);
    databaseTable.getTable().addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            if (databaseTable.getTable().getSelectionIndices().length > 0) {
                getButton(EDIT_ID).setEnabled(true);
            } else {
                getButton(EDIT_ID).setEnabled(false);
            }
        }
    });
    return parentComp;
}
Also used : Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) MenuAdapter(org.eclipse.swt.events.MenuAdapter) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) MenuItem(org.eclipse.swt.widgets.MenuItem) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) 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) TableViewerColumn(org.eclipse.jface.viewers.TableViewerColumn) MenuEvent(org.eclipse.swt.events.MenuEvent)

Aggregations

DoubleClickEvent (org.eclipse.jface.viewers.DoubleClickEvent)67 IDoubleClickListener (org.eclipse.jface.viewers.IDoubleClickListener)67 GridData (org.eclipse.swt.layout.GridData)40 TableViewer (org.eclipse.jface.viewers.TableViewer)37 Composite (org.eclipse.swt.widgets.Composite)33 SelectionEvent (org.eclipse.swt.events.SelectionEvent)32 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)28 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)25 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)25 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)23 GridLayout (org.eclipse.swt.layout.GridLayout)21 Table (org.eclipse.swt.widgets.Table)16 TableViewerColumn (org.eclipse.jface.viewers.TableViewerColumn)15 ArrayContentProvider (org.eclipse.jface.viewers.ArrayContentProvider)13 Button (org.eclipse.swt.widgets.Button)13 Label (org.eclipse.swt.widgets.Label)13 TableColumn (org.eclipse.swt.widgets.TableColumn)13 ISelection (org.eclipse.jface.viewers.ISelection)11 TreeViewer (org.eclipse.jface.viewers.TreeViewer)11 FillLayout (org.eclipse.swt.layout.FillLayout)10