3 * Copyright (C) 2007 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
7 * The contents of this file are subject to the Mozilla Public License Version 1.1
8 * See LICENSE.TXT at the top of this package for the full license terms.
11 package eu
.etaxonomy
.taxeditor
.ui
.section
.name
;
13 import java
.util
.Arrays
;
15 import eu
.etaxonomy
.cdm
.model
.name
.NonViralName
;
16 import eu
.etaxonomy
.taxeditor
.model
.AuthorHelper
;
17 import eu
.etaxonomy
.taxeditor
.ui
.element
.CdmFormFactory
;
18 import eu
.etaxonomy
.taxeditor
.ui
.element
.CdmPropertyChangeEvent
;
19 import eu
.etaxonomy
.taxeditor
.ui
.element
.ICdmFormElement
;
20 import eu
.etaxonomy
.taxeditor
.ui
.element
.IEnableableFormElement
;
21 import eu
.etaxonomy
.taxeditor
.ui
.section
.AbstractIdentifiableEntityDetailElement
;
22 import eu
.etaxonomy
.taxeditor
.ui
.selection
.EntitySelectionElement
;
23 import eu
.etaxonomy
.taxeditor
.ui
.selection
.NomenclaturalAuthorTeamSelectionElement
;
24 import eu
.etaxonomy
.taxeditor
.preference
.IPreferenceKeys
;
25 import eu
.etaxonomy
.taxeditor
.preference
.PreferencesUtil
;
29 * AuthorshipDetailElement class.
33 * @created Mar 4, 2010
36 public class AuthorshipDetailElement
extends
37 AbstractIdentifiableEntityDetailElement
<NonViralName
> implements
38 IEnableableFormElement
{
40 private NomenclaturalAuthorTeamSelectionElement selection_exBasionymAuthorTeam
;
41 private NomenclaturalAuthorTeamSelectionElement selection_basionymAuthorTeam
;
42 private NomenclaturalAuthorTeamSelectionElement selection_exCombinationAuthorTeam
;
43 private NomenclaturalAuthorTeamSelectionElement selection_combinationAuthorTeam
;
47 * Constructor for AuthorshipDetailElement.
50 * @param cdmFormFactory
51 * a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory}
54 * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
59 public AuthorshipDetailElement(CdmFormFactory cdmFormFactory
,
60 ICdmFormElement formElement
, int style
) {
61 super(cdmFormFactory
, formElement
);
66 protected void createControls(ICdmFormElement formElement
,
67 NonViralName entity
, int style
) {
68 toggleable_cache
= formFactory
.createToggleableTextField(this,
69 "Authorship Cache", entity
.getAuthorshipCache(),
70 entity
.isProtectedAuthorshipCache(), style
);
73 if(PreferencesUtil
.getPreferenceStore().getBoolean(IPreferenceKeys
.IS_RL
)){
74 toggleable_cache
.setVisible(false);
76 selection_combinationAuthorTeam
= formFactory
.createNomenclaturalAuthorTeamSelectionElement(
77 getConversationHolder(),
78 formElement
, "Author",
79 AuthorHelper
.getAuthor(entity
.getCombinationAuthorTeam()),
80 EntitySelectionElement
.ALL
, style
);
81 addElement(selection_combinationAuthorTeam
);
82 selection_exCombinationAuthorTeam
= formFactory
.createNomenclaturalAuthorTeamSelectionElement(
83 getConversationHolder(),
84 formElement
, "Ex Author",
85 AuthorHelper
.getAuthor(entity
.getExCombinationAuthorTeam()),
86 EntitySelectionElement
.ALL
, style
);
87 addElement(selection_exCombinationAuthorTeam
);
88 selection_basionymAuthorTeam
= formFactory
.createNomenclaturalAuthorTeamSelectionElement(
89 getConversationHolder(),
90 formElement
, "Basionym Author",
91 AuthorHelper
.getAuthor(entity
.getBasionymAuthorTeam()),
92 EntitySelectionElement
.ALL
, style
);
93 addElement(selection_basionymAuthorTeam
);
94 selection_exBasionymAuthorTeam
= formFactory
.createNomenclaturalAuthorTeamSelectionElement(
95 getConversationHolder(),
96 formElement
, "Ex Basionym Author",
97 AuthorHelper
.getAuthor(entity
.getExBasionymAuthorTeam()),
98 EntitySelectionElement
.ALL
, style
);
99 addElement(selection_exBasionymAuthorTeam
);
104 public void updateContent() {
105 if (getEntity() == null) {
106 setEntity(NonViralName
.NewInstance(null));
109 super.updateContent();
110 toggleable_cache
.setEnabled(getEntity().isProtectedAuthorshipCache());
112 if (this.isIrrelevant()) {
113 setIrrelevant(isIrrelevant());
115 setIrrelevant(toggleable_cache
.getState(),
116 Arrays
.asList(new Object
[] { toggleable_cache
}));
122 public void handleEvent(Object eventSource
) {
123 if (eventSource
== toggleable_cache
) {
124 getEntity().setAuthorshipCache(toggleable_cache
.getText(),
125 toggleable_cache
.getState());
126 if (!isIrrelevant()){
127 setIrrelevant(toggleable_cache
.getState(),
128 Arrays
.asList(new Object
[] { toggleable_cache
}));
130 } else if (eventSource
== selection_combinationAuthorTeam
) {
131 getEntity().setCombinationAuthorTeam(
132 selection_combinationAuthorTeam
.getSelection());
133 } else if (eventSource
== selection_exCombinationAuthorTeam
) {
134 getEntity().setExCombinationAuthorTeam(
135 selection_exCombinationAuthorTeam
.getSelection());
136 } else if (eventSource
== selection_basionymAuthorTeam
) {
137 getEntity().setBasionymAuthorTeam(
138 selection_basionymAuthorTeam
.getSelection());
139 } else if (eventSource
== selection_exBasionymAuthorTeam
) {
140 getEntity().setExBasionymAuthorTeam(
141 selection_exBasionymAuthorTeam
.getSelection());
144 // if (eventSource != toggleable_cache) {
145 // toggleable_cache.setText(getEntity().getAuthorshipCache());
148 // we have to notify the parent if this is embedded in the nonviral name
150 // maybe we can handle this a little bit more elegant
151 // if (getParentElement() instanceof AbstractCdmDetailSection)
152 firePropertyChangeEvent(new CdmPropertyChangeEvent(
153 getParentElement(), null));
157 public void updateToggleableCacheField() {
158 if(! getEntity().isProtectedAuthorshipCache()){
159 toggleable_cache
.setText(getEntity().getAuthorshipCache());