Search in sources :

Example 36 with SelectionAdapter

use of org.eclipse.swt.events.SelectionAdapter 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 37 with SelectionAdapter

use of org.eclipse.swt.events.SelectionAdapter 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 38 with SelectionAdapter

use of org.eclipse.swt.events.SelectionAdapter 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)

Example 39 with SelectionAdapter

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

the class CustomMessageDialog method createButtonsForButtonBar.

@Override
protected void createButtonsForButtonBar(Composite parent) {
    Button btnDownload = createButton(parent, -1, Messages.getString("license.CustomMessageDialog.download"), false);
    btnDownload.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            Program.launch(MessageFormat.format(Messages.getString("license.CustomMessageDialog.urlDownload"), ProtectionFactory.getProduct(editionInput), ProtectionFactory.getPlatform(), ProtectionFactory.getVersion()));
        }
    });
    if (!"L".equals(System.getProperty("TSEdition"))) {
        Button btnBuy = createButton(parent, -1, Messages.getString("license.LicenseManageDialog.link1"), false);
        btnBuy.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                Program.launch(Messages.getString("license.LicenseManageDialog.urlr8buy") + "&PRODUCT=" + ProtectionFactory.getProduct() + "&PLATFORM=" + ProtectionFactory.getPlatform());
            }
        });
    }
    Button btnTrial = createButton(parent, -1, Messages.getString("license.LicenseManageDialog.link2"), false);
    btnTrial.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            Program.launch(Messages.getString("license.LicenseManageDialog.urlr8trial") + "&PRODUCT=" + ProtectionFactory.getProduct() + "&PLATFORM=" + ProtectionFactory.getPlatform());
        }
    });
    createButton(parent, IDialogConstants.OK_ID, Messages.getString("license.CustomMessageDialog.inputAgain"), true).setFocus();
}
Also used : Button(org.eclipse.swt.widgets.Button) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SelectionEvent(org.eclipse.swt.events.SelectionEvent)

Example 40 with SelectionAdapter

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

the class GetActiveKeyDialog method createDialogArea.

@Override
protected Control createDialogArea(Composite parent) {
    Composite tparent = (Composite) super.createDialogArea(parent);
    GridLayout layout = new GridLayout();
    layout.marginWidth = 10;
    layout.marginTop = 10;
    tparent.setLayout(layout);
    GridDataFactory.fillDefaults().grab(true, true).applyTo(tparent);
    Composite compNav = new Composite(tparent, SWT.NONE);
    GridLayout navLayout = new GridLayout();
    compNav.setLayout(navLayout);
    createNavigation(compNav);
    Group groupActivekey = new Group(tparent, SWT.NONE);
    groupActivekey.setText(Messages.getString("license.GetActiveKeyDialog.activekey"));
    GridDataFactory.fillDefaults().grab(true, true).applyTo(groupActivekey);
    GridLayout layoutGroup = new GridLayout(2, false);
    layoutGroup.marginWidth = 5;
    layoutGroup.marginHeight = 20;
    groupActivekey.setLayout(layoutGroup);
    StyledText text = new StyledText(groupActivekey, SWT.WRAP | SWT.READ_ONLY);
    text.setBackground(text.getParent().getBackground());
    text.setText(Messages.getString("license.GetActiveKeyDialog.activemessage"));
    GridData dataText = new GridData();
    dataText.horizontalSpan = 2;
    dataText.widthHint = 470;
    text.setLayoutData(dataText);
    int start = Messages.getString("license.GetActiveKeyDialog.activemessage").indexOf(Messages.getString("license.GetActiveKeyDialog.ts"));
    int length = Messages.getString("license.GetActiveKeyDialog.ts").length();
    StyleRange styleRange = new StyleRange();
    styleRange.start = start;
    styleRange.length = length;
    styleRange.fontStyle = SWT.BOLD;
    styleRange.foreground = Display.getDefault().getSystemColor(SWT.COLOR_BLUE);
    text.setStyleRange(styleRange);
    Label label = new Label(groupActivekey, SWT.WRAP | SWT.NONE);
    label.setText(Messages.getString("license.GetActiveKeyDialog.activemessage1"));
    GridDataFactory.fillDefaults().span(2, 1).applyTo(label);
    textActivekey = new Text(groupActivekey, SWT.MULTI | SWT.WRAP);
    textActivekey.setEditable(false);
    textActivekey.setText(activekey);
    textActivekey.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE));
    GridDataFactory.fillDefaults().grab(true, false).hint(SWT.DEFAULT, 150).applyTo(textActivekey);
    Button btnCopy = new Button(groupActivekey, SWT.NONE);
    GridDataFactory.fillDefaults().align(SWT.CENTER, SWT.END).applyTo(btnCopy);
    btnCopy.setImage(Activator.getImageDescriptor("images/help/copy.png").createImage());
    btnCopy.setToolTipText(Messages.getString("license.GetActiveKeyDialog.copytoclipboard"));
    btnCopy.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            Clipboard cb = new Clipboard(Display.getCurrent());
            String textData = textActivekey.getText();
            TextTransfer textTransfer = TextTransfer.getInstance();
            cb.setContents(new Object[] { textData }, new Transfer[] { textTransfer });
        }
    });
    return tparent;
}
Also used : Group(org.eclipse.swt.widgets.Group) StyledText(org.eclipse.swt.custom.StyledText) Composite(org.eclipse.swt.widgets.Composite) StyleRange(org.eclipse.swt.custom.StyleRange) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) StyledText(org.eclipse.swt.custom.StyledText) Text(org.eclipse.swt.widgets.Text) Point(org.eclipse.swt.graphics.Point) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) TextTransfer(org.eclipse.swt.dnd.TextTransfer) Transfer(org.eclipse.swt.dnd.Transfer) Clipboard(org.eclipse.swt.dnd.Clipboard) TextTransfer(org.eclipse.swt.dnd.TextTransfer)

Aggregations

SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)925 SelectionEvent (org.eclipse.swt.events.SelectionEvent)924 GridData (org.eclipse.swt.layout.GridData)566 GridLayout (org.eclipse.swt.layout.GridLayout)474 Button (org.eclipse.swt.widgets.Button)463 Composite (org.eclipse.swt.widgets.Composite)463 Label (org.eclipse.swt.widgets.Label)299 Text (org.eclipse.swt.widgets.Text)214 Group (org.eclipse.swt.widgets.Group)149 ModifyEvent (org.eclipse.swt.events.ModifyEvent)130 ModifyListener (org.eclipse.swt.events.ModifyListener)129 Combo (org.eclipse.swt.widgets.Combo)110 TableViewer (org.eclipse.jface.viewers.TableViewer)80 MenuItem (org.eclipse.swt.widgets.MenuItem)80 ToolItem (org.eclipse.swt.widgets.ToolItem)80 Menu (org.eclipse.swt.widgets.Menu)78 ToolBar (org.eclipse.swt.widgets.ToolBar)73 Point (org.eclipse.swt.graphics.Point)72 Table (org.eclipse.swt.widgets.Table)72 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)70