Search in sources :

Example 11 with LanguageInfo

use of com.amalto.workbench.detailtabs.sections.model.annotationinfo.langinfo.LanguageInfo in project tmdm-studio-se by Talend.

the class LangInfoCellEditor method parseInput.

private LanguageInfo[] parseInput() {
    if (getValue() == null || !(getValue() instanceof String))
        return new LanguageInfo[0];
    List<LanguageInfo> results = new ArrayList<LanguageInfo>();
    String expression = (String) getValue();
    boolean find = false;
    Matcher match = Pattern.compile(REGEXP_METACHARACTERS).matcher(expression);
    while (match.find()) {
        find = true;
        String countryISOCode = match.group(1).trim().toLowerCase();
        String desc = match.group(2).trim();
        String country = Util.iso2lang.get(countryISOCode);
        if (country != null)
            results.add(new LanguageInfo(country, countryISOCode, desc));
    }
    if (// $NON-NLS-1$
    !find && !expression.equals(""))
        // $NON-NLS-1$//$NON-NLS-2$
        results.add(new LanguageInfo("English", "en", expression));
    return results.toArray(new LanguageInfo[0]);
}
Also used : LanguageInfo(com.amalto.workbench.detailtabs.sections.model.annotationinfo.langinfo.LanguageInfo) Matcher(java.util.regex.Matcher) ArrayList(java.util.ArrayList)

Aggregations

LanguageInfo (com.amalto.workbench.detailtabs.sections.model.annotationinfo.langinfo.LanguageInfo)11 XSDAnnotationsStructure (com.amalto.workbench.utils.XSDAnnotationsStructure)3 ArrayList (java.util.ArrayList)2 LinkedHashMap (java.util.LinkedHashMap)2 LanguageInfoComposite (com.amalto.workbench.detailtabs.sections.composites.LanguageInfoComposite)1 Matcher (java.util.regex.Matcher)1 FillLayout (org.eclipse.swt.layout.FillLayout)1 Composite (org.eclipse.swt.widgets.Composite)1