Search in sources :

Example 26 with ModifyEvent

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

the class SearchDialog method createInputPanel.

private Composite createInputPanel(final Composite composite) {
    final Composite row = new Composite(composite, SWT.NONE);
    row.setLayout(new GridLayout(2, false));
    final Label findLabel = new Label(row, SWT.NONE);
    findLabel.setText("F&ind:");
    GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(findLabel);
    findText = new Text(row, SWT.SINGLE | SWT.BORDER);
    GridDataFactory.fillDefaults().grab(true, false).applyTo(findText);
    findText.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            findButton.setEnabled(findText.getText().length() > 0);
        }
    });
    findText.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            if (findButton.isEnabled()) {
                doFind();
            }
        }
    });
    return row;
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) ModifyEvent(org.eclipse.swt.events.ModifyEvent) Composite(org.eclipse.swt.widgets.Composite) ModifyListener(org.eclipse.swt.events.ModifyListener) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Text(org.eclipse.swt.widgets.Text)

Example 27 with ModifyEvent

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

the class SetSplitPointByWordNumDialog method createDialogArea.

@Override
protected Control createDialogArea(Composite parent) {
    Composite tparent = (Composite) super.createDialogArea(parent);
    GridData parentData = new GridData(SWT.FILL, SWT.FILL, true, true);
    parentData.widthHint = 400;
    parentData.heightHint = 350;
    tparent.setLayoutData(parentData);
    GridLayoutFactory.swtDefaults().numColumns(1).applyTo(tparent);
    Group typeGroup = new Group(tparent, SWT.NONE);
    typeGroup.setText(Messages.getString("SetSplitPointByWordNumDialog.splitType"));
    GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(typeGroup);
    GridLayoutFactory.swtDefaults().numColumns(2).equalWidth(true).applyTo(typeGroup);
    averageBtn = new Button(typeGroup, SWT.RADIO);
    GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(averageBtn);
    averageBtn.setText(Messages.getString("SetSplitPointByWordNumDialog.splitByAverWordNum"));
    averageBtn.setSelection(true);
    wordNumberBtn = new Button(typeGroup, SWT.RADIO);
    GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(wordNumberBtn);
    wordNumberBtn.setText(Messages.getString("SetSplitPointByWordNumDialog.splitByFixWordNum"));
    // >显示总字数的面板
    Composite allNumCmp = new Composite(tparent, SWT.NONE);
    GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER).applyTo(allNumCmp);
    GridLayoutFactory.swtDefaults().numColumns(2).applyTo(allNumCmp);
    Label countLbl = new Label(allNumCmp, SWT.NONE);
    countLbl.setText(Messages.getString("SetSplitPointByWordNumDialog.curFileTotalWordNum"));
    countLbl.setFont(totalLblFont);
    Label countValueLbl = new Label(allNumCmp, SWT.NONE);
    countValueLbl.setText(totalWordNum + "");
    countValueLbl.setFont(totalLblFont);
    // >两个面板的父面板
    Composite contentCmp = new Composite(tparent, SWT.NONE);
    GridDataFactory.fillDefaults().grab(true, true).applyTo(contentCmp);
    contentCmp.setLayout(stack);
    // >>平均字数分割方式的面板
    averageContentCmp = new Composite(contentCmp, SWT.BORDER);
    GridDataFactory.fillDefaults().grab(true, true).applyTo(averageContentCmp);
    GridLayoutFactory.swtDefaults().numColumns(2).applyTo(averageContentCmp);
    Label segLbl = new Label(averageContentCmp, SWT.NONE);
    segLbl.setText(Messages.getString("SetSplitPointByWordNumDialog.segNumLbl"));
    segSpiner = new Spinner(averageContentCmp, SWT.BORDER);
    segSpiner.setIncrement(1);
    segSpiner.setMinimum(2);
    segSpiner.setMaximum(totalTuNum - 1);
    segSpiner.setSelection(segList.size());
    segSpiner.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent arg0) {
            String text = segSpiner.getText();
            if (!(text.matches("\\d{1,}") && Integer.parseInt(text) <= (totalTuNum - 1))) {
                segSpiner.setSelection(2);
            }
        }
    });
    GridDataFactory.swtDefaults().hint(50, SWT.DEFAULT).applyTo(segSpiner);
    // >>按指定字数分割的面板
    wordNumberScroll = new ScrolledComposite(contentCmp, SWT.NONE | SWT.V_SCROLL | SWT.BORDER);
    GridDataFactory.fillDefaults().grab(true, true).applyTo(wordNumberScroll);
    GridLayoutFactory.swtDefaults().numColumns(1).applyTo(wordNumberScroll);
    wordNumberScroll.setExpandHorizontal(true);
    wordNumberScroll.setExpandVertical(true);
    segParentCmp = new Composite(wordNumberScroll, SWT.NONE);
    GridDataFactory.fillDefaults().grab(true, false).applyTo(segParentCmp);
    GridLayoutFactory.swtDefaults().spacing(SWT.DEFAULT, 0).numColumns(1).applyTo(segParentCmp);
    wordNumberScroll.setContent(segParentCmp);
    averageBtn.addSelectionListener(new SelectionListener() {

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

        public void widgetDefaultSelected(SelectionEvent e) {
            viewerTopControl();
        }
    });
    wordNumberBtn.addSelectionListener(new SelectionListener() {

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

        public void widgetDefaultSelected(SelectionEvent e) {
            viewerTopControl();
        }
    });
    stack.topControl = averageContentCmp;
    // 开始创建片断列表
    for (int i = 0; i < segList.size(); i++) {
        SegPointBean bean = segList.get(i);
        createSegCmp(bean);
    }
    wordNumberScroll.setMinSize(segParentCmp.computeSize(SWT.DEFAULT, SWT.DEFAULT));
    segParentCmp.layout();
    wordNumberScroll.layout();
    return tparent;
}
Also used : Group(org.eclipse.swt.widgets.Group) SegPointBean(net.heartsome.cat.ts.core.bean.SegPointBean) Composite(org.eclipse.swt.widgets.Composite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) ModifyListener(org.eclipse.swt.events.ModifyListener) Spinner(org.eclipse.swt.widgets.Spinner) Label(org.eclipse.swt.widgets.Label) ModifyEvent(org.eclipse.swt.events.ModifyEvent) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 28 with ModifyEvent

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

the class AddOrEditElementOfXmlConvertDialog method createDialogArea.

@Override
protected Control createDialogArea(Composite parent) {
    Composite tparent = (Composite) super.createDialogArea(parent);
    GridDataFactory.fillDefaults().grab(true, true).applyTo(tparent);
    Composite composite = new Composite(tparent, SWT.NONE);
    GridDataFactory.fillDefaults().grab(true, true).applyTo(composite);
    GridLayoutFactory.fillDefaults().numColumns(2).equalWidth(false).applyTo(composite);
    // 元素类型下拉框的值, 备注:不能本地化
    String[] typeValues = { "segment", "inline", "ignore" };
    // 内联类型下拉框的值, 备注:不能本地化
    String[] internalValues = { "", "image", "pb", "lb", "x-bold", "x-entry", "x-font", "x-italic", "x-link", "x-underlined", "x-other" };
    // 保留空格下拉框的值, 备注:不能本地化
    String[] remainSpaceVlaues = { "", "yes", "no" };
    GridData textData = new GridData(SWT.FILL, SWT.CENTER, true, false);
    textData.widthHint = 100;
    // 元素名称
    Label nameLbl = new Label(composite, SWT.NONE);
    nameLbl.setText(Messages.getString("dialogs.AddOrEditElementOfXmlConvertDialog.nameLbl"));
    nameLbl.setAlignment(SWT.RIGHT);
    GridDataFactory.swtDefaults().align(SWT.RIGHT, SWT.CENTER).grab(false, false).applyTo(nameLbl);
    nameTxt = new Text(composite, SWT.BORDER);
    nameTxt.setLayoutData(textData);
    // 元素类型
    Label typeLbl = new Label(composite, SWT.NONE);
    typeLbl.setText(Messages.getString("dialogs.AddOrEditElementOfXmlConvertDialog.typeLbl"));
    GridDataFactory.swtDefaults().align(SWT.RIGHT, SWT.CENTER).grab(false, false).applyTo(typeLbl);
    typeCmb = new Combo(composite, SWT.BORDER | SWT.READ_ONLY);
    typeCmb.setLayoutData(textData);
    typeCmb.setItems(typeValues);
    typeCmb.select(0);
    // 内联类型
    Label inlineLbl = new Label(composite, SWT.NONE);
    inlineLbl.setText(Messages.getString("dialogs.AddOrEditElementOfXmlConvertDialog.inlineLbl"));
    GridDataFactory.swtDefaults().align(SWT.RIGHT, SWT.CENTER).grab(false, false).applyTo(inlineLbl);
    inlineCmb = new Combo(composite, SWT.BORDER | SWT.READ_ONLY);
    inlineCmb.setLayoutData(textData);
    inlineCmb.setItems(internalValues);
    inlineCmb.setEnabled(false);
    // 可翻译属性
    Label transAttriLbl = new Label(composite, SWT.NONE);
    transAttriLbl.setText(Messages.getString("dialogs.AddOrEditElementOfXmlConvertDialog.transAttriLbl"));
    GridDataFactory.swtDefaults().align(SWT.RIGHT, SWT.CENTER).grab(false, false).applyTo(transAttriLbl);
    transAtrriTxt = new Text(composite, SWT.BORDER);
    transAtrriTxt.setLayoutData(textData);
    // 保留空格
    Label remainSpaceLbl = new Label(composite, SWT.NONE);
    remainSpaceLbl.setText(Messages.getString("dialogs.AddOrEditElementOfXmlConvertDialog.remainSpaceLbl"));
    GridDataFactory.swtDefaults().align(SWT.RIGHT, SWT.CENTER).grab(false, false).applyTo(remainSpaceLbl);
    remainSpaceCmb = new Combo(composite, SWT.BORDER | SWT.READ_ONLY);
    remainSpaceCmb.setLayoutData(textData);
    remainSpaceCmb.setItems(remainSpaceVlaues);
    // 当元素类型是segment时,禁用内联内型,当元素类型是inline时,禁用可翻译属性。当元素类型是ignore时,禁用可翻译属性与内联内型
    typeCmb.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            String type = typeCmb.getText();
            if ("segment".equals(type)) {
                inlineCmb.setText("");
                inlineCmb.setEnabled(false);
                transAtrriTxt.setEnabled(true);
            } else if ("inline".equals(type)) {
                inlineCmb.setEnabled(true);
                transAtrriTxt.setText("");
                transAtrriTxt.setEnabled(false);
            } else if ("ignore".equals(type)) {
                inlineCmb.setText("");
                inlineCmb.setEnabled(false);
                transAtrriTxt.setText("");
                transAtrriTxt.setEnabled(false);
            }
        }
    });
    return tparent;
}
Also used : ModifyEvent(org.eclipse.swt.events.ModifyEvent) Composite(org.eclipse.swt.widgets.Composite) ModifyListener(org.eclipse.swt.events.ModifyListener) GridData(org.eclipse.swt.layout.GridData) Label(org.eclipse.swt.widgets.Label) Text(org.eclipse.swt.widgets.Text) Combo(org.eclipse.swt.widgets.Combo)

Example 29 with ModifyEvent

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

the class AddOrEditXmlConvertConfigDialog method createRootTxt.

/**
	 * 创建xml根,与存储目录
	 * @param tparent
	 *            ;
	 */
private void createRootTxt(Composite tparent) {
    Composite composite = new Composite(tparent, SWT.NONE);
    GridDataFactory.fillDefaults().grab(true, false).applyTo(composite);
    GridLayoutFactory.fillDefaults().spacing(0, SWT.DEFAULT).numColumns(5).applyTo(composite);
    Label rootLbl = new Label(composite, SWT.NONE);
    rootLbl.setText(Messages.getString("dialogs.AddOrEditXmlConvertConfigDialog.rootLbl"));
    rootTxt = new Text(composite, SWT.BORDER);
    GridDataFactory.fillDefaults().indent(6, SWT.DEFAULT).hint(100, SWT.DEFAULT).applyTo(rootTxt);
    // 显示一个图标与“被保存到:”
    Label iconLbl = new Label(composite, SWT.NONE);
    iconLbl.setImage(icon);
    GridDataFactory.fillDefaults().indent(4, SWT.DEFAULT).applyTo(iconLbl);
    Label textLbl = new Label(composite, SWT.NONE);
    textLbl.setText(Messages.getString("dialogs.AddOrEditXmlConvertConfigDialog.textLbl"));
    rootTipLbl = new Label(composite, SWT.NONE);
    GridDataFactory.fillDefaults().grab(true, false).align(SWT.LEFT, SWT.CENTER).applyTo(rootTipLbl);
    rootTxt.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            String tipText = root.getFullPath().append(ADConstants.AD_xmlConverterConfigFolder).append("config_" + rootTxt.getText().trim() + ".xml").toOSString();
            rootTipLbl.setText(tipText);
            rootTipLbl.pack();
            rootTipLbl.setToolTipText(tipText);
        }
    });
    // 在添加状态下,当根元素文本框失去焦点后,验证是否为空,验证是否重复
    rootTxt.addFocusListener(new org.eclipse.swt.events.FocusAdapter() {

        @Override
        public void focusLost(FocusEvent e) {
            String rootStr = rootTxt.getText().trim();
            if (isAdd || (!rootStr.equals(curRootStr))) {
                if ("".equals(rootStr)) {
                    MessageDialog.openWarning(getShell(), Messages.getString("dialogs.AddOrEditXmlConvertConfigDialog.msgTitle1"), Messages.getString("dialogs.AddOrEditXmlConvertConfigDialog.msg1"));
                } else {
                    // 提示文件是否重复
                    String configXmlLoaction = root.getLocation().append(ADConstants.AD_xmlConverterConfigFolder).append("config_" + rootStr + ".xml").toOSString();
                    File xmlConfigFile = new File(configXmlLoaction);
                    if (xmlConfigFile.exists()) {
                        String configXmlFullPath = root.getFullPath().append(ADConstants.AD_xmlConverterConfigFolder).append("config_" + rootStr + ".xml").toOSString();
                        MessageDialog.openWarning(getShell(), Messages.getString("dialogs.AddOrEditXmlConvertConfigDialog.msgTitle1"), MessageFormat.format(Messages.getString("dialogs.AddOrEditXmlConvertConfigDialog.msg2"), configXmlFullPath));
                    }
                }
                super.focusLost(e);
            }
        }
    });
}
Also used : ModifyEvent(org.eclipse.swt.events.ModifyEvent) Composite(org.eclipse.swt.widgets.Composite) ModifyListener(org.eclipse.swt.events.ModifyListener) Label(org.eclipse.swt.widgets.Label) Text(org.eclipse.swt.widgets.Text) FocusEvent(org.eclipse.swt.events.FocusEvent) File(java.io.File)

Example 30 with ModifyEvent

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

the class AnalysisXmlConvertConfigDialg method createRootTxt.

private void createRootTxt(Composite tparent) {
    Composite composite = new Composite(tparent, SWT.NONE);
    GridDataFactory.fillDefaults().grab(true, false).applyTo(composite);
    GridLayoutFactory.fillDefaults().spacing(0, 1).numColumns(5).applyTo(composite);
    Label analysisXmlLbl = new Label(composite, SWT.NONE);
    analysisXmlLbl.setText(Messages.getString("dialogs.AnalysisXmlConvertConfigDialg.analysisXmlLbl"));
    GridDataFactory.swtDefaults().align(SWT.RIGHT, SWT.CENTER).applyTo(analysisXmlLbl);
    Composite browseCmp = new Composite(composite, SWT.NONE);
    GridDataFactory.fillDefaults().indent(6, SWT.DEFAULT).grab(true, false).span(4, SWT.DEFAULT).applyTo(browseCmp);
    GridLayoutFactory.fillDefaults().numColumns(2).extendedMargins(0, 0, 0, 0).applyTo(browseCmp);
    analysisTxt = new Text(browseCmp, SWT.BORDER);
    GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(analysisTxt);
    Button browseBtn = new Button(browseCmp, SWT.NONE);
    browseBtn.setText(Messages.getString("dialogs.AnalysisXmlConvertConfigDialg.browseBtn"));
    Label rootLbl = new Label(composite, SWT.NONE);
    rootLbl.setText(Messages.getString("dialogs.AnalysisXmlConvertConfigDialg.rootLbl"));
    GridDataFactory.swtDefaults().align(SWT.RIGHT, SWT.CENTER).applyTo(rootLbl);
    rootTxt = new Text(composite, SWT.BORDER);
    GridDataFactory.fillDefaults().indent(6, SWT.DEFAULT).hint(100, SWT.DEFAULT).applyTo(rootTxt);
    // 显示一个图标与“被保存到:”
    Label iconLbl = new Label(composite, SWT.NONE);
    iconLbl.setImage(icon);
    GridDataFactory.fillDefaults().indent(4, SWT.DEFAULT).applyTo(iconLbl);
    Label textLbl = new Label(composite, SWT.NONE);
    textLbl.setText(Messages.getString("dialogs.AnalysisXmlConvertConfigDialg.textLbl"));
    rootTipLbl = new Label(composite, SWT.NONE);
    GridDataFactory.fillDefaults().grab(true, false).align(SWT.LEFT, SWT.CENTER).applyTo(rootTipLbl);
    rootTxt.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            String tipText = root.getFullPath().append(ADConstants.AD_xmlConverterConfigFolder).append("config_" + rootTxt.getText().trim().toLowerCase() + ".xml").toOSString();
            rootTipLbl.setText(tipText);
            rootTipLbl.pack();
            rootTipLbl.setToolTipText(tipText);
        }
    });
    // 在添加状态下,当根元素文本框失去焦点后,验证是否为空,验证是否重复
    rootTxt.addFocusListener(new org.eclipse.swt.events.FocusAdapter() {

        public void focusLost(FocusEvent e) {
            String rootStr = rootTxt.getText().trim().toLowerCase();
            if ("".equals(rootStr)) {
                MessageDialog.openInformation(getShell(), Messages.getString("dialogs.AnalysisXmlConvertConfigDialg.msgTitle"), Messages.getString("dialogs.AnalysisXmlConvertConfigDialg.msg1"));
            } else {
                // 提示文件是否重复
                String configXmlLoaction = root.getLocation().append(ADConstants.AD_xmlConverterConfigFolder).append("config_" + rootStr + ".xml").toOSString();
                File xmlConfigFile = new File(configXmlLoaction);
                if (xmlConfigFile.exists()) {
                    String configXmlFullPath = root.getFullPath().append(ADConstants.AD_xmlConverterConfigFolder).append("config_" + rootStr + ".xml").toOSString();
                    MessageDialog.openInformation(getShell(), Messages.getString("dialogs.AnalysisXmlConvertConfigDialg.msgTitle"), MessageFormat.format(Messages.getString("dialogs.AnalysisXmlConvertConfigDialg.msg2"), configXmlFullPath));
                }
            }
            super.focusLost(e);
        }
    });
    browseBtn.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            FileDialog fd = new FileDialog(getShell(), SWT.OPEN);
            String[] extensions = { "*.xml", "*" };
            String[] names = { Messages.getString("dialogs.AnalysisXmlConvertConfigDialg.filterXML"), Messages.getString("dialogs.AnalysisXmlConvertConfigDialg.filterAll") };
            fd.setText(Messages.getString("dialogs.AnalysisXmlConvertConfigDialg.fdTitle"));
            fd.setFilterExtensions(extensions);
            fd.setFilterNames(names);
            String xmlLocation = fd.open();
            analysisTxt.setText(xmlLocation);
            // 解析XML文件并且填充到列表
            analysisXml(xmlLocation);
        }
    });
    analysisTxt.addFocusListener(new FocusAdapter() {

        @Override
        public void focusLost(FocusEvent e) {
            analysisXml(analysisTxt.getText());
            super.focusLost(e);
        }
    });
}
Also used : FocusAdapter(org.eclipse.swt.events.FocusAdapter) Composite(org.eclipse.swt.widgets.Composite) ModifyListener(org.eclipse.swt.events.ModifyListener) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) Text(org.eclipse.swt.widgets.Text) FocusEvent(org.eclipse.swt.events.FocusEvent) ModifyEvent(org.eclipse.swt.events.ModifyEvent) Button(org.eclipse.swt.widgets.Button) SelectionEvent(org.eclipse.swt.events.SelectionEvent) FocusAdapter(org.eclipse.swt.events.FocusAdapter) File(java.io.File) FileDialog(org.eclipse.swt.widgets.FileDialog)

Aggregations

ModifyEvent (org.eclipse.swt.events.ModifyEvent)269 ModifyListener (org.eclipse.swt.events.ModifyListener)269 GridData (org.eclipse.swt.layout.GridData)179 Text (org.eclipse.swt.widgets.Text)160 GridLayout (org.eclipse.swt.layout.GridLayout)159 Composite (org.eclipse.swt.widgets.Composite)148 SelectionEvent (org.eclipse.swt.events.SelectionEvent)141 Label (org.eclipse.swt.widgets.Label)140 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)120 Button (org.eclipse.swt.widgets.Button)87 Combo (org.eclipse.swt.widgets.Combo)54 Group (org.eclipse.swt.widgets.Group)42 SelectionListener (org.eclipse.swt.events.SelectionListener)30 File (java.io.File)27 KeyEvent (org.eclipse.swt.events.KeyEvent)23 StyledText (org.eclipse.swt.custom.StyledText)21 DirectoryDialog (org.eclipse.swt.widgets.DirectoryDialog)21 FileDialog (org.eclipse.swt.widgets.FileDialog)18 FocusEvent (org.eclipse.swt.events.FocusEvent)17 List (java.util.List)16