Revision bcad19b9
Added by Cherian Mathew over 9 years ago
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/LanguagePreferencePage.java | ||
---|---|---|
1 | 1 |
// $Id$ |
2 | 2 |
/** |
3 | 3 |
* Copyright (C) 2007 EDIT |
4 |
* European Distributed Institute of Taxonomy
|
|
4 |
* European Distributed Institute of Taxonomy |
|
5 | 5 |
* http://www.e-taxonomy.eu |
6 |
*
|
|
6 |
* |
|
7 | 7 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
8 | 8 |
* See LICENSE.TXT at the top of this package for the full license terms. |
9 | 9 |
*/ |
... | ... | |
39 | 39 |
|
40 | 40 |
private boolean isMultilanguageTextEditingCapability; |
41 | 41 |
private Language globalLanguage; |
42 |
|
|
42 |
|
|
43 | 43 |
private Composite createComposite(Composite parent){ |
44 | 44 |
Composite composite = new Composite(parent, SWT.NULL); |
45 | 45 |
composite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 2, 1)); |
46 | 46 |
composite.setLayout(new RowLayout(SWT.HORIZONTAL)); |
47 | 47 |
return composite; |
48 | 48 |
} |
49 |
|
|
49 |
|
|
50 | 50 |
/* (non-Javadoc) |
51 | 51 |
* @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite) |
52 | 52 |
*/ |
... | ... | |
55 | 55 |
Composite container = new Composite(parent, SWT.NULL); |
56 | 56 |
final GridLayout gridLayout = new GridLayout(); |
57 | 57 |
container.setLayout(gridLayout); |
58 |
|
|
58 |
|
|
59 | 59 |
createSetDefaultLanguage(container); |
60 |
|
|
60 |
|
|
61 | 61 |
createSetMultiLanguageTextEditingCapability(container); |
62 |
|
|
62 |
|
|
63 | 63 |
return container; |
64 |
|
|
65 |
|
|
64 |
|
|
65 |
|
|
66 | 66 |
} |
67 | 67 |
|
68 | 68 |
/** |
... | ... | |
70 | 70 |
*/ |
71 | 71 |
private void createSetDefaultLanguage(Composite parent) { |
72 | 72 |
globalLanguage = PreferencesUtil.getGlobalLanguage(); |
73 |
|
|
73 |
|
|
74 |
if(globalLanguage == null) { |
|
75 |
return; |
|
76 |
} |
|
77 |
|
|
74 | 78 |
int curentSelectionIndex = 0; |
75 |
|
|
79 |
|
|
76 | 80 |
final Composite composite = createComposite(parent); |
77 | 81 |
composite.setLayout(new RowLayout(1)); |
78 |
|
|
82 |
|
|
79 | 83 |
final Label label = new Label(composite, SWT.NONE); |
80 | 84 |
label.setText("Choose the global language that will be used throughout the editor to get representations in."); |
81 |
|
|
82 |
final Combo combo_globalLanguage = new Combo(composite, SWT.NONE);
|
|
83 |
|
|
85 |
|
|
86 |
final Combo combo_globalLanguage = new Combo(composite, SWT.NONE); |
|
87 |
|
|
84 | 88 |
List<Language> preferredLanguages = CdmStore.getTermManager().getPreferredTerms(Language.class); |
85 |
|
|
89 |
|
|
86 | 90 |
for(int i = 0; i < preferredLanguages.size(); i++){ |
87 | 91 |
Language language = preferredLanguages.get(i); |
88 | 92 |
combo_globalLanguage.add(language.getLabel(), i); |
... | ... | |
90 | 94 |
curentSelectionIndex = i; |
91 | 95 |
} |
92 | 96 |
} |
93 |
|
|
97 |
|
|
94 | 98 |
combo_globalLanguage.select(curentSelectionIndex); |
95 |
|
|
99 |
|
|
96 | 100 |
combo_globalLanguage.addSelectionListener(new SelectionAdapter() { |
97 | 101 |
/* (non-Javadoc) |
98 | 102 |
* @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent) |
... | ... | |
102 | 106 |
int selectionIndex = combo_globalLanguage.getSelectionIndex(); |
103 | 107 |
globalLanguage = Language.getLanguageByLabel(combo_globalLanguage.getItem(selectionIndex)); |
104 | 108 |
} |
105 |
});
|
|
109 |
}); |
|
106 | 110 |
} |
107 | 111 |
|
108 | 112 |
/** |
109 |
*
|
|
113 |
* |
|
110 | 114 |
*/ |
111 | 115 |
private void createSetMultiLanguageTextEditingCapability(Composite parent) { |
112 | 116 |
isMultilanguageTextEditingCapability = getPreferenceStore().getBoolean(IPreferenceKeys.MULTILANGUAGE_TEXT_EDITING_CAPABILITY); |
113 |
|
|
117 |
|
|
114 | 118 |
final Composite composite = createComposite(parent); |
115 |
|
|
116 |
final Button button_toggle = new Button(composite, SWT.CHECK);
|
|
117 |
|
|
118 |
|
|
119 |
|
|
120 |
final Button button_toggle = new Button(composite, SWT.CHECK); |
|
121 |
|
|
122 |
|
|
119 | 123 |
button_toggle.setText("Enable Multiple Language Editing Capability"); |
120 |
|
|
124 |
|
|
121 | 125 |
button_toggle.setSelection(isMultilanguageTextEditingCapability); |
122 |
|
|
123 |
|
|
126 |
|
|
127 |
|
|
124 | 128 |
button_toggle.addSelectionListener(new SelectionAdapter(){ |
125 | 129 |
/* (non-Javadoc) |
126 | 130 |
* @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent) |
... | ... | |
147 | 151 |
public boolean performOk() { |
148 | 152 |
getPreferenceStore().setValue(IPreferenceKeys.MULTILANGUAGE_TEXT_EDITING_CAPABILITY, isMultilanguageTextEditingCapability); |
149 | 153 |
PreferencesUtil.setGlobalLanguage(globalLanguage); |
150 |
|
|
154 |
|
|
151 | 155 |
return super.performOk(); |
152 | 156 |
} |
153 | 157 |
} |
Also available in: Unified diff
MessagingUtils : added new method for a warning dialog when not connected to a datasource
CdmStore : changed warning dialog to new method mentioned above
LanguagePreferencePage, PreferencesUtil, AbstractMenuPreferences : checks to fail nicely if not connected to a datasoruce