1
|
// $Id$
|
2
|
/**
|
3
|
* Copyright (C) 2013 EDIT
|
4
|
* European Distributed Institute of Taxonomy
|
5
|
* http://www.e-taxonomy.eu
|
6
|
*
|
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.
|
9
|
*/
|
10
|
package eu.etaxonomy.taxeditor.ui.campanula.detailViews.specimen;
|
11
|
|
12
|
import eu.etaxonomy.cdm.api.facade.DerivedUnitFacade;
|
13
|
import eu.etaxonomy.cdm.model.agent.AgentBase;
|
14
|
import eu.etaxonomy.cdm.model.common.LanguageString;
|
15
|
import eu.etaxonomy.cdm.model.location.NamedArea;
|
16
|
import eu.etaxonomy.cdm.model.occurrence.Collection;
|
17
|
import eu.etaxonomy.taxeditor.ui.campanula.basicFields.EntitySelectionFieldController;
|
18
|
import eu.etaxonomy.taxeditor.ui.campanula.basicFields.LanguageTextFieldController;
|
19
|
import eu.etaxonomy.taxeditor.ui.campanula.basicFields.NumberFieldController;
|
20
|
import eu.etaxonomy.taxeditor.ui.campanula.basicFields.PointFieldController;
|
21
|
import eu.etaxonomy.taxeditor.ui.campanula.basicFields.TextFieldController;
|
22
|
import eu.etaxonomy.taxeditor.ui.campanula.basicFields.ToggleableTextFieldController;
|
23
|
import eu.etaxonomy.taxeditor.ui.campanula.compatibility.ICdmFormElement;
|
24
|
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
|
25
|
import eu.etaxonomy.taxeditor.ui.element.TimePeriodElement;
|
26
|
import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement;
|
27
|
import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElement;
|
28
|
|
29
|
/**
|
30
|
* @author pplitzner
|
31
|
* @date 16.08.2013
|
32
|
*
|
33
|
*/
|
34
|
public class SpecimenGeneralElementController extends AbstractCdmDetailElement<DerivedUnitFacade> {
|
35
|
|
36
|
private SpecimenGeneralElement specimenGeneralElement;
|
37
|
|
38
|
private ToggleableTextFieldController toggleableText_titleCache;
|
39
|
private EntitySelectionFieldController<NamedArea> selection_country;
|
40
|
private LanguageTextFieldController languageText_locality;
|
41
|
private PointFieldController element_point;
|
42
|
private NumberFieldController number_elevation;
|
43
|
private TimePeriodElement element_date;//TODO convert
|
44
|
private EntitySelectionFieldController<AgentBase> selection_collector;
|
45
|
private TextFieldController text_collectingNumber;
|
46
|
private EntitySelectionFieldController<Collection> selectionCollection;
|
47
|
private TextFieldController textAccessionNumber;
|
48
|
|
49
|
/**
|
50
|
* @param fieldObservationGeneralElement
|
51
|
* @param formFactory
|
52
|
* @param formElement
|
53
|
*/
|
54
|
public SpecimenGeneralElementController(SpecimenGeneralElement specimenGeneralElement, CdmFormFactory formFactory, ICdmFormElement formElement) {
|
55
|
super(formFactory, formElement);
|
56
|
this.specimenGeneralElement = specimenGeneralElement;
|
57
|
setPropertyChangeListeners(formFactory.getPropertyChangeListeners());
|
58
|
formFactory.addPropertyChangeListener(this);
|
59
|
}
|
60
|
|
61
|
|
62
|
@Override
|
63
|
protected void createControls(ICdmFormElement formElement, DerivedUnitFacade entity, int style) {
|
64
|
toggleableText_titleCache = new ToggleableTextFieldController(specimenGeneralElement.getToggleableTextField(), getFormFactory(), formElement, entity.getTitleCache(), entity.isProtectedTitleCache(), style);
|
65
|
|
66
|
selection_country = new EntitySelectionFieldController<NamedArea>(specimenGeneralElement.getCountrySelectionField(), getFormFactory(), getConversationHolder(), formElement, NamedArea.class, entity.getCountry(), EntitySelectionElement.NOTHING);
|
67
|
languageText_locality = new LanguageTextFieldController(specimenGeneralElement.getTextLocality(), getFormFactory(), formElement, entity.getLocality());
|
68
|
element_point = new PointFieldController(specimenGeneralElement.getPointField(),getFormFactory(), formElement, entity.getExactLocation(), style);
|
69
|
number_elevation = new NumberFieldController(specimenGeneralElement.getTextElevation(), getFormFactory(), formElement, entity.getAbsoluteElevation());
|
70
|
// element_date = formFactory.createTimePeriodElement(formElement, "Date", entity.getGatheringPeriod(), style);
|
71
|
selection_collector = new EntitySelectionFieldController<AgentBase>(specimenGeneralElement.getCollectorSelectionField(), getFormFactory(), getConversationHolder(), formElement, AgentBase.class, entity.getCollector(), EntitySelectionElement.ALL);
|
72
|
text_collectingNumber = new TextFieldController(specimenGeneralElement.getTextCollectingNumber(), getFormFactory(), formElement, entity.getFieldNumber(), null);
|
73
|
selectionCollection = new EntitySelectionFieldController<Collection>(specimenGeneralElement.getCollectionSelectionField(), getFormFactory(), getConversationHolder(), formElement, Collection.class, entity.getCollection(), EntitySelectionElement.ALL);
|
74
|
textAccessionNumber = new TextFieldController(specimenGeneralElement.getTextAccessionNumber(), getFormFactory(), formElement, entity.getAccessionNumber(), null);
|
75
|
}
|
76
|
|
77
|
@Override
|
78
|
public void handleEvent(Object eventSource) {
|
79
|
if (eventSource == toggleableText_titleCache) {
|
80
|
getEntity().setTitleCache(toggleableText_titleCache.getText(), toggleableText_titleCache.getState());
|
81
|
} else if (eventSource == selection_country) {
|
82
|
getEntity().setCountry(selection_country.getSelection());
|
83
|
} else if (eventSource == languageText_locality) {
|
84
|
LanguageString locality = languageText_locality.getLanguageString();
|
85
|
getEntity().setLocality(locality);
|
86
|
} else if (eventSource == element_point) {
|
87
|
getEntity().setExactLocation(element_point.getPoint());
|
88
|
} else if (eventSource == number_elevation) {
|
89
|
getEntity().setAbsoluteElevation(number_elevation.getInteger());
|
90
|
} else if (eventSource == element_date) {
|
91
|
getEntity().setGatheringPeriod(element_date.getTimePeriod());
|
92
|
} else if (eventSource == selection_collector) {
|
93
|
getEntity().setCollector(selection_collector.getSelection());
|
94
|
} else if (eventSource == text_collectingNumber) {
|
95
|
getEntity().setFieldNumber(text_collectingNumber.getText());
|
96
|
}
|
97
|
else if (eventSource == selectionCollection) {
|
98
|
getEntity().setCollection(selectionCollection.getSelection());
|
99
|
} else if (eventSource == textAccessionNumber) {
|
100
|
getEntity().setAccessionNumber(textAccessionNumber.getText());
|
101
|
}
|
102
|
if (eventSource != toggleableText_titleCache) {
|
103
|
toggleableText_titleCache.setText(getEntity().getTitleCache());
|
104
|
}
|
105
|
}
|
106
|
|
107
|
}
|