Search in sources :

Example 16 with Language

use of net.heartsome.cat.common.locale.Language in project translationstudio8 by heartsome.

the class LanguageCodesPreferencePage method refreshFormatControls.

/**
	 * 根据当前选择的语言,更新数字、货币等的显示示例
	 * @param selection
	 *            ;
	 */
protected void refreshFormatControls(IStructuredSelection selection) {
    Object firstSelected = selection.getFirstElement();
    if (firstSelected instanceof Language) {
        Language language = (Language) firstSelected;
        digitalValue.setText(language.getName());
        digitalValue.setToolTipText(language.getName());
        currencyValue.setText(language.getName());
        currencyValue.setToolTipText(language.getName());
        timeValue.setText(language.getName());
        timeValue.setToolTipText(language.getName());
        shortDateValue.setText(language.getName());
        shortDateValue.setToolTipText(language.getName());
        longDateValue.setText(language.getName());
        longDateValue.setToolTipText(language.getName());
    }
}
Also used : Language(net.heartsome.cat.common.locale.Language)

Example 17 with Language

use of net.heartsome.cat.common.locale.Language in project translationstudio8 by heartsome.

the class LanguageCodesPreferencePage method verifyCurrentSelected.

// 验证当前的选择是否合法,如果合法,根据操作类型进行后续的操作
protected void verifyCurrentSelected(int operateType) {
    ISelection selection = fFilteredTree.getViewer().getSelection();
    if (selection.isEmpty()) {
        String messagePattern = Messages.getString("languagecode.LanguageCodesPreferencePage.msg1");
        Object[] values = new String[0];
        if (operateType == EDIT) {
            values = new String[] { Messages.getString("languagecode.LanguageCodesPreferencePage.msg2") };
        } else if (operateType == REMOVE) {
            values = new String[] { Messages.getString("languagecode.LanguageCodesPreferencePage.msg3") };
        }
        String message = MessageFormat.format(messagePattern, values);
        MessageDialog.openInformation(fFilteredTree.getShell(), Messages.getString("languagecode.LanguageCodesPreferencePage.msgTitle"), message);
        return;
    } else if (operateType == EDIT && fFilteredTree.getViewer().getTree().getSelectionCount() > 1) {
        MessageDialog.openInformation(fFilteredTree.getShell(), Messages.getString("languagecode.LanguageCodesPreferencePage.msgTitle"), Messages.getString("languagecode.LanguageCodesPreferencePage.msg4"));
        return;
    }
    if (selection instanceof IStructuredSelection) {
        IStructuredSelection iStructuredSelection = (IStructuredSelection) selection;
        Object object = iStructuredSelection.getFirstElement();
        if (object instanceof Language) {
            if (operateType == EDIT) {
                Language language = (Language) object;
                editLanguage(language);
            } else if (operateType == REMOVE) {
                // 删除所选择的语言
                if (MessageDialog.openConfirm(fFilteredTree.getShell(), Messages.getString("languagecode.LanguageCodesPreferencePage.msgTitle"), Messages.getString("languagecode.LanguageCodesPreferencePage.msg5"))) {
                    removeLanguage(iStructuredSelection.toList());
                }
            }
        }
    }
}
Also used : Language(net.heartsome.cat.common.locale.Language) ISelection(org.eclipse.jface.viewers.ISelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

Example 18 with Language

use of net.heartsome.cat.common.locale.Language in project translationstudio8 by heartsome.

the class ProjectSettingBaseInfoPage method initData.

/**
	 * 初始化界面数据 ;
	 */
private void initData() {
    projectNameLabel.setText(this.projCfgBean.getProjectName().replaceAll("&", "&&"));
    sourceLangLabel.setText(this.projCfgBean.getSourceLang().getName());
    List<Language> targetLangs = this.projCfgBean.getTargetLang();
    StringBuffer targetlang = new StringBuffer();
    for (int i = 0; i < targetLangs.size(); i++) {
        targetlang.append(targetLangs.get(i).getName()).append(",");
    }
    String tLangs = targetlang.toString();
    targetlangLabel.setText(tLangs.substring(0, tLangs.length() - 1));
}
Also used : Language(net.heartsome.cat.common.locale.Language) Point(org.eclipse.swt.graphics.Point)

Example 19 with Language

use of net.heartsome.cat.common.locale.Language in project translationstudio8 by heartsome.

the class NewProjectWizardLanguagePage 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(1, false));
    // source language control
    Group sourceLanguageGrp = new Group(container, SWT.NONE);
    sourceLanguageGrp.setLayout(new GridLayout(1, false));
    sourceLanguageGrp.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    sourceLanguageGrp.setText(Messages.getString("wizard.NewProjectWizardLanguagePage.sourceLanguageGrp"));
    srcLangComboViewer = new TableComboViewer(sourceLanguageGrp, SWT.READ_ONLY | SWT.BORDER);
    TableCombo tableCombo = srcLangComboViewer.getTableCombo();
    // set options.
    tableCombo.setShowTableLines(false);
    tableCombo.setShowTableHeader(false);
    tableCombo.setDisplayColumnIndex(-1);
    tableCombo.setShowImageWithinSelection(true);
    tableCombo.setShowColorWithinSelection(false);
    tableCombo.setShowFontWithinSelection(false);
    tableCombo.setVisibleItemCount(20);
    srcLangComboViewer.getTableCombo().setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    srcLangComboViewer.setLabelProvider(new LanguageLabelProvider());
    srcLangComboViewer.setContentProvider(new ArrayContentProvider());
    srcLangComboViewer.setInput(languages);
    srcLangComboViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        public void selectionChanged(SelectionChangedEvent event) {
            IStructuredSelection selection = (IStructuredSelection) event.getSelection();
            srcLanguage = (Language) selection.getFirstElement();
            validator.update();
        }
    });
    // initialization remember value
    String rmSrcLangCode = ps.getString(IPreferenceConstants.NEW_PROJECT_SRC_LANG);
    if (rmSrcLangCode != null && !rmSrcLangCode.equals("")) {
        for (Language srcLang : languages) {
            if (srcLang.getCode().equals(rmSrcLangCode)) {
                srcLangComboViewer.setSelection(new StructuredSelection(srcLang));
                break;
            }
        }
    }
    // end source language
    // target language control
    Group targetLanguageGrp = new Group(container, SWT.NONE);
    targetLanguageGrp.setLayout(new GridLayout(3, false));
    targetLanguageGrp.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, true, 1, 1));
    targetLanguageGrp.setText(Messages.getString("wizard.NewProjectWizardLanguagePage.targetLanguageGrp"));
    targetLangControl.createControl(targetLanguageGrp);
    // end Target language
    setControl(container);
    validator.update();
}
Also used : Group(org.eclipse.swt.widgets.Group) Composite(org.eclipse.swt.widgets.Composite) LanguageLabelProvider(net.heartsome.cat.ts.ui.composite.LanguageLabelProvider) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) TableComboViewer(org.eclipse.nebula.jface.tablecomboviewer.TableComboViewer) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) GridLayout(org.eclipse.swt.layout.GridLayout) Language(net.heartsome.cat.common.locale.Language) GridData(org.eclipse.swt.layout.GridData) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) TableCombo(org.eclipse.nebula.widgets.tablecombo.TableCombo)

Example 20 with Language

use of net.heartsome.cat.common.locale.Language in project translationstudio8 by heartsome.

the class ProjectSettingLanguagePage method validator.

/**
	 * 输入验证器
	 * @return ;
	 */
public boolean validator() {
    if (projCfgBean.getTargetLang().size() == 0) {
        MessageDialog.openError(getShell(), Messages.getString("projectsetting.ProjectSettingLanguagePage.msgTitle"), Messages.getString("projectsetting.ProjectSettingLanguagePage.msg1"));
        return false;
    }
    String srcCode = projCfgBean.getSourceLang().getCode();
    List<Language> target = projCfgBean.getTargetLang();
    for (Language tLang : target) {
        String tCode = tLang.getCode();
        if (tCode.equals(srcCode)) {
            MessageDialog.openError(getShell(), Messages.getString("projectsetting.ProjectSettingLanguagePage.msgTitle"), Messages.getString("projectsetting.ProjectSettingLanguagePage.msg2"));
            return false;
        }
    }
    return true;
}
Also used : Language(net.heartsome.cat.common.locale.Language)

Aggregations

Language (net.heartsome.cat.common.locale.Language)31 ArrayList (java.util.ArrayList)10 AutoPilot (com.ximpleware.AutoPilot)6 NavException (com.ximpleware.NavException)5 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)5 XPathEvalException (com.ximpleware.XPathEvalException)4 XPathParseException (com.ximpleware.XPathParseException)4 File (java.io.File)4 IOException (java.io.IOException)4 ProjectConfiger (net.heartsome.cat.ts.core.file.ProjectConfiger)4 CoreException (org.eclipse.core.runtime.CoreException)4 GridData (org.eclipse.swt.layout.GridData)4 VTDGen (com.ximpleware.VTDGen)3 VTDNav (com.ximpleware.VTDNav)3 List (java.util.List)3 LanguageLabelProvider (net.heartsome.cat.ts.ui.composite.LanguageLabelProvider)3 IXliffEditor (net.heartsome.cat.ts.ui.editors.IXliffEditor)3 VTDUtils (net.heartsome.xml.vtdimpl.VTDUtils)3 XMLModifier (com.ximpleware.XMLModifier)2 FileOutputStream (java.io.FileOutputStream)2