Revision 80379c19
Added by Katja Luther almost 5 years ago
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/ChecklistEditorGeneralPreference.java | ||
---|---|---|
25 | 25 |
|
26 | 26 |
import eu.etaxonomy.cdm.model.metadata.CdmPreference; |
27 | 27 |
import eu.etaxonomy.cdm.model.metadata.PreferencePredicate; |
28 |
import eu.etaxonomy.cdm.model.metadata.TermComboEnum; |
|
28 | 29 |
import eu.etaxonomy.cdm.model.metadata.TermDisplayEnum; |
29 | 30 |
import eu.etaxonomy.cdm.model.metadata.TermOrder; |
30 | 31 |
import eu.etaxonomy.taxeditor.l10n.Messages; |
... | ... | |
47 | 48 |
protected Boolean isShowRank; |
48 | 49 |
protected String orderAreas; |
49 | 50 |
protected String displayStatus; |
51 |
protected String displayStatusCombo; |
|
50 | 52 |
protected String displayArea; |
51 | 53 |
protected Boolean ownDescriptionForDistributionEditor; |
52 | 54 |
|
... | ... | |
56 | 58 |
protected boolean overrideOrderAreas; |
57 | 59 |
protected boolean overrideAreaDisplay; |
58 | 60 |
protected boolean overrideStatusDisplay; |
61 |
protected boolean overrideStatusDisplayCombo; |
|
59 | 62 |
|
60 | 63 |
protected Combo areaOrderSelectionCombo; |
61 | 64 |
protected Button allowOverrideOrderAreasButton; |
62 | 65 |
protected Combo statusDisplaySelectionCombo; |
63 | 66 |
protected Button allowOverrideStatusDisplayButton; |
67 |
protected Combo statusDisplayInComboSelectionCombo; |
|
68 |
protected Button allowOverrideStatusDisplayInComboButton; |
|
64 | 69 |
protected Combo areaDisplaySelectionCombo; |
65 | 70 |
protected Button allowOverrideAreaDisplayButton; |
66 | 71 |
protected String commandHandlerString; |
... | ... | |
71 | 76 |
protected CdmPreference prefAreaVoc; |
72 | 77 |
protected CdmPreference prefAreaDisplay; |
73 | 78 |
protected CdmPreference prefStatusDisplay; |
79 |
protected CdmPreference prefStatusDisplayInCombo; |
|
74 | 80 |
protected CdmPreference prefAreaSort; |
75 | 81 |
protected CdmPreference prefRank; |
76 | 82 |
protected CdmPreference prefOwnDescription; |
... | ... | |
187 | 193 |
@Override |
188 | 194 |
public void widgetSelected(SelectionEvent e) { |
189 | 195 |
setApply(true); |
196 |
if (prefRank == null){ |
|
197 |
prefRank = CdmPreference.NewTaxEditorInstance(PreferencePredicate.ShowRankInDistributionEditor, PreferencePredicate.ShowRankInDistributionEditor.getDefaultValue() != null ? PreferencePredicate.ShowRankInDistributionEditor.getDefaultValue().toString(): null); |
|
198 |
} |
|
190 | 199 |
prefRank.setAllowOverride(allowOverrideRankButton.getSelection()); |
191 | 200 |
} |
192 | 201 |
}); |
... | ... | |
230 | 239 |
@Override |
231 | 240 |
public void widgetSelected(SelectionEvent e) { |
232 | 241 |
setApply(true); |
242 |
if (prefAreaSort == null){ |
|
243 |
prefAreaSort = CdmPreference.NewTaxEditorInstance(PreferencePredicate.AreasSortedInDistributionEditor, PreferencePredicate.AreasSortedInDistributionEditor.getDefaultValue() != null ? PreferencePredicate.AreasSortedInDistributionEditor.getDefaultValue().toString(): null); |
|
244 |
} |
|
233 | 245 |
prefAreaSort.setAllowOverride(allowOverrideOrderAreasButton.getSelection()); |
234 | 246 |
} |
235 | 247 |
}); |
... | ... | |
272 | 284 |
@Override |
273 | 285 |
public void widgetSelected(SelectionEvent e) { |
274 | 286 |
setApply(true); |
287 |
if (prefAreaDisplay == null){ |
|
288 |
prefAreaDisplay = CdmPreference.NewTaxEditorInstance(PreferencePredicate.DisplayOfAreasInDistributionEditor, PreferencePredicate.DisplayOfAreasInDistributionEditor.getDefaultValue() != null ? PreferencePredicate.DisplayOfAreasInDistributionEditor.getDefaultValue().toString(): null); |
|
289 |
} |
|
275 | 290 |
prefAreaDisplay.setAllowOverride(allowOverrideOrderAreasButton.getSelection()); |
276 | 291 |
} |
277 | 292 |
}); |
... | ... | |
312 | 327 |
@Override |
313 | 328 |
public void widgetSelected(SelectionEvent e) { |
314 | 329 |
setApply(true); |
330 |
if (prefStatusDisplay == null){ |
|
331 |
prefStatusDisplay = CdmPreference.NewTaxEditorInstance(PreferencePredicate.DisplayOfStatus, PreferencePredicate.DisplayOfStatus.getDefaultValue() != null ? PreferencePredicate.DisplayOfStatus.getDefaultValue().toString(): null); |
|
332 |
} |
|
315 | 333 |
prefStatusDisplay.setAllowOverride(allowOverrideStatusDisplayButton.getSelection()); |
316 | 334 |
} |
317 | 335 |
}); |
318 | 336 |
} |
319 | 337 |
|
338 |
statusDisplayInComboSelectionCombo = createCombo(child, TermComboEnum.values(), PreferencePredicate.DisplayOfStatusInCombo, Messages.ChecklistEditorGeneralPreference_Configure_display_of_Status_in_Combo, isAdminPreference); |
|
339 |
|
|
340 |
index = 0; |
|
341 |
TermComboEnum statusComboDisplay; |
|
342 |
try { |
|
343 |
if (displayStatusCombo != null) { |
|
344 |
statusComboDisplay = TermComboEnum.byKey(displayStatusCombo); |
|
345 |
} else { |
|
346 |
statusComboDisplay = TermComboEnum.Title; |
|
347 |
} |
|
348 |
} catch (IllegalArgumentException e) { |
|
349 |
statusComboDisplay = TermComboEnum.Title; |
|
350 |
} |
|
351 |
for (String itemLabel : statusDisplayInComboSelectionCombo.getItems()) { |
|
352 |
if (itemLabel.equals(Messages.Preference_Use_Default) && displayStatusCombo.equals(Messages.Preference_Use_Default)){ |
|
353 |
statusDisplayInComboSelectionCombo.select(index); |
|
354 |
break; |
|
355 |
} |
|
356 |
if (itemLabel.startsWith(statusComboDisplay.getLabel())) { |
|
357 |
statusDisplayInComboSelectionCombo.select(index); |
|
358 |
break; |
|
359 |
} |
|
360 |
|
|
361 |
index++; |
|
362 |
} |
|
363 |
|
|
364 |
statusDisplayInComboSelectionCombo.addSelectionListener(this); |
|
365 |
|
|
366 |
if (isAdminPreference) { |
|
367 |
allowOverrideStatusDisplayInComboButton = createAllowOverrideButton(child); |
|
368 |
allowOverrideStatusDisplayInComboButton.setSelection(prefStatusDisplayInCombo != null ? prefStatusDisplayInCombo.isAllowOverride(): true); |
|
369 |
allowOverrideStatusDisplayInComboButton.addSelectionListener(new SelectionAdapter() { |
|
370 |
@Override |
|
371 |
public void widgetSelected(SelectionEvent e) { |
|
372 |
setApply(true); |
|
373 |
if (prefStatusDisplayInCombo == null){ |
|
374 |
prefStatusDisplayInCombo = CdmPreference.NewTaxEditorInstance(PreferencePredicate.DisplayOfStatusInCombo, PreferencePredicate.DisplayOfStatusInCombo.getDefaultValue() != null ? PreferencePredicate.DisplayOfStatusInCombo.getDefaultValue().toString(): null); |
|
375 |
} |
|
376 |
prefStatusDisplayInCombo.setAllowOverride(allowOverrideStatusDisplayInComboButton.getSelection()); |
|
377 |
} |
|
378 |
}); |
|
379 |
} |
|
380 |
|
|
381 |
|
|
320 | 382 |
final CLabel labelStatus = new CLabel(child, SWT.NULL); |
321 | 383 |
labelStatus.setText(Messages.DistributionAdminPreferences_SELECT_STATUS); |
322 | 384 |
labelStatus.setLayoutData(textGrid); |
... | ... | |
369 | 431 |
if (prefStatusDisplay != null && !prefStatusDisplay.isAllowOverride()) { |
370 | 432 |
statusDisplaySelectionCombo.setEnabled(false); |
371 | 433 |
} |
434 |
if (prefStatusDisplayInCombo != null && !prefStatusDisplayInCombo.isAllowOverride()) { |
|
435 |
statusDisplayInComboSelectionCombo.setEnabled(false); |
|
436 |
} |
|
372 | 437 |
} |
373 | 438 |
|
374 | 439 |
} |
... | ... | |
423 | 488 |
PreferencesUtil.prefOverrideKey(PreferencePredicate.DisplayOfStatus.getKey()), |
424 | 489 |
override); |
425 | 490 |
|
491 |
override = false; |
|
492 |
if (!displayStatusCombo.equals(Messages.Preference_Use_Default)) { |
|
493 |
override = true; |
|
494 |
PreferencesUtil.setStringValue(PreferencePredicate.DisplayOfStatusInCombo.getKey(), displayStatusCombo); |
|
495 |
} |
|
496 |
PreferencesUtil.setBooleanValue( |
|
497 |
PreferencesUtil.prefOverrideKey(PreferencePredicate.DisplayOfStatusInCombo.getKey()), |
|
498 |
override); |
|
426 | 499 |
|
427 | 500 |
|
428 | 501 |
|
... | ... | |
472 | 545 |
|
473 | 546 |
} |
474 | 547 |
} |
548 |
if (e.getSource().equals(statusDisplayInComboSelectionCombo)) { |
|
549 |
String text = statusDisplayInComboSelectionCombo.getText(); |
|
550 |
if(text.equals(Messages.Preference_Use_Default)){ |
|
551 |
displayStatusCombo = Messages.Preference_Use_Default; |
|
552 |
if(isAdminPreference){ |
|
553 |
prefStatusDisplayInCombo.setAllowOverride(true); |
|
554 |
allowOverrideStatusDisplayInComboButton.setSelection(true); |
|
555 |
} |
|
556 |
|
|
557 |
return; |
|
558 |
} |
|
559 |
for (TermComboEnum display : TermComboEnum.values()) { |
|
560 |
if (text.startsWith(display.getLabel())) { |
|
561 |
displayStatusCombo = display.getKey(); |
|
562 |
break; |
|
563 |
} |
|
564 |
|
|
565 |
} |
|
566 |
} |
|
475 | 567 |
if (e.getSource().equals(areaDisplaySelectionCombo)) { |
476 | 568 |
String text = areaDisplaySelectionCombo.getText(); |
477 | 569 |
if(text.equals(Messages.Preference_Use_Default)){ |
... | ... | |
642 | 734 |
//prefStatusDisplay = CdmPreference.NewTaxEditorInstance(PreferencePredicate.DisplayOfStatus, PreferencePredicate.DisplayOfStatus.getDefaultValue() != null ? PreferencePredicate.DisplayOfStatus.getDefaultValue().toString(): null); |
643 | 735 |
} |
644 | 736 |
|
737 |
prefStatusDisplayInCombo = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.DisplayOfStatusInCombo); |
|
738 |
overrideStatusDisplayCombo = PreferencesUtil |
|
739 |
.getBooleanValue(PreferencesUtil.prefOverrideKey(PreferencePredicate.DisplayOfStatusInCombo.getKey()), true); |
|
740 |
if (prefStatusDisplayInCombo != null) { |
|
741 |
if (prefStatusDisplayInCombo.isAllowOverride()){ |
|
742 |
if (overrideStatusDisplayCombo) { |
|
743 |
displayStatusCombo = PreferencesUtil.getStringValue(PreferencePredicate.DisplayOfStatusInCombo.getKey()); |
|
744 |
}else{ |
|
745 |
displayStatusCombo = Messages.Preference_Use_Default; |
|
746 |
} |
|
747 |
} else { |
|
748 |
this.displayStatusCombo = prefStatusDisplayInCombo.getValue(); |
|
749 |
} |
|
750 |
} else { |
|
751 |
if (overrideStatusDisplayCombo){ |
|
752 |
displayStatusCombo = PreferencesUtil.getStringValue(PreferencePredicate.DisplayOfStatusInCombo.getKey()); |
|
753 |
} else{ |
|
754 |
displayStatusCombo = Messages.Preference_Use_Default; |
|
755 |
} |
|
756 |
|
|
757 |
} |
|
758 |
|
|
759 |
|
|
645 | 760 |
prefAreaSort = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.AreasSortedInDistributionEditor); |
646 | 761 |
overrideOrderAreas = PreferencesUtil.getBooleanValue( |
647 | 762 |
PreferencesUtil.prefOverrideKey(PreferencePredicate.AreasSortedInDistributionEditor.getKey()), true); |
Also available in: Unified diff
mend
display of status in drop down according to preference