1 package eu
.etaxonomy
.taxeditor
.preference
;
4 import org
.eclipse
.jface
.layout
.GridLayoutFactory
;
5 import org
.eclipse
.swt
.SWT
;
6 import org
.eclipse
.swt
.custom
.CLabel
;
7 import org
.eclipse
.swt
.events
.SelectionAdapter
;
8 import org
.eclipse
.swt
.events
.SelectionEvent
;
9 import org
.eclipse
.swt
.layout
.GridData
;
10 import org
.eclipse
.swt
.layout
.GridLayout
;
11 import org
.eclipse
.swt
.widgets
.Button
;
12 import org
.eclipse
.swt
.widgets
.Composite
;
13 import org
.eclipse
.swt
.widgets
.Control
;
14 import org
.eclipse
.swt
.widgets
.Label
;
16 import eu
.etaxonomy
.cdm
.model
.metadata
.CdmPreference
;
17 import eu
.etaxonomy
.cdm
.model
.metadata
.PreferencePredicate
;
18 import eu
.etaxonomy
.taxeditor
.l10n
.Messages
;
19 import eu
.etaxonomy
.taxeditor
.preference
.menu
.CdmPreferencePage
;
22 public class NameDetailsViewConfiguration
extends CdmPreferencePage
{
24 protected boolean isSimpleDetailsViewActivated
;
25 boolean isUseLocalSettings
;
26 protected NameDetailsConfigurator nameDetailsConfig
;
27 Composite localSettings
;
30 protected boolean isShowTaxon
;
31 protected boolean isShowNameApprobiation
;
32 protected boolean isShowHybrid
;
33 protected boolean isShowNameRelationship
;
34 protected boolean isShowTypeDesignation
;
35 protected boolean isShowProtologue
;
36 protected boolean isShowNomenclaturalStatus
;
37 protected boolean isShowNomenclaturalRef
;
38 protected boolean isShowAuthorship
;
39 protected boolean isShowAuthorCache
;
40 protected boolean isShowEpithets
;
41 protected boolean isShowRank
;
42 protected boolean isShowAppendedPhrase
;
43 protected boolean isShowNameCache
;
44 protected boolean isShowNomenclaturalCode
;
45 protected boolean isShowLSID
;
46 protected boolean isSecEnabled
;
47 protected boolean isSecDetailsActivated
;
49 protected boolean isAllowOverride
;
50 private boolean isOverride
;
51 private Button showSecDetail
;
52 private Button secEnabled
;
54 protected Button activateCheckButton
;
55 protected Button allowLocalPreference
;
56 protected Button showTaxon
;
57 protected Button showLsid
;
58 protected Button showNomenclaturalCode
;
59 protected Button showNameCache
;
60 protected Button showAppendedPhrase
;
61 protected Button showRank
;
62 protected Button showEpithets
;
63 protected Button showAuthorCache
;
64 protected Button showAuthorship
;
65 protected Button showNomenclaturalRef
;
66 protected Button showNomenclaturalStatus
;
67 protected Button showProtologue
;
68 protected Button showTypeDesignation
;
69 protected Button showNameRelationship
;
70 protected Button showHybrid
;
71 protected Button showNameApprobiation
;
74 protected Control
createContents(Composite parent
) {
76 if (isAllowOverride
|| isAdminPreference
){
78 final CLabel description
= new CLabel(parent
, SWT
.NULL
);
79 description
.setText(Messages
.NameDetailsViewConfiguration_description
);
81 Composite title
= createComposite(parent
);
82 // nameDetailsConfig = PreferencesUtil.getPreferredNameDetailsConfiguration(!isAdminPreference);
83 if (nameDetailsConfig
== null){
84 nameDetailsConfig
= new NameDetailsConfigurator(false);
87 activateCheckButton
= new Button(title
, SWT
.CHECK
);
88 allowLocalPreference
= createAllowOverrideButton(title
);
89 Composite dbSettings
= new Composite(parent
, SWT
.NONE
);
91 activateCheckButton
.setLayoutData(new GridData(SWT
.LEFT
, SWT
.CENTER
, true, true, 1, 1));
92 activateCheckButton
.setText(Messages
.NameDetailsViewConfiguration_activateSimpleDetailsView
);
93 isSimpleDetailsViewActivated
= nameDetailsConfig
.isSimpleDetailsViewActivated();
95 activateCheckButton
.addSelectionListener(new SelectionAdapter(){
97 public void widgetSelected(SelectionEvent e
) {
99 isSimpleDetailsViewActivated
= activateCheckButton
.getSelection();
100 nameDetailsConfig
.setSimpleDetailsViewActivated(isSimpleDetailsViewActivated
);
101 dbSettings
.setEnabled(isSimpleDetailsViewActivated
);
102 PreferencesUtil
.recursiveSetEnabled(dbSettings
, isSimpleDetailsViewActivated
);
103 if (isSimpleDetailsViewActivated
){
104 showSecDetail
.setEnabled(isShowTaxon
);
105 secEnabled
.setEnabled(isShowTaxon
);
112 allowLocalPreference
.addSelectionListener(new SelectionAdapter(){
114 public void widgetSelected(SelectionEvent e
) {
116 if (isAdminPreference
){
117 isAllowOverride
= allowLocalPreference
.getSelection();
119 isOverride
= allowLocalPreference
.getSelection();
125 dbSettings
.setLayout(new GridLayout());
126 dbSettings
.setEnabled(isSimpleDetailsViewActivated
);
129 Label separator
= new Label(dbSettings
, SWT
.HORIZONTAL
| SWT
.SEPARATOR
);
130 separator
.setLayoutData(new GridData(GridData
.FILL_HORIZONTAL
));
131 showTaxon
= new Button(dbSettings
, SWT
.CHECK
);
132 showTaxon
.setText(Messages
.NameDetailsViewComposite_Show_Taxon
);
133 isShowTaxon
= nameDetailsConfig
.isTaxonSectionActivated();
135 showTaxon
.addSelectionListener(new SelectionAdapter(){
137 public void widgetSelected(SelectionEvent e
) {
139 isShowTaxon
= showTaxon
.getSelection();
140 nameDetailsConfig
.setTaxonSectionActivated(isShowTaxon
);
141 if (isSimpleDetailsViewActivated
){
142 showSecDetail
.setEnabled(isShowTaxon
);
143 secEnabled
.setEnabled(isShowTaxon
);
149 Composite taxonComp
= new Composite(dbSettings
, SWT
.NULL
);
151 GridLayoutFactory
.fillDefaults().applyTo(taxonComp
);
153 GridData data
= new GridData();
154 data
.horizontalIndent
= 5;
155 data
.horizontalSpan
= 2;
156 taxonComp
.setLayoutData(data
);
158 secEnabled
= new Button(taxonComp
, SWT
.CHECK
);
159 secEnabled
.setText(Messages
.NameDetailsViewComposite_SecEnabled
);
161 isSecEnabled
= nameDetailsConfig
.isSecEnabled();
163 secEnabled
.addSelectionListener(new SelectionAdapter(){
165 public void widgetSelected(SelectionEvent e
) {
167 isSecEnabled
= secEnabled
.getSelection();
168 nameDetailsConfig
.setSecEnabled(isSecEnabled
);
171 showSecDetail
= new Button(taxonComp
, SWT
.CHECK
);
172 showSecDetail
.setText(Messages
.NameDetailsViewComposite_Show_SecDetail
);
174 isSecDetailsActivated
= nameDetailsConfig
.isSecDetailsActivated();
176 showSecDetail
.addSelectionListener(new SelectionAdapter(){
178 public void widgetSelected(SelectionEvent e
) {
180 isSecDetailsActivated
= showSecDetail
.getSelection();
181 nameDetailsConfig
.setSecDetailsActivated(isSecDetailsActivated
);
185 showLsid
= new Button(dbSettings
, SWT
.CHECK
);
186 showLsid
.setText(Messages
.NameDetailsViewComposite_Show_LSID
);
187 isShowLSID
= nameDetailsConfig
.isLSIDActivated();
189 showLsid
.addSelectionListener(new SelectionAdapter(){
191 public void widgetSelected(SelectionEvent e
) {
193 isShowLSID
= showLsid
.getSelection();
194 nameDetailsConfig
.setLSIDActivated(isShowLSID
);
198 showNomenclaturalCode
= new Button(dbSettings
, SWT
.CHECK
);
199 showNomenclaturalCode
.setText(Messages
.NameDetailsViewComposite_Show_NomenclaturalCode
);
200 isShowNomenclaturalCode
= nameDetailsConfig
.isNomenclaturalCodeActived();
202 showNomenclaturalCode
.addSelectionListener(new SelectionAdapter(){
204 public void widgetSelected(SelectionEvent e
) {
206 isShowNomenclaturalCode
= showNomenclaturalCode
.getSelection();
207 nameDetailsConfig
.setNomenclaturalCodeActived(isShowNomenclaturalCode
);
211 showNameCache
= new Button(dbSettings
, SWT
.CHECK
);
212 showNameCache
.setText(Messages
.NameDetailsViewComposite_Show_NameCache
);
213 isShowNameCache
= nameDetailsConfig
.isNameCacheActivated();
215 showNameCache
.addSelectionListener(new SelectionAdapter(){
217 public void widgetSelected(SelectionEvent e
) {
219 isShowNameCache
= showNameCache
.getSelection();
220 nameDetailsConfig
.setNameCacheActivated(isShowNameCache
);
223 showAppendedPhrase
= new Button(dbSettings
, SWT
.CHECK
);
224 isShowAppendedPhrase
= nameDetailsConfig
.isAppendedPhraseActivated();
225 showAppendedPhrase
.setText(Messages
.NameDetailsViewComposite_Show_AppendedPhrase
);
227 showAppendedPhrase
.addSelectionListener(new SelectionAdapter(){
229 public void widgetSelected(SelectionEvent e
) {
231 isShowAppendedPhrase
= showAppendedPhrase
.getSelection();
232 nameDetailsConfig
.setAppendedPhraseActivated(isShowAppendedPhrase
);
236 showRank
= new Button(dbSettings
, SWT
.CHECK
);
237 isShowRank
= nameDetailsConfig
.isRankActivated();
238 showRank
.setText(Messages
.NameDetailsViewComposite_Show_Rank
);
240 showRank
.addSelectionListener(new SelectionAdapter(){
242 public void widgetSelected(SelectionEvent e
) {
244 isShowRank
= showRank
.getSelection();
245 nameDetailsConfig
.setRankActivated(isShowRank
);
248 showEpithets
= new Button(dbSettings
, SWT
.CHECK
);
249 isShowEpithets
= nameDetailsConfig
.isAtomisedEpithetsActivated();
250 showEpithets
.setText(Messages
.NameDetailsViewComposite_Show_AtomisedEpithets
);
252 showEpithets
.addSelectionListener(new SelectionAdapter(){
254 public void widgetSelected(SelectionEvent e
) {
256 isShowEpithets
= showEpithets
.getSelection();
257 nameDetailsConfig
.setAtomisedEpithetsActivated(isShowEpithets
);
261 showAuthorCache
= new Button(dbSettings
, SWT
.CHECK
);
262 isShowAuthorCache
= nameDetailsConfig
.isAuthorCacheActivated();
263 showAuthorCache
.setText(Messages
.NameDetailsViewComposite_Show_AuthorCache
);
265 showAuthorCache
.addSelectionListener(new SelectionAdapter(){
267 public void widgetSelected(SelectionEvent e
) {
269 isShowAuthorCache
= showAuthorCache
.getSelection();
270 nameDetailsConfig
.setAuthorCacheActivated(isShowAuthorCache
);
274 showAuthorship
= new Button(dbSettings
, SWT
.CHECK
);
275 isShowAuthorship
= nameDetailsConfig
.isAuthorshipSectionActivated();
276 showAuthorship
.setText(Messages
.NameDetailsViewComposite_Show_Author
);
278 showAuthorship
.addSelectionListener(new SelectionAdapter(){
280 public void widgetSelected(SelectionEvent e
) {
282 isShowAuthorship
= showAuthorship
.getSelection();
283 nameDetailsConfig
.setAuthorshipSectionActivated(isShowAuthorship
);
287 showNomenclaturalRef
= new Button(dbSettings
, SWT
.CHECK
);
288 isShowNomenclaturalRef
= nameDetailsConfig
.isNomenclaturalReferenceSectionActivated();
289 showNomenclaturalRef
.setText(Messages
.NameDetailsViewComposite_Show_NomenclaturalReference
);
291 showNomenclaturalRef
.addSelectionListener(new SelectionAdapter(){
293 public void widgetSelected(SelectionEvent e
) {
295 isShowNomenclaturalRef
= showNomenclaturalRef
.getSelection();
296 nameDetailsConfig
.setNomenclaturalReferenceSectionActivated(isShowNomenclaturalRef
);
300 showNomenclaturalStatus
= new Button(dbSettings
, SWT
.CHECK
);
301 isShowNomenclaturalStatus
= nameDetailsConfig
.isNomenclaturalStatusSectionActivated();
302 showNomenclaturalStatus
.setText(Messages
.NameDetailsViewComposite_Show_NomenclaturalStatus
);
304 showNomenclaturalStatus
.addSelectionListener(new SelectionAdapter(){
306 public void widgetSelected(SelectionEvent e
) {
308 isShowNomenclaturalStatus
= showNomenclaturalStatus
.getSelection();
309 nameDetailsConfig
.setNomenclaturalStatusSectionActivated(isShowNomenclaturalStatus
);
313 showProtologue
= new Button(dbSettings
, SWT
.CHECK
);
314 isShowProtologue
= nameDetailsConfig
.isProtologueActivated();
315 showProtologue
.setText(Messages
.NameDetailsViewComposite_Show_Protologue
);
317 showProtologue
.addSelectionListener(new SelectionAdapter(){
319 public void widgetSelected(SelectionEvent e
) {
321 isShowProtologue
= showProtologue
.getSelection();
322 nameDetailsConfig
.setProtologueActivated(isShowProtologue
);
326 showTypeDesignation
= new Button(dbSettings
, SWT
.CHECK
);
327 isShowTypeDesignation
= nameDetailsConfig
.isTypeDesignationSectionActivated();
328 showTypeDesignation
.setText(Messages
.NameDetailsViewComposite_Show_TypeDesignation
);
330 showTypeDesignation
.addSelectionListener(new SelectionAdapter(){
332 public void widgetSelected(SelectionEvent e
) {
334 isShowTypeDesignation
= showTypeDesignation
.getSelection();
335 nameDetailsConfig
.setTypeDesignationSectionActivated(isShowTypeDesignation
);
340 showNameRelationship
= new Button(dbSettings
, SWT
.CHECK
);
341 isShowNameRelationship
= nameDetailsConfig
.isNameRelationsSectionActivated();
342 showNameRelationship
.setText(Messages
.NameDetailsViewComposite_Show_Namerelationships
);
344 showNameRelationship
.addSelectionListener(new SelectionAdapter(){
346 public void widgetSelected(SelectionEvent e
) {
348 isShowNameRelationship
= showNameRelationship
.getSelection();
349 nameDetailsConfig
.setNameRelationsSectionActivated(isShowNameRelationship
);
353 showHybrid
= new Button(dbSettings
, SWT
.CHECK
);
354 isShowHybrid
= nameDetailsConfig
.isHybridActivated();
355 showHybrid
.setText(Messages
.NameDetailsViewComposite_Show_Hybrid
);
357 showHybrid
.addSelectionListener(new SelectionAdapter(){
359 public void widgetSelected(SelectionEvent e
) {
361 isShowHybrid
= showHybrid
.getSelection();
362 nameDetailsConfig
.setHybridActivated(isShowHybrid
);
365 showNameApprobiation
= new Button(dbSettings
, SWT
.CHECK
);
366 isShowNameApprobiation
= nameDetailsConfig
.isNameApprobiationActivated();
367 showNameApprobiation
.setText(Messages
.NameDetailsViewComposite_Show_NameApprobiation
);
368 showNameApprobiation
.addSelectionListener(new SelectionAdapter(){
370 public void widgetSelected(SelectionEvent e
) {
372 isShowNameApprobiation
= showNameApprobiation
.getSelection();
373 nameDetailsConfig
.setNameApprobiationActivated(isShowNameApprobiation
);
376 PreferencesUtil
.recursiveSetEnabled(dbSettings
, isSimpleDetailsViewActivated
);
377 if (isSimpleDetailsViewActivated
){
378 showSecDetail
.setEnabled(isShowTaxon
);
379 secEnabled
.setEnabled(isShowTaxon
);
381 setButtonSelections();
384 final CLabel description
= new CLabel(parent
, SWT
.NULL
);
385 description
.setText(Messages
.NameDetailsViewConfiguration_description_not_available
);
395 public boolean performOk() {
396 if (nameDetailsConfig
!= null){
397 PreferencesUtil
.setStringValue(PreferencePredicate
.NameDetailsView
.getKey(), nameDetailsConfig
.toString());
398 PreferencesUtil
.setBooleanValue(PreferencesUtil
.prefOverrideKey(PreferencePredicate
.NameDetailsView
.getKey()), isOverride
);
406 public void getValues(){
407 if (nameDetailsConfig
== null){
408 CdmPreference nameDetailsPref
= PreferencesUtil
.getPreferenceFromDB(PreferencePredicate
.NameDetailsView
);
409 isAdminPreference
= false;
410 isAllowOverride
= true;
411 if (nameDetailsPref
!= null){
412 isAllowOverride
= nameDetailsPref
.isAllowOverride();
415 isOverride
= PreferencesUtil
.getBooleanValue(PreferencesUtil
.prefOverrideKey(PreferencePredicate
.NameDetailsView
.getKey()));
416 nameDetailsConfig
= PreferencesUtil
.getPreferredNameDetailsConfiguration(true);
420 protected void setButtonSelections(){
421 activateCheckButton
.setSelection(isSimpleDetailsViewActivated
);;
422 if (isAdminPreference
){
423 allowLocalPreference
.setSelection(isAllowOverride
);
425 allowLocalPreference
.setSelection(isOverride
);
427 showTaxon
.setSelection(isShowTaxon
);
428 showLsid
.setSelection(isShowLSID
);
429 showNomenclaturalCode
.setSelection(isShowNomenclaturalCode
);
430 showNameCache
.setSelection(isShowNameCache
);
431 showAppendedPhrase
.setSelection(isShowAppendedPhrase
);
432 showRank
.setSelection(isShowRank
);
433 showEpithets
.setSelection(isShowEpithets
);
434 showAuthorCache
.setSelection(isShowAuthorCache
);
435 showAuthorship
.setSelection(isShowAuthorship
);
436 showNomenclaturalRef
.setSelection(isShowNomenclaturalRef
);
437 showNomenclaturalStatus
.setSelection(isShowNomenclaturalStatus
);
438 showProtologue
.setSelection(isShowProtologue
);
439 showTypeDesignation
.setSelection(isShowTypeDesignation
);
440 showNameRelationship
.setSelection(isShowNameRelationship
);
441 showHybrid
.setSelection(isShowHybrid
);
442 showNameApprobiation
.setSelection(isShowNameApprobiation
);
443 secEnabled
.setSelection(isSecEnabled
);
444 secEnabled
.setEnabled(isShowTaxon
);
445 showSecDetail
.setSelection(isSecDetailsActivated
);
446 showSecDetail
.setEnabled(isShowTaxon
);
451 protected void performDefaults() {
452 nameDetailsConfig
= new NameDetailsConfigurator(false);
453 isShowAppendedPhrase
= nameDetailsConfig
.isAppendedPhraseActivated();
454 isShowEpithets
= nameDetailsConfig
.isAtomisedEpithetsActivated();
455 isShowAuthorship
= nameDetailsConfig
.isAuthorshipSectionActivated();
456 isShowAuthorCache
= nameDetailsConfig
.isAuthorCacheActivated();
457 isShowLSID
= nameDetailsConfig
.isLSIDActivated();
458 isShowNameApprobiation
= nameDetailsConfig
.isNameApprobiationActivated();
459 isShowNameCache
= nameDetailsConfig
.isNameCacheActivated();
460 isShowNameRelationship
= nameDetailsConfig
.isNameRelationsSectionActivated();
461 isShowNomenclaturalCode
= nameDetailsConfig
.isNomenclaturalCodeActived();
462 isShowNomenclaturalStatus
= nameDetailsConfig
.isNomenclaturalStatusSectionActivated();
463 isShowNomenclaturalRef
= nameDetailsConfig
.isNomenclaturalReferenceSectionActivated();
464 isShowProtologue
= nameDetailsConfig
.isProtologueActivated();
465 isShowRank
= nameDetailsConfig
.isRankActivated();
466 isShowTaxon
= nameDetailsConfig
.isTaxonSectionActivated();
467 isSecDetailsActivated
= nameDetailsConfig
.isSecDetailsActivated();
468 isSecEnabled
= nameDetailsConfig
.isSecEnabled();
469 isShowTypeDesignation
= nameDetailsConfig
.isTypeDesignationSectionActivated();
470 isShowHybrid
= nameDetailsConfig
.isHybridActivated();
471 this.setButtonSelections();
472 super.performDefaults();