Search in sources :

Example 36 with Spinner

use of org.eclipse.swt.widgets.Spinner in project cogtool by cogtool.

the class SNIFACTDialog method addMoreFields.

@Override
protected void addMoreFields() {
    super.addMoreFields();
    responseBox.setEditable(false);
    Label lbl = new Label(dialog, SWT.NONE);
    lbl.setText(L10N.get("PM.NumTrials", "Number of Trials") + ": ");
    GridData lblLayout = new GridData(GridData.HORIZONTAL_ALIGN_END);
    lbl.setLayoutData(lblLayout);
    numRunsSpinner = new Spinner(dialog, SWT.NONE);
    numRunsSpinner.setMinimum(1);
    numRunsSpinner.setMaximum(1000);
    numRunsSpinner.setSelection(defaultParameters.numRuns);
    lblLayout = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
    lblLayout.grabExcessHorizontalSpace = true;
    lblLayout.horizontalSpan = 3;
    numRunsSpinner.setLayoutData(lblLayout);
    lbl = new Label(dialog, SWT.NONE);
    lbl.setText(L10N.get("PM.KValue", "Eagerness to satisfy (smaller is more eager)") + ": ");
    lblLayout = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
    lbl.setLayoutData(lblLayout);
    kValueSpinner = new Spinner(dialog, SWT.NONE);
    kValueSpinner.setMinimum(1);
    kValueSpinner.setMaximum(999);
    kValueSpinner.setSelection(defaultParameters.kValue);
    kValueSpinner.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            if (addGroupMode == ENABLED) {
                boolean equal = kValueSpinner.getSelection() == defaultParameters.kValue;
                addToGroup.setEnabled(equal);
                if (!equal) {
                    addToGroup.setSelection(false);
                }
            }
        }
    });
    lblLayout = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
    lblLayout.grabExcessHorizontalSpace = true;
    lblLayout.horizontalSpan = 3;
    kValueSpinner.setLayoutData(lblLayout);
    lbl = new Label(dialog, SWT.NONE);
    lbl.setText(L10N.get("PM.StartFrame", "Start Frame") + ": ");
    lblLayout = new GridData(GridData.HORIZONTAL_ALIGN_END);
    lbl.setLayoutData(lblLayout);
    startFrameCombo = new ComboWithEnableFix(dialog, SWT.DROP_DOWN | SWT.READ_ONLY);
    startFrameCombo.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            if (addGroupMode == ENABLED) {
                int selIndex = startFrameCombo.getSelectionIndex();
                String frameName = startFrameCombo.getItem(selIndex);
                String defaultName = defaultParameters.startFrame;
                boolean equal = frameName.equals(defaultName);
                addToGroup.setEnabled(equal);
                if (!equal) {
                    addToGroup.setSelection(false);
                }
            }
        }
    });
    lblLayout = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
    lblLayout.grabExcessHorizontalSpace = true;
    lblLayout.horizontalSpan = 3;
    startFrameCombo.setLayoutData(lblLayout);
    lbl = new Label(dialog, SWT.NONE);
    lbl.setText(L10N.get("PM.TargetFrames", "Target Frames") + ": ");
    lblLayout = new GridData(GridData.HORIZONTAL_ALIGN_END);
    lbl.setLayoutData(lblLayout);
    targetFrameList = new org.eclipse.swt.widgets.List(dialog, SWT.MULTI | SWT.V_SCROLL | SWT.BORDER);
    targetFrameList.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            okButton.setEnabled(targetFrameList.getSelectionCount() > 0);
            if (addGroupMode == ENABLED) {
                // Need to test whether the list of selected frame names
                // is identical (except for order) to the list of frame
                // names specified in defaultParameters.targetFrames, so
                // check if they are the same size and then test whether
                // any names in one list don't appear in the other
                String[] targets = targetFrameList.getSelection();
                java.util.List<String> defaultTargets = defaultParameters.targetFrames;
                boolean equal = targets.length == defaultTargets.size();
                if (equal) {
                    for (int i = 0; i < targets.length; i++) {
                        String curDefault = defaultTargets.get(i);
                        if (!(curDefault.equals(targets[i]))) {
                            equal = false;
                        }
                    }
                }
                addToGroup.setEnabled(equal);
                if (!equal) {
                    addToGroup.setSelection(false);
                }
            }
        }
    });
    for (int i = 0; i < sortedFrames.size(); i++) {
        String name = sortedFrames.get(i).getName();
        String display = SWTStringUtil.insertEllipsis(name, WIDTH, StringUtil.NO_FRONT, SWTStringUtil.DEFAULT_FONT);
        startFrameCombo.add(display);
        targetFrameList.add(display);
        if (name.equals(defaultParameters.startFrame)) {
            startFrameCombo.select(i);
        }
        if (defaultParameters.targetFrames.contains(name)) {
            targetFrameList.select(i);
        }
    }
    lblLayout = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
    lblLayout.grabExcessHorizontalSpace = true;
    lblLayout.horizontalSpan = 3;
    lblLayout.heightHint = 100;
    targetFrameList.setLayoutData(lblLayout);
    if (algorithmSet.size() > 1) {
        lbl = new Label(dialog, SWT.NONE);
        lbl.setText(L10N.get("PM.Algorithm", "Algorithm") + ": ");
        lblLayout = new GridData(GridData.HORIZONTAL_ALIGN_END);
        lbl.setLayoutData(lblLayout);
        algCombo = new ComboWithEnableFix(dialog, SWT.DROP_DOWN | SWT.READ_ONLY);
        algCombo.add(L10N.get("PM.All", "All"));
        int i = 0;
        algArray[i++] = null;
        int selectIndex = 0;
        Iterator<ITermSimilarity> algs = algorithmSet.iterator();
        while (algs.hasNext()) {
            ITermSimilarity alg = algs.next();
            algArray[i] = alg;
            algCombo.add(DictionaryEditorUIModel.getAlgLabel(alg));
            if (alg.getClass().isInstance(defaultParameters.algorithm)) {
                selectIndex = i;
            }
            i++;
        }
        algCombo.select(selectIndex);
        lblLayout = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
        lblLayout.grabExcessHorizontalSpace = true;
        lblLayout.horizontalSpan = 3;
        algCombo.setLayoutData(lblLayout);
    }
    numRunsSpinner.forceFocus();
    if (addGroupMode != NONE) {
        addToGroup = new Button(dialog, SWT.CHECK);
        addToGroup.setText(L10N.get("PM.AddToGroup", "Add scripts to existing task group"));
        addToGroup.setEnabled(true);
        addToGroup.setSelection(true);
        lblLayout = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
        lblLayout.grabExcessHorizontalSpace = true;
        lblLayout.horizontalSpan = 3;
        addToGroup.setLayoutData(lblLayout);
    }
    exportOnly = new Button(dialog, SWT.CHECK);
    exportOnly.setText(L10N.get("PM.ExportOnly", "Only export model, do not run it"));
    exportOnly.setEnabled(true);
    exportOnly.setSelection(false);
    lblLayout = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
    lblLayout.grabExcessHorizontalSpace = true;
    lblLayout.horizontalSpan = 3;
    exportOnly.setLayoutData(lblLayout);
}
Also used : Spinner(org.eclipse.swt.widgets.Spinner) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) ITermSimilarity(edu.cmu.cs.hcii.cogtool.model.ITermSimilarity) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) List(org.eclipse.swt.widgets.List) ArrayList(java.util.ArrayList) List(org.eclipse.swt.widgets.List) ComboWithEnableFix(edu.cmu.cs.hcii.cogtool.util.ComboWithEnableFix)

Example 37 with Spinner

use of org.eclipse.swt.widgets.Spinner in project translationstudio8 by heartsome.

the class SystemPreferencePage method createContents.

@Override
protected Control createContents(Composite parent) {
    isInit = true;
    Composite tparent = new Composite(parent, SWT.NONE);
    tparent.setLayout(new GridLayout());
    tparent.setLayoutData(new GridData(GridData.FILL_BOTH));
    Group groupCommon = new Group(tparent, SWT.NONE);
    groupCommon.setLayout(new GridLayout());
    groupCommon.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    groupCommon.setText(Messages.getString("preferencepage.SystemPreferencePage.groupCommon"));
    HsImageLabel imageLabel1 = new HsImageLabel(Messages.getString("preferencepage.SystemPreferencePage.imageLabel1"), Activator.getImageDescriptor(ImageConstant.PREFERENCE_SYS_UPDATE));
    Composite cmpCommon = imageLabel1.createControl(groupCommon);
    cmpCommon.setLayout(new GridLayout());
    cmpCommon.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    btnCheckUpdateWithStartup = new Button(cmpCommon, SWT.RADIO);
    btnCheckUpdateWithStartup.setText(Messages.getString("preferencepage.SystemPreferencePage.btnCheckUpdateWithStartup"));
    GridDataFactory.fillDefaults().applyTo(btnCheckUpdateWithStartup);
    btnCheckUpdateWithStartup.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            if (btnCheckUpdateWithStartup.getSelection()) {
                btnCheckUpdateWithMonthly.setSelection(false);
                btnCheckUpdateWithWeekly.setSelection(false);
                btnCheckUpdateWithNever.setSelection(false);
                selectDateSpi.setEnabled(false);
                cmbSelectWeek.setEnabled(false);
            }
        }

        public void widgetDefaultSelected(SelectionEvent e) {
        }
    });
    cmpMonthly = new Composite(cmpCommon, SWT.None);
    GridLayoutFactory.swtDefaults().numColumns(3).equalWidth(false).margins(0, 0).spacing(0, 0).applyTo(cmpMonthly);
    cmpMonthly.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    btnCheckUpdateWithMonthly = new Button(cmpMonthly, SWT.RADIO);
    btnCheckUpdateWithMonthly.setText(Messages.getString("preferencepage.SystemPreferencePage.btnCheckUpdateWithMonthly1"));
    GridData spinnaData = new GridData();
    spinnaData.widthHint = 20;
    selectDateSpi = new Spinner(cmpMonthly, SWT.BORDER);
    selectDateSpi.setMinimum(1);
    selectDateSpi.setMaximum(31);
    selectDateSpi.setTextLimit(2);
    selectDateSpi.setEnabled(false);
    selectDateSpi.setLayoutData(spinnaData);
    selectDateSpi.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            String text = selectDateSpi.getText();
            if (text != null && !text.trim().equals("")) {
                if (Integer.parseInt(text.trim()) > 31) {
                    selectDateSpi.setSelection(31);
                } else if (Integer.parseInt(text.trim()) < 1) {
                    selectDateSpi.setSelection(1);
                }
            }
        }
    });
    new Label(cmpMonthly, SWT.None).setText(Messages.getString("preferencepage.SystemPreferencePage.btnCheckUpdateWithMonthly2"));
    btnCheckUpdateWithMonthly.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            selectDateSpi.setEnabled(btnCheckUpdateWithMonthly.getSelection());
            if (btnCheckUpdateWithMonthly.getSelection()) {
                btnCheckUpdateWithStartup.setSelection(false);
                btnCheckUpdateWithWeekly.setSelection(false);
                btnCheckUpdateWithNever.setSelection(false);
                cmbSelectWeek.setEnabled(false);
            }
        }

        public void widgetDefaultSelected(SelectionEvent e) {
        }
    });
    cmpWeekly = new Composite(cmpCommon, SWT.None);
    GridLayoutFactory.swtDefaults().numColumns(3).equalWidth(false).margins(0, 0).spacing(0, 0).applyTo(cmpWeekly);
    cmpWeekly.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    btnCheckUpdateWithWeekly = new Button(cmpWeekly, SWT.RADIO);
    btnCheckUpdateWithWeekly.setText(Messages.getString("preferencepage.SystemPreferencePage.btnCheckUpdateWithWeekly1"));
    cmbSelectWeek = new Combo(cmpWeekly, SWT.READ_ONLY);
    cmbSelectWeek.setItems(arrWeek);
    cmbSelectWeek.setEnabled(false);
    cmbSelectWeek.select(0);
    GridDataFactory.swtDefaults().applyTo(cmbSelectWeek);
    new Label(cmpWeekly, SWT.NONE).setText(Messages.getString("preferencepage.SystemPreferencePage.btnCheckUpdateWithWeekly2"));
    btnCheckUpdateWithWeekly.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            cmbSelectWeek.setEnabled(btnCheckUpdateWithWeekly.getSelection());
            if (btnCheckUpdateWithWeekly.getSelection()) {
                btnCheckUpdateWithStartup.setSelection(false);
                btnCheckUpdateWithMonthly.setSelection(false);
                btnCheckUpdateWithNever.setSelection(false);
                selectDateSpi.setEnabled(false);
            }
        }

        public void widgetDefaultSelected(SelectionEvent e) {
        }
    });
    btnCheckUpdateWithNever = new Button(cmpCommon, SWT.RADIO);
    btnCheckUpdateWithNever.setText(Messages.getString("preferencepage.SystemPreferencePage.btnCheckUpdateWithNever"));
    btnCheckUpdateWithNever.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    GridDataFactory.fillDefaults().applyTo(btnCheckUpdateWithNever);
    btnCheckUpdateWithNever.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            if (btnCheckUpdateWithNever.getSelection()) {
                btnCheckUpdateWithMonthly.setSelection(false);
                btnCheckUpdateWithWeekly.setSelection(false);
                btnCheckUpdateWithStartup.setSelection(false);
                selectDateSpi.setEnabled(false);
                cmbSelectWeek.setEnabled(false);
            }
        }

        public void widgetDefaultSelected(SelectionEvent e) {
        }
    });
    Group groupLanguage = new Group(tparent, SWT.NONE);
    groupLanguage.setLayout(new GridLayout());
    groupLanguage.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    groupLanguage.setText(Messages.getString("preferencepage.SystemPreferencePage.groupLanguage"));
    HsImageLabel imageLabel2 = new HsImageLabel(Messages.getString("preferencepage.SystemPreferencePage.imageLabel3"), Activator.getImageDescriptor(ImageConstant.PREFERENCE_SYS_LANGUAGE));
    Composite cmpLang = imageLabel2.createControl(groupLanguage);
    cmpLang.setLayout(new GridLayout());
    cmpLang.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    btnLanguageWithEN = new Button(cmpLang, SWT.RADIO);
    btnLanguageWithEN.setText(Messages.getString("preferencepage.SystemPreferencePage.btnLanguageWithEN"));
    btnLanguageWithEN.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    btnLanguageWithZHCN = new Button(cmpLang, SWT.RADIO);
    btnLanguageWithZHCN.setText(Messages.getString("preferencepage.SystemPreferencePage.btnLanguageWithZHCN"));
    btnLanguageWithZHCN.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    Group groupFont = new Group(tparent, SWT.NONE);
    groupFont.setLayout(new GridLayout());
    groupFont.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    groupFont.setText(Messages.getString("preferencepage.SystemPreferencePage.groupFont"));
    HsImageLabel imageLabel4 = new HsImageLabel(Messages.getString("preferencepage.SystemPreferencePage.groupFont.desc"), Activator.getImageDescriptor("images/preference/system/font.png"));
    Composite cmpFont = imageLabel4.createControl(groupFont);
    GridLayout cmpFontGl = new GridLayout(2, true);
    cmpFontGl.marginLeft = 0;
    cmpFontGl.marginRight = 0;
    cmpFontGl.marginTop = 0;
    cmpFontGl.marginBottom = 0;
    cmpFontGl.marginWidth = 0;
    cmpFontGl.marginHeight = 0;
    cmpFont.setLayout(cmpFontGl);
    GridData cmpFontGd = new GridData(SWT.FILL, SWT.FILL, true, true);
    cmpFont.setLayoutData(cmpFontGd);
    editorFontSetting = new HSFontSettingComposite(cmpFont, SWT.NONE, Messages.getString("preferencepage.fontsetting.editor.title"));
    GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
    editorFontSetting.setLayoutData(gd);
    matchViewFontSetting = new HSFontSettingComposite(cmpFont, SWT.NONE, Messages.getString("preferencepage.fontsetting.matchView.title"));
    matchViewFontSetting.setLayoutData(gd);
    Group groupSystemUser = new Group(tparent, SWT.NONE);
    groupSystemUser.setLayout(new GridLayout());
    groupSystemUser.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    groupSystemUser.setText(Messages.getString("preferencepage.SystemPreferencePage.groupSystemUser"));
    HsImageLabel imageLabel3 = new HsImageLabel(Messages.getString("preferencepage.SystemPreferencePage.imageLabel4"), Activator.getImageDescriptor(ImageConstant.PREFERENCE_SYS_USER));
    Composite cmpUser = imageLabel3.createControl(groupSystemUser);
    cmpUser.setLayout(new GridLayout(2, false));
    cmpUser.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    new Label(cmpUser, SWT.NONE).setText(Messages.getString("preferencepage.SystemPreferencePage.lblUser"));
    txtSystemUser = new Text(cmpUser, SWT.BORDER);
    txtSystemUser.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    imageLabel1.computeSize();
    imageLabel2.computeSize();
    imageLabel3.computeSize();
    imageLabel4.computeSize();
    setInitValues(false);
    return parent;
}
Also used : Group(org.eclipse.swt.widgets.Group) HSFontSettingComposite(net.heartsome.cat.common.ui.HSFontSettingComposite) Composite(org.eclipse.swt.widgets.Composite) ModifyListener(org.eclipse.swt.events.ModifyListener) Spinner(org.eclipse.swt.widgets.Spinner) HsImageLabel(net.heartsome.cat.common.ui.HsImageLabel) Label(org.eclipse.swt.widgets.Label) Combo(org.eclipse.swt.widgets.Combo) Text(org.eclipse.swt.widgets.Text) GridLayout(org.eclipse.swt.layout.GridLayout) ModifyEvent(org.eclipse.swt.events.ModifyEvent) HsImageLabel(net.heartsome.cat.common.ui.HsImageLabel) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) HSFontSettingComposite(net.heartsome.cat.common.ui.HSFontSettingComposite) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 38 with Spinner

use of org.eclipse.swt.widgets.Spinner in project translationstudio8 by heartsome.

the class IntegerCellEditor method createControl.

/**
     * Create the control.
     * 
     * @param table parent table
     */
private void createControl(JaretTable table) {
    if (_spinner == null) {
        _table = table;
        _spinner = new Spinner(table, SWT.BORDER);
        _spinner.setMaximum(_max);
        _spinner.setMinimum(_min);
        _spinner.addTraverseListener(new TraverseListener() {

            public void keyTraversed(TraverseEvent e) {
                e.doit = false;
            }
        });
        _spinner.addKeyListener(new KeyListener() {

            public void keyPressed(KeyEvent event) {
                if (event.keyCode == SWT.TAB) {
                    event.doit = false;
                    stopEditing(true);
                    _table.forceFocus();
                    _table.focusRight();
                } else if (event.keyCode == SWT.CR) {
                    event.doit = false;
                    stopEditing(true);
                    _table.forceFocus();
                    _table.focusDown();
                } else if (event.keyCode == SWT.ESC) {
                    event.doit = false;
                    stopEditing(false);
                    _column.setValue(_row, _oldVal);
                    _table.forceFocus();
                }
            }

            public void keyReleased(KeyEvent arg0) {
            }
        });
        _spinner.addFocusListener(this);
    }
}
Also used : KeyEvent(org.eclipse.swt.events.KeyEvent) TraverseEvent(org.eclipse.swt.events.TraverseEvent) TraverseListener(org.eclipse.swt.events.TraverseListener) Spinner(org.eclipse.swt.widgets.Spinner) KeyListener(org.eclipse.swt.events.KeyListener)

Example 39 with Spinner

use of org.eclipse.swt.widgets.Spinner in project translationstudio8 by heartsome.

the class EquivalentPage method createMatchEqui.

/**
	 * 创建加权系统设置区间
	 */
public void createMatchEqui(String equivalStr) {
    boolean isDelete = false;
    String[] equivalArray = equivalStr.split(";");
    for (int i = 0; i < equivalArray.length; i++) {
        String equival = equivalArray[i];
        String matchStr = equival.substring(0, equival.indexOf(":"));
        String equiValue = equival.substring(equival.indexOf(":") + 1, equival.length());
        // 先处理所有重复加权系数
        if (QAConstant._InternalRepeat.equals(matchStr)) {
            Composite interRepeatCmp = (Composite) repeatCmp.getChildren()[0];
            Text text = (Text) interRepeatCmp.getChildren()[2];
            text.setText(equiValue);
        } else if (QAConstant._External101.equals(matchStr)) {
            if (isUltimate) {
                Composite exter101Cmp = (Composite) repeatCmp.getChildren()[1];
                Text text = (Text) exter101Cmp.getChildren()[2];
                text.setText(equiValue);
            }
        } else if (QAConstant._External100.equals(matchStr)) {
            Composite exter100Cmp = (Composite) repeatCmp.getChildren()[2 - (isUltimate ? 0 : 1)];
            Text text = (Text) exter100Cmp.getChildren()[2];
            text.setText(equiValue);
        } else {
            int minMacth = Integer.parseInt(equival.substring(0, equival.indexOf("-")));
            int maxMatch = Integer.parseInt(equival.substring(equival.indexOf("-") + 1, equival.indexOf(":")));
            if (maxMatch == 99) {
                // 如果最大匹配率是99,那么就是模糊匹配的第一个设置
                Composite macthCmp = (Composite) matchParent.getChildren()[0];
                Control[] ctls = macthCmp.getChildren();
                Text text = (Text) ctls[6];
                Spinner minSp = (Spinner) ctls[0];
                Spinner maxSp = (Spinner) ctls[3];
                text.setText(equiValue);
                minSp.setSelection(minMacth);
                maxSp.setSelection(maxMatch);
            } else {
                if (!isDelete) {
                    // 若模糊匹配区间有两个或两个以上的匹配,那么先删除所有除第一个以外的其他设置
                    if (matchParent.getChildren().length > 1) {
                        for (int j = matchParent.getChildren().length - 1; j >= 1; j--) {
                            Control[] ctls = matchParent.getChildren();
                            ctls[j].dispose();
                        }
                        index = 1;
                    }
                    // 创建除第一个模糊匹配之外的其他匹配段
                    int fixItemNum = equivalStr.indexOf("external101") == -1 ? 3 : 4;
                    for (int j = 0; j < equivalStr.split(";").length - fixItemNum; j++) {
                        Composite cmp = (Composite) ((Composite) matchParent.getChildren()[j]).getChildren()[7];
                        Button addBtn = (Button) cmp.getChildren()[0];
                        addEquiCmp(null, addBtn);
                    }
                    isDelete = true;
                }
                int fixItemNum = equivalStr.indexOf("external101") == -1 ? 2 : 3;
                Composite macthCmp = (Composite) matchParent.getChildren()[i - fixItemNum];
                Control[] ctls = macthCmp.getChildren();
                Text text = (Text) ctls[6];
                Spinner minSp = (Spinner) ctls[0];
                Spinner maxSp = (Spinner) ctls[3];
                text.setText(equiValue);
                minSp.setSelection(minMacth);
                maxSp.setSelection(maxMatch);
            }
        }
    }
    //		matchParent.pack();
    matchParent.layout();
// matchParent.getParent().pack();
//		matchParent.getParent().layout();
}
Also used : Control(org.eclipse.swt.widgets.Control) Composite(org.eclipse.swt.widgets.Composite) Button(org.eclipse.swt.widgets.Button) Spinner(org.eclipse.swt.widgets.Spinner) Text(org.eclipse.swt.widgets.Text)

Example 40 with Spinner

use of org.eclipse.swt.widgets.Spinner in project translationstudio8 by heartsome.

the class FileAnalysisInstalPage method createContents.

@Override
protected Control createContents(Composite parent) {
    isInit = true;
    Composite tparent = new Composite(parent, SWT.NONE);
    tparent.setLayout(new GridLayout());
    tparent.setLayoutData(new GridData(GridData.FILL_BOTH));
    Group faGroup = new Group(tparent, SWT.NONE);
    faGroup.setLayout(new GridLayout());
    faGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    faGroup.setText(Messages.getString("preference.FileAnalysisInstalPage.faGroup"));
    String tip = Messages.getString("preference.FileAnalysisInstalPage.faImgLbl");
    HsImageLabel faImgLbl = new HsImageLabel(tip, Activator.getImageDescriptor(ImageConstant.PREFERENCE_FA_analysis));
    Composite faLblCmp = faImgLbl.createControl(faGroup);
    faLblCmp.setLayout(new GridLayout());
    faLblCmp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    ignoreCaseBtn = new Button(faLblCmp, SWT.CHECK);
    ignoreCaseBtn.setText(Messages.getString("preference.FileAnalysisInstalPage.ignoreCaseBtn"));
    ignoreTagBtn = new Button(faLblCmp, SWT.CHECK);
    ignoreTagBtn.setText(Messages.getString("preference.FileAnalysisInstalPage.ignoreTagBtn"));
    ignoreTagBtn.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            setTagPenaltyEnable();
        }

        public void widgetDefaultSelected(SelectionEvent e) {
            setTagPenaltyEnable();
        }
    });
    GridData spinnerData = new GridData(30, SWT.DEFAULT);
    // 罚分制度
    Composite tagPenaltyCmp = new Composite(faLblCmp, SWT.NONE);
    GridLayoutFactory.fillDefaults().extendedMargins(0, 0, 0, 0).numColumns(3).applyTo(tagPenaltyCmp);
    tagPenaltyCmp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    tagPenaltyLbl = new Label(tagPenaltyCmp, SWT.NONE);
    tagPenaltyLbl.setText(Messages.getString("preference.FileAnalysisInstalPage.tagPenalty"));
    tagPenaltySpi = new Spinner(tagPenaltyCmp, SWT.BORDER);
    tagPenaltySpi.setLayoutData(spinnerData);
    GridLayout pGl = new GridLayout(2, false);
    pGl.marginHeight = 0;
    pGl.marginWidth = 0;
    tagPenaltySpi.setMinimum(1);
    tagPenaltySpi.setMaximum(100);
    if (CommonFunction.checkEdition("U")) {
        // 上下文个数
        Composite contextCmp = new Composite(faLblCmp, SWT.NONE);
        GridLayoutFactory.fillDefaults().extendedMargins(0, 0, 0, 0).numColumns(3).applyTo(contextCmp);
        contextCmp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
        Label contextLbl = new Label(contextCmp, SWT.NONE);
        contextLbl.setText(Messages.getString("preference.FileAnalysisInstalPage.contextLbl"));
        contextSpinner = new Spinner(contextCmp, SWT.BORDER);
        contextSpinner.setLayoutData(spinnerData);
        contextSpinner.setMinimum(1);
        contextSpinner.setMaximum(100);
        // 步值为1
        contextSpinner.setIncrement(1);
        contextSpinner.setSelection(1);
        Label unitLbl = new Label(contextCmp, SWT.NONE);
        unitLbl.setText(Messages.getString("preference.FileAnalysisInstalPage.unitLbl"));
    }
    faImgLbl.computeSize();
    // 分析文件设置
    Group faFileGroup = new Group(tparent, SWT.NONE);
    faFileGroup.setLayout(new GridLayout());
    faFileGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    faFileGroup.setText(Messages.getString("preference.FileAnalysisInstalPage.faFileGroup"));
    String faFileTip = Messages.getString("preference.FileAnalysisInstalPage.faFileTip");
    HsImageLabel faFileImgLbl = new HsImageLabel(faFileTip, Activator.getImageDescriptor(ImageConstant.PREFERENCE_FA_fileAnalysis));
    Composite faFileLblCmp = faFileImgLbl.createControl(faFileGroup);
    faFileLblCmp.setLayout(new GridLayout());
    faFileLblCmp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    interRepateBtn = new Button(faFileLblCmp, SWT.CHECK);
    interRepateBtn.setText(Messages.getString("preference.FileAnalysisInstalPage.faFileInterRepeate"));
    interMatchBtn = new Button(faFileLblCmp, SWT.CHECK);
    interMatchBtn.setText(Messages.getString("preference.FileAnalysisInstalPage.faFileInterMatch"));
    faFileImgLbl.computeSize();
    initListener();
    initValue();
    return parent;
}
Also used : Group(org.eclipse.swt.widgets.Group) GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) HsImageLabel(net.heartsome.cat.common.ui.HsImageLabel) Button(org.eclipse.swt.widgets.Button) Spinner(org.eclipse.swt.widgets.Spinner) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) HsImageLabel(net.heartsome.cat.common.ui.HsImageLabel) Label(org.eclipse.swt.widgets.Label) SelectionListener(org.eclipse.swt.events.SelectionListener)

Aggregations

Spinner (org.eclipse.swt.widgets.Spinner)70 GridLayout (org.eclipse.swt.layout.GridLayout)54 Label (org.eclipse.swt.widgets.Label)54 Button (org.eclipse.swt.widgets.Button)53 Composite (org.eclipse.swt.widgets.Composite)52 GridData (org.eclipse.swt.layout.GridData)51 Group (org.eclipse.swt.widgets.Group)32 SelectionEvent (org.eclipse.swt.events.SelectionEvent)25 Text (org.eclipse.swt.widgets.Text)24 Combo (org.eclipse.swt.widgets.Combo)20 SelectionListener (org.eclipse.swt.events.SelectionListener)19 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)18 SWT (org.eclipse.swt.SWT)16 ModifyListener (org.eclipse.swt.events.ModifyListener)14 ModifyEvent (org.eclipse.swt.events.ModifyEvent)11 Point (org.eclipse.swt.graphics.Point)11 Control (org.eclipse.swt.widgets.Control)10 CoreException (org.eclipse.core.runtime.CoreException)6 ILaunchConfiguration (org.eclipse.debug.core.ILaunchConfiguration)6 ILaunchConfigurationWorkingCopy (org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)6