Revision 185eb33b
Added by Katja Luther over 5 years ago
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/ChecklistEditorGeneralPreference.java | ||
---|---|---|
55 | 55 |
protected boolean overrideAreaDisplay; |
56 | 56 |
protected boolean allowOverrideStatusDisplay; |
57 | 57 |
protected boolean overrideStatusDisplay; |
58 |
|
|
59 |
protected boolean allowOverrideStatus; |
|
58 | 60 |
Combo statusDisplaySelectionCombo; |
59 | 61 |
Combo areaDisplaySelectionCombo; |
60 | 62 |
|
61 | 63 |
protected String commandHandlerString; |
62 | 64 |
protected String commandHandlerStringStatus; |
63 | 65 |
|
66 |
|
|
67 |
|
|
64 | 68 |
protected CdmPreference distributionEditorPref; |
65 | 69 |
Composite child ; |
66 | 70 |
protected boolean isAllowOverride; |
67 | 71 |
|
68 | 72 |
@Override |
69 | 73 |
protected Control createContents(Composite parent) { |
70 |
|
|
74 |
getValues(); |
|
71 | 75 |
Composite composite = new Composite(parent, SWT.NULL); |
72 | 76 |
composite.setLayout(new GridLayout()); |
73 | 77 |
|
74 |
|
|
75 | 78 |
if (isAllowOverride || isAdminPreference){ |
76 | 79 |
Composite activateComp = createComposite(composite); |
80 |
|
|
77 | 81 |
final Button activateCheckButton = new Button(activateComp, SWT.CHECK); |
78 | 82 |
activateCheckButton.setText(Messages.ChecklistEditorGeneralPreference_enable); |
79 | 83 |
activateCheckButton.setSelection(isEditorActivated); |
... | ... | |
95 | 99 |
|
96 | 100 |
} |
97 | 101 |
}); |
98 |
|
|
102 |
Button allowOverrideActivatedButton = createAllowOverrideButton(activateComp); |
|
99 | 103 |
if (isAdminPreference){ |
100 |
Button allowOverrideActivatedButton = createAllowOverrideButton(activateComp); |
|
101 | 104 |
allowOverrideActivatedButton.setSelection(allowOverrideActivated); |
102 |
|
|
103 | 105 |
allowOverrideActivatedButton.addSelectionListener(new SelectionAdapter(){ |
104 | 106 |
@Override |
105 | 107 |
public void widgetSelected(SelectionEvent e) { |
106 | 108 |
allowOverrideActivated = allowOverrideActivatedButton.getSelection(); |
107 | 109 |
} |
108 | 110 |
}); |
111 |
}else{ |
|
112 |
allowOverrideActivatedButton.setSelection(overrideActivated); |
|
113 |
allowOverrideActivatedButton.addSelectionListener(new SelectionAdapter(){ |
|
114 |
@Override |
|
115 |
public void widgetSelected(SelectionEvent e) { |
|
116 |
overrideActivated = allowOverrideActivatedButton.getSelection(); |
|
117 |
} |
|
118 |
}); |
|
109 | 119 |
} |
110 | 120 |
|
111 | 121 |
|
... | ... | |
113 | 123 |
|
114 | 124 |
child.setVisible(isEditorActivated); |
115 | 125 |
Label separator= new Label(child, SWT.HORIZONTAL | SWT.SEPARATOR); |
116 |
GridData sepGrid = new GridData(GridData.FILL_HORIZONTAL); |
|
117 |
if (isAdminPreference){ |
|
118 |
sepGrid.horizontalSpan = 2; |
|
119 |
} |
|
126 |
GridData sepGrid = createTextGridData(); |
|
120 | 127 |
|
121 |
GridData textGrid = new GridData(GridData.FILL_HORIZONTAL); |
|
122 |
if (isAdminPreference){ |
|
123 |
textGrid.horizontalSpan = 2; |
|
124 |
} |
|
128 |
GridData textGrid = createTextGridData(); |
|
125 | 129 |
textGrid.verticalSpan = 2; |
126 | 130 |
separator.setLayoutData(sepGrid); |
127 | 131 |
|
... | ... | |
132 | 136 |
activateRankButton.addSelectionListener(new SelectionAdapter(){ |
133 | 137 |
@Override |
134 | 138 |
public void widgetSelected(SelectionEvent e) { |
135 |
if(!isAdminPreference){ |
|
136 |
overrideRank = true; |
|
137 |
} |
|
138 | 139 |
isShowRank = activateRankButton.getSelection(); |
139 | 140 |
} |
140 | 141 |
}); |
141 |
|
|
142 |
Button allowOverrideRankButton = createAllowOverrideButton(child); |
|
142 | 143 |
if (isAdminPreference){ |
143 |
Button allowOverrideRankButton = createAllowOverrideButton(child); |
|
144 | 144 |
allowOverrideRankButton.setSelection(allowOverrideRank); |
145 |
|
|
146 | 145 |
allowOverrideRankButton.addSelectionListener(new SelectionAdapter(){ |
147 | 146 |
@Override |
148 | 147 |
public void widgetSelected(SelectionEvent e) { |
... | ... | |
150 | 149 |
} |
151 | 150 |
}); |
152 | 151 |
}else{ |
152 |
allowOverrideRankButton.setSelection(overrideRank); |
|
153 |
allowOverrideRankButton.addSelectionListener(new SelectionAdapter(){ |
|
154 |
@Override |
|
155 |
public void widgetSelected(SelectionEvent e) { |
|
156 |
overrideRank = allowOverrideRankButton.getSelection(); |
|
157 |
} |
|
158 |
}); |
|
153 | 159 |
if (!allowOverrideRank){ |
154 | 160 |
activateRankButton.setEnabled(false); |
161 |
allowOverrideRankButton.setEnabled(false); |
|
155 | 162 |
} |
156 | 163 |
} |
157 | 164 |
|
... | ... | |
162 | 169 |
sortNamedAreaByVocabularyOrder.addSelectionListener(new SelectionAdapter(){ |
163 | 170 |
@Override |
164 | 171 |
public void widgetSelected(SelectionEvent e) { |
165 |
if(!isAdminPreference){ |
|
166 |
overrideOrderAreas = true; |
|
167 |
} |
|
168 | 172 |
isSortByVocabularyOrder = sortNamedAreaByVocabularyOrder.getSelection(); |
169 | 173 |
} |
170 | 174 |
}); |
171 |
|
|
175 |
Button allowOverrideOrderAreasButton = createAllowOverrideButton(child); |
|
172 | 176 |
if (isAdminPreference){ |
173 |
Button allowOverrideOrderAreasButton = createAllowOverrideButton(child); |
|
174 | 177 |
allowOverrideOrderAreasButton.setSelection(allowOverrideOrderAreas); |
175 |
|
|
176 | 178 |
allowOverrideOrderAreasButton.addSelectionListener(new SelectionAdapter(){ |
177 | 179 |
@Override |
178 | 180 |
public void widgetSelected(SelectionEvent e) { |
... | ... | |
180 | 182 |
} |
181 | 183 |
}); |
182 | 184 |
}else{ |
185 |
allowOverrideOrderAreasButton.setSelection(overrideOrderAreas); |
|
186 |
allowOverrideOrderAreasButton.addSelectionListener(new SelectionAdapter(){ |
|
187 |
@Override |
|
188 |
public void widgetSelected(SelectionEvent e) { |
|
189 |
overrideOrderAreas = allowOverrideOrderAreasButton.getSelection(); |
|
190 |
} |
|
191 |
}); |
|
183 | 192 |
if (!allowOverrideOrderAreas){ |
184 | 193 |
sortNamedAreaByVocabularyOrder.setEnabled(false); |
194 |
allowOverrideOrderAreasButton.setEnabled(false); |
|
185 | 195 |
} |
186 | 196 |
} |
187 | 197 |
|
188 | 198 |
final Button ownDescription = new Button(child, SWT.CHECK); |
189 | 199 |
ownDescription.setText(Messages.ChecklistEditorGeneralPreference_own_Description); |
190 |
ownDescription.setToolTipText(Messages.ChecklistEditorGeneralPreference_own_Description); |
|
200 |
ownDescription.setToolTipText(Messages.ChecklistEditorGeneralPreference_own_DescriptionToolTip);
|
|
191 | 201 |
ownDescription.setSelection(ownDescriptionForDistributionEditor); |
192 | 202 |
ownDescription.addSelectionListener(new SelectionAdapter(){ |
193 | 203 |
@Override |
194 | 204 |
public void widgetSelected(SelectionEvent e) { |
195 |
if(!isAdminPreference){ |
|
196 |
overrideOwnDescriptionForDistributionEditor = true; |
|
197 |
} |
|
205 |
|
|
198 | 206 |
ownDescriptionForDistributionEditor = ownDescription.getSelection(); |
199 | 207 |
} |
200 | 208 |
}); |
201 |
|
|
209 |
Button allowOverrideDescription = createAllowOverrideButton(child); |
|
202 | 210 |
if (isAdminPreference){ |
203 |
Button allowOverrideDescription = createAllowOverrideButton(child); |
|
204 | 211 |
allowOverrideDescription.setSelection(allowOverrideOwnDescriptionForDistributionEditor); |
205 |
|
|
206 | 212 |
allowOverrideDescription.addSelectionListener(new SelectionAdapter(){ |
207 | 213 |
@Override |
208 | 214 |
public void widgetSelected(SelectionEvent e) { |
... | ... | |
210 | 216 |
} |
211 | 217 |
}); |
212 | 218 |
}else{ |
219 |
allowOverrideDescription.setSelection(overrideOwnDescriptionForDistributionEditor); |
|
220 |
allowOverrideDescription.addSelectionListener(new SelectionAdapter(){ |
|
221 |
@Override |
|
222 |
public void widgetSelected(SelectionEvent e) { |
|
223 |
overrideOwnDescriptionForDistributionEditor = allowOverrideDescription.getSelection(); |
|
224 |
} |
|
225 |
}); |
|
213 | 226 |
if (!allowOverrideOwnDescriptionForDistributionEditor){ |
214 | 227 |
ownDescription.setEnabled(false); |
228 |
allowOverrideDescription.setEnabled(false); |
|
215 | 229 |
} |
216 | 230 |
} |
217 | 231 |
|
... | ... | |
253 | 267 |
} |
254 | 268 |
} |
255 | 269 |
areaDisplaySelectionCombo.addSelectionListener(this); |
256 |
|
|
270 |
Button allowOverrideOrderAreaDisplayButton = createAllowOverrideButton(child); |
|
257 | 271 |
if (isAdminPreference){ |
258 |
Button allowOverrideOrderAreaDisplayButton = createAllowOverrideButton(child); |
|
259 | 272 |
allowOverrideOrderAreaDisplayButton.setSelection(allowOverrideAreaDisplay); |
260 |
|
|
261 | 273 |
allowOverrideOrderAreaDisplayButton.addSelectionListener(new SelectionAdapter(){ |
262 | 274 |
@Override |
263 | 275 |
public void widgetSelected(SelectionEvent e) { |
... | ... | |
265 | 277 |
} |
266 | 278 |
}); |
267 | 279 |
}else{ |
280 |
allowOverrideOrderAreaDisplayButton.setSelection(overrideAreaDisplay); |
|
281 |
allowOverrideOrderAreaDisplayButton.addSelectionListener(new SelectionAdapter(){ |
|
282 |
@Override |
|
283 |
public void widgetSelected(SelectionEvent e) { |
|
284 |
overrideAreaDisplay = allowOverrideOrderAreaDisplayButton.getSelection(); |
|
285 |
} |
|
286 |
}); |
|
268 | 287 |
if (!allowOverrideAreaDisplay){ |
269 | 288 |
areaDisplaySelectionCombo.setEnabled(false); |
289 |
allowOverrideOrderAreaDisplayButton.setEnabled(false); |
|
270 | 290 |
} |
271 | 291 |
} |
272 | 292 |
|
... | ... | |
285 | 305 |
index = 0; |
286 | 306 |
if (PreferencesUtil.displayStatusInChecklistEditor() != null){ |
287 | 307 |
TermDisplayEnum statusDisplay = TermDisplayEnum.valueOf(displayStatus); |
288 |
for (String itemLabel : areaDisplaySelectionCombo.getItems()){
|
|
308 |
for (String itemLabel : statusDisplaySelectionCombo.getItems()){
|
|
289 | 309 |
if (itemLabel.equalsIgnoreCase(statusDisplay.getLabel())){ |
290 | 310 |
statusDisplaySelectionCombo.select(index); |
291 | 311 |
break; |
... | ... | |
295 | 315 |
} |
296 | 316 |
|
297 | 317 |
statusDisplaySelectionCombo.addSelectionListener(this); |
318 |
Button allowOverrideOrderStatusDisplayButton = createAllowOverrideButton(child); |
|
298 | 319 |
if (isAdminPreference){ |
299 |
Button allowOverrideOrderStatusDisplayButton = createAllowOverrideButton(child); |
|
300 | 320 |
allowOverrideOrderStatusDisplayButton.setSelection(allowOverrideStatusDisplay); |
301 |
|
|
302 | 321 |
allowOverrideOrderStatusDisplayButton.addSelectionListener(new SelectionAdapter(){ |
303 | 322 |
@Override |
304 | 323 |
public void widgetSelected(SelectionEvent e) { |
... | ... | |
306 | 325 |
} |
307 | 326 |
}); |
308 | 327 |
}else{ |
328 |
allowOverrideOrderStatusDisplayButton.setSelection(overrideStatusDisplay); |
|
329 |
allowOverrideOrderStatusDisplayButton.addSelectionListener(new SelectionAdapter(){ |
|
330 |
@Override |
|
331 |
public void widgetSelected(SelectionEvent e) { |
|
332 |
overrideStatusDisplay = allowOverrideOrderStatusDisplayButton.getSelection(); |
|
333 |
} |
|
334 |
}); |
|
309 | 335 |
if (!allowOverrideStatusDisplay){ |
310 | 336 |
statusDisplaySelectionCombo.setEnabled(false); |
337 |
allowOverrideOrderStatusDisplayButton.setEnabled(false); |
|
311 | 338 |
} |
312 | 339 |
} |
313 | 340 |
|
314 |
// if (isAdminPreference){ |
|
315 |
// final CLabel labelStatus = new CLabel(child, SWT.NULL); |
|
316 |
// labelStatus.setText(Messages.DistributionAdminPreferences_SELECT_STATUS); |
|
317 |
// labelStatus.setLayoutData(textGrid); |
|
318 |
// |
|
319 |
// final CommandHandlerButton button_openStatusWizard = new CommandHandlerButton(child, SWT.PUSH, |
|
320 |
// commandHandlerStringStatus); //$NON-NLS-1$ |
|
321 |
// |
|
322 |
// button_openStatusWizard.setText(Messages.Distribution_status_selection); |
|
323 |
// |
|
324 |
// } |
|
341 |
|
|
342 |
final CLabel labelStatus = new CLabel(child, SWT.NULL); |
|
343 |
labelStatus.setText(Messages.DistributionAdminPreferences_SELECT_STATUS); |
|
344 |
labelStatus.setLayoutData(textGrid); |
|
345 |
|
|
346 |
final CommandHandlerButton button_openStatusWizard = new CommandHandlerButton(child, SWT.PUSH, |
|
347 |
commandHandlerStringStatus); |
|
348 |
|
|
349 |
button_openStatusWizard.setText(Messages.Distribution_status_selection); |
|
325 | 350 |
|
326 | 351 |
final CLabel label = new CLabel(child, SWT.NULL); |
327 | 352 |
label.setText(Messages.ChecklistEditorGeneralPreference_open_wizard); |
328 | 353 |
label.setLayoutData(textGrid); |
354 |
|
|
329 | 355 |
final CommandHandlerButton button_openSelectAreas = new CommandHandlerButton(child, SWT.PUSH, |
330 | 356 |
commandHandlerString); |
331 | 357 |
button_openSelectAreas.setText(Messages.ChecklistEditorGeneralPreference_open_distribution_selection); |
332 | 358 |
|
333 |
if (isAdminPreference){ |
|
334 |
createAllowOverrideButton(child); |
|
335 |
}else{ |
|
336 |
if (!allowOverrideAreaVoc){ |
|
337 |
button_openSelectAreas.setEnabled(false); |
|
338 |
} |
|
339 |
} |
|
340 |
// PreferencesUtil.recursiveSetEnabled(child, CdmStore.isActive()); |
|
359 |
|
|
360 |
|
|
341 | 361 |
|
342 | 362 |
if(isEditorActivated){ |
343 | 363 |
child.setEnabled(true); |
344 | 364 |
}else{ |
345 | 365 |
child.setEnabled(false); |
346 | 366 |
} |
367 |
if (!isAdminPreference){ |
|
368 |
if (!allowOverrideAreaVoc){ |
|
369 |
button_openSelectAreas.setButtonEnabled(false); |
|
370 |
} |
|
371 |
if (!allowOverrideStatus){ |
|
372 |
button_openStatusWizard.setButtonEnabled(false); |
|
373 |
} |
|
374 |
} |
|
347 | 375 |
}else{ |
348 | 376 |
Label label = new Label(composite, SWT.NONE); |
349 | 377 |
label.setText("The CDM settings don't allow to set the preferences for using the distribution editor locally. If you need to make local settings, please ask an administrator."); |
... | ... | |
355 | 383 |
|
356 | 384 |
|
357 | 385 |
|
358 |
private Button createAllowOverrideButton(Composite activateComp) { |
|
359 |
final Button allowOverrideCheckButton = new Button(activateComp, SWT.CHECK); |
|
360 |
allowOverrideCheckButton.setText(Messages.ChecklistEditorGeneralPreference_allowOverride); |
|
361 |
return allowOverrideCheckButton; |
|
362 |
} |
|
386 |
|
|
387 |
|
|
388 |
|
|
389 |
|
|
390 |
|
|
363 | 391 |
|
364 | 392 |
@Override |
365 | 393 |
public boolean performOk() { |
366 | 394 |
if (isAllowOverride){ |
395 |
|
|
367 | 396 |
PreferencesUtil.setBooleanValue(EditorPreferencePredicate.DistributionEditorActivated.getKey(), isEditorActivated); |
368 | 397 |
PreferencesUtil.setBooleanValue(IPreferenceKeys.DISTRIBUTION_AREA_PREFRENCES_ACTIVE_OVERRIDE, overrideActivated); |
369 | 398 |
PreferencesUtil.setSortNamedAreasByOrderInVocabulary(isSortByVocabularyOrder); |
... | ... | |
378 | 407 |
PreferencesUtil.setBooleanValue(IPreferenceKeys.OWN_DESCRIPTION_OVERRIDE, overrideOwnDescriptionForDistributionEditor); |
379 | 408 |
|
380 | 409 |
|
410 |
|
|
411 |
|
|
381 | 412 |
} |
382 | 413 |
return true; |
383 | 414 |
} |
... | ... | |
387 | 418 |
*/ |
388 | 419 |
@Override |
389 | 420 |
public void widgetSelected(SelectionEvent e) { |
421 |
|
|
390 | 422 |
if (e.getSource().equals(statusDisplaySelectionCombo)){ |
391 | 423 |
String text = statusDisplaySelectionCombo.getText(); |
392 | 424 |
for (TermDisplayEnum display: TermDisplayEnum.values()){ |
... | ... | |
417 | 449 |
|
418 | 450 |
} |
419 | 451 |
|
452 |
|
|
453 |
/** |
|
454 |
* {@inheritDoc} |
|
455 |
*/ |
|
420 | 456 |
@Override |
421 |
public void init() {
|
|
457 |
protected void getValues() {
|
|
422 | 458 |
isAdminPreference = false; |
423 | 459 |
setPreferenceStore(PreferencesUtil.getPreferenceStore()); |
424 | 460 |
distributionEditorPref = PreferencesUtil.getPreferenceFromDB(EditorPreferencePredicate.DistributionEditorActivated); |
... | ... | |
436 | 472 |
isEditorActivated = PreferencesUtil.getBooleanValue(EditorPreferencePredicate.DistributionEditorActivated.getKey()); |
437 | 473 |
isAllowOverride = true; |
438 | 474 |
} |
439 |
CdmPreference prefStatus = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.AvailableDistributionAreaVocabularies); |
|
440 | 475 |
|
476 |
CdmPreference prefStatus = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.AvailableDistributionAreaVocabularies); |
|
441 | 477 |
allowOverrideAreaVoc = prefStatus != null?prefStatus.isAllowOverride():false; |
442 | 478 |
|
479 |
prefStatus = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.AvailableDistributionStatus); |
|
480 |
allowOverrideStatus = prefStatus != null?prefStatus.isAllowOverride():false; |
|
481 |
|
|
443 | 482 |
CdmPreference pref = PreferencesUtil.getPreferenceFromDB(EditorPreferencePredicate.DisplayOfAreasInDistributionEditor); |
444 | 483 |
if (pref != null){ |
445 | 484 |
this.allowOverrideAreaDisplay = pref.isAllowOverride(); |
... | ... | |
511 | 550 |
|
512 | 551 |
commandHandlerString = "eu.etaxonomy.taxeditor.store.open.OpenDistributionEditorWizardHandler"; |
513 | 552 |
commandHandlerStringStatus = "eu.etaxonomy.taxeditor.store.open.OpenDistributionStatusWizardHandler"; |
553 |
overrideString = Messages.GeneralPreference_override; |
|
514 | 554 |
|
515 | 555 |
} |
516 | 556 |
} |
Also available in: Unified diff
ref #7849: improve DB preference handling and use editorpreferencePredicates keys also for local preferences