49 |
49 |
import eu.etaxonomy.taxeditor.ui.selection.TaxonNodeSelectionElement;
|
50 |
50 |
|
51 |
51 |
/**
|
52 |
|
*
|
53 |
52 |
* @author n.hoffmann
|
54 |
53 |
* @created Sep 27, 2010
|
55 |
|
* @version 1.0
|
56 |
54 |
*/
|
57 |
55 |
public class TaxonNodeDetailElement extends AbstractCdmDetailElement<TaxonNode> {
|
58 |
56 |
|
... | ... | |
60 |
58 |
private Classification classification;
|
61 |
59 |
private TaxonNode parentNode;
|
62 |
60 |
private Taxon taxon;
|
|
61 |
private boolean complete;
|
|
62 |
private TaxonNodeStatus status = null;
|
|
63 |
private Map<Language, LanguageString> multilanguageTextCache;
|
63 |
64 |
|
64 |
65 |
private TaxonNodeSelectionElement selection_parentTaxonNode;
|
65 |
66 |
private EntitySelectionElement<Taxon> selection_reuseExistingTaxon;
|
66 |
67 |
private EntitySelectionElement<TaxonName> selection_reuseExistingName;
|
67 |
|
|
68 |
68 |
private EntitySelectionElement<Reference> selection_SecRef;
|
69 |
69 |
private EntitySelectionElement<Reference> selection_Ref;
|
70 |
|
|
71 |
|
|
72 |
|
TextWithLabelElement textTaxonSec;
|
73 |
|
|
|
70 |
private TextWithLabelElement textTaxonSec;
|
74 |
71 |
private TextWithLabelElement microReference;
|
75 |
|
|
76 |
|
|
77 |
72 |
private TextWithLabelElement textNewTaxonName;
|
78 |
|
|
79 |
73 |
private TaxonNodeAgentRelationCollectionSection selectionNodeAgentRelation;
|
80 |
|
|
81 |
|
private EnumComboElement combo_status;
|
82 |
|
// private CheckboxElement checkbox_excluded;
|
|
74 |
private EnumComboElement<TaxonNodeStatus> combo_status;
|
83 |
75 |
private CheckboxElement checkbox_publish;
|
84 |
|
// private CheckboxElement checkbox_placementDoubtful;
|
85 |
|
|
86 |
76 |
private MultilanguageTextElement multiLanguageTextStatusNotes;
|
87 |
|
private Map<Language, LanguageString> multilanguageTextCache;
|
88 |
|
|
89 |
|
|
90 |
|
private boolean complete;
|
91 |
|
|
92 |
|
private TaxonNodeStatus status = null;
|
93 |
77 |
|
94 |
78 |
public TaxonNodeDetailElement(CdmFormFactory formFactory,
|
95 |
79 |
ICdmFormElement formElement, boolean isCreateNew) {
|
... | ... | |
97 |
81 |
createNew = isCreateNew;
|
98 |
82 |
}
|
99 |
83 |
|
100 |
|
|
101 |
84 |
public Map<Language, LanguageString> getMultiLanguageTextExcludedNotes() {
|
102 |
85 |
return multiLanguageTextStatusNotes.getMultilanguageText();
|
103 |
86 |
}
|
104 |
87 |
|
105 |
|
|
106 |
|
|
107 |
88 |
public boolean isExcluded() {
|
108 |
|
if (status == null){
|
109 |
|
return false;
|
110 |
|
}
|
111 |
|
return status.equals(TaxonNodeStatus.EXCLUDED);
|
|
89 |
return status == null? false : status.equals(TaxonNodeStatus.EXCLUDED);
|
112 |
90 |
}
|
113 |
91 |
|
114 |
|
|
115 |
|
|
116 |
92 |
public boolean isUnplaced() {
|
117 |
|
if (status == null){
|
118 |
|
return false;
|
119 |
|
}
|
120 |
|
return status.equals(TaxonNodeStatus.UNPLACED);
|
|
93 |
return status == null? false : status.equals(TaxonNodeStatus.UNPLACED);
|
121 |
94 |
}
|
122 |
95 |
|
123 |
|
|
124 |
|
|
125 |
96 |
public boolean isPlacementDoubtful() {
|
126 |
|
if (status == null){
|
127 |
|
return false;
|
128 |
|
}
|
129 |
|
return status.equals(TaxonNodeStatus.DOUBTFUL);
|
|
97 |
return status == null? false : status.equals(TaxonNodeStatus.DOUBTFUL);
|
130 |
98 |
}
|
131 |
99 |
|
132 |
100 |
public Reference getRef() {
|
... | ... | |
139 |
107 |
return microReference.getText();
|
140 |
108 |
}
|
141 |
109 |
|
142 |
|
/** {@inheritDoc} */
|
143 |
110 |
@Override
|
144 |
111 |
protected void createControls(ICdmFormElement formElement,
|
145 |
112 |
TaxonNode entity, int style) {
|
... | ... | |
180 |
147 |
textNewTaxonName.setFocus();
|
181 |
148 |
} else{
|
182 |
149 |
textNewTaxonName = formFactory.createTextWithLabelElement(formElement,"Taxon", "", style);
|
183 |
|
|
184 |
150 |
}
|
185 |
151 |
}else{
|
186 |
152 |
taxon = getEntity().getTaxon();
|
... | ... | |
208 |
174 |
textTaxonSec.setText(taxon.getSec().getTitleCache());
|
209 |
175 |
}
|
210 |
176 |
textTaxonSec.setEnabled(false);
|
211 |
|
|
212 |
|
|
213 |
|
|
214 |
177 |
}
|
215 |
178 |
|
216 |
|
|
217 |
179 |
if (!isCreateNew()){
|
218 |
180 |
if (entity.getReference() != null){
|
219 |
181 |
selection_Ref.setEntity(entity.getReference());
|
220 |
182 |
}
|
221 |
|
|
222 |
183 |
}
|
223 |
184 |
|
224 |
|
|
225 |
185 |
Taxon tax = null;
|
226 |
186 |
if (entity.getTaxon() != null){
|
227 |
187 |
tax = entity.getTaxon();
|
... | ... | |
229 |
189 |
checkbox_publish = formFactory.createCheckbox(formElement,
|
230 |
190 |
"Taxon is published", tax != null? tax.isPublish(): true, style);
|
231 |
191 |
|
232 |
|
|
233 |
192 |
checkbox_publish.setEnabled(isCreateNew());
|
234 |
193 |
|
235 |
194 |
combo_status = formFactory.createEnumComboElement(TaxonNodeStatus.class, formElement, style, true);
|
... | ... | |
239 |
198 |
|
240 |
199 |
if(isCreateNew()){
|
241 |
200 |
|
242 |
|
|
243 |
201 |
String defaultPublish = PreferencesUtil.getStringValue(PreferencePredicate.DefaultBehaviourForPublishFlag.getKey());
|
244 |
202 |
if (defaultPublish != null && defaultPublish.equals(PublishEnum.Publish.getKey())){
|
245 |
203 |
checkbox_publish.setSelection(true);
|
... | ... | |
252 |
210 |
checkbox_publish.setSelection(true);
|
253 |
211 |
}
|
254 |
212 |
}
|
255 |
|
|
256 |
213 |
} else{
|
257 |
214 |
setTreeNode(entity);
|
258 |
215 |
complete = true;
|
259 |
216 |
}
|
260 |
217 |
|
261 |
|
|
262 |
218 |
if (isCreateNew()){
|
263 |
219 |
preFillTaxonName();
|
264 |
220 |
}
|
265 |
221 |
|
266 |
|
|
267 |
222 |
multiLanguageTextStatusNotes = formFactory.createMultiLanguageTextElement(formElement, "Status Notes", null, 50, style);
|
268 |
223 |
if (!isCreateNew()){
|
269 |
224 |
multiLanguageTextStatusNotes.setMultilanguageText(entity.getStatusNote());
|
270 |
225 |
multiLanguageTextStatusNotes.setEnabled(entity.getStatus() != null);
|
271 |
226 |
}
|
272 |
227 |
|
273 |
|
|
274 |
228 |
if (!isCreateNew()){
|
275 |
229 |
selectionNodeAgentRelation = formFactory.createTaxonNodeAgentRelationCollectionSection(formElement, getConversationHolder(), StoreUtil.getSectionStyle(TaxonNodeAgentRelationCollectionSection.class, entity.getClass().getCanonicalName()));
|
276 |
230 |
selectionNodeAgentRelation.setEntity(entity);
|
277 |
231 |
selectionNodeAgentRelation.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
|
278 |
232 |
}
|
279 |
|
|
280 |
233 |
}
|
281 |
234 |
|
282 |
235 |
private void preFillTaxonName() {
|
... | ... | |
305 |
258 |
}
|
306 |
259 |
}
|
307 |
260 |
}
|
308 |
|
|
309 |
261 |
}
|
310 |
262 |
|
311 |
|
/** {@inheritDoc} */
|
312 |
263 |
@Override
|
313 |
264 |
public void handleEvent(Object eventSource) {
|
314 |
265 |
if (eventSource == selection_parentTaxonNode) {
|
... | ... | |
368 |
319 |
}
|
369 |
320 |
|
370 |
321 |
if (eventSource == combo_status) {
|
371 |
|
status = (TaxonNodeStatus) combo_status.getSelection();
|
|
322 |
status = combo_status.getSelection();
|
372 |
323 |
if (status == null){
|
373 |
324 |
if (multiLanguageTextStatusNotes.getMultilanguageText() != null && !multiLanguageTextStatusNotes.getMultilanguageText().isEmpty()){
|
374 |
325 |
multilanguageTextCache = new HashMap<>();
|
... | ... | |
400 |
351 |
}
|
401 |
352 |
}
|
402 |
353 |
|
403 |
|
|
404 |
354 |
multiLanguageTextStatusNotes.setEnabled(status != null);
|
405 |
355 |
|
406 |
356 |
complete = true;
|
... | ... | |
429 |
379 |
return classification;
|
430 |
380 |
}
|
431 |
381 |
|
432 |
|
|
433 |
|
|
434 |
382 |
public TaxonNode getParentTreeNode() {
|
435 |
383 |
return parentNode;
|
436 |
384 |
}
|
... | ... | |
453 |
401 |
selection_parentTaxonNode.setClassification(classification);
|
454 |
402 |
selection_SecRef.setEntity(parentTreeNode.getTaxon().getSec());
|
455 |
403 |
}
|
456 |
|
|
457 |
|
|
458 |
404 |
}
|
459 |
405 |
}
|
|
406 |
|
460 |
407 |
@Override
|
461 |
408 |
protected void updateControlStates(){
|
462 |
409 |
Collection<Object> except = new ArrayList<Object>();
|
... | ... | |
499 |
446 |
this.textTaxonSec.setText(taxon.getSec().getTitleCache());
|
500 |
447 |
}
|
501 |
448 |
}
|
502 |
|
|
503 |
|
|
504 |
449 |
}
|
505 |
450 |
|
506 |
451 |
private void setTaxon(TaxonName taxonName) {
|
... | ... | |
580 |
525 |
}
|
581 |
526 |
updateControlStates();
|
582 |
527 |
}
|
583 |
|
|
584 |
|
|
585 |
528 |
}
|
cleanup