Search in sources :

Example 41 with SelectionEvent

use of org.eclipse.swt.events.SelectionEvent in project translationstudio8 by heartsome.

the class LicenseAgreementDialog method createDialogArea.

@Override
protected Control createDialogArea(Composite parent) {
    Composite tparent = (Composite) super.createDialogArea(parent);
    GridLayout layout = new GridLayout();
    layout.marginTop = 5;
    layout.marginWidth = 10;
    tparent.setLayout(layout);
    GridData parentData = new GridData(SWT.FILL, SWT.FILL, true, true);
    parentData.heightHint = 380;
    tparent.setLayoutData(parentData);
    Label lbl = new Label(tparent, SWT.NONE);
    lbl.setText(Messages.getString("license.LicenseAgreementDialog.label"));
    lbl.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    Text text = new Text(tparent, SWT.MULTI | SWT.WRAP | SWT.V_SCROLL);
    text.setEditable(false);
    text.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE));
    text.setText(Messages.getString("license.LicenseAgreementDialog.agreement"));
    GridData textData = new GridData(GridData.FILL_BOTH);
    text.setLayoutData(textData);
    agreeBtn = new Button(tparent, SWT.CHECK);
    agreeBtn.setText(Messages.getString("license.LicenseAgreementDialog.agreeBtn"));
    agreeBtn.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    agreeBtn.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            getButton(IDialogConstants.OK_ID).setEnabled(agreeBtn.getSelection());
        }
    });
    return super.createDialogArea(parent);
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) 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 42 with SelectionEvent

use of org.eclipse.swt.events.SelectionEvent in project translationstudio8 by heartsome.

the class LicenseManageDialog method createStatusComp.

private void createStatusComp(Composite parent) {
    Group statusGroup = new Group(parent, SWT.NONE);
    statusGroup.setText(Messages.getString("license.LicenseManageDialog.statusGroup"));
    GridData dataStatusGroup = new GridData(GridData.GRAB_HORIZONTAL | GridData.FILL_HORIZONTAL);
    dataStatusGroup.heightHint = 150;
    statusGroup.setLayoutData(dataStatusGroup);
    statusGroup.setLayout(new GridLayout());
    GridData data = new GridData(GridData.GRAB_HORIZONTAL | GridData.FILL_HORIZONTAL);
    RowLayout layout = new RowLayout();
    layout.center = true;
    Composite comp0 = new Composite(statusGroup, SWT.NONE);
    comp0.setLayoutData(data);
    comp0.setLayout(layout);
    Label statusLbl = new Label(comp0, SWT.NONE);
    statusLbl.setText(Messages.getString("license.LicenseManageDialog.statusLabel"));
    if (type == Constants.STATE_NOT_ACTIVATED) {
        Label statusLbl1 = new Label(comp0, SWT.NONE);
        statusLbl1.setText(Messages.getString("license.LicenseManageDialog.notActiveLabel"));
    } else if (type == Constants.STATE_VALID) {
        Label statusLbl1 = new Label(comp0, SWT.NONE);
        statusLbl1.setText(Messages.getString("license.LicenseManageDialog.activeLabel"));
        new Label(comp0, SWT.NONE).setLayoutData(new RowData(30, SWT.DEFAULT));
        Button btnCancelActive = new Button(comp0, SWT.NONE);
        btnCancelActive.setText(Messages.getString("license.LicenseManageDialog.cancelActiveButton"));
        btnCancelActive.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                boolean result = MessageDialog.openConfirm(getShell(), Messages.getString("license.LicenseManageDialog.confirm"), Messages.getString("license.LicenseManageDialog.confirmMessage"));
                if (result) {
                    try {
                        int re = ServiceUtil.cancel();
                        if (re == Constants.LOGOUT_SUCCESS) {
                            MessageDialog.openInformation(getShell(), Messages.getString("license.LicenseManageDialog.notice"), Messages.getString("license.LicenseManageDialog.unactiveSuccess"));
                            LicenseManageDialog.this.close();
                            PlatformUI.getWorkbench().restart();
                        } else {
                            MessageDialog.openInformation(getShell(), Messages.getString("license.LicenseManageDialog.notice"), Messages.getString("license.LicenseManageDialog.unactiveFail"));
                        }
                    } catch (Exception e1) {
                        e1.printStackTrace();
                        Throwable t = e1;
                        while (t.getCause() != null) {
                            t = t.getCause();
                        }
                        if (t instanceof java.security.cert.CertificateException) {
                            MessageDialog.openInformation(getShell(), Messages.getString("license.LicenseManageDialog.titleNet"), MessageFormat.format(Messages.getString("license.LicenseManageDialog.infoNet"), Constants.EXCEPTION_STRING16));
                        } else {
                            MessageDialog.openInformation(getShell(), Messages.getString("license.LicenseManageDialog.titleNet"), MessageFormat.format(Messages.getString("license.LicenseManageDialog.infoNet"), Constants.EXCEPTION_STRING17));
                        }
                    }
                }
            }
        });
        Composite comp1 = new Composite(statusGroup, SWT.NONE);
        comp1.setLayoutData(data);
        comp1.setLayout(layout);
        Label typeLbl = new Label(comp1, SWT.NONE);
        typeLbl.setText(Messages.getString("license.LicenseManageDialog.typeLabel"));
        Label typeLbl1 = new Label(comp1, SWT.NONE);
        typeLbl1.setText(Messages.getString(utilDate == null ? "license.LicenseManageDialog.typeBusiness" : "license.LicenseManageDialog.typeTemp"));
        if (utilDate != null) {
            Composite comp2 = new Composite(statusGroup, SWT.NONE);
            comp2.setLayoutData(data);
            comp2.setLayout(layout);
            Label typeLbl2 = new Label(comp2, SWT.NONE);
            typeLbl2.setText(Messages.getString("license.LicenseManageDialog.utilDate"));
            Label dateLbl = new Label(comp2, SWT.NONE);
            dateLbl.setText(utilDate);
        }
    } else if (type == Constants.STATE_INVALID) {
        Label statusLbl1 = new Label(comp0, SWT.NONE);
        statusLbl1.setText(Messages.getString("license.LicenseManageDialog.invalidLicense"));
    } else if (type == Constants.STATE_EXPIRED) {
        Label statusLbl1 = new Label(comp0, SWT.NONE);
        statusLbl1.setText(Messages.getString("license.LicenseManageDialog.expired"));
        Composite comp1 = new Composite(statusGroup, SWT.NONE);
        comp1.setLayoutData(data);
        comp1.setLayout(layout);
        Label typeLbl = new Label(comp1, SWT.NONE);
        typeLbl.setText(Messages.getString("license.LicenseManageDialog.typeLabel"));
        Label typeLbl1 = new Label(comp1, SWT.NONE);
        typeLbl1.setText(Messages.getString(utilDate == null ? "license.LicenseManageDialog.typeBusiness" : "license.LicenseManageDialog.typeTemp"));
        if (utilDate != null) {
            Composite comp2 = new Composite(statusGroup, SWT.NONE);
            comp2.setLayoutData(data);
            comp2.setLayout(layout);
            Label typeLbl2 = new Label(comp2, SWT.NONE);
            typeLbl2.setText(Messages.getString("license.LicenseManageDialog.utilDate"));
            Label dateLbl = new Label(comp2, SWT.NONE);
            dateLbl.setText(utilDate);
        }
    } else if (type == Constants.EXCEPTION_INT16 || type == Constants.EXCEPTION_INT17) {
        Label statusLbl1 = new Label(comp0, SWT.NONE);
        statusLbl1.setText(Messages.getString("license.LicenseManageDialog.unvalidate"));
        Composite comp1 = new Composite(statusGroup, SWT.NONE);
        GridData data1 = new GridData(GridData.GRAB_HORIZONTAL | GridData.FILL_BOTH);
        comp1.setLayoutData(data1);
        GridLayout layout1 = new GridLayout();
        comp1.setLayout(layout1);
        Label noticeLbl = new Label(comp1, SWT.WRAP);
        GridData dataLabel = new GridData(GridData.FILL_HORIZONTAL);
        noticeLbl.setLayoutData(dataLabel);
        noticeLbl.setText(MessageFormat.format(Messages.getString("license.LicenseManageDialog.noticeLbl"), StringUtils.getErrorCode(type)));
    } else if (type == Constants.EXCEPTION_INT14) {
        Label statusLbl1 = new Label(comp0, SWT.NONE);
        statusLbl1.setText(Messages.getString("license.LicenseManageDialog.licenseException"));
        Composite comp1 = new Composite(statusGroup, SWT.NONE);
        GridData data1 = new GridData(GridData.GRAB_HORIZONTAL | GridData.FILL_BOTH);
        comp1.setLayoutData(data1);
        GridLayout layout1 = new GridLayout();
        comp1.setLayout(layout1);
        Label noticeLbl = new Label(comp1, SWT.WRAP);
        GridData dataLabel = new GridData(GridData.FILL_HORIZONTAL);
        noticeLbl.setLayoutData(dataLabel);
        noticeLbl.setText(MessageFormat.format(Messages.getString("license.LicenseManageDialog.noSameVersion"), getVersionContent(System.getProperty("TSEdition")), getVersionContent(new LicenseIdGenerator(licenseId).getVersion())));
    } else if (type == Constants.EXCEPTION_INT15) {
        Label statusLbl1 = new Label(comp0, SWT.NONE);
        statusLbl1.setText(Messages.getString("license.LicenseManageDialog.licenseException"));
        Composite comp1 = new Composite(statusGroup, SWT.NONE);
        GridData data1 = new GridData(GridData.GRAB_HORIZONTAL | GridData.FILL_BOTH);
        comp1.setLayoutData(data1);
        GridLayout layout1 = new GridLayout();
        comp1.setLayout(layout1);
        Label noticeLbl = new Label(comp1, SWT.WRAP);
        GridData dataLabel = new GridData(GridData.FILL_HORIZONTAL);
        noticeLbl.setLayoutData(dataLabel);
        noticeLbl.setText(Messages.getString("license.LicenseManageDialog.maccodeError"));
    } else if (type == Constants.EXCEPTION_INT1 || type == Constants.EXCEPTION_INT2 || type == Constants.EXCEPTION_INT3 || type == Constants.EXCEPTION_INT4) {
        Label statusLbl1 = new Label(comp0, SWT.NONE);
        statusLbl1.setText(Messages.getString("license.LicenseManageDialog.licenseException"));
        Composite comp1 = new Composite(statusGroup, SWT.NONE);
        GridData data1 = new GridData(GridData.GRAB_HORIZONTAL | GridData.FILL_BOTH);
        comp1.setLayoutData(data1);
        GridLayout layout1 = new GridLayout();
        comp1.setLayout(layout1);
        Label noticeLbl = new Label(comp1, SWT.WRAP);
        GridData dataLabel = new GridData(GridData.FILL_HORIZONTAL);
        noticeLbl.setLayoutData(dataLabel);
        noticeLbl.setText(MessageFormat.format(Messages.getString("license.LicenseManageDialog.licenseExceptionInfo1"), StringUtils.getErrorCode(type)));
    } else {
        Label statusLbl1 = new Label(comp0, SWT.NONE);
        statusLbl1.setText(Messages.getString("license.LicenseManageDialog.licenseException"));
        Composite comp1 = new Composite(statusGroup, SWT.NONE);
        GridData data1 = new GridData(GridData.GRAB_HORIZONTAL | GridData.FILL_BOTH);
        comp1.setLayoutData(data1);
        GridLayout layout1 = new GridLayout();
        comp1.setLayout(layout1);
        Label noticeLbl = new Label(comp1, SWT.WRAP);
        GridData dataLabel = new GridData(GridData.FILL_HORIZONTAL);
        noticeLbl.setLayoutData(dataLabel);
        noticeLbl.setText(MessageFormat.format(Messages.getString("license.LicenseManageDialog.licenseExceptionInfo"), StringUtils.getErrorCode(type)));
    }
}
Also used : Group(org.eclipse.swt.widgets.Group) Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) Point(org.eclipse.swt.graphics.Point) LicenseIdGenerator(net.heartsome.license.generator.LicenseIdGenerator) GridLayout(org.eclipse.swt.layout.GridLayout) RowData(org.eclipse.swt.layout.RowData) Button(org.eclipse.swt.widgets.Button) RowLayout(org.eclipse.swt.layout.RowLayout) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent)

Example 43 with SelectionEvent

use of org.eclipse.swt.events.SelectionEvent in project translationstudio8 by heartsome.

the class LicenseManageDialog method createButtonsForButtonBar.

@Override
protected void createButtonsForButtonBar(Composite parent) {
    if (isShowBack) {
        Button backBtn = createButton(parent, IDialogConstants.BACK_ID, Messages.getString("license.OfflineActiveDialog.backBtn"), false);
        backBtn.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                setReturnCode(OK);
                Point p = getShell().getLocation();
                close();
                ActiveMethodDialog dialog = new ActiveMethodDialog(getShell(), p);
                int result = dialog.open();
                if (result != IDialogConstants.OK_ID) {
                    System.exit(0);
                }
            }
        });
    }
    Button button = createButton(parent, 11, Messages.getString("license.LicenseManageDialog.netconnection"), false);
    button.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
            PreferenceManager mgr = window.getWorkbench().getPreferenceManager();
            IPreferenceNode node = null;
            @SuppressWarnings("unchecked") List<IPreferenceNode> lstNodes = mgr.getElements(PreferenceManager.PRE_ORDER);
            for (IPreferenceNode n : lstNodes) {
                if (n.getId().equals("org.eclipse.ui.net.proxy_preference_page_context")) {
                    node = n;
                }
            }
            if (node == null) {
                return;
            }
            mgr = new PreferenceManager();
            mgr.addToRoot(node);
            HsPreferenceDialog dlg = new HsPreferenceDialog(window.getShell(), mgr);
            dlg.create();
            final List<Image> imageList = new ArrayList<Image>();
            dlg.getTreeViewer().setLabelProvider(new PreferenceLabelProvider() {

                Image image = null;

                public Image getImage(Object element) {
                    String id = ((IPreferenceNode) element).getId();
                    if ("org.eclipse.ui.net.proxy_preference_page_context".equals(id)) {
                        // 网络连接							
                        image = Activator.getImageDescriptor("icons/network.png").createImage();
                        imageList.add(image);
                        return image;
                    } else {
                        return null;
                    }
                }
            });
            dlg.open();
            for (Image img : imageList) {
                if (img != null && !img.isDisposed()) {
                    img.dispose();
                }
            }
            imageList.clear();
        }
    });
    boolean isDefault = false;
    if (type == Constants.STATE_NOT_ACTIVATED || type == Constants.STATE_INVALID || type == Constants.STATE_EXPIRED || type == Constants.EXCEPTION_INT14 || type == Constants.EXCEPTION_INT15 || type == Constants.EXCEPTION_INT1 || type == Constants.EXCEPTION_INT2 || type == Constants.EXCEPTION_INT3 || type == Constants.EXCEPTION_INT4) {
        createButton(parent, IDialogConstants.OK_ID, Messages.getString("license.LicenseManageDialog.activeBtn"), true);
        isDefault = true;
    }
    createButton(parent, IDialogConstants.CANCEL_ID, Messages.getString("license.LicenseManageDialog.exitBtn"), !isDefault).setFocus();
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) HsPreferenceDialog(net.heartsome.cat.common.ui.dialog.HsPreferenceDialog) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Point(org.eclipse.swt.graphics.Point) IPreferenceNode(org.eclipse.jface.preference.IPreferenceNode) Image(org.eclipse.swt.graphics.Image) PreferenceManager(org.eclipse.jface.preference.PreferenceManager) Button(org.eclipse.swt.widgets.Button) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ArrayList(java.util.ArrayList) List(java.util.List) PreferenceLabelProvider(org.eclipse.jface.preference.PreferenceLabelProvider)

Example 44 with SelectionEvent

use of org.eclipse.swt.events.SelectionEvent in project translationstudio8 by heartsome.

the class OfflineActiveDialog method createButtonsForButtonBar.

@Override
protected void createButtonsForButtonBar(Composite parent) {
    Button backBtn = createButton(parent, IDialogConstants.BACK_ID, Messages.getString("license.OfflineActiveDialog.backBtn"), false);
    backBtn.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            setReturnCode(OK);
            Point p = getShell().getLocation();
            close();
            ActiveMethodDialog dialog = new ActiveMethodDialog(getShell(), p);
            int result = dialog.open();
            if (result != IDialogConstants.OK_ID) {
                System.exit(0);
            }
        }
    });
    super.createButtonsForButtonBar(parent);
    Button nextBtn = getButton(IDialogConstants.OK_ID);
    nextBtn.setText(Messages.getString("license.LicenseAgreementDialog.nextBtn"));
    Button exitBtn = getButton(IDialogConstants.CANCEL_ID);
    exitBtn.setText(Messages.getString("license.LicenseAgreementDialog.exitBtn"));
}
Also used : Button(org.eclipse.swt.widgets.Button) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Point(org.eclipse.swt.graphics.Point)

Example 45 with SelectionEvent

use of org.eclipse.swt.events.SelectionEvent in project translationstudio8 by heartsome.

the class ActiveMethodDialog method createDialogArea.

@Override
protected Control createDialogArea(Composite parent) {
    Composite tparent = (Composite) super.createDialogArea(parent);
    GridLayout layout = new GridLayout();
    layout.marginWidth = 10;
    layout.marginTop = 5;
    tparent.setLayout(layout);
    GridDataFactory.fillDefaults().grab(true, true).applyTo(tparent);
    Group groupActiveMethod = new Group(tparent, SWT.NONE);
    groupActiveMethod.setText(Messages.getString("license.ActiveMethodDialog.activemethod"));
    GridLayout groupLayout = new GridLayout();
    groupLayout.marginWidth = 20;
    groupLayout.marginHeight = 20;
    groupLayout.verticalSpacing = 10;
    groupLayout.numColumns = 2;
    groupActiveMethod.setLayout(groupLayout);
    GridDataFactory.fillDefaults().grab(true, true).applyTo(groupActiveMethod);
    Button btnOnline = new Button(groupActiveMethod, SWT.NONE);
    GridData btnData = new GridData();
    btnData.widthHint = 200;
    btnData.heightHint = 40;
    btnOnline.setLayoutData(btnData);
    btnOnline.setText(Messages.getString("license.ActiveMethodDialog.activeonline"));
    btnOnline.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            setReturnCode(OK);
            Point p = getShell().getLocation();
            close();
            LicenseManageDialog dialog = new LicenseManageDialog(getShell(), Constants.STATE_NOT_ACTIVATED, null, null, true, p);
            int result = dialog.open();
            if (result != IDialogConstants.OK_ID) {
                System.exit(0);
            }
        }
    });
    Label labelRecommend = new Label(groupActiveMethod, SWT.NONE);
    labelRecommend.setText(Messages.getString("license.ActiveMethodDialog.recommend"));
    Label labelOnline = new Label(groupActiveMethod, SWT.WRAP);
    labelOnline.setText(Messages.getString("license.ActiveMethodDialog.onlinemessage"));
    GridData dataLabel = new GridData();
    dataLabel.horizontalSpan = 2;
    dataLabel.widthHint = 450;
    labelOnline.setLayoutData(dataLabel);
    Label labelSpace = new Label(groupActiveMethod, SWT.NONE);
    GridData dataSpace = new GridData();
    dataSpace.horizontalSpan = 2;
    dataSpace.heightHint = 20;
    labelSpace.setLayoutData(dataSpace);
    Button btnOffline = new Button(groupActiveMethod, SWT.NONE);
    GridData btnData1 = new GridData();
    btnData1.widthHint = 200;
    btnData1.heightHint = 40;
    btnData1.horizontalSpan = 2;
    btnOffline.setLayoutData(btnData1);
    btnOffline.setText(Messages.getString("license.ActiveMethodDialog.activeoffline"));
    btnOffline.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            setReturnCode(OK);
            Point p = getShell().getLocation();
            close();
            OfflineActiveDialog dialog = new OfflineActiveDialog(getShell(), p);
            int result = dialog.open();
            if (result != IDialogConstants.OK_ID) {
                System.exit(0);
            }
        }
    });
    Label labelOffline = new Label(groupActiveMethod, SWT.WRAP);
    labelOffline.setText(Messages.getString("license.ActiveMethodDialog.offlinemessage"));
    labelOffline.setLayoutData(dataLabel);
    Label labelOffline1 = new Label(groupActiveMethod, SWT.WRAP);
    labelOffline1.setText(Messages.getString("license.ActiveMethodDialog.offlinemessage1"));
    GridData dataLabel1 = new GridData();
    dataLabel1.horizontalSpan = 2;
    dataLabel1.widthHint = 450;
    labelOffline1.setLayoutData(dataLabel1);
    return super.createDialogArea(parent);
}
Also used : Group(org.eclipse.swt.widgets.Group) GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) Button(org.eclipse.swt.widgets.Button) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Label(org.eclipse.swt.widgets.Label) Point(org.eclipse.swt.graphics.Point)

Aggregations

SelectionEvent (org.eclipse.swt.events.SelectionEvent)1136 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)923 GridData (org.eclipse.swt.layout.GridData)670 GridLayout (org.eclipse.swt.layout.GridLayout)566 Button (org.eclipse.swt.widgets.Button)558 Composite (org.eclipse.swt.widgets.Composite)553 Label (org.eclipse.swt.widgets.Label)370 SelectionListener (org.eclipse.swt.events.SelectionListener)262 Text (org.eclipse.swt.widgets.Text)253 Group (org.eclipse.swt.widgets.Group)193 ModifyEvent (org.eclipse.swt.events.ModifyEvent)160 ModifyListener (org.eclipse.swt.events.ModifyListener)159 Combo (org.eclipse.swt.widgets.Combo)140 Point (org.eclipse.swt.graphics.Point)98 MenuItem (org.eclipse.swt.widgets.MenuItem)95 Menu (org.eclipse.swt.widgets.Menu)94 TableViewer (org.eclipse.jface.viewers.TableViewer)91 Table (org.eclipse.swt.widgets.Table)91 ToolItem (org.eclipse.swt.widgets.ToolItem)90 ArrayList (java.util.ArrayList)88