LanguagePanelpublic class LanguagePanel extends org.gudy.azureus2.ui.swt.wizard.AbstractWizardPanel
Methods Summary |
---|
private java.lang.String | buildName(java.util.Locale locale)
StringBuffer sName = new StringBuffer();
String sName1 = locale.getDisplayLanguage(locale);
String sName2 = locale.getDisplayLanguage();
sName.append(sName1);
if (!sName1.equals(sName2)) {
sName.append("/").append(sName2);
}
sName1 = locale.getDisplayCountry(locale);
sName2 = locale.getDisplayCountry();
if (sName1.length() > 0 || sName2.length() > 0) {
sName.append(" (");
if (sName1.length() > 0)
sName.append(sName1);
if (sName2.length() > 0 && !sName1.equals(sName2)) {
sName.append("/").append(sName2);
}
sName1 = locale.getDisplayVariant(locale);
sName2 = locale.getDisplayVariant();
if (sName1.length() > 0 || sName2.length() > 0) {
sName.append(", ");
if (sName1.length() > 0)
sName.append(sName1);
if (sName2.length() > 0 && !sName1.equals(sName2)) {
sName.append("/").append(sName2);
}
}
sName.append(")");
}
return sName.toString();
| public org.gudy.azureus2.ui.swt.wizard.IWizardPanel | getNextPanel()
return new WelcomePanel(((ConfigureWizard) wizard), this);
| public boolean | isNextEnabled()
return true;
| private void | setChooseLabel(Label lblChoose)
String sLocaleChooseString = MessageText
.getString("ConfigureWizard.language.choose");
String sDefChooseString = MessageText
.getDefaultLocaleString("ConfigureWizard.language.choose");
if (sLocaleChooseString.equals(sDefChooseString)) {
lblChoose.setText(sLocaleChooseString);
} else {
lblChoose.setText(sLocaleChooseString + "\n" + sDefChooseString);
}
| public void | show()
GridData gridData;
wizard.setTitleAsResourceID("configureWizard.welcome.title");
Composite rootPanel = wizard.getPanel();
GridLayout layout = new GridLayout();
layout.numColumns = 1;
rootPanel.setLayout(layout);
final Label lblChoose = new Label(rootPanel, SWT.WRAP);
setChooseLabel(lblChoose);
gridData = new GridData(GridData.FILL_HORIZONTAL);
lblChoose.setLayoutData(gridData);
final List lstLanguage = new List(rootPanel, SWT.BORDER | SWT.V_SCROLL
| SWT.SINGLE);
gridData = new GridData(GridData.FILL_BOTH);
gridData.heightHint = 200;
lstLanguage.setLayoutData(gridData);
final Locale[] locales = MessageText.getLocales();
int iUsingLocale = -1;
for (int i = 0; i < locales.length; i++) {
Locale locale = locales[i];
lstLanguage.add(buildName(locale));
if (MessageText.isCurrentLocale(locale))
iUsingLocale = i;
}
lstLanguage.select(iUsingLocale);
lstLanguage.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event e) {
int index = lstLanguage.getSelectionIndex();
if (index >= 0 && index < locales.length) {
COConfigurationManager.setParameter("locale", locales[index]
.toString());
MessageText.loadBundle();
DisplayFormatters.setUnits();
DisplayFormatters.loadMessages();
Shell shell = wizard.getWizardWindow();
Messages.updateLanguageForControl(shell);
setChooseLabel(lblChoose);
shell.layout(true, true);
lstLanguage.setRedraw(false);
for (int i = 0; i < locales.length; i++) {
lstLanguage.setItem(i, buildName(locales[i]));
}
lstLanguage.setRedraw(true);
try {
UIFunctions uiFunctions = UIFunctionsManager.getUIFunctions();
if (uiFunctions != null) {
uiFunctions.refreshLanguage();
}
} catch (Exception ex) {
}
}
}
});
FontData[] fontData = lstLanguage.getFont().getFontData();
for (int i = 0; i < fontData.length; i++) {
if (fontData[i].getHeight() < 10)
fontData[i].setHeight(10);
}
final Font font = new Font(rootPanel.getDisplay(), fontData);
lstLanguage.setFont(font);
lstLanguage.getShell().addListener(SWT.Show, new Listener() {
public void handleEvent(Event event) {
lstLanguage.showSelection();
}
});
lstLanguage.addDisposeListener(new DisposeListener() {
public void widgetDisposed(DisposeEvent e) {
if (font != null && !font.isDisposed())
font.dispose();
}
});
|
|