Search in sources :

Example 46 with SelectionEvent

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

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

Example 48 with SelectionEvent

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

the class TermDbManagerImportWizardDialog method createButtonsForButtonBar.

@Override
protected void createButtonsForButtonBar(Composite parent) {
    btnSetting = createButton(parent, -1, Messages.getString("wizard.TermDbManagerImportWizardTbxPage.settingBtn"), true);
    super.createButtonsForButtonBar(parent);
    btnSetting.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            PreferenceUtil.openPreferenceDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow(), TBDatabasePage.ID);
        }
    });
}
Also used : SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SelectionEvent(org.eclipse.swt.events.SelectionEvent)

Example 49 with SelectionEvent

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

the class TermDbManagerImportWizardTbxPage method createControl.

/**
	 * Create contents of the wizard.
	 * @param parent
	 */
public void createControl(Composite parent) {
    Composite container = new Composite(parent, SWT.NULL);
    container.setLayout(new GridLayout(3, false));
    Label lblTmx = new Label(container, SWT.NONE);
    lblTmx.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    lblTmx.setText(Messages.getString("wizard.TermDbManagerImportWizardTbxPage.lblTmx"));
    tbxFileText = new Text(container, SWT.BORDER | SWT.READ_ONLY);
    tbxFileText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    tbxFileText.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            validator();
        }
    });
    Button tmxFileBorwserBtn = new Button(container, SWT.NONE);
    tmxFileBorwserBtn.setText(Messages.getString("wizard.TermDbManagerImportWizardTbxPage.tmxFileBorwserBtn"));
    tmxFileBorwserBtn.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            FileDialog dlg = new FileDialog(getShell());
            String[] filterExt = { "*.tbx", "*.xlsx", "*.txt" };
            dlg.setFilterExtensions(filterExt);
            String path = dlg.open();
            // Messages.getString("wizard.TermDbManagerImportWizardTbxPage.openFile"), SWT.OPEN);
            if (path != null) {
                tbxFileText.setText(path);
            }
        }
    });
    Label lblNewLabel = new Label(container, SWT.NONE);
    lblNewLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    lblNewLabel.setText(Messages.getString("wizard.TermDbManagerImportWizardTbxPage.lblNewLabel"));
    text = new Text(container, SWT.BORDER | SWT.READ_ONLY);
    text.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    text.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            validator();
        }
    });
    HSDropDownButton addBtn = new HSDropDownButton(container, SWT.NONE);
    addBtn.setText(Messages.getString("wizard.TermDbManagerImportWizardTbxPage.button"));
    Menu addMenu = addBtn.getMenu();
    MenuItem item = new MenuItem(addMenu, SWT.PUSH);
    item.setText(Messages.getString("tb.dialog.addTb.DropDownButton.AddFileTb"));
    item.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            FileDialog fileDialg = new FileDialog(getShell());
            fileDialg.setFilterExtensions(new String[] { "*.hstb", "*.*" });
            String result = fileDialg.open();
            if (result == null) {
                return;
            }
            File f = new File(result);
            if (!f.exists()) {
                return;
            }
            Map<DatabaseModelBean, String> r = null;
            try {
                r = Utils.convertFile2TbModel(f, false);
            } catch (Exception e1) {
                MessageDialog.openError(getShell(), Messages.getString("tb.dialog.addFileTb.errorTitle"), e1.getMessage());
            }
            if (r == null) {
                return;
            }
            Iterator<DatabaseModelBean> it = r.keySet().iterator();
            if (it.hasNext()) {
                dbModel = it.next();
                text.setText(f.getAbsolutePath());
            }
        }
    });
    MenuItem serverItem = new MenuItem(addMenu, SWT.PUSH);
    serverItem.setText(Messages.getString("tb.dialog.addTb.DropDownButton.AddServerTb"));
    serverItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            TermDbManagerDialog dialog = new TermDbManagerDialog(getShell());
            dialog.setDialogUseFor(TermDbManagerDialog.TYPE_DBSELECTED);
            if (dialog.open() == Window.OK) {
                Iterator<DatabaseModelBean> it = dialog.getHasSelectedDatabase().keySet().iterator();
                List<DatabaseModelBean> list = new ArrayList<DatabaseModelBean>();
                while (it.hasNext()) {
                    list.add(it.next());
                }
                if (list.size() > 0) {
                    // 只取第一个.
                    dbModel = list.get(0);
                    text.setText(dbModel.getDbName());
                }
            }
        }
    });
    setControl(container);
}
Also used : HSDropDownButton(net.heartsome.cat.common.ui.HSDropDownButton) Composite(org.eclipse.swt.widgets.Composite) ModifyListener(org.eclipse.swt.events.ModifyListener) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) DatabaseModelBean(net.heartsome.cat.common.bean.DatabaseModelBean) Label(org.eclipse.swt.widgets.Label) Text(org.eclipse.swt.widgets.Text) MenuItem(org.eclipse.swt.widgets.MenuItem) ImportException(net.heartsome.cat.common.core.exception.ImportException) TermDbManagerDialog(net.heartsome.cat.database.ui.tb.dialog.TermDbManagerDialog) GridLayout(org.eclipse.swt.layout.GridLayout) ModifyEvent(org.eclipse.swt.events.ModifyEvent) HSDropDownButton(net.heartsome.cat.common.ui.HSDropDownButton) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) Menu(org.eclipse.swt.widgets.Menu) FileDialog(org.eclipse.swt.widgets.FileDialog) File(java.io.File) Map(java.util.Map)

Example 50 with SelectionEvent

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

the class TmDbManagerDialog method addListeners.

/**
	 * Add Selection Listener to tree viewer
	 * @param viewer
	 *            ;
	 */
private void addListeners(final TreeViewer viewer) {
    // 选择事件
    viewer.addPostSelectionChangedListener(new ISelectionChangedListener() {

        public void selectionChanged(SelectionChangedEvent event) {
            ISelection selection = event.getSelection();
            if (selection.isEmpty()) {
                return;
            }
            IStructuredSelection structuredSelection = (IStructuredSelection) selection;
            Object obj = structuredSelection.getFirstElement();
            if (obj instanceof DatabaseModelBean) {
                DatabaseModelBean bean = (DatabaseModelBean) obj;
                setCurrDbType(bean.getDbType());
                bean.copyToOtherIntance(currServer);
                SystemDBOperator dbop = getCurrSysDbOp();
                if (dbop != null) {
                    executeSearch(dbop);
                }
                // 当数据库类型发生改变时重新初始化界面
                initUI(false);
            } else if (obj instanceof String) {
                setCurrDbType((String) obj);
                resetInputValue();
                currServerdbListInput.clear();
                initUI(true);
            }
        }
    });
    // 双击展开事件
    ((Tree) viewer.getControl()).addSelectionListener(new SelectionAdapter() {

        public void widgetDefaultSelected(final SelectionEvent event) {
            ISelection selection = viewer.getSelection();
            if (selection.isEmpty()) {
                return;
            }
            IStructuredSelection structuredSelection = (IStructuredSelection) selection;
            Object obj = structuredSelection.getFirstElement();
            if (obj instanceof String) {
                String type = (String) obj;
                boolean expanded = viewer.getExpandedState(type);
                viewer.setExpandedState(type, !expanded);
            }
        }
    });
    // 右键菜单事件,判断何时出现右键菜单
    viewer.getControl().addMenuDetectListener(new MenuDetectListener() {

        public void menuDetected(MenuDetectEvent e) {
            ISelection selection = viewer.getSelection();
            if (selection.isEmpty()) {
                return;
            }
            IStructuredSelection structuredSelection = (IStructuredSelection) selection;
            Object obj = structuredSelection.getFirstElement();
            Tree tree = treeViewer.getTree();
            if (obj instanceof DatabaseModelBean) {
                // 将菜单挂到树上
                tree.setMenu(treePopMenu);
            } else {
                tree.setMenu(null);
            }
        }
    });
}
Also used : ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) DatabaseModelBean(net.heartsome.cat.common.bean.DatabaseModelBean) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) SystemDBOperator(net.heartsome.cat.database.SystemDBOperator) MenuDetectEvent(org.eclipse.swt.events.MenuDetectEvent) ISelection(org.eclipse.jface.viewers.ISelection) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Tree(org.eclipse.swt.widgets.Tree) MenuDetectListener(org.eclipse.swt.events.MenuDetectListener)

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