Search in sources :

Example 11 with SelectionEvent

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

the class SettingView method createMemTabItem.

/**
	 * 为了迎合兰姐的界面,要求改的好丑啊
	 * @param parent
	 */
private void createMemTabItem(TabFolder parent) {
    TabItem memTabItem = new TabItem(parent, SWT.NONE);
    memTabItem.setText("内存");
    Composite memTabRoot = new Composite(parent, SWT.NONE);
    memTabRoot.setLayout(new FormLayout());
    FormData testPeriodGroupFormData = new FormData();
    testPeriodGroupFormData.left = new FormAttachment(0, Constant.MARGIN_WIDTH);
    testPeriodGroupFormData.right = new FormAttachment(100, -Constant.MARGIN_WIDTH);
    testPeriodGroupFormData.top = new FormAttachment(memTabRoot, Constant.MARGIN_WIDTH_NARROW);
    Group periodGroup = new Group(memTabRoot, SWT.NONE);
    periodGroup.setLayoutData(testPeriodGroupFormData);
    periodGroup.setLayout(new FillLayout(SWT.HORIZONTAL));
    Label memLabel = new Label(periodGroup, SWT.NONE);
    memLabel.setText("采样间隔(ms)");
    itemTestPeriod[Constant.MEM_INDEX] = new Text(periodGroup, SWT.BORDER);
    itemTestPeriod[Constant.MEM_INDEX].setText("3000");
    itemTestPeriod[Constant.MEM_INDEX].addVerifyListener(new SWTNumberVerifyListener());
    itemTestPeriod[Constant.MEM_INDEX].addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            APTState.getInstance().DealWithEventBefore(APTEventEnum.CONFIGRURE_OPER);
            APTState.getInstance().DealWithEventAfter(APTEventEnum.CONFIGRURE_OPER);
        }
    });
    FormData hprofDumpSwitchGroupFormData = new FormData();
    hprofDumpSwitchGroupFormData.left = new FormAttachment(0, Constant.MARGIN_WIDTH);
    hprofDumpSwitchGroupFormData.right = new FormAttachment(100, -Constant.MARGIN_WIDTH);
    hprofDumpSwitchGroupFormData.top = new FormAttachment(periodGroup, Constant.MARGIN_WIDTH_NARROW);
    Group hprofDumpSwitchGroup = new Group(memTabRoot, SWT.NONE);
    hprofDumpSwitchGroup.setLayoutData(hprofDumpSwitchGroupFormData);
    hprofDumpSwitchGroup.setLayout(new FillLayout(SWT.HORIZONTAL));
    Label hprofDumpLabel = new Label(hprofDumpSwitchGroup, SWT.NONE);
    hprofDumpLabel.setText("Dump Hprof");
    hprofDumpSwitch = new Combo(hprofDumpSwitchGroup, SWT.DROP_DOWN | SWT.READ_ONLY);
    hprofDumpSwitch.setItems(new String[] { "否", "是" });
    hprofDumpSwitch.select(0);
    hprofDumpSwitch.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
        //				APTState.getInstance().DealWithEventBefore(APTEventEnum.CONFIGRURE_OPER);
        //				APTState.getInstance().DealWithEventAfter(APTEventEnum.CONFIGRURE_OPER);
        }
    });
    FormData hprofDumpThresholdGroupFormData = new FormData();
    hprofDumpThresholdGroupFormData.left = new FormAttachment(0, Constant.MARGIN_WIDTH);
    hprofDumpThresholdGroupFormData.right = new FormAttachment(100, -Constant.MARGIN_WIDTH);
    hprofDumpThresholdGroupFormData.top = new FormAttachment(hprofDumpSwitchGroup, Constant.MARGIN_WIDTH_NARROW);
    Group hrpofDumpThresholdGroup = new Group(memTabRoot, SWT.NONE);
    hrpofDumpThresholdGroup.setLayoutData(hprofDumpThresholdGroupFormData);
    hrpofDumpThresholdGroup.setLayout(new FillLayout(SWT.HORIZONTAL));
    Label hprofDumpThresholdLabel = new Label(hrpofDumpThresholdGroup, SWT.NONE);
    hprofDumpThresholdLabel.setText("Dump阈值(kB)");
    hprofDumpThreshold = new Text(hrpofDumpThresholdGroup, SWT.BORDER);
    hprofDumpThreshold.setText("30000");
    hprofDumpThreshold.addVerifyListener(new SWTNumberVerifyListener());
    hprofDumpThreshold.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            APTState.getInstance().DealWithEventBefore(APTEventEnum.CONFIGRURE_OPER);
            APTState.getInstance().DealWithEventAfter(APTEventEnum.CONFIGRURE_OPER);
        }
    });
    //Priv Dirty Group
    FormData privGroupFormData = new FormData();
    privGroupFormData.left = new FormAttachment(0, Constant.MARGIN_WIDTH);
    privGroupFormData.right = new FormAttachment(100, -Constant.MARGIN_WIDTH);
    privGroupFormData.top = new FormAttachment(hrpofDumpThresholdGroup, Constant.MARGIN_WIDTH_NARROW);
    Group privGroup = new Group(memTabRoot, SWT.NONE);
    privGroup.setText("Priv Dirty");
    privGroup.setLayoutData(privGroupFormData);
    privGroup.setLayout(new GridLayout(3, true));
    //PSS Group
    FormData pssGroupFormData = new FormData();
    pssGroupFormData.left = new FormAttachment(0, Constant.MARGIN_WIDTH);
    pssGroupFormData.right = new FormAttachment(100, -Constant.MARGIN_WIDTH);
    pssGroupFormData.top = new FormAttachment(privGroup, Constant.MARGIN_WIDTH_NARROW);
    Group pssGroup = new Group(memTabRoot, SWT.NONE);
    pssGroup.setText("PSS");
    pssGroup.setLayoutData(pssGroupFormData);
    pssGroup.setLayout(new GridLayout(3, true));
    //Heap Allocated Group
    FormData heapGroupFormData = new FormData();
    heapGroupFormData.left = new FormAttachment(0, Constant.MARGIN_WIDTH);
    heapGroupFormData.right = new FormAttachment(100, -Constant.MARGIN_WIDTH);
    heapGroupFormData.top = new FormAttachment(pssGroup, Constant.MARGIN_WIDTH_NARROW);
    Group heapGroup = new Group(memTabRoot, SWT.NONE);
    heapGroup.setText("Heap Allocated");
    heapGroup.setLayoutData(heapGroupFormData);
    heapGroup.setLayout(new GridLayout(3, true));
    //Heap Size Group
    FormData heapsizeGroupFormData = new FormData();
    heapsizeGroupFormData.left = new FormAttachment(0, Constant.MARGIN_WIDTH);
    heapsizeGroupFormData.right = new FormAttachment(100, -Constant.MARGIN_WIDTH);
    heapsizeGroupFormData.top = new FormAttachment(heapGroup, Constant.MARGIN_WIDTH_NARROW);
    Group heapsizeGroup = new Group(memTabRoot, SWT.NONE);
    heapsizeGroup.setText("Heap Size");
    heapsizeGroup.setLayoutData(heapsizeGroupFormData);
    heapsizeGroup.setLayout(new GridLayout(3, true));
    memStatCheckBtns = new Button[Constant.ALL_MEM_KIND_COUNT];
    for (int i = 0; i < Constant.ALL_MEM_KIND_COUNT; i++) {
        Group group = null;
        if (i < 3) {
            group = privGroup;
        } else if (i < 6) {
            group = pssGroup;
        } else if (i < 9) {
            group = heapGroup;
        } else {
            group = heapsizeGroup;
        }
        //final int index = i;
        memStatCheckBtns[i] = new Button(group, SWT.CHECK);
        memStatCheckBtns[i].setText(memStatCheckBtnTitles[i]);
        memStatCheckBtns[i].addSelectionListener(new SelectionListener() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                if (isSupportCheckChangeOper) {
                    //APTConsoleFactory.getInstance().APTPrint("内存check更新");
                    GetCurCheckedStateUtil.update();
                }
            }

            @Override
            public void widgetDefaultSelected(SelectionEvent e) {
            }
        });
    }
    //memStatCheckBtns[Constant.PRIV_TOTAL_INDEX].setSelection(true);
    memStatCheckBtns[Constant.PSS_TOTAL_INDEX].setSelection(true);
    //memStatCheckBtns[Constant.HEAPALLOC_TOTAL_INDEX].setSelection(true);
    FormData labelFormData = new FormData();
    labelFormData.left = new FormAttachment(0, Constant.MARGIN_WIDTH);
    labelFormData.right = new FormAttachment(100, -Constant.MARGIN_WIDTH);
    labelFormData.bottom = new FormAttachment(100, -Constant.MARGIN_WIDTH);
    Label showLabel = new Label(memTabRoot, SWT.NONE);
    showLabel.setLayoutData(labelFormData);
    showLabel.setText("提示:测试过程中可动态调整曲线显示");
    showLabel.setForeground(new Color(parent.getDisplay(), 0, 64, 64));
    showLabel.setFont(new Font(parent.getDisplay(), "宋体", 10, SWT.BOLD));
    memTabItem.setControl(memTabRoot);
}
Also used : FormLayout(org.eclipse.swt.layout.FormLayout) FormData(org.eclipse.swt.layout.FormData) Group(org.eclipse.swt.widgets.Group) Composite(org.eclipse.swt.widgets.Composite) ModifyListener(org.eclipse.swt.events.ModifyListener) Color(org.eclipse.swt.graphics.Color) Label(org.eclipse.swt.widgets.Label) Text(org.eclipse.swt.widgets.Text) Combo(org.eclipse.swt.widgets.Combo) FillLayout(org.eclipse.swt.layout.FillLayout) Font(org.eclipse.swt.graphics.Font) TabItem(org.eclipse.swt.widgets.TabItem) ModifyEvent(org.eclipse.swt.events.ModifyEvent) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) SelectionEvent(org.eclipse.swt.events.SelectionEvent) SWTNumberVerifyListener(com.tencent.wstt.apt.ui.custom.SWTNumberVerifyListener) FormAttachment(org.eclipse.swt.layout.FormAttachment) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 12 with SelectionEvent

use of org.eclipse.swt.events.SelectionEvent in project generator by mybatis.

the class AbstractGeneratorComposite method createFileNameBrowseButtons.

private void createFileNameBrowseButtons(Composite parent) {
    new Label(parent, SWT.NONE);
    Composite buttonComposite = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout(2, false);
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    buttonComposite.setLayout(layout);
    GridData gd = new GridData(SWT.END, SWT.CENTER, false, false);
    buttonComposite.setLayoutData(gd);
    buttonComposite.setFont(parent.getFont());
    btnBrowseWorkplace = new Button(buttonComposite, SWT.NONE);
    btnBrowseWorkplace.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            IResource chosenFile = chooseFileFromWorkspace();
            if (chosenFile != null) {
                IPath path = chosenFile.getFullPath();
                //$NON-NLS-1$ //$NON-NLS-2$
                txtFileName.setText("${workspace_loc:" + path.toString() + "}");
                javaProjectName = GeneratorLaunchShortcut.getJavaProjectNameFromResource(chosenFile);
            }
        }
    });
    btnBrowseWorkplace.setText(Messages.FILE_PICKER_BROWSE_WORKSPACE);
    btnBrowseFileSystem = new Button(buttonComposite, SWT.NONE);
    btnBrowseFileSystem.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            chooseFileFromFileSystem();
        }
    });
    btnBrowseFileSystem.setText(Messages.FILE_PICKER_BROWSE_FILE_SYSTEM);
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) IPath(org.eclipse.core.runtime.IPath) Button(org.eclipse.swt.widgets.Button) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) IResource(org.eclipse.core.resources.IResource)

Example 13 with SelectionEvent

use of org.eclipse.swt.events.SelectionEvent in project generator by mybatis.

the class SqlScriptComposite method createConnectionGroup.

private void createConnectionGroup(Composite parent) {
    Group group = new Group(parent, SWT.NONE);
    group.setText(Messages.SQL_SCRIPT_TAB_JDBC_CONNECTION_GROUP_TITLE);
    GridLayout groupLayout = new GridLayout(2, false);
    group.setLayout(groupLayout);
    group.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    group.setFont(parent.getFont());
    Label lblJdbcDriverClass = new Label(group, SWT.NONE);
    lblJdbcDriverClass.setText(Messages.SQL_SCRIPT_TAB_JDBC_DRIVER_LABEL);
    new Label(group, SWT.NONE);
    txtJdbcDriver = new Text(group, SWT.BORDER);
    txtJdbcDriver.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            sqlScriptTab.updateLaunchConfigurationDialog();
        }
    });
    GridData gd_txtJdbcDriver = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1);
    gd_txtJdbcDriver.horizontalIndent = 30;
    txtJdbcDriver.setLayoutData(gd_txtJdbcDriver);
    new Label(group, SWT.NONE);
    Label lblJdbcUrl = new Label(group, SWT.NONE);
    lblJdbcUrl.setText(Messages.SQL_SCRIPT_TAB_JDBC_URL_LABEL);
    new Label(group, SWT.NONE);
    txtJdbcURL = new Text(group, SWT.BORDER);
    txtJdbcURL.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            sqlScriptTab.updateLaunchConfigurationDialog();
        }
    });
    GridData gd_txtJdbcURL = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1);
    gd_txtJdbcURL.horizontalIndent = 30;
    txtJdbcURL.setLayoutData(gd_txtJdbcURL);
    new Label(group, SWT.NONE);
    Label lblUserId = new Label(group, SWT.NONE);
    lblUserId.setText(Messages.SQL_SCRIPT_TAB_USERID_LABEL);
    new Label(group, SWT.NONE);
    txtUserID = new Text(group, SWT.BORDER);
    txtUserID.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            sqlScriptTab.updateLaunchConfigurationDialog();
        }
    });
    GridData gd_txtUserID = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1);
    gd_txtUserID.horizontalIndent = 30;
    txtUserID.setLayoutData(gd_txtUserID);
    new Label(group, SWT.NONE);
    Label lblPassword = new Label(group, SWT.NONE);
    lblPassword.setText(Messages.SQL_SCRIPT_TAB_PASSWORD_LABEL);
    new Label(group, SWT.NONE);
    txtPassword = new Text(group, SWT.PASSWORD | SWT.BORDER);
    txtPassword.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            sqlScriptTab.updateLaunchConfigurationDialog();
        }
    });
    GridData gd_txtPassword = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1);
    gd_txtPassword.horizontalIndent = 30;
    txtPassword.setLayoutData(gd_txtPassword);
    new Label(group, SWT.NONE);
    btnSecureStorage = new Button(group, SWT.CHECK);
    btnSecureStorage.setText(Messages.SQL_SCRIPT_TAB_SECURE_STORAGE);
    btnSecureStorage.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            sqlScriptTab.updateLaunchConfigurationDialog();
        }
    });
    new Label(group, SWT.NONE);
}
Also used : Group(org.eclipse.swt.widgets.Group) GridLayout(org.eclipse.swt.layout.GridLayout) ModifyEvent(org.eclipse.swt.events.ModifyEvent) ModifyListener(org.eclipse.swt.events.ModifyListener) Button(org.eclipse.swt.widgets.Button) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) GridData(org.eclipse.swt.layout.GridData) Label(org.eclipse.swt.widgets.Label) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Text(org.eclipse.swt.widgets.Text)

Example 14 with SelectionEvent

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

the class NavigatorActiveProjectContributor method createMenu.

private void createMenu(final Menu menu) {
    final IProject activeProject = DBeaverCore.getInstance().getProjectRegistry().getActiveProject();
    for (final IProject project : DBeaverCore.getInstance().getLiveProjects()) {
        MenuItem txnItem = new MenuItem(menu, SWT.RADIO);
        txnItem.setText(project.getName());
        txnItem.setSelection(project == activeProject);
        txnItem.setData(project);
        txnItem.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                DBeaverCore.getInstance().getProjectRegistry().setActiveProject(project);
            }
        });
    }
}
Also used : SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SelectionEvent(org.eclipse.swt.events.SelectionEvent) MenuItem(org.eclipse.swt.widgets.MenuItem) IProject(org.eclipse.core.resources.IProject)

Example 15 with SelectionEvent

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

the class ProgressLoaderVisualizer method showProgress.

private void showProgress() {
    if (progressOverlay == null) {
        // Start progress visualization
        cancelButton = new Button(progressPane, SWT.PUSH);
        cancelButton.setText("Cancel");
        GridData gd = new GridData(GridData.FILL_BOTH);
        gd.verticalIndent = DBeaverIcons.getImage(UIIcon.PROGRESS0).getBounds().height * 2;
        cancelButton.setLayoutData(gd);
        cancelButton.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                cancelButton.setText("Canceled");
                cancelButton.setEnabled(false);
                Point buttonSize = cancelButton.computeSize(SWT.DEFAULT, SWT.DEFAULT);
                progressOverlay.minimumWidth = buttonSize.x;
                progressOverlay.minimumHeight = buttonSize.y;
                progressOverlay.layout();
                try {
                    loadService.cancel();
                } catch (InvocationTargetException e1) {
                    log.error(e1.getTargetException());
                }
            }
        });
        painListener = new PaintListener() {

            @Override
            public void paintControl(PaintEvent e) {
                Image image = DBeaverIcons.getImage(PROGRESS_IMAGES[drawCount % PROGRESS_IMAGES.length]);
                Rectangle buttonBounds = cancelButton.getBounds();
                Rectangle imageBounds = image.getBounds();
                e.gc.drawImage(image, (buttonBounds.x + buttonBounds.width / 2) - imageBounds.width / 2, buttonBounds.y - imageBounds.height - 5);
                long elapsedTime = System.currentTimeMillis() - loadStartTime;
                String elapsedString = elapsedTime > 10000 ? String.valueOf(elapsedTime / 1000) : String.valueOf(((double) (elapsedTime / 100)) / 10);
                String statusMessage = CommonUtils.truncateString(progressMessage.replaceAll("\\s", " "), 64);
                String status = statusMessage + " - " + elapsedString + "s";
                Point statusSize = e.gc.textExtent(status);
                int statusX = (buttonBounds.x + buttonBounds.width / 2) - statusSize.x / 2;
                int statusY = buttonBounds.y - imageBounds.height - 10 - statusSize.y;
                e.gc.setForeground(progressPane.getForeground());
                e.gc.setBackground(progressPane.getBackground());
                e.gc.fillRectangle(statusX - 2, statusY - 2, statusSize.x + 4, statusSize.y + 4);
                e.gc.drawText(status, statusX, statusY, true);
                e.gc.setForeground(shadowColor);
                e.gc.drawRoundRectangle(statusX - 3, statusY - 3, statusSize.x + 5, statusSize.y + 5, 5, 5);
            }
        };
        progressPane.addPaintListener(painListener);
        progressOverlay = new ControlEditor(progressPane);
        Point buttonSize = cancelButton.computeSize(SWT.DEFAULT, SWT.DEFAULT);
        progressOverlay.minimumWidth = buttonSize.x;
        progressOverlay.minimumHeight = buttonSize.y;
        progressOverlay.setEditor(cancelButton);
    }
    drawCount++;
    progressOverlay.layout();
    progressPane.redraw();
}
Also used : ControlEditor(org.eclipse.swt.custom.ControlEditor) PaintEvent(org.eclipse.swt.events.PaintEvent) PaintListener(org.eclipse.swt.events.PaintListener) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Rectangle(org.eclipse.swt.graphics.Rectangle) Point(org.eclipse.swt.graphics.Point) Image(org.eclipse.swt.graphics.Image) InvocationTargetException(java.lang.reflect.InvocationTargetException) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent)

Aggregations

SelectionEvent (org.eclipse.swt.events.SelectionEvent)971 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)831 GridData (org.eclipse.swt.layout.GridData)572 GridLayout (org.eclipse.swt.layout.GridLayout)481 Composite (org.eclipse.swt.widgets.Composite)479 Button (org.eclipse.swt.widgets.Button)468 Label (org.eclipse.swt.widgets.Label)314 Text (org.eclipse.swt.widgets.Text)221 SelectionListener (org.eclipse.swt.events.SelectionListener)185 Group (org.eclipse.swt.widgets.Group)168 ModifyEvent (org.eclipse.swt.events.ModifyEvent)143 ModifyListener (org.eclipse.swt.events.ModifyListener)143 Combo (org.eclipse.swt.widgets.Combo)118 MenuItem (org.eclipse.swt.widgets.MenuItem)89 ToolItem (org.eclipse.swt.widgets.ToolItem)89 Menu (org.eclipse.swt.widgets.Menu)88 TableViewer (org.eclipse.jface.viewers.TableViewer)84 Point (org.eclipse.swt.graphics.Point)82 ArrayList (java.util.ArrayList)79 ToolBar (org.eclipse.swt.widgets.ToolBar)76