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
.agent
.INomenclaturalAuthor
;
16 import eu
.etaxonomy
.cdm
.model
.name
.NonViralName
;
17 import eu
.etaxonomy
.taxeditor
.model
.AuthorHelper
;
18 import eu
.etaxonomy
.taxeditor
.ui
.campanula
.compatibility
.ICdmFormElement
;
19 import eu
.etaxonomy
.taxeditor
.ui
.element
.CdmFormFactory
;
20 import eu
.etaxonomy
.taxeditor
.ui
.element
.CdmPropertyChangeEvent
;
21 import eu
.etaxonomy
.taxeditor
.ui
.element
.IEnableableFormElement
;
22 import eu
.etaxonomy
.taxeditor
.ui
.section
.AbstractIdentifiableEntityDetailElement
;
23 import eu
.etaxonomy
.taxeditor
.ui
.selection
.EntitySelectionElement
;
24 import eu
.etaxonomy
.taxeditor
.ui
.selection
.NomenclaturalAuthorTeamSelectionElement
;
28 * AuthorshipDetailElement class.
32 * @created Mar 4, 2010
35 public class AuthorshipDetailElement
extends
36 AbstractIdentifiableEntityDetailElement
<NonViralName
> implements
37 IEnableableFormElement
{
39 private NomenclaturalAuthorTeamSelectionElement selection_exBasionymAuthorTeam
;
40 private NomenclaturalAuthorTeamSelectionElement selection_basionymAuthorTeam
;
41 private NomenclaturalAuthorTeamSelectionElement selection_exCombinationAuthorTeam
;
42 private NomenclaturalAuthorTeamSelectionElement selection_combinationAuthorTeam
;
46 * Constructor for AuthorshipDetailElement.
49 * @param cdmFormFactory
50 * a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory}
53 * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
58 public AuthorshipDetailElement(CdmFormFactory cdmFormFactory
,
59 ICdmFormElement formElement
, int style
) {
60 super(cdmFormFactory
, formElement
);
65 protected void createControls(ICdmFormElement formElement
,
66 NonViralName entity
, int style
) {
67 toggleable_cache
= formFactory
.createToggleableTextField(this,
68 "Authorship Cache", entity
.getAuthorshipCache(),
69 entity
.isProtectedAuthorshipCache(), style
);
70 selection_combinationAuthorTeam
= formFactory
.createNomenclaturalAuthorTeamSelectionElement(
71 getConversationHolder(),
72 formElement
, "Author",
73 AuthorHelper
.getAuthor(entity
.getCombinationAuthorTeam()),
74 EntitySelectionElement
.ALL
, style
);
75 addElement(selection_combinationAuthorTeam
);
76 selection_exCombinationAuthorTeam
= formFactory
.createNomenclaturalAuthorTeamSelectionElement(
77 getConversationHolder(),
78 formElement
, "Ex Author",
79 AuthorHelper
.getAuthor(entity
.getExCombinationAuthorTeam()),
80 EntitySelectionElement
.ALL
, style
);
81 addElement(selection_exCombinationAuthorTeam
);
82 selection_basionymAuthorTeam
= formFactory
.createNomenclaturalAuthorTeamSelectionElement(
83 getConversationHolder(),
84 formElement
, "Basionym Author",
85 AuthorHelper
.getAuthor(entity
.getBasionymAuthorTeam()),
86 EntitySelectionElement
.ALL
, style
);
87 addElement(selection_basionymAuthorTeam
);
88 selection_exBasionymAuthorTeam
= formFactory
.createNomenclaturalAuthorTeamSelectionElement(
89 getConversationHolder(),
90 formElement
, "Ex Basionym Author",
91 AuthorHelper
.getAuthor(entity
.getExBasionymAuthorTeam()),
92 EntitySelectionElement
.ALL
, style
);
93 addElement(selection_exBasionymAuthorTeam
);
98 public void updateContent() {
99 if (getEntity() == null) {
100 setEntity(NonViralName
.NewInstance(null));
103 super.updateContent();
104 toggleable_cache
.setEnabled(getEntity().isProtectedAuthorshipCache());
106 if (this.isIrrelevant()) {
107 setIrrelevant(isIrrelevant());
109 setIrrelevant(toggleable_cache
.getState(),
110 Arrays
.asList(new Object
[] { toggleable_cache
}));
116 public void handleEvent(Object eventSource
) {
117 if (eventSource
== toggleable_cache
) {
118 getEntity().setAuthorshipCache(toggleable_cache
.getText(),
119 toggleable_cache
.getState());
121 setIrrelevant(toggleable_cache
.getState(),
122 Arrays
.asList(new Object
[] { toggleable_cache
}));
123 } else if (eventSource
== selection_combinationAuthorTeam
) {
124 getEntity().setCombinationAuthorTeam(
125 (INomenclaturalAuthor
) selection_combinationAuthorTeam
127 } else if (eventSource
== selection_exCombinationAuthorTeam
) {
128 getEntity().setExCombinationAuthorTeam(
129 (INomenclaturalAuthor
) selection_exCombinationAuthorTeam
131 } else if (eventSource
== selection_basionymAuthorTeam
) {
132 getEntity().setBasionymAuthorTeam(
133 (INomenclaturalAuthor
) selection_basionymAuthorTeam
135 } else if (eventSource
== selection_exBasionymAuthorTeam
) {
136 getEntity().setExBasionymAuthorTeam(
137 (INomenclaturalAuthor
) selection_exBasionymAuthorTeam
141 // if (eventSource != toggleable_cache) {
142 // toggleable_cache.setText(getEntity().getAuthorshipCache());
145 // we have to notify the parent if this is embedded in the nonviral name
147 // maybe we can handle this a little bit more elegant
148 // if (getParentElement() instanceof AbstractCdmDetailSection)
149 firePropertyChangeEvent(new CdmPropertyChangeEvent(
150 getParentElement(), null));
154 public void updateToggleableCacheField() {
155 if(! getEntity().isProtectedAuthorshipCache()){
156 toggleable_cache
.setText(getEntity().getAuthorshipCache());