1 |
729887cf
|
n.hoffmann
|
/**
|
2 |
f561b00c
|
n.hoffmann
|
* Copyright (C) 2007 EDIT
|
3 |
040d6554
|
Patric Plitzner
|
* European Distributed Institute of Taxonomy
|
4 |
f561b00c
|
n.hoffmann
|
* http://www.e-taxonomy.eu
|
5 |
040d6554
|
Patric Plitzner
|
*
|
6 |
f561b00c
|
n.hoffmann
|
* 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.
|
8 |
|
|
*/
|
9 |
729887cf
|
n.hoffmann
|
|
10 |
f211dd28
|
n.hoffmann
|
package eu.etaxonomy.taxeditor.ui.section.name;
|
11 |
729887cf
|
n.hoffmann
|
|
12 |
|
|
import java.util.Arrays;
|
13 |
|
|
|
14 |
040d6554
|
Patric Plitzner
|
import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase;
|
15 |
e3a4a3ff
|
Andreas Müller
|
import eu.etaxonomy.cdm.model.name.INonViralName;
|
16 |
|
|
import eu.etaxonomy.cdm.model.name.IZoologicalName;
|
17 |
d1adff8f
|
Katja Luther
|
import eu.etaxonomy.cdm.model.name.NomenclaturalCode;
|
18 |
|
|
import eu.etaxonomy.cdm.model.name.TaxonNameFactory;
|
19 |
17d882ef
|
Katja Luther
|
import eu.etaxonomy.taxeditor.event.EventUtility;
|
20 |
|
|
import eu.etaxonomy.taxeditor.event.WorkbenchEventConstants;
|
21 |
040d6554
|
Patric Plitzner
|
import eu.etaxonomy.taxeditor.preference.IPreferenceKeys;
|
22 |
|
|
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
|
23 |
78222507
|
n.hoffmann
|
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
|
24 |
|
|
import eu.etaxonomy.taxeditor.ui.element.CdmPropertyChangeEvent;
|
25 |
dacb59c9
|
Patric Plitzner
|
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
|
26 |
32e6766e
|
Katja Luther
|
import eu.etaxonomy.taxeditor.ui.element.NumberWithLabelElement;
|
27 |
89f83939
|
n.hoffmann
|
import eu.etaxonomy.taxeditor.ui.section.AbstractIdentifiableEntityDetailElement;
|
28 |
23783f7a
|
n.hoffmann
|
import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElement;
|
29 |
729887cf
|
n.hoffmann
|
|
30 |
|
|
/**
|
31 |
f561b00c
|
n.hoffmann
|
* <p>
|
32 |
|
|
* AuthorshipDetailElement class.
|
33 |
|
|
* </p>
|
34 |
040d6554
|
Patric Plitzner
|
*
|
35 |
729887cf
|
n.hoffmann
|
* @author n.hoffmann
|
36 |
|
|
* @created Mar 4, 2010
|
37 |
|
|
* @version 1.0
|
38 |
|
|
*/
|
39 |
f561b00c
|
n.hoffmann
|
public class AuthorshipDetailElement extends
|
40 |
e3a4a3ff
|
Andreas Müller
|
AbstractIdentifiableEntityDetailElement<INonViralName> {
|
41 |
f561b00c
|
n.hoffmann
|
|
42 |
040d6554
|
Patric Plitzner
|
private EntitySelectionElement<TeamOrPersonBase> selectionExBasionymAuthor;
|
43 |
|
|
private EntitySelectionElement<TeamOrPersonBase> selectionBasionymAuthor;
|
44 |
|
|
private EntitySelectionElement<TeamOrPersonBase> selectionExCombinationAuthor;
|
45 |
|
|
private EntitySelectionElement<TeamOrPersonBase> selectionCombinationAuthor;
|
46 |
32e6766e
|
Katja Luther
|
|
47 |
|
|
private NumberWithLabelElement text_publicationYear;
|
48 |
|
|
private NumberWithLabelElement text_originalPublicationYear;
|
49 |
3be6ef3e
|
n.hoffmann
|
/**
|
50 |
f561b00c
|
n.hoffmann
|
* <p>
|
51 |
|
|
* Constructor for AuthorshipDetailElement.
|
52 |
|
|
* </p>
|
53 |
040d6554
|
Patric Plitzner
|
*
|
54 |
f561b00c
|
n.hoffmann
|
* @param cdmFormFactory
|
55 |
78222507
|
n.hoffmann
|
* a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory}
|
56 |
f561b00c
|
n.hoffmann
|
* object.
|
57 |
|
|
* @param formElement
|
58 |
78222507
|
n.hoffmann
|
* a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
|
59 |
f561b00c
|
n.hoffmann
|
* object.
|
60 |
|
|
* @param style
|
61 |
|
|
* a int.
|
62 |
3be6ef3e
|
n.hoffmann
|
*/
|
63 |
729887cf
|
n.hoffmann
|
public AuthorshipDetailElement(CdmFormFactory cdmFormFactory,
|
64 |
|
|
ICdmFormElement formElement, int style) {
|
65 |
|
|
super(cdmFormFactory, formElement);
|
66 |
|
|
}
|
67 |
f561b00c
|
n.hoffmann
|
|
68 |
3be6ef3e
|
n.hoffmann
|
/** {@inheritDoc} */
|
69 |
729887cf
|
n.hoffmann
|
@Override
|
70 |
f561b00c
|
n.hoffmann
|
protected void createControls(ICdmFormElement formElement,
|
71 |
e3a4a3ff
|
Andreas Müller
|
INonViralName entity, int style) {
|
72 |
69e82edd
|
Katja Luther
|
if (isAdvancedView || PreferencesUtil.getBooleanValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_AUTHORSHIP_CACHE)){
|
73 |
1bfcc747
|
Katja Luther
|
toggleable_cache = formFactory.createToggleableTextField(this,
|
74 |
f561b00c
|
n.hoffmann
|
"Authorship Cache", entity.getAuthorshipCache(),
|
75 |
|
|
entity.isProtectedAuthorshipCache(), style);
|
76 |
cd19940f
|
Katja Luther
|
addElement(toggleable_cache);
|
77 |
|
|
}
|
78 |
32e6766e
|
Katja Luther
|
NomenclaturalCode code = entity.getNomenclaturalCode();
|
79 |
040d6554
|
Patric Plitzner
|
|
80 |
69e82edd
|
Katja Luther
|
if (isAdvancedView || PreferencesUtil.getBooleanValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_AUTHORSHIP)){
|
81 |
fa39cfe4
|
Katja Luther
|
selectionCombinationAuthor = formFactory.createSelectionElementWithAbbreviatedTitle(TeamOrPersonBase.class,
|
82 |
|
|
getConversationHolder(),
|
83 |
|
|
formElement, "Author",
|
84 |
|
|
entity.getCombinationAuthorship(),
|
85 |
4c154cfa
|
Katja Luther
|
EntitySelectionElement.DELETABLE | EntitySelectionElement.SELECTABLE | EntitySelectionElement.EDITABLE, style);
|
86 |
fa39cfe4
|
Katja Luther
|
addElement(selectionCombinationAuthor);
|
87 |
|
|
selectionExCombinationAuthor = formFactory.createSelectionElementWithAbbreviatedTitle(TeamOrPersonBase.class,
|
88 |
|
|
getConversationHolder(),
|
89 |
|
|
formElement, "Ex Author",
|
90 |
|
|
entity.getExCombinationAuthorship(),
|
91 |
4c154cfa
|
Katja Luther
|
EntitySelectionElement.DELETABLE | EntitySelectionElement.SELECTABLE | EntitySelectionElement.EDITABLE, style);
|
92 |
fa39cfe4
|
Katja Luther
|
addElement(selectionExCombinationAuthor);
|
93 |
|
|
if (code != null){
|
94 |
|
|
if (code.equals(NomenclaturalCode.ICZN)){
|
95 |
e3a4a3ff
|
Andreas Müller
|
text_publicationYear = formFactory.createNumberTextWithLabelElement(formElement, "Publication Year", ((IZoologicalName)entity).getPublicationYear(), style);
|
96 |
fa39cfe4
|
Katja Luther
|
|
97 |
|
|
}
|
98 |
|
|
}
|
99 |
|
|
selectionBasionymAuthor = formFactory.createSelectionElementWithAbbreviatedTitle(TeamOrPersonBase.class, getConversationHolder(),
|
100 |
|
|
formElement, "Basionym Author", entity.getBasionymAuthorship(),
|
101 |
4c154cfa
|
Katja Luther
|
EntitySelectionElement.DELETABLE | EntitySelectionElement.SELECTABLE | EntitySelectionElement.EDITABLE, style);
|
102 |
fa39cfe4
|
Katja Luther
|
addElement(selectionBasionymAuthor);
|
103 |
|
|
selectionExBasionymAuthor = formFactory.createSelectionElementWithAbbreviatedTitle(TeamOrPersonBase.class, getConversationHolder(),
|
104 |
|
|
formElement, "Ex Basionym Author",entity.getExBasionymAuthorship(),
|
105 |
4c154cfa
|
Katja Luther
|
EntitySelectionElement.DELETABLE | EntitySelectionElement.SELECTABLE | EntitySelectionElement.EDITABLE, style);
|
106 |
fa39cfe4
|
Katja Luther
|
|
107 |
|
|
addElement(selectionExBasionymAuthor);
|
108 |
|
|
if (code != null){
|
109 |
|
|
if (code.equals(NomenclaturalCode.ICZN)){
|
110 |
|
|
|
111 |
e3a4a3ff
|
Andreas Müller
|
text_originalPublicationYear = formFactory.createNumberTextWithLabelElement(formElement, "Orig. Publication Year", ((IZoologicalName)entity).getOriginalPublicationYear(), style);
|
112 |
fa39cfe4
|
Katja Luther
|
|
113 |
|
|
}
|
114 |
|
|
}
|
115 |
32e6766e
|
Katja Luther
|
|
116 |
fa39cfe4
|
Katja Luther
|
}
|
117 |
32e6766e
|
Katja Luther
|
|
118 |
729887cf
|
n.hoffmann
|
}
|
119 |
|
|
|
120 |
3be6ef3e
|
n.hoffmann
|
/** {@inheritDoc} */
|
121 |
729887cf
|
n.hoffmann
|
@Override
|
122 |
|
|
public void updateContent() {
|
123 |
f561b00c
|
n.hoffmann
|
if (getEntity() == null) {
|
124 |
e48774bc
|
Andreas Müller
|
setEntity(TaxonNameFactory.NewNonViralInstance(null));
|
125 |
729887cf
|
n.hoffmann
|
}
|
126 |
040d6554
|
Patric Plitzner
|
|
127 |
729887cf
|
n.hoffmann
|
super.updateContent();
|
128 |
1bfcc747
|
Katja Luther
|
if (toggleable_cache != null){
|
129 |
|
|
toggleable_cache.setEnabled(getEntity().isProtectedAuthorshipCache());
|
130 |
|
|
|
131 |
f561b00c
|
n.hoffmann
|
|
132 |
1bfcc747
|
Katja Luther
|
if (this.isIrrelevant()) {
|
133 |
|
|
setIrrelevant(isIrrelevant());
|
134 |
|
|
} else {
|
135 |
|
|
setIrrelevant(toggleable_cache.getState(),
|
136 |
|
|
Arrays.asList(new Object[] { toggleable_cache }));
|
137 |
|
|
}
|
138 |
729887cf
|
n.hoffmann
|
}
|
139 |
|
|
}
|
140 |
f561b00c
|
n.hoffmann
|
|
141 |
3be6ef3e
|
n.hoffmann
|
/** {@inheritDoc} */
|
142 |
729887cf
|
n.hoffmann
|
@Override
|
143 |
|
|
public void handleEvent(Object eventSource) {
|
144 |
f561b00c
|
n.hoffmann
|
if (eventSource == toggleable_cache) {
|
145 |
|
|
getEntity().setAuthorshipCache(toggleable_cache.getText(),
|
146 |
|
|
toggleable_cache.getState());
|
147 |
1c215f0d
|
Andreas Müller
|
if (!isIrrelevant()){
|
148 |
f561b00c
|
n.hoffmann
|
setIrrelevant(toggleable_cache.getState(),
|
149 |
|
|
Arrays.asList(new Object[] { toggleable_cache }));
|
150 |
1c215f0d
|
Andreas Müller
|
}
|
151 |
040d6554
|
Patric Plitzner
|
} else if (eventSource == selectionCombinationAuthor) {
|
152 |
6992befa
|
Andreas Müller
|
getEntity().setCombinationAuthorship(
|
153 |
040d6554
|
Patric Plitzner
|
selectionCombinationAuthor.getSelection());
|
154 |
|
|
} else if (eventSource == selectionExCombinationAuthor) {
|
155 |
6992befa
|
Andreas Müller
|
getEntity().setExCombinationAuthorship(
|
156 |
040d6554
|
Patric Plitzner
|
selectionExCombinationAuthor.getSelection());
|
157 |
|
|
} else if (eventSource == selectionBasionymAuthor) {
|
158 |
6992befa
|
Andreas Müller
|
getEntity().setBasionymAuthorship(
|
159 |
040d6554
|
Patric Plitzner
|
selectionBasionymAuthor.getSelection());
|
160 |
|
|
} else if (eventSource == selectionExBasionymAuthor) {
|
161 |
6992befa
|
Andreas Müller
|
getEntity().setExBasionymAuthorship(
|
162 |
040d6554
|
Patric Plitzner
|
selectionExBasionymAuthor.getSelection());
|
163 |
32e6766e
|
Katja Luther
|
} else if (eventSource == text_originalPublicationYear) {
|
164 |
e3a4a3ff
|
Andreas Müller
|
((IZoologicalName)getEntity()).setOriginalPublicationYear(text_originalPublicationYear.getInteger());
|
165 |
32e6766e
|
Katja Luther
|
} else if (eventSource == text_publicationYear) {
|
166 |
e3a4a3ff
|
Andreas Müller
|
((IZoologicalName)getEntity()).setPublicationYear(text_publicationYear.getInteger());
|
167 |
32e6766e
|
Katja Luther
|
}
|
168 |
f561b00c
|
n.hoffmann
|
|
169 |
89f83939
|
n.hoffmann
|
// if (eventSource != toggleable_cache) {
|
170 |
|
|
// toggleable_cache.setText(getEntity().getAuthorshipCache());
|
171 |
|
|
// }
|
172 |
f561b00c
|
n.hoffmann
|
|
173 |
89f83939
|
n.hoffmann
|
// we have to notify the parent if this is embedded in the nonviral name
|
174 |
|
|
// section
|
175 |
|
|
// maybe we can handle this a little bit more elegant
|
176 |
|
|
// if (getParentElement() instanceof AbstractCdmDetailSection)
|
177 |
f561b00c
|
n.hoffmann
|
firePropertyChangeEvent(new CdmPropertyChangeEvent(
|
178 |
|
|
getParentElement(), null));
|
179 |
48efbc43
|
Katja Luther
|
EventUtility.postEvent(WorkbenchEventConstants.REFRESH_NAME_EDITOR, this.getEntity());
|
180 |
729887cf
|
n.hoffmann
|
}
|
181 |
040d6554
|
Patric Plitzner
|
|
182 |
89f83939
|
n.hoffmann
|
@Override
|
183 |
|
|
public void updateToggleableCacheField() {
|
184 |
1bfcc747
|
Katja Luther
|
if (toggleable_cache != null){
|
185 |
|
|
if(! getEntity().isProtectedAuthorshipCache()){
|
186 |
|
|
toggleable_cache.setText(getEntity().getAuthorshipCache());
|
187 |
|
|
}
|
188 |
|
|
}
|
189 |
89f83939
|
n.hoffmann
|
}
|
190 |
729887cf
|
n.hoffmann
|
}
|