use of org.talend.commons.ui.utils.workbench.preferences.OneLineComboFieldEditor in project tdi-studio-se by Talend.
the class I18nPreferencePage method createFieldEditors.
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.preference.FieldEditorPreferencePage#createFieldEditors()
*/
@Override
protected void createFieldEditors() {
// Adds a combo for language selection.
//$NON-NLS-1$
String spanish = "Español";
byte[] utf8Bytes;
try {
//$NON-NLS-1$
utf8Bytes = spanish.getBytes("UTF8");
//$NON-NLS-1$
spanish = new String(utf8Bytes, "UTF8");
} catch (UnsupportedEncodingException e1) {
// could be translated, but it's only in case of error when change UTF8 characters.
//$NON-NLS-1$
spanish = "Spanish";
}
//$NON-NLS-1$
String russian = "Русский";
try {
//$NON-NLS-1$
utf8Bytes = russian.getBytes("UTF8");
//$NON-NLS-1$
russian = new String(utf8Bytes, "UTF8");
} catch (UnsupportedEncodingException e1) {
// could be translated, but it's only in case of error when change UTF8 characters.
//$NON-NLS-1$
russian = "Russian";
}
//$NON-NLS-1$
String greek = "Ελληνικά";
try {
//$NON-NLS-1$
utf8Bytes = greek.getBytes("UTF8");
//$NON-NLS-1$
greek = new String(utf8Bytes, "UTF8");
} catch (UnsupportedEncodingException e1) {
// could be translated, but it's only in case of error when change UTF8 characters.
//$NON-NLS-1$
greek = "Greek";
}
//$NON-NLS-1$
String arabic = "العربيه";
try {
//$NON-NLS-1$
utf8Bytes = arabic.getBytes("UTF8");
//$NON-NLS-1$
arabic = new String(utf8Bytes, "UTF8");
} catch (UnsupportedEncodingException e1) {
// could be translated, but it's only in case of error when change UTF8 characters.
//$NON-NLS-1$
arabic = "Arabic";
}
//$NON-NLS-1$
String serbian = "Српски";
try {
//$NON-NLS-1$
utf8Bytes = serbian.getBytes("UTF8");
//$NON-NLS-1$
serbian = new String(utf8Bytes, "UTF8");
} catch (UnsupportedEncodingException e1) {
// could be translated, but it's only in case of error when change UTF8 characters.
//$NON-NLS-1$
serbian = "Serbian";
}
String[][] entryNamesAndValues = { { Locale.ENGLISH.getDisplayLanguage(Locale.ENGLISH), Locale.ENGLISH.getLanguage() }, { Locale.FRENCH.getDisplayLanguage(Locale.FRENCH), Locale.FRENCH.getLanguage() }, { Locale.CHINESE.getDisplayLanguage(Locale.CHINESE), "zh_CN" }, { Locale.GERMAN.getDisplayLanguage(Locale.GERMAN), Locale.GERMAN.getLanguage() }, { Locale.JAPANESE.getDisplayLanguage(Locale.JAPANESE), Locale.JAPANESE.getLanguage() }, { Locale.ITALIAN.getDisplayLanguage(Locale.ITALIAN), Locale.ITALIAN.getLanguage() }, //$NON-NLS-1$ //$NON-NLS-2$
{ "Brasil", "pt_BR" }, //$NON-NLS-1$ //$NON-NLS-2$
{ spanish, "es" }, //$NON-NLS-1$ //$NON-NLS-2$
{ russian, "ru" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
{ Locale.KOREA.getDisplayLanguage(Locale.KOREA), "kr" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
{ "Turkish", "tr" }, { greek, "el" }, { "Hrvatski", "hr" }, { arabic, "ar" }, { serbian, "sr" }, { "Polski", "pl" }, { "Romanian", "ro" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ // /$NON-NLS-7$
{ "Netherlands", "nl" } };
languageSelectionEditor = new OneLineComboFieldEditor(ITalendCorePrefConstants.LANGUAGE_SELECTOR, Messages.getString("I18nPreferencePage.needRestart"), entryNamesAndValues, //$NON-NLS-1$
getFieldEditorParent());
addField(languageSelectionEditor);
Composite composite = getFieldEditorParent();
LabelFieldEditor importAll = new //$NON-NLS-1$
LabelFieldEditor(//$NON-NLS-1$
Messages.getString("I18nPreferencePage.translationInformation"), composite);
addField(importAll);
Button allUpdate = new Button(composite, SWT.FLAT);
//$NON-NLS-1$
allUpdate.setText(Messages.getString("I18nPreferencePage.importBabili"));
allUpdate.setLayoutData(new GridData());
allUpdate.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
// import all update from Babili
// select the .zip file
FileDialog fd = new FileDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), SWT.OPEN);
//$NON-NLS-1$
fd.setText("Open");
//$NON-NLS-1$
fd.setFilterPath("C:" + fs);
//$NON-NLS-1$
String[] filterExtensions = { "*.zip" };
fd.setFilterExtensions(filterExtensions);
String selected = fd.open();
if (selected != null) {
isBabiliButtonClicked = true;
runProgressMonitorDialog(selected);
if (MessageDialog.openConfirm(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), //$NON-NLS-1$
Messages.getString("I18nPreferencePage.restart"), Messages.getString("I18nPreferencePage.restartButton"))) {
PlatformUI.getWorkbench().restart();
}
}
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
// Nothing to do
}
});
// added by nma
Button restoredefault = new Button(composite, SWT.FLAT);
//$NON-NLS-1$
restoredefault.setText("Restore Defaults");
restoredefault.setLayoutData(new GridData());
restoredefault.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
// Nothing to do
}
@Override
public void widgetSelected(SelectionEvent e) {
isBabiliButtonClicked = true;
//$NON-NLS-1$
runProgressMonitorDialog(Messages.getString("I18nPreferencePage.restoreDefault"));
if (MessageDialog.openConfirm(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), Messages.getString("I18nPreferencePage.restart"), Messages.getString("I18nPreferencePage.restartButton"))) {
PlatformUI.getWorkbench().restart();
}
}
});
}
Aggregations