1
|
// $Id$
|
2
|
/**
|
3
|
* Copyright (C) 2007 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
|
|
11
|
package eu.etaxonomy.taxeditor.section.occurrence;
|
12
|
|
13
|
import org.apache.log4j.Logger;
|
14
|
import org.eclipse.ui.forms.widgets.Section;
|
15
|
|
16
|
import eu.etaxonomy.cdm.api.facade.DerivedUnitFacade;
|
17
|
import eu.etaxonomy.cdm.api.facade.DerivedUnitFacadeConfigurator;
|
18
|
import eu.etaxonomy.cdm.api.facade.DerivedUnitFacadeNotSupportedException;
|
19
|
import eu.etaxonomy.cdm.model.occurrence.DerivedUnitBase;
|
20
|
import eu.etaxonomy.taxeditor.editor.EditorUtil;
|
21
|
import eu.etaxonomy.taxeditor.forms.CdmFormFactory;
|
22
|
import eu.etaxonomy.taxeditor.forms.CdmFormFactory.DetailType;
|
23
|
import eu.etaxonomy.taxeditor.forms.ICdmFormElement;
|
24
|
import eu.etaxonomy.taxeditor.section.AbstractCdmDetailElement;
|
25
|
import eu.etaxonomy.taxeditor.section.AbstractCdmDetailSection;
|
26
|
|
27
|
/**
|
28
|
* <p>DerivedUnitFacadeDetailElement class.</p>
|
29
|
*
|
30
|
* @author n.hoffmann
|
31
|
* @created Jun 17, 2010
|
32
|
* @version 1.0
|
33
|
*/
|
34
|
public class DerivedUnitFacadeDetailElement extends AbstractCdmDetailElement<DerivedUnitBase> {
|
35
|
|
36
|
private DerivedUnitFacade facade;
|
37
|
|
38
|
private DerivedUnitFacadeConfigurator configurator;
|
39
|
|
40
|
private GatheringEventDetailSection section_gatheringEvent;
|
41
|
private DerivedUnitBaseDetailSection section_derivedUnitBase;
|
42
|
private FieldObservationDetailSection section_fieldObservation;
|
43
|
|
44
|
|
45
|
private static final Logger logger = Logger
|
46
|
.getLogger(DerivedUnitFacadeDetailElement.class);
|
47
|
|
48
|
/**
|
49
|
* <p>Constructor for DerivedUnitFacadeDetailElement.</p>
|
50
|
*
|
51
|
* @param formFactory a {@link eu.etaxonomy.taxeditor.forms.CdmFormFactory} object.
|
52
|
* @param formElement a {@link eu.etaxonomy.taxeditor.forms.ICdmFormElement} object.
|
53
|
*/
|
54
|
public DerivedUnitFacadeDetailElement(CdmFormFactory formFactory,
|
55
|
ICdmFormElement formElement) {
|
56
|
super(formFactory, formElement);
|
57
|
configurator = DerivedUnitFacadeConfigurator.NewInstance();
|
58
|
configurator.setMoveDerivedUnitMediaToGallery(true);
|
59
|
configurator.setMoveFieldObjectMediaToGallery(true);
|
60
|
}
|
61
|
|
62
|
/** {@inheritDoc} */
|
63
|
@Override
|
64
|
public void setEntity(DerivedUnitBase entity) {
|
65
|
super.setEntity(entity);
|
66
|
try {
|
67
|
facade = DerivedUnitFacade.NewInstance(entity, configurator);
|
68
|
|
69
|
section_derivedUnitBase.setFacade(facade);
|
70
|
section_gatheringEvent.setFacade(facade);
|
71
|
section_fieldObservation.setFacade(facade);
|
72
|
|
73
|
} catch (DerivedUnitFacadeNotSupportedException e) {
|
74
|
EditorUtil.errorDialog("Error", this, "SpecimenFacadeNotSupportedException while inititating SpecimenFacade", e);
|
75
|
}
|
76
|
}
|
77
|
|
78
|
/** {@inheritDoc} */
|
79
|
@Override
|
80
|
public void removeElements() {
|
81
|
super.removeElements();
|
82
|
if(section_derivedUnitBase != null){
|
83
|
removeControl(section_derivedUnitBase);
|
84
|
section_derivedUnitBase.dispose();
|
85
|
section_derivedUnitBase = null;
|
86
|
}
|
87
|
if(section_gatheringEvent != null){
|
88
|
removeControl(section_gatheringEvent);
|
89
|
section_gatheringEvent.dispose();
|
90
|
section_gatheringEvent = null;
|
91
|
}
|
92
|
if(section_fieldObservation != null){
|
93
|
removeControl(section_fieldObservation);
|
94
|
section_fieldObservation.dispose();
|
95
|
section_fieldObservation = null;
|
96
|
}
|
97
|
}
|
98
|
|
99
|
/** {@inheritDoc} */
|
100
|
@Override
|
101
|
public DerivedUnitBase getEntity() {
|
102
|
throw new IllegalArgumentException("Should not be called");
|
103
|
}
|
104
|
|
105
|
/**
|
106
|
* <p>Getter for the field <code>facade</code>.</p>
|
107
|
*
|
108
|
* @return a {@link eu.etaxonomy.cdm.api.facade.DerivedUnitFacade} object.
|
109
|
*/
|
110
|
public DerivedUnitFacade getFacade(){
|
111
|
return facade;
|
112
|
}
|
113
|
|
114
|
/** {@inheritDoc} */
|
115
|
@Override
|
116
|
protected void createControls(ICdmFormElement formElement,
|
117
|
DerivedUnitBase entity, int style) {
|
118
|
|
119
|
section_gatheringEvent = (GatheringEventDetailSection) formFactory.createCdmDetailSection(DetailType.GATHERING_EVENT, getConversationHolder(), formElement, null, Section.TWISTIE | Section.EXPANDED);
|
120
|
section_gatheringEvent.setLayoutData(CdmFormFactory.FILL_HORIZONTALLY(2, 1));
|
121
|
addControl(section_gatheringEvent);
|
122
|
addElement(section_gatheringEvent);
|
123
|
|
124
|
section_fieldObservation = (FieldObservationDetailSection) formFactory.createCdmDetailSection(DetailType.FIELD_OBSERVATION, getConversationHolder(), formElement, null, Section.TWISTIE | Section.EXPANDED);
|
125
|
section_fieldObservation.setLayoutData(CdmFormFactory.FILL_HORIZONTALLY(2, 1));
|
126
|
addControl(section_fieldObservation);
|
127
|
addElement(section_fieldObservation);
|
128
|
|
129
|
section_derivedUnitBase = (DerivedUnitBaseDetailSection) formFactory.createCdmDetailSection(DetailType.DERIVED_UNIT, getConversationHolder(), formElement, null, Section.TWISTIE | Section.EXPANDED);
|
130
|
section_derivedUnitBase.setLayoutData(CdmFormFactory.FILL_HORIZONTALLY(2, 1));
|
131
|
addControl(section_derivedUnitBase);
|
132
|
addElement(section_derivedUnitBase);
|
133
|
}
|
134
|
|
135
|
/** {@inheritDoc} */
|
136
|
@Override
|
137
|
public void handleEvent(Object eventSource) {
|
138
|
if(eventSource == section_derivedUnitBase || eventSource == section_gatheringEvent || eventSource == section_fieldObservation){
|
139
|
if(getParentElement() instanceof AbstractCdmDetailSection)
|
140
|
((AbstractCdmDetailSection) getParentElement()).updateTitle();
|
141
|
}
|
142
|
}
|
143
|
}
|