Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
Fixed bug when selecting a locale that was not present in the current…
Browse files Browse the repository at this point in the history
… project.
  • Loading branch information
HannesEskebaek committed Nov 4, 2013
1 parent 276541a commit d91be2e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
Expand Up @@ -158,14 +158,16 @@ public Locale getLocaleAtSelectedIndex()
public int getIndexForLocaleId(String localeId)
{
//The default reference, "none", should be at index 0
if(localeId.equals(UserConfigHolder.DEFAULT_SELECTED_REFERENCE)){
if(localeId.equals(UserConfigHolder.DEFAULT_SELECTED_REFERENCE))
{
return 0;
}

//iterate from index 1 to avoid the default locale at index 0
for (int i = 1; i <= locales.size(); i++)
for (int i = 1; i < locales.size(); i++)
{
if(locales.get(i).getId().getLocaleId().getId().equals(localeId)){
if(locales.get(i).getId().getLocaleId().getId().equals(localeId))
{
return i;
}
}
Expand Down
Expand Up @@ -88,15 +88,23 @@ public void buildListBox(List<Locale> locales)
@Override
public void setSelectedLocale(String localeId)
{
if(localeId.equals(UserConfigHolder.DEFAULT_SELECTED_REFERENCE)){
if(localeId.equals(UserConfigHolder.DEFAULT_SELECTED_REFERENCE))
{
sourceLangListBox.setSelectedIndex(0);
listener.onHideReference();
}
else
{
int selectedIndex = sourceLangListBox.getIndexForLocaleId(localeId);
sourceLangListBox.setSelectedIndex(selectedIndex);
listener.onShowReference(sourceLangListBox.getLocaleAtSelectedIndex());
if (selectedIndex == 0)
{
listener.onHideReference();
}
else
{
listener.onShowReference(sourceLangListBox.getLocaleAtSelectedIndex());
}
}
}

Expand Down

0 comments on commit d91be2e

Please sign in to comment.