Label label;
GridLayout layout;
GridData gridData;
Composite cMain = new Composite( parent, SWT.NULL );
cMain.setLayoutData( new GridData( GridData.FILL_BOTH ) );
layout = new GridLayout();
layout.numColumns = 1;
layout.marginHeight = 0;
layout.marginWidth = 0;
cMain.setLayout( layout );
label = new Label( cMain, SWT.NULL );
gridData = new GridData(GridData.VERTICAL_ALIGN_BEGINNING);
label.setLayoutData(gridData);
Messages.setLanguageText( label, "MainWindow.menu.language" ); //old name path, but already translated
Locale[] locales = MessageText.getLocales();
String[] drop_labels = new String[ locales.length ];
String[] drop_values = new String[ locales.length ];
int iUsingLocale = -1;
for( int i=0; i < locales.length; i++ ) {
Locale locale = locales[ i ];
String sName = locale.getDisplayName(locale);
String sName2 = locale.getDisplayName();
if (!sName.equals(sName2)) {
sName += " - " + sName2;
}
drop_labels[ i ] = sName + " - " + locale;
drop_values[ i ] = locale.toString();
if (MessageText.isCurrentLocale(locale))
iUsingLocale = i;
}
StringListParameter locale_param = new StringListParameter(cMain, "locale",
drop_labels, drop_values, false);
gridData = new GridData(GridData.FILL_BOTH);
gridData.minimumHeight = 50;
locale_param.setLayoutData(gridData);
// There may be no "locale" setting stored in config, so set it to
// what we are using now. Don't automatically write it to config, because
// the user may switch languages (or a new language file may become avail
// in the future that matches closer to their locale)
if (iUsingLocale >= 0)
((List)locale_param.getControl()).select(iUsingLocale);
locale_param.addChangeListener( new ParameterChangeAdapter() {
public void parameterChanged( Parameter p, boolean caused_internally ) {
MessageText.loadBundle();
DisplayFormatters.setUnits();
DisplayFormatters.loadMessages();
UIFunctions uiFunctions = UIFunctionsManager.getUIFunctions();
if (uiFunctions != null) {
uiFunctions.refreshLanguage();
}
}
});
return cMain;