Search in sources :

Example 1 with MouseEvent

use of org.eclipse.swt.events.MouseEvent in project GT by Tencent.

the class DevicesView method createTargetPkgTableView.

/**
	 * 创建被测进程列表
	* @Title: createTargetPkgTableView  
	* @Description:   
	* @param parent 
	* void 
	* @throws
	 */
private void createTargetPkgTableView(Composite parent) {
    targetPkgTableViewer = new TableViewer(parent, SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL | SWT.CHECK);
    ctv = new CheckboxTableViewer(targetPkgTableViewer.getTable());
    ctv.addCheckStateListener(new ICheckStateListener() {

        @Override
        public void checkStateChanged(CheckStateChangedEvent event) {
            if (isSupportCheckChangePer) {
                GetCurCheckedStateUtil.update();
            } else {
                APTConsoleFactory.getInstance().APTPrint("Operation forbid");
            }
        }
    });
    // 设置表头内容 
    for (int i = 0; i < TARGET_COLUMN_NAME.length; i++) {
        new TableColumn(targetPkgTableViewer.getTable(), SWT.LEFT).setText(TARGET_COLUMN_NAME[i]);
    }
    targetPkgTableViewer.getTable().getColumn(0).setWidth(200);
    targetPkgTableViewer.getTable().getColumn(1).setWidth(50);
    // 设置表头和表格线可见
    targetPkgTableViewer.getTable().setHeaderVisible(true);
    targetPkgTableViewer.getTable().setLinesVisible(true);
    targetPkgTableViewer.setContentProvider(new ViewContentProvider());
    targetPkgTableViewer.setLabelProvider(new ViewLabelProvider());
    targetPkgTableViewer.getTable().addMouseListener(new MouseListener() {

        @Override
        public void mouseUp(MouseEvent e) {
        }

        @Override
        public void mouseDown(MouseEvent e) {
        }

        @Override
        public void mouseDoubleClick(MouseEvent e) {
            if (isSupportAddOrDeleteOper) {
                APTState.getInstance().DealWithEventBefore(APTEventEnum.CONFIGRURE_OPER);
                TableItem[] selectData = targetPkgTableViewer.getTable().getSelection();
                if (selectData == null || selectData.length == 0) {
                    return;
                }
                PkgInfo itemData = (PkgInfo) selectData[0].getData();
                targetPkgTableViewer.remove(itemData);
                APTState.getInstance().DealWithEventAfter(APTEventEnum.CONFIGRURE_OPER);
            } else {
                APTConsoleFactory.getInstance().APTPrint("Operation forbid");
            }
        }
    });
    targetPkgTableViewer.getTable().setToolTipText("双击或者右键菜单可删除被测进程");
    FormData tableViewFormData = new FormData();
    tableViewFormData.left = new FormAttachment(0, 5);
    tableViewFormData.right = new FormAttachment(100, -5);
    tableViewFormData.top = new FormAttachment(pkgNameText, 10);
    tableViewFormData.height = 125;
    Table table = targetPkgTableViewer.getTable();
    table.setLayoutData(tableViewFormData);
}
Also used : FormData(org.eclipse.swt.layout.FormData) MouseEvent(org.eclipse.swt.events.MouseEvent) Table(org.eclipse.swt.widgets.Table) CheckboxTableViewer(org.eclipse.jface.viewers.CheckboxTableViewer) ICheckStateListener(org.eclipse.jface.viewers.ICheckStateListener) TableColumn(org.eclipse.swt.widgets.TableColumn) PkgInfo(com.tencent.wstt.apt.data.PkgInfo) MouseListener(org.eclipse.swt.events.MouseListener) CheckStateChangedEvent(org.eclipse.jface.viewers.CheckStateChangedEvent) TableViewer(org.eclipse.jface.viewers.TableViewer) CheckboxTableViewer(org.eclipse.jface.viewers.CheckboxTableViewer) FormAttachment(org.eclipse.swt.layout.FormAttachment)

Example 2 with MouseEvent

use of org.eclipse.swt.events.MouseEvent in project dbeaver by serge-rider.

the class AboutBoxDialog method createDialogArea.

@Override
protected Control createDialogArea(Composite parent) {
    Color background = JFaceColors.getBannerBackground(parent.getDisplay());
    //Color foreground = JFaceColors.getBannerForeground(parent.getDisplay());
    parent.setBackground(background);
    Composite group = new Composite(parent, SWT.NONE);
    group.setBackground(background);
    GridLayout layout = new GridLayout(1, false);
    layout.marginHeight = 20;
    layout.marginWidth = 20;
    group.setLayout(layout);
    GridData gd;
    IProduct product = Platform.getProduct();
    {
        Label nameLabel = new Label(group, SWT.NONE);
        nameLabel.setBackground(background);
        nameLabel.setFont(NAME_FONT);
        nameLabel.setText(product.getName());
        gd = new GridData(GridData.FILL_HORIZONTAL);
        gd.horizontalAlignment = GridData.CENTER;
        nameLabel.setLayoutData(gd);
    }
    Label titleLabel = new Label(group, SWT.NONE);
    titleLabel.setBackground(background);
    titleLabel.setFont(TITLE_FONT);
    titleLabel.setText(product.getProperty(PRODUCT_PROP_SUB_TITLE));
    gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalAlignment = GridData.CENTER;
    titleLabel.setLayoutData(gd);
    titleLabel.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseDoubleClick(MouseEvent e) {
            BusyIndicator.showWhile(getShell().getDisplay(), new Runnable() {

                @Override
                public void run() {
                    // Do not create InstallationDialog directly
                    // but execute "org.eclipse.ui.help.installationDialog" command
                    IWorkbenchWindow workbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
                    IHandlerService service = workbenchWindow.getService(IHandlerService.class);
                    if (service != null) {
                        try {
                            //$NON-NLS-1$
                            service.executeCommand("org.eclipse.ui.help.installationDialog", null);
                        } catch (Exception e1) {
                        // just ignore error
                        }
                    }
                }
            });
        }
    });
    Label imageLabel = new Label(group, SWT.NONE);
    imageLabel.setBackground(background);
    gd = new GridData();
    gd.verticalAlignment = GridData.BEGINNING;
    gd.horizontalAlignment = GridData.CENTER;
    gd.grabExcessHorizontalSpace = true;
    imageLabel.setLayoutData(gd);
    imageLabel.setImage(ABOUT_IMAGE);
    Label versionLabel = new Label(group, SWT.NONE);
    versionLabel.setBackground(background);
    versionLabel.setText(CoreMessages.dialog_about_label_version + GeneralUtils.getProductVersion().toString());
    gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalAlignment = GridData.CENTER;
    versionLabel.setLayoutData(gd);
    Label releaseTimeLabel = new Label(group, SWT.NONE);
    releaseTimeLabel.setBackground(background);
    releaseTimeLabel.setText(DateFormat.getDateInstance(DateFormat.LONG).format(GeneralUtils.getProductReleaseDate()));
    gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalAlignment = GridData.CENTER;
    releaseTimeLabel.setLayoutData(gd);
    Label authorLabel = new Label(group, SWT.NONE);
    authorLabel.setBackground(background);
    authorLabel.setText(product.getProperty(PRODUCT_PROP_COPYRIGHT));
    gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalAlignment = GridData.CENTER;
    authorLabel.setLayoutData(gd);
    Link siteLink = UIUtils.createLink(group, UIUtils.makeAnchor(product.getProperty(PRODUCT_PROP_WEBSITE)), new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            UIUtils.launchProgram(e.text);
        }
    });
    siteLink.setBackground(background);
    gd = new GridData();
    gd.horizontalAlignment = GridData.CENTER;
    siteLink.setLayoutData(gd);
    return parent;
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) MouseEvent(org.eclipse.swt.events.MouseEvent) Color(org.eclipse.swt.graphics.Color) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) MouseAdapter(org.eclipse.swt.events.MouseAdapter) GridLayout(org.eclipse.swt.layout.GridLayout) IHandlerService(org.eclipse.ui.handlers.IHandlerService) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) IProduct(org.eclipse.core.runtime.IProduct)

Example 3 with MouseEvent

use of org.eclipse.swt.events.MouseEvent in project dbeaver by serge-rider.

the class StatusDetailsDialog method createDialogArea.

@Override
protected Composite createDialogArea(Composite parent) {
    Composite composite = super.createDialogArea(parent);
    if (!CommonUtils.isEmpty(warnings)) {
        // Create warnings table
        UIUtils.createControlLabel(composite, "Warnings");
        warnTable = new Table(composite, SWT.BORDER | SWT.FULL_SELECTION);
        TableColumn exColumn = UIUtils.createTableColumn(warnTable, SWT.NONE, "Exception");
        TableColumn msgColumn = UIUtils.createTableColumn(warnTable, SWT.NONE, "Message");
        warnTable.setLinesVisible(true);
        GridData gd = new GridData(GridData.FILL_BOTH);
        gd.minimumHeight = 100;
        warnTable.setLayoutData(gd);
        for (Throwable ex : warnings) {
            TableItem warnItem = new TableItem(warnTable, SWT.NONE);
            warnItem.setText(0, ex.getClass().getName());
            if (ex.getMessage() != null) {
                warnItem.setText(1, ex.getMessage());
            }
            warnItem.setData(ex);
        }
        exColumn.pack();
        msgColumn.pack();
        warnTable.addMouseListener(new MouseAdapter() {

            @Override
            public void mouseDoubleClick(MouseEvent e) {
                openWarning();
            }
        });
        warnTable.addTraverseListener(new TraverseListener() {

            @Override
            public void keyTraversed(TraverseEvent e) {
                if (e.detail == SWT.TRAVERSE_RETURN) {
                    openWarning();
                    e.doit = false;
                }
            }
        });
    }
    return composite;
}
Also used : Table(org.eclipse.swt.widgets.Table) MouseEvent(org.eclipse.swt.events.MouseEvent) TraverseEvent(org.eclipse.swt.events.TraverseEvent) Composite(org.eclipse.swt.widgets.Composite) TraverseListener(org.eclipse.swt.events.TraverseListener) TableItem(org.eclipse.swt.widgets.TableItem) GridData(org.eclipse.swt.layout.GridData) MouseAdapter(org.eclipse.swt.events.MouseAdapter) TableColumn(org.eclipse.swt.widgets.TableColumn)

Example 4 with MouseEvent

use of org.eclipse.swt.events.MouseEvent in project dbeaver by serge-rider.

the class PrefPageProjectSettings method createContents.

@Override
protected Control createContents(final Composite parent) {
    Composite composite = UIUtils.createPlaceholder(parent, 1, 5);
    {
        UIUtils.createControlLabel(composite, "Resource locations");
        resourceTable = new Table(composite, SWT.SINGLE | SWT.BORDER | SWT.FULL_SELECTION);
        resourceTable.setLayoutData(new GridData(GridData.FILL_BOTH));
        resourceTable.setHeaderVisible(true);
        resourceTable.setLinesVisible(true);
        UIUtils.createTableColumn(resourceTable, SWT.LEFT, "Resource");
        UIUtils.createTableColumn(resourceTable, SWT.LEFT, "Folder");
        resourceTable.setHeaderVisible(true);
        resourceTable.setLayoutData(new GridData(GridData.FILL_BOTH));
        handlerTableEditor = new TableEditor(resourceTable);
        handlerTableEditor.verticalAlignment = SWT.TOP;
        handlerTableEditor.horizontalAlignment = SWT.RIGHT;
        handlerTableEditor.grabHorizontal = true;
        handlerTableEditor.grabVertical = true;
        resourceTable.addMouseListener(new MouseAdapter() {

            @Override
            public void mouseUp(MouseEvent e) {
                disposeOldEditor();
                final TableItem item = resourceTable.getItem(new Point(0, e.y));
                if (item == null) {
                    return;
                }
                int columnIndex = UIUtils.getColumnAtPos(item, e.x, e.y);
                if (columnIndex <= 0) {
                    return;
                }
                if (columnIndex == 1) {
                    final String resourcePath = item.getText(1);
                    if (project != null) {
                        final IFolder folder = project.getFolder(resourcePath);
                        ContainerSelectionDialog dialog = new ContainerSelectionDialog(resourceTable.getShell(), folder, true, "Select " + item.getText(0) + " root folder");
                        dialog.showClosedProjects(false);
                        dialog.setValidator(new ISelectionValidator() {

                            @Override
                            public String isValid(Object selection) {
                                if (selection instanceof IPath) {
                                    final File file = ((IPath) selection).toFile();
                                    if (file.isHidden() || file.getName().startsWith(".")) {
                                        return "Can't use hidden folders";
                                    }
                                    final String[] segments = ((IPath) selection).segments();
                                    if (!project.getName().equals(segments[0])) {
                                        return "Can't store resources in another project";
                                    }
                                }
                                return null;
                            }
                        });
                        if (dialog.open() == IDialogConstants.OK_ID) {
                            final Object[] result = dialog.getResult();
                            if (result.length == 1 && result[0] instanceof IPath) {
                                final IPath plainPath = ((IPath) result[0]).removeFirstSegments(1).removeTrailingSeparator();
                                item.setText(1, plainPath.toString());
                            }
                        }
                    } else {
                        final Text editor = new Text(resourceTable, SWT.NONE);
                        editor.setText(resourcePath);
                        editor.selectAll();
                        handlerTableEditor.setEditor(editor, item, 1);
                        editor.setFocus();
                        editor.addFocusListener(new FocusAdapter() {

                            @Override
                            public void focusLost(FocusEvent e) {
                                item.setText(1, editor.getText());
                            }
                        });
                    }
                }
            }
        });
    }
    performDefaults();
    return composite;
}
Also used : FocusAdapter(org.eclipse.swt.events.FocusAdapter) MouseEvent(org.eclipse.swt.events.MouseEvent) IPath(org.eclipse.core.runtime.IPath) MouseAdapter(org.eclipse.swt.events.MouseAdapter) ISelectionValidator(org.eclipse.ui.dialogs.ISelectionValidator) Point(org.eclipse.swt.graphics.Point) TableEditor(org.eclipse.swt.custom.TableEditor) FocusEvent(org.eclipse.swt.events.FocusEvent) Point(org.eclipse.swt.graphics.Point) ContainerSelectionDialog(org.eclipse.ui.dialogs.ContainerSelectionDialog) GridData(org.eclipse.swt.layout.GridData) File(java.io.File) IFolder(org.eclipse.core.resources.IFolder)

Example 5 with MouseEvent

use of org.eclipse.swt.events.MouseEvent in project dbeaver by serge-rider.

the class MySQLScriptExecuteWizardPageSettings method createControl.

@Override
public void createControl(Composite parent) {
    Composite composite = UIUtils.createPlaceholder(parent, 1);
    Group outputGroup = UIUtils.createControlGroup(composite, MySQLMessages.tools_script_execute_wizard_page_settings_group_input, 3, GridData.FILL_HORIZONTAL, 0);
    inputFileText = UIUtils.createLabelText(outputGroup, MySQLMessages.tools_script_execute_wizard_page_settings_label_input_file, "", //$NON-NLS-2$
    SWT.BORDER | SWT.READ_ONLY);
    inputFileText.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseUp(MouseEvent e) {
            chooseInputFile();
        }
    });
    Button browseButton = new Button(outputGroup, SWT.PUSH);
    browseButton.setImage(DBeaverIcons.getImage(DBIcon.TREE_FOLDER));
    browseButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            chooseInputFile();
        }
    });
    if (wizard.getInputFile() != null) {
        inputFileText.setText(wizard.getInputFile().getName());
    }
    Group settingsGroup = UIUtils.createControlGroup(composite, MySQLMessages.tools_script_execute_wizard_page_settings_group_settings, 2, GridData.HORIZONTAL_ALIGN_BEGINNING, 0);
    logLevelCombo = UIUtils.createLabelCombo(settingsGroup, MySQLMessages.tools_script_execute_wizard_page_settings_label_log_level, SWT.DROP_DOWN | SWT.READ_ONLY);
    for (MySQLScriptExecuteWizard.LogLevel logLevel : MySQLScriptExecuteWizard.LogLevel.values()) {
        logLevelCombo.add(logLevel.name());
    }
    logLevelCombo.select(wizard.getLogLevel().ordinal());
    logLevelCombo.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            wizard.setLogLevel(MySQLScriptExecuteWizard.LogLevel.valueOf(logLevelCombo.getText()));
        }
    });
    createSecurityGroup(composite);
    setControl(composite);
//updateState();
}
Also used : MouseEvent(org.eclipse.swt.events.MouseEvent) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) MouseAdapter(org.eclipse.swt.events.MouseAdapter) SelectionEvent(org.eclipse.swt.events.SelectionEvent)

Aggregations

MouseEvent (org.eclipse.swt.events.MouseEvent)75 MouseAdapter (org.eclipse.swt.events.MouseAdapter)39 GridData (org.eclipse.swt.layout.GridData)30 SelectionEvent (org.eclipse.swt.events.SelectionEvent)29 MouseListener (org.eclipse.swt.events.MouseListener)25 Point (org.eclipse.swt.graphics.Point)25 KeyEvent (org.eclipse.swt.events.KeyEvent)22 Composite (org.eclipse.swt.widgets.Composite)22 GridLayout (org.eclipse.swt.layout.GridLayout)21 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)18 Button (org.eclipse.swt.widgets.Button)15 FocusEvent (org.eclipse.swt.events.FocusEvent)14 PaintEvent (org.eclipse.swt.events.PaintEvent)12 Text (org.eclipse.swt.widgets.Text)12 KeyListener (org.eclipse.swt.events.KeyListener)11 ModifyEvent (org.eclipse.swt.events.ModifyEvent)11 ModifyListener (org.eclipse.swt.events.ModifyListener)11 TraverseEvent (org.eclipse.swt.events.TraverseEvent)11 Event (org.eclipse.swt.widgets.Event)11 Label (org.eclipse.swt.widgets.Label)11