2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
6 * The contents of this file are subject to the Mozilla Public License Version 1.1
7 * See LICENSE.TXT at the top of this package for the full license terms.
9 package eu
.etaxonomy
.taxeditor
.ui
.section
.taxon
;
11 import org
.eclipse
.jface
.util
.PropertyChangeEvent
;
12 import org
.eclipse
.swt
.SWT
;
14 import eu
.etaxonomy
.cdm
.model
.reference
.Reference
;
15 import eu
.etaxonomy
.cdm
.model
.taxon
.Synonym
;
16 import eu
.etaxonomy
.cdm
.model
.taxon
.SynonymType
;
17 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
18 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonBase
;
19 import eu
.etaxonomy
.cdm
.persistence
.permission
.Role
;
20 import eu
.etaxonomy
.taxeditor
.preference
.NameDetailsConfigurator
;
21 import eu
.etaxonomy
.taxeditor
.preference
.PreferencesUtil
;
22 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
23 import eu
.etaxonomy
.taxeditor
.ui
.combo
.term
.TermComboElement
;
24 import eu
.etaxonomy
.taxeditor
.ui
.element
.CdmFormFactory
;
25 import eu
.etaxonomy
.taxeditor
.ui
.element
.CheckboxElement
;
26 import eu
.etaxonomy
.taxeditor
.ui
.element
.ICdmFormElement
;
27 import eu
.etaxonomy
.taxeditor
.ui
.element
.TextWithLabelElement
;
28 import eu
.etaxonomy
.taxeditor
.ui
.section
.AbstractIdentifiableEntityDetailElement
;
29 import eu
.etaxonomy
.taxeditor
.ui
.selection
.EntitySelectionElement
;
33 * @created Feb 26, 2010
35 public class TaxonBaseDetailElement
extends AbstractIdentifiableEntityDetailElement
<TaxonBase
<?
>> {
37 private CheckboxElement checkbox_doubtful
;
39 private CheckboxElement checkbox_useNameCache
;
41 private EntitySelectionElement
<Reference
> selection_secundum
;
42 private TextWithLabelElement text_secundum_microreference
;
44 private TextWithLabelElement text_appendedPhrase
;
46 private CheckboxElement checkbox_published
;
48 private TermComboElement
<SynonymType
> combo_relationshipType
;
50 public TaxonBaseDetailElement(CdmFormFactory cdmFormFactory
,
51 ICdmFormElement formElement
, int style
) {
52 super(cdmFormFactory
, formElement
);
56 protected void createControls(ICdmFormElement formElement
, TaxonBase
<?
> entity
, int style
) {
58 NameDetailsConfigurator config
= PreferencesUtil
.getPreferredNameDetailsConfiguration();
59 toggleable_cache
= formFactory
.createToggleableTextField(formElement
,
60 "Title Cache", entity
.getTitleCache(),
61 entity
.isProtectedTitleCache(), style
);
63 text_appendedPhrase
= formFactory
.createTextWithLabelElement(
64 formElement
, "Appended Phrase", entity
.getAppendedPhrase(),
67 selection_secundum
= formFactory
.createSelectionElement(Reference
.class,
68 formElement
, "Secundum",
69 entity
.getSec(), EntitySelectionElement
.ALL
,
71 if (config
!= null && !config
.isSecEnabled()){
72 selection_secundum
.setEnabled(false);
74 if (config
!= null && config
.isSecDetailsActivated()){
75 text_secundum_microreference
= formFactory
.createTextWithLabelElement(
76 formElement
, "Detail",
77 entity
.getSecMicroReference(),null,
81 checkbox_useNameCache
= formFactory
.createCheckbox(formElement
,
82 "Exclude Authorship", entity
.isUseNameCache(), style
);
83 checkbox_doubtful
= formFactory
.createCheckbox(formElement
,
84 entity
.getClass().getSimpleName() + " is doubtful", entity
.isDoubtful(), style
);
87 checkbox_published
= formFactory
.createCheckbox(formElement
,
88 entity
.getClass().getSimpleName()+" is published", entity
.isPublish(), style
);
90 if(entity
instanceof Synonym
){
91 //#6198 removed type as it is currently not handled correctly in the editor
92 // combo_relationshipType = formFactory.createDefinedTermComboElement(TermType.SynonymType, formElement, "Synonym Type", ((Synonym) entity).getType(), style);
96 registerCacheRelevance(checkbox_doubtful
);
97 registerCacheRelevance(checkbox_useNameCache
);
98 registerCacheRelevance(selection_secundum
);
99 registerCacheRelevance(text_secundum_microreference
);
100 registerCacheRelevance(text_appendedPhrase
);
101 registerCacheRelevance(combo_relationshipType
);
104 private void updateCheckboxPublish() {
105 if(getEntity() instanceof Taxon
){
106 checkbox_published
.setEnabled(
107 CdmStore
.currentAuthentiationHasOneOfRoles(Role
.ROLE_PUBLISH
, Role
.ROLE_ADMIN
)
113 protected void updateControlStates() {
114 super.updateControlStates();
115 updateCheckboxPublish();
119 protected void updateContent() {
120 super.updateContent();
121 toggleable_cache
.setEnabled(getEntity().isProtectedTitleCache());
122 updateCacheRelevance();
126 protected void handleTitleCacheRelevantChange(PropertyChangeEvent event
) {
127 String title
= getEntity().generateTitle();
128 getEntity().setTitleCache(title
);
129 super.handleTitleCacheRelevantChange(event
);
133 public void handleEvent(Object eventSource
) {
134 if (eventSource
== toggleable_cache
) {
135 handleToggleableCacheField();
136 } else if (eventSource
== checkbox_doubtful
) {
137 getEntity().setDoubtful(checkbox_doubtful
.getSelection());
138 } else if (eventSource
== checkbox_useNameCache
) {
139 getEntity().setUseNameCache(checkbox_useNameCache
.getSelection());
140 } else if (eventSource
== selection_secundum
) {
141 getEntity().setSec(selection_secundum
.getSelection());
142 } else if (eventSource
== text_appendedPhrase
) {
143 getEntity().setAppendedPhrase(text_appendedPhrase
.getText());
144 } else if (eventSource
== text_secundum_microreference
) {
145 getEntity().setSecMicroReference(text_secundum_microreference
.getText());
146 } else if (eventSource
== checkbox_published
) {
147 getEntity().setPublish(checkbox_published
.getSelection());
148 } else if(eventSource
== combo_relationshipType
){
149 ((Synonym
) getEntity()).setType(combo_relationshipType
.getSelection());
150 //#7334/5 removed pro parte and partial as they are handled as concept relationships now
151 // } else if(eventSource == checkPartial){
152 // ((Synonym) getEntity()).setPartial(checkPartial.getSelection());
153 // } else if(eventSource == checkProParte){
154 // ((Synonym) getEntity()).setProParte(checkProParte.getSelection());
159 protected void handleToggleableCacheField() {
160 getEntity().setTitleCache(toggleable_cache
.getText(), toggleable_cache
.getState());
161 updateCacheRelevance();
162 updateToggleableCacheField();