Merge "Remove unused locale info"
diff --git a/propertysheet/src/org/eclipse/wb/internal/core/icons/nls/flags/an.png b/propertysheet/src/org/eclipse/wb/internal/core/icons/nls/flags/an.png
deleted file mode 100644
index 633e4b8..0000000
--- a/propertysheet/src/org/eclipse/wb/internal/core/icons/nls/flags/an.png
+++ /dev/null
Binary files differ
diff --git a/propertysheet/src/org/eclipse/wb/internal/core/icons/nls/flags/cs.png b/propertysheet/src/org/eclipse/wb/internal/core/icons/nls/flags/cs.png
deleted file mode 100644
index 8254790..0000000
--- a/propertysheet/src/org/eclipse/wb/internal/core/icons/nls/flags/cs.png
+++ /dev/null
Binary files differ
diff --git a/propertysheet/src/org/eclipse/wb/internal/core/icons/nls/flags/europeanunion.png b/propertysheet/src/org/eclipse/wb/internal/core/icons/nls/flags/europeanunion.png
deleted file mode 100644
index d6d8711..0000000
--- a/propertysheet/src/org/eclipse/wb/internal/core/icons/nls/flags/europeanunion.png
+++ /dev/null
Binary files differ
diff --git a/propertysheet/src/org/eclipse/wb/internal/core/icons/nls/flags/fam.png b/propertysheet/src/org/eclipse/wb/internal/core/icons/nls/flags/fam.png
deleted file mode 100644
index cf50c75..0000000
--- a/propertysheet/src/org/eclipse/wb/internal/core/icons/nls/flags/fam.png
+++ /dev/null
Binary files differ
diff --git a/propertysheet/src/org/eclipse/wb/internal/core/nls/model/LocaleInfo.java b/propertysheet/src/org/eclipse/wb/internal/core/nls/model/LocaleInfo.java
deleted file mode 100644
index 0403351..0000000
--- a/propertysheet/src/org/eclipse/wb/internal/core/nls/model/LocaleInfo.java
+++ /dev/null
@@ -1,190 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011 Google, Inc.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- *    Google, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wb.internal.core.nls.model;
-
-import java.util.Locale;
-
-/**
- * Information about {@link Locale}.
- *
- * We separate {@link LocaleInfo} from {@link BundleInfo} because {@link BundleInfo} is wrapper for
- * single *.properties file and we support more than one source of bundles in one
- * {@link CompilationUnit}.
- *
- * @author scheglov_ke
- * @coverage core.nls
- */
-public final class LocaleInfo implements Comparable<LocaleInfo> {
-  /**
-   * The default {@link LocaleInfo}.
-   */
-  public static final LocaleInfo DEFAULT = new LocaleInfo(null);
-  ////////////////////////////////////////////////////////////////////////////
-  //
-  // Instance fields
-  //
-  ////////////////////////////////////////////////////////////////////////////
-  private final Locale m_locale;
-
-  ////////////////////////////////////////////////////////////////////////////
-  //
-  // Constructor
-  //
-  ////////////////////////////////////////////////////////////////////////////
-  public LocaleInfo(Locale locale) {
-    m_locale = locale;
-  }
-
-  ////////////////////////////////////////////////////////////////////////////
-  //
-  // Object
-  //
-  ////////////////////////////////////////////////////////////////////////////
-  @Override
-  public String toString() {
-    return getTitle();
-  }
-
-  @Override
-  public boolean equals(Object obj) {
-    if (obj == this) {
-      return true;
-    }
-    if (obj instanceof LocaleInfo) {
-      LocaleInfo localeInfo = (LocaleInfo) obj;
-      if (isDefault()) {
-        return localeInfo.isDefault();
-      }
-      return m_locale.equals(localeInfo.m_locale);
-    }
-    return false;
-  }
-
-  @Override
-  public int hashCode() {
-    if (isDefault()) {
-      return 0;
-    }
-    return m_locale.hashCode();
-  }
-
-  ////////////////////////////////////////////////////////////////////////////
-  //
-  // Comparable
-  //
-  ////////////////////////////////////////////////////////////////////////////
-  @Override
-public int compareTo(LocaleInfo o) {
-    if (m_locale == null) {
-      if (o.m_locale == null) {
-        return 0;
-      }
-      return -1;
-    }
-    if (o.m_locale == null) {
-      return 1;
-    }
-    String localeNameA = m_locale.toString();
-    String localeNameB = o.m_locale.toString();
-    return localeNameA.compareTo(localeNameB);
-  }
-
-  ////////////////////////////////////////////////////////////////////////////
-  //
-  // Access
-  //
-  ////////////////////////////////////////////////////////////////////////////
-  /**
-   * @return {@link Locale} for this {@link LocaleInfo}.
-   */
-  public Locale getLocale() {
-    return m_locale;
-  }
-
-  /**
-   * @return <code>true</code> if that {@link Locale} is default.
-   */
-  public boolean isDefault() {
-    return m_locale == null;
-  }
-
-  /**
-   * @return the title to display in UI.
-   */
-  public String getTitle() {
-    if (isDefault()) {
-      return "(default)";
-    }
-    return m_locale.toString();
-  }
-
-  ////////////////////////////////////////////////////////////////////////////
-  //
-  // Utils
-  //
-  ////////////////////////////////////////////////////////////////////////////
-  /**
-   * @return the "parent" {@link LocaleInfo} from given array.<br>
-   *         Here "parent" is locale that is more general than current one.<br>
-   *         For example "parent" locale for 'ru_RU' is 'ru'.
-   *
-   *         If there are no parent locale in array, return default locale.<br>
-   */
-  public LocaleInfo getParent(LocaleInfo locales[]) {
-    String localeName = m_locale.toString();
-    int lastSeparatorIndex = localeName.lastIndexOf('_');
-    if (lastSeparatorIndex != -1) {
-      String parentLocaleName = localeName.substring(0, lastSeparatorIndex);
-      // try to find locale with parent name
-      for (LocaleInfo locale : locales) {
-        if (locale.getLocale() != null && locale.getLocale().toString().equals(parentLocaleName)) {
-          return locale;
-        }
-      }
-    }
-    // use default
-    return LocaleInfo.DEFAULT;
-  }
-
-  /**
-   * @param localeName
-   *          the name of locale, such as "en" or "ru_RU".
-   * @param localeDescription
-   *          the description of {@link Locale}, used in exception.
-   * @return the {@link LocaleInfo} which wraps {@link Locale}.
-   */
-  public static LocaleInfo create(String localeName, String localeDescription) {
-    // try to find locale in list of available locales
-    Locale[] locales = Locale.getAvailableLocales();
-    for (int i = 0; i < locales.length; i++) {
-      Locale locale = locales[i];
-      if (locale.toString().equals(localeName)) {
-        return new LocaleInfo(locale);
-      }
-    }
-    // try to create new, this constructor is since 1.4, so do this in try/catch
-    try {
-      Locale locale;
-      int separatorIndex = localeName.indexOf('_');
-      if (separatorIndex != -1) {
-        String language = localeName.substring(0, separatorIndex);
-        String country = localeName.substring(separatorIndex + 1);
-        locale = new Locale(language, country);
-      } else {
-        locale = new Locale(localeName);
-      }
-      return new LocaleInfo(locale);
-    } catch (Throwable e) {
-      String msg = "Locale not found for " + localeDescription;
-      throw new IllegalArgumentException(msg);
-    }
-  }
-}
diff --git a/propertysheet/src/org/eclipse/wb/internal/core/nls/model/LocalePartInfo.java b/propertysheet/src/org/eclipse/wb/internal/core/nls/model/LocalePartInfo.java
deleted file mode 100644
index 9278979..0000000
--- a/propertysheet/src/org/eclipse/wb/internal/core/nls/model/LocalePartInfo.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011 Google, Inc.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- *    Google, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wb.internal.core.nls.model;
-
-import org.eclipse.swt.graphics.Image;
-
-/**
- * Information about part of Locale - language or country.
- * 
- * @author scheglov_ke
- * @coverage core.nls
- */
-public final class LocalePartInfo implements Comparable<LocalePartInfo> {
-  private final String m_name;
-  private final String m_displayName;
-  private final Image m_flagImage;
-
-  ////////////////////////////////////////////////////////////////////////////
-  //
-  // Constructor
-  //
-  ////////////////////////////////////////////////////////////////////////////
-  public LocalePartInfo(String name, String displayName, Image flagImage) {
-    m_name = name;
-    m_displayName = displayName;
-    m_flagImage = flagImage;
-  }
-
-  ////////////////////////////////////////////////////////////////////////////
-  //
-  // Access
-  //
-  ////////////////////////////////////////////////////////////////////////////
-  public String getName() {
-    return m_name;
-  }
-
-  public Image getFlagImage() {
-    return m_flagImage;
-  }
-
-  ////////////////////////////////////////////////////////////////////////////
-  //
-  // Object
-  //
-  ////////////////////////////////////////////////////////////////////////////
-  @Override
-  public String toString() {
-    if (m_name.length() == 0) {
-      return m_displayName;
-    }
-    return m_name + " - " + m_displayName;
-  }
-
-  @Override
-  public int hashCode() {
-    return m_name.hashCode();
-  }
-
-  @Override
-  public boolean equals(Object obj) {
-    return obj instanceof LocalePartInfo && m_name.equals(((LocalePartInfo) obj).m_name);
-  }
-
-  ////////////////////////////////////////////////////////////////////////////
-  //
-  // Comparable
-  //
-  ////////////////////////////////////////////////////////////////////////////
-  public int compareTo(LocalePartInfo o) {
-    return m_name.compareTo(o.m_name);
-  }
-}
\ No newline at end of file
diff --git a/propertysheet/src/org/eclipse/wb/internal/core/nls/model/LocalePartInfos.java b/propertysheet/src/org/eclipse/wb/internal/core/nls/model/LocalePartInfos.java
deleted file mode 100644
index 68f9097..0000000
--- a/propertysheet/src/org/eclipse/wb/internal/core/nls/model/LocalePartInfos.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011 Google, Inc.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- *    Google, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wb.internal.core.nls.model;
-
-import com.google.common.collect.Sets;
-
-import org.eclipse.wb.internal.core.nls.ui.FlagImagesRepository;
-
-import org.eclipse.swt.graphics.Image;
-
-import java.util.Arrays;
-import java.util.Locale;
-import java.util.Set;
-
-/**
- * Utilities for {@link LocaleInfo}.
- * 
- * @author scheglov_ke
- * @coverage core.nls
- */
-public final class LocalePartInfos {
-  private static LocalePartInfo m_languages[];
-  private static LocalePartInfo m_countries[];
-
-  ////////////////////////////////////////////////////////////////////////////
-  //
-  // Access
-  //
-  ////////////////////////////////////////////////////////////////////////////
-  public static LocalePartInfo[] getLanguages() {
-    initLanguagesAndCountries();
-    return m_languages;
-  }
-
-  public static LocalePartInfo[] getCountries() {
-    initLanguagesAndCountries();
-    return m_countries;
-  }
-
-  ////////////////////////////////////////////////////////////////////////////
-  //
-  // Find items
-  //
-  ////////////////////////////////////////////////////////////////////////////
-  public static int indexByName(LocalePartInfo[] parts, String name) {
-    for (int i = 0; i < parts.length; i++) {
-      LocalePartInfo part = parts[i];
-      if (part.getName().equals(name)) {
-        return i;
-      }
-    }
-    return -1;
-  }
-
-  ////////////////////////////////////////////////////////////////////////////
-  //
-  // Initialization
-  //
-  ////////////////////////////////////////////////////////////////////////////
-  /**
-   * Prepare arrays of all available languages and countries with titles and flags.
-   */
-  private static void initLanguagesAndCountries() {
-    if (m_languages == null) {
-      // languages
-      {
-        Set<LocalePartInfo> languagesSet = Sets.newHashSet();
-        // fill
-        for (String language : Locale.getISOLanguages()) {
-          Locale locale = new Locale(language);
-          Image flagImage = FlagImagesRepository.getFlagImage(locale);
-          languagesSet.add(new LocalePartInfo(locale.getLanguage(),
-              locale.getDisplayLanguage(),
-              flagImage));
-        }
-        // remember as array
-        m_languages = languagesSet.toArray(new LocalePartInfo[languagesSet.size()]);
-        Arrays.sort(m_languages);
-      }
-      // countries
-      {
-        Set<LocalePartInfo> countriesSet = Sets.newHashSet();
-        countriesSet.add(new LocalePartInfo("", "(none)", FlagImagesRepository.getEmptyFlagImage()));
-        // fill
-        for (String country : Locale.getISOCountries()) {
-          Locale locale = new Locale("", country);
-          Image flagImage = FlagImagesRepository.getFlagImage(locale);
-          countriesSet.add(new LocalePartInfo(locale.getCountry(),
-              locale.getDisplayCountry(),
-              flagImage));
-        }
-        // remember as array
-        m_countries = countriesSet.toArray(new LocalePartInfo[countriesSet.size()]);
-        Arrays.sort(m_countries);
-      }
-    }
-  }
-}
diff --git a/propertysheet/src/org/eclipse/wb/internal/core/nls/ui/FlagImagesRepository.java b/propertysheet/src/org/eclipse/wb/internal/core/nls/ui/FlagImagesRepository.java
deleted file mode 100644
index 854ba17..0000000
--- a/propertysheet/src/org/eclipse/wb/internal/core/nls/ui/FlagImagesRepository.java
+++ /dev/null
@@ -1,144 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011 Google, Inc.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- *    Google, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wb.internal.core.nls.ui;
-
-import com.google.common.base.Strings;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
-
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.wb.internal.core.DesignerPlugin;
-
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-
-/**
- * Repository of flags for locale/country.
- *
- * @author scheglov_ke
- * @coverage core.nls.ui
- */
-public class FlagImagesRepository {
-  private static Map<String, Image> m_countriesFlags = Maps.newHashMap();
-  private static Locale[] m_locales;
-
-  ////////////////////////////////////////////////////////////////////////////
-  //
-  // Initialization
-  //
-  ////////////////////////////////////////////////////////////////////////////
-  private static void init() {
-    if (m_locales == null) {
-      // prepare sorted Locale's
-      {
-        List<Locale> locales = Lists.newArrayList();
-        Collections.addAll(locales, Locale.getAvailableLocales());
-        Collections.sort(locales, new Comparator<Locale>() {
-          @Override
-        public int compare(Locale o1, Locale o2) {
-            return o1.toString().compareTo(o2.toString());
-          }
-        });
-        m_locales = locales.toArray(new Locale[locales.size()]);
-      }
-    }
-  }
-
-  ////////////////////////////////////////////////////////////////////////////
-  //
-  // Access
-  //
-  ////////////////////////////////////////////////////////////////////////////
-  /**
-   * @return the array of {@link Locale}'s sorted by title.
-   */
-  public static Locale[] getSortedLocales() {
-    init();
-    return m_locales;
-  }
-
-  /**
-   * @return the {@link Image} of flag for default {@link Locale}.
-   */
-  public static Image getEmptyFlagImage() {
-    return DesignerPlugin.getImage("nls/flags/flag_empty.png");
-  }
-
-  /**
-   * @return the {@link Image} of flag for given {@link Locale}.
-   */
-  public static Image getFlagImage(Locale locale) {
-    init();
-    String localeCountry = locale.getCountry();
-    String localeLanguage = locale.getLanguage();
-
-// BEGIN ADT MODIFICATIONS
-    return getFlagImage(localeCountry, localeLanguage);
-  }
-
-  public static Image getFlagImage(String localeCountry, String localeLanguage) {
-        init();
-// END ADT MODIFICATIONS
-
-    // if locale has no assosiated country set, try to find the locale with the same language but with the country set
-    if (localeCountry.length() == 0) {
-      // special cases
-      if (localeLanguage.equals("ar")) {
-        localeCountry = "AE";
-      } else if (localeLanguage.equals("zh")) {
-        localeCountry = "CN";
-      } else if (localeLanguage.equals("en")) {
-        localeCountry = "US";
-      } else {
-        // try to guess
-        String localeCountryCandidate = "";
-        for (int i = 0; i < m_locales.length; i++) {
-          Locale lookupLocale = m_locales[i];
-          String lookupLanguage = lookupLocale.getLanguage();
-          if (lookupLanguage.equals(localeLanguage)) {
-            if (lookupLocale.getCountry().length() != 0) {
-              localeCountryCandidate = lookupLocale.getCountry();
-              if (localeCountryCandidate.equalsIgnoreCase(lookupLanguage)) {
-                localeCountry = localeCountryCandidate;
-                break;
-              }
-            }
-          }
-        }
-        if (localeCountry.length() == 0) {
-          localeCountry = localeCountryCandidate;
-        }
-      }
-    }
-    //
-    Image flagImage = m_countriesFlags.get(localeCountry);
-    if (flagImage == null) {
-      try {
-        String flagFileName = null;
-        if (localeCountry.equalsIgnoreCase("YU")) {
-          localeCountry = "CS"; // use Serbia and Montenegro
-        }
-        if (Strings.isNullOrEmpty(localeCountry)) {
-          return null;
-        }
-        flagFileName = localeCountry.toLowerCase() + ".png";
-        flagImage = DesignerPlugin.getImage("nls/flags/" + flagFileName);
-        m_countriesFlags.put(localeCountry, flagImage);
-      } catch (Throwable e) {
-        return null;
-      }
-    }
-    return flagImage;
-  }
-}
diff --git a/propertysheet/src/org/eclipse/wb/internal/core/nls/ui/LocaleUtils.java b/propertysheet/src/org/eclipse/wb/internal/core/nls/ui/LocaleUtils.java
deleted file mode 100644
index 699bba8..0000000
--- a/propertysheet/src/org/eclipse/wb/internal/core/nls/ui/LocaleUtils.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011 Google, Inc.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- *    Google, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wb.internal.core.nls.ui;
-
-import org.eclipse.wb.internal.core.nls.model.LocaleInfo;
-
-import org.eclipse.swt.graphics.Image;
-
-import java.util.Arrays;
-import java.util.Comparator;
-
-/**
- * UI utils for {@link LocaleInfo}.
- * 
- * @author scheglov_ke
- * @coverage core.nls.ui
- */
-public class LocaleUtils {
-  ////////////////////////////////////////////////////////////////////////////
-  //
-  // Constructor
-  //
-  ////////////////////////////////////////////////////////////////////////////
-  private LocaleUtils() {
-  }
-
-  ////////////////////////////////////////////////////////////////////////////
-  //
-  // Utils
-  //
-  ////////////////////////////////////////////////////////////////////////////
-  /**
-   * @return the flag image for given {@link LocaleInfo}.
-   */
-  public static Image getImage(LocaleInfo localeInfo) {
-    if (localeInfo.isDefault()) {
-      return FlagImagesRepository.getEmptyFlagImage();
-    } else {
-      return FlagImagesRepository.getFlagImage(localeInfo.getLocale());
-    }
-  }
-
-  /**
-   * Sorts given array of {@link LocaleInfo}'s by title.
-   */
-  public static void sortByTitle(LocaleInfo locales[]) {
-    Arrays.sort(locales, new Comparator<LocaleInfo>() {
-      public int compare(LocaleInfo locale_1, LocaleInfo locale_2) {
-        return locale_1.getTitle().compareTo(locale_2.getTitle());
-      }
-    });
-  }
-}