4 package eu
.etaxonomy
.taxeditor
.forms
;
9 import org
.apache
.log4j
.Logger
;
10 import org
.eclipse
.core
.runtime
.Assert
;
11 import org
.eclipse
.core
.runtime
.ListenerList
;
12 import org
.eclipse
.jface
.util
.IPropertyChangeListener
;
13 import org
.eclipse
.jface
.viewers
.ISelection
;
14 import org
.eclipse
.jface
.viewers
.ISelectionProvider
;
15 import org
.eclipse
.jface
.window
.Window
;
16 import org
.eclipse
.swt
.SWT
;
17 import org
.eclipse
.swt
.events
.FocusAdapter
;
18 import org
.eclipse
.swt
.events
.FocusEvent
;
19 import org
.eclipse
.swt
.events
.FocusListener
;
20 import org
.eclipse
.swt
.events
.MouseAdapter
;
21 import org
.eclipse
.swt
.events
.MouseEvent
;
22 import org
.eclipse
.swt
.events
.MouseListener
;
23 import org
.eclipse
.swt
.events
.SelectionEvent
;
24 import org
.eclipse
.swt
.events
.SelectionListener
;
25 import org
.eclipse
.swt
.events
.TypedEvent
;
26 import org
.eclipse
.swt
.graphics
.Color
;
27 import org
.eclipse
.swt
.graphics
.Font
;
28 import org
.eclipse
.swt
.widgets
.Composite
;
29 import org
.eclipse
.swt
.widgets
.Control
;
30 import org
.eclipse
.swt
.widgets
.Display
;
31 import org
.eclipse
.swt
.widgets
.Event
;
32 import org
.eclipse
.swt
.widgets
.Label
;
33 import org
.eclipse
.ui
.forms
.IFormColors
;
34 import org
.eclipse
.ui
.forms
.widgets
.FormToolkit
;
35 import org
.eclipse
.ui
.forms
.widgets
.Section
;
36 import org
.eclipse
.ui
.forms
.widgets
.TableWrapData
;
37 import org
.eclipse
.ui
.forms
.widgets
.TableWrapLayout
;
38 import org
.eclipse
.ui
.internal
.forms
.widgets
.FormFonts
;
39 import org
.joda
.time
.Partial
;
41 import eu
.etaxonomy
.cdm
.api
.conversation
.ConversationHolder
;
42 import eu
.etaxonomy
.cdm
.hibernate
.HibernateProxyHelper
;
43 import eu
.etaxonomy
.cdm
.model
.agent
.Institution
;
44 import eu
.etaxonomy
.cdm
.model
.agent
.Person
;
45 import eu
.etaxonomy
.cdm
.model
.agent
.Team
;
46 import eu
.etaxonomy
.cdm
.model
.agent
.TeamOrPersonBase
;
47 import eu
.etaxonomy
.cdm
.model
.common
.Annotation
;
48 import eu
.etaxonomy
.cdm
.model
.common
.AnnotationType
;
49 import eu
.etaxonomy
.cdm
.model
.common
.Credit
;
50 import eu
.etaxonomy
.cdm
.model
.common
.DefinedTermBase
;
51 import eu
.etaxonomy
.cdm
.model
.common
.DescriptionElementSource
;
52 import eu
.etaxonomy
.cdm
.model
.common
.Extension
;
53 import eu
.etaxonomy
.cdm
.model
.common
.ExtensionType
;
54 import eu
.etaxonomy
.cdm
.model
.common
.IVersionableEntity
;
55 import eu
.etaxonomy
.cdm
.model
.common
.IdentifiableEntity
;
56 import eu
.etaxonomy
.cdm
.model
.common
.IdentifiableSource
;
57 import eu
.etaxonomy
.cdm
.model
.common
.Language
;
58 import eu
.etaxonomy
.cdm
.model
.common
.LanguageString
;
59 import eu
.etaxonomy
.cdm
.model
.common
.Marker
;
60 import eu
.etaxonomy
.cdm
.model
.common
.MarkerType
;
61 import eu
.etaxonomy
.cdm
.model
.common
.TimePeriod
;
62 import eu
.etaxonomy
.cdm
.model
.common
.VersionableEntity
;
63 import eu
.etaxonomy
.cdm
.model
.description
.CategoricalData
;
64 import eu
.etaxonomy
.cdm
.model
.description
.CommonTaxonName
;
65 import eu
.etaxonomy
.cdm
.model
.description
.DescriptionElementBase
;
66 import eu
.etaxonomy
.cdm
.model
.description
.Distribution
;
67 import eu
.etaxonomy
.cdm
.model
.description
.Feature
;
68 import eu
.etaxonomy
.cdm
.model
.description
.FeatureTree
;
69 import eu
.etaxonomy
.cdm
.model
.description
.IndividualsAssociation
;
70 import eu
.etaxonomy
.cdm
.model
.description
.MeasurementUnit
;
71 import eu
.etaxonomy
.cdm
.model
.description
.Modifier
;
72 import eu
.etaxonomy
.cdm
.model
.description
.PresenceAbsenceTermBase
;
73 import eu
.etaxonomy
.cdm
.model
.description
.QuantitativeData
;
74 import eu
.etaxonomy
.cdm
.model
.description
.Scope
;
75 import eu
.etaxonomy
.cdm
.model
.description
.Sex
;
76 import eu
.etaxonomy
.cdm
.model
.description
.Stage
;
77 import eu
.etaxonomy
.cdm
.model
.description
.State
;
78 import eu
.etaxonomy
.cdm
.model
.description
.StateData
;
79 import eu
.etaxonomy
.cdm
.model
.description
.StatisticalMeasure
;
80 import eu
.etaxonomy
.cdm
.model
.description
.StatisticalMeasurementValue
;
81 import eu
.etaxonomy
.cdm
.model
.description
.TaxonInteraction
;
82 import eu
.etaxonomy
.cdm
.model
.description
.TextData
;
83 import eu
.etaxonomy
.cdm
.model
.location
.NamedArea
;
84 import eu
.etaxonomy
.cdm
.model
.location
.NamedAreaType
;
85 import eu
.etaxonomy
.cdm
.model
.media
.ImageFile
;
86 import eu
.etaxonomy
.cdm
.model
.media
.Media
;
87 import eu
.etaxonomy
.cdm
.model
.media
.MediaRepresentation
;
88 import eu
.etaxonomy
.cdm
.model
.media
.Rights
;
89 import eu
.etaxonomy
.cdm
.model
.media
.RightsTerm
;
90 import eu
.etaxonomy
.cdm
.model
.name
.NameRelationship
;
91 import eu
.etaxonomy
.cdm
.model
.name
.NameRelationshipType
;
92 import eu
.etaxonomy
.cdm
.model
.name
.NameTypeDesignation
;
93 import eu
.etaxonomy
.cdm
.model
.name
.NameTypeDesignationStatus
;
94 import eu
.etaxonomy
.cdm
.model
.name
.NomenclaturalStatus
;
95 import eu
.etaxonomy
.cdm
.model
.name
.NomenclaturalStatusType
;
96 import eu
.etaxonomy
.cdm
.model
.name
.Rank
;
97 import eu
.etaxonomy
.cdm
.model
.name
.SpecimenTypeDesignation
;
98 import eu
.etaxonomy
.cdm
.model
.name
.SpecimenTypeDesignationStatus
;
99 import eu
.etaxonomy
.cdm
.model
.name
.TaxonNameBase
;
100 import eu
.etaxonomy
.cdm
.model
.occurrence
.DerivedUnit
;
101 import eu
.etaxonomy
.cdm
.model
.occurrence
.DerivedUnitBase
;
102 import eu
.etaxonomy
.cdm
.model
.occurrence
.FieldObservation
;
103 import eu
.etaxonomy
.cdm
.model
.occurrence
.PreservationMethod
;
104 import eu
.etaxonomy
.cdm
.model
.reference
.ReferenceBase
;
105 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonBase
;
106 import eu
.etaxonomy
.cdm
.strategy
.parser
.ParserProblem
;
107 import eu
.etaxonomy
.taxeditor
.forms
.selection
.AbstractSelectionElement
;
108 import eu
.etaxonomy
.taxeditor
.forms
.selection
.AgentSelectionElement
;
109 import eu
.etaxonomy
.taxeditor
.forms
.selection
.DerivedUnitBaseSelectionElement
;
110 import eu
.etaxonomy
.taxeditor
.forms
.selection
.FeatureTreeSelectionElement
;
111 import eu
.etaxonomy
.taxeditor
.forms
.selection
.FieldObservationSelectionElement
;
112 import eu
.etaxonomy
.taxeditor
.forms
.selection
.InstitutionSelectionElement
;
113 import eu
.etaxonomy
.taxeditor
.forms
.selection
.NameSelectionElement
;
114 import eu
.etaxonomy
.taxeditor
.forms
.selection
.NamedAreaSelectionElement
;
115 import eu
.etaxonomy
.taxeditor
.forms
.selection
.NomenclaturalAuthorTeamSelectionElement
;
116 import eu
.etaxonomy
.taxeditor
.forms
.selection
.PersonSelectionElement
;
117 import eu
.etaxonomy
.taxeditor
.forms
.selection
.ReferenceSelectionElement
;
118 import eu
.etaxonomy
.taxeditor
.forms
.selection
.TaxonSelectionElement
;
119 import eu
.etaxonomy
.taxeditor
.forms
.selection
.TeamSelectionElement
;
120 import eu
.etaxonomy
.taxeditor
.forms
.term
.AbstractEnumComboElement
;
121 import eu
.etaxonomy
.taxeditor
.forms
.term
.AbstractTermComboElement
;
122 import eu
.etaxonomy
.taxeditor
.forms
.term
.AnnotationTypeComboElement
;
123 import eu
.etaxonomy
.taxeditor
.forms
.term
.ExtensionTypeComboElement
;
124 import eu
.etaxonomy
.taxeditor
.forms
.term
.LanguageComboElement
;
125 import eu
.etaxonomy
.taxeditor
.forms
.term
.MarkerTypeComboElement
;
126 import eu
.etaxonomy
.taxeditor
.forms
.term
.MeasurementUnitComboElement
;
127 import eu
.etaxonomy
.taxeditor
.forms
.term
.ModifierComboElement
;
128 import eu
.etaxonomy
.taxeditor
.forms
.term
.NameRelationshipTypeComboElement
;
129 import eu
.etaxonomy
.taxeditor
.forms
.term
.NameTypeDesignationStatusComboElement
;
130 import eu
.etaxonomy
.taxeditor
.forms
.term
.NamedAreaTypeComboElement
;
131 import eu
.etaxonomy
.taxeditor
.forms
.term
.NomenclaturalCodeComboElement
;
132 import eu
.etaxonomy
.taxeditor
.forms
.term
.NomenclaturalStatusTypeComboElement
;
133 import eu
.etaxonomy
.taxeditor
.forms
.term
.PresenceAbsenceTermComboElement
;
134 import eu
.etaxonomy
.taxeditor
.forms
.term
.PreservationMethodComboElement
;
135 import eu
.etaxonomy
.taxeditor
.forms
.term
.RankComboElement
;
136 import eu
.etaxonomy
.taxeditor
.forms
.term
.ReferenceTypeComboElement
;
137 import eu
.etaxonomy
.taxeditor
.forms
.term
.RightsTypeComboElement
;
138 import eu
.etaxonomy
.taxeditor
.forms
.term
.ScopeComboElement
;
139 import eu
.etaxonomy
.taxeditor
.forms
.term
.SexComboElement
;
140 import eu
.etaxonomy
.taxeditor
.forms
.term
.SpecimenTypeDesignationStatusComboElement
;
141 import eu
.etaxonomy
.taxeditor
.forms
.term
.StageComboElement
;
142 import eu
.etaxonomy
.taxeditor
.forms
.term
.StateComboElement
;
143 import eu
.etaxonomy
.taxeditor
.forms
.term
.StatisticalMeasureComboElement
;
144 import eu
.etaxonomy
.taxeditor
.section
.AbstractCdmDetailElement
;
145 import eu
.etaxonomy
.taxeditor
.section
.AbstractEntityCollectionElement
;
146 import eu
.etaxonomy
.taxeditor
.section
.EmptyElement
;
147 import eu
.etaxonomy
.taxeditor
.section
.agent
.PersonDetailElement
;
148 import eu
.etaxonomy
.taxeditor
.section
.agent
.PersonDetailSection
;
149 import eu
.etaxonomy
.taxeditor
.section
.agent
.TeamDetailElement
;
150 import eu
.etaxonomy
.taxeditor
.section
.agent
.TeamDetailSection
;
151 import eu
.etaxonomy
.taxeditor
.section
.agent
.TeamMemberElement
;
152 import eu
.etaxonomy
.taxeditor
.section
.agent
.TeamMemberSection
;
153 import eu
.etaxonomy
.taxeditor
.section
.agent
.TeamOrPersonBaseDetailSection
;
154 import eu
.etaxonomy
.taxeditor
.section
.description
.DerivedUnitElement
;
155 import eu
.etaxonomy
.taxeditor
.section
.description
.DescribedSpecimenSection
;
156 import eu
.etaxonomy
.taxeditor
.section
.description
.DescriptionDetailElement
;
157 import eu
.etaxonomy
.taxeditor
.section
.description
.DescriptionDetailSection
;
158 import eu
.etaxonomy
.taxeditor
.section
.description
.DescriptionElementDetailElement
;
159 import eu
.etaxonomy
.taxeditor
.section
.description
.DescriptionElementDetailSection
;
160 import eu
.etaxonomy
.taxeditor
.section
.description
.DescriptionElementMediaSection
;
161 import eu
.etaxonomy
.taxeditor
.section
.description
.DescriptionElementSourceElement
;
162 import eu
.etaxonomy
.taxeditor
.section
.description
.DescriptionElementSourceSection
;
163 import eu
.etaxonomy
.taxeditor
.section
.description
.DescriptionSourceElement
;
164 import eu
.etaxonomy
.taxeditor
.section
.description
.DescriptionSourceSection
;
165 import eu
.etaxonomy
.taxeditor
.section
.description
.ModifierElement
;
166 import eu
.etaxonomy
.taxeditor
.section
.description
.ModifierSection
;
167 import eu
.etaxonomy
.taxeditor
.section
.description
.NaturalLanguageDetailElement
;
168 import eu
.etaxonomy
.taxeditor
.section
.description
.NaturalLanguageSection
;
169 import eu
.etaxonomy
.taxeditor
.section
.description
.ScopeElement
;
170 import eu
.etaxonomy
.taxeditor
.section
.description
.ScopeSection
;
171 import eu
.etaxonomy
.taxeditor
.section
.description
.StateDataElement
;
172 import eu
.etaxonomy
.taxeditor
.section
.description
.StateDataSection
;
173 import eu
.etaxonomy
.taxeditor
.section
.description
.StatisticalMeasurementValueElement
;
174 import eu
.etaxonomy
.taxeditor
.section
.description
.StatisticalMeasurementValueSection
;
175 import eu
.etaxonomy
.taxeditor
.section
.description
.detail
.AbstractDetailedDescriptionDetailElement
;
176 import eu
.etaxonomy
.taxeditor
.section
.description
.detail
.CategoricalDataDetailElement
;
177 import eu
.etaxonomy
.taxeditor
.section
.description
.detail
.CommonNameDetailElement
;
178 import eu
.etaxonomy
.taxeditor
.section
.description
.detail
.DistributionDetailElement
;
179 import eu
.etaxonomy
.taxeditor
.section
.description
.detail
.IndividualsAssociationDetailElement
;
180 import eu
.etaxonomy
.taxeditor
.section
.description
.detail
.QuantitativeDataDetailElement
;
181 import eu
.etaxonomy
.taxeditor
.section
.description
.detail
.TaxonInteractionDetailElement
;
182 import eu
.etaxonomy
.taxeditor
.section
.description
.detail
.TextDataDetailElement
;
183 import eu
.etaxonomy
.taxeditor
.section
.name
.AuthorshipDetailElement
;
184 import eu
.etaxonomy
.taxeditor
.section
.name
.AuthorshipDetailSection
;
185 import eu
.etaxonomy
.taxeditor
.section
.name
.NameDetailElement
;
186 import eu
.etaxonomy
.taxeditor
.section
.name
.NameDetailSection
;
187 import eu
.etaxonomy
.taxeditor
.section
.name
.NameRelationshipDetailElement
;
188 import eu
.etaxonomy
.taxeditor
.section
.name
.NameRelationshipDetailSection
;
189 import eu
.etaxonomy
.taxeditor
.section
.name
.NameTypeDesignationElement
;
190 import eu
.etaxonomy
.taxeditor
.section
.name
.NomenclaturalStatusElement
;
191 import eu
.etaxonomy
.taxeditor
.section
.name
.NomenclaturalStatusSection
;
192 import eu
.etaxonomy
.taxeditor
.section
.name
.NonViralNameDetailElement
;
193 import eu
.etaxonomy
.taxeditor
.section
.name
.NonViralNameDetailSection
;
194 import eu
.etaxonomy
.taxeditor
.section
.name
.ProtologueElement
;
195 import eu
.etaxonomy
.taxeditor
.section
.name
.ProtologueSection
;
196 import eu
.etaxonomy
.taxeditor
.section
.name
.SpecimenTypeDesignationElement
;
197 import eu
.etaxonomy
.taxeditor
.section
.name
.TypeDesignationSection
;
198 import eu
.etaxonomy
.taxeditor
.section
.occurrence
.DerivedUnitBaseDetailElement
;
199 import eu
.etaxonomy
.taxeditor
.section
.occurrence
.DerivedUnitBaseDetailSection
;
200 import eu
.etaxonomy
.taxeditor
.section
.occurrence
.DerivedUnitFacadeDetailElement
;
201 import eu
.etaxonomy
.taxeditor
.section
.occurrence
.DerivedUnitFacadeDetailSection
;
202 import eu
.etaxonomy
.taxeditor
.section
.occurrence
.FieldObservationDetailElement
;
203 import eu
.etaxonomy
.taxeditor
.section
.occurrence
.FieldObservationDetailSection
;
204 import eu
.etaxonomy
.taxeditor
.section
.occurrence
.GatheringEventDetailElement
;
205 import eu
.etaxonomy
.taxeditor
.section
.occurrence
.GatheringEventDetailSection
;
206 import eu
.etaxonomy
.taxeditor
.section
.reference
.NomenclaturalReferenceDetailElement
;
207 import eu
.etaxonomy
.taxeditor
.section
.reference
.NomenclaturalReferenceDetailSection
;
208 import eu
.etaxonomy
.taxeditor
.section
.reference
.ReferenceBaseDetailElement
;
209 import eu
.etaxonomy
.taxeditor
.section
.reference
.ReferenceBaseDetailSection
;
210 import eu
.etaxonomy
.taxeditor
.section
.supplemental
.AnnotationElement
;
211 import eu
.etaxonomy
.taxeditor
.section
.supplemental
.AnnotationSection
;
212 import eu
.etaxonomy
.taxeditor
.section
.supplemental
.CreditElement
;
213 import eu
.etaxonomy
.taxeditor
.section
.supplemental
.CreditSection
;
214 import eu
.etaxonomy
.taxeditor
.section
.supplemental
.ExtensionElement
;
215 import eu
.etaxonomy
.taxeditor
.section
.supplemental
.ExtensionSection
;
216 import eu
.etaxonomy
.taxeditor
.section
.supplemental
.HeadlineSection
;
217 import eu
.etaxonomy
.taxeditor
.section
.supplemental
.IdentifiableSourceElement
;
218 import eu
.etaxonomy
.taxeditor
.section
.supplemental
.ImageFileElement
;
219 import eu
.etaxonomy
.taxeditor
.section
.supplemental
.MarkerElement
;
220 import eu
.etaxonomy
.taxeditor
.section
.supplemental
.MarkerSection
;
221 import eu
.etaxonomy
.taxeditor
.section
.supplemental
.MediaElement
;
222 import eu
.etaxonomy
.taxeditor
.section
.supplemental
.MediaRepresentationElement
;
223 import eu
.etaxonomy
.taxeditor
.section
.supplemental
.MediaRepresentationPartSection
;
224 import eu
.etaxonomy
.taxeditor
.section
.supplemental
.MediaRepresentationSection
;
225 import eu
.etaxonomy
.taxeditor
.section
.supplemental
.MediaSection
;
226 import eu
.etaxonomy
.taxeditor
.section
.supplemental
.RightsElement
;
227 import eu
.etaxonomy
.taxeditor
.section
.supplemental
.RightsSection
;
228 import eu
.etaxonomy
.taxeditor
.section
.supplemental
.SourceSection
;
229 import eu
.etaxonomy
.taxeditor
.section
.supplemental
.VersionElement
;
230 import eu
.etaxonomy
.taxeditor
.section
.supplemental
.VersionSection
;
231 import eu
.etaxonomy
.taxeditor
.section
.taxon
.ParsingMessageElement
;
232 import eu
.etaxonomy
.taxeditor
.section
.taxon
.ParsingMessagesSection
;
233 import eu
.etaxonomy
.taxeditor
.section
.taxon
.TaxonBaseDetailElement
;
234 import eu
.etaxonomy
.taxeditor
.section
.taxon
.TaxonBaseDetailSection
;
239 * @created Feb 24, 2010
242 public class CdmFormFactory
extends FormToolkit
{
244 private static final Logger logger
= Logger
245 .getLogger(CdmFormFactory
.class);
247 private BoldFontHolder2 boldFontHolder2
;
248 private MouseListener selectionMouseHandler
;
249 private FocusListener selectionFocusHandler
;
251 private ListenerList selectionListenerList
= new ListenerList();
253 private ListenerList propertyChangeListeners
= new ListenerList();
255 private int orientation
= Window
.getDefaultOrientation();
256 private ISelectionProvider selectionProvider
;
262 public static final TableWrapLayout
LAYOUT(){
263 return LAYOUT(1, false);
272 public static final TableWrapLayout
LAYOUT(int columns
, boolean equalWidth
){
273 TableWrapLayout layout
= new TableWrapLayout();
274 layout
.topMargin
= 0;
275 layout
.rightMargin
= 0;
276 layout
.bottomMargin
= 0;
277 layout
.leftMargin
= 0;
278 layout
.numColumns
= columns
;
279 layout
.makeColumnsEqualWidth
= equalWidth
;
280 layout
.verticalSpacing
= 0;
281 layout
.horizontalSpacing
= 0;
289 public static final TableWrapData
FILL(){
290 TableWrapData layoutData
= new TableWrapData(TableWrapData
.FILL_GRAB
, TableWrapData
.FILL_GRAB
);
291 // layoutData.grabHorizontal = true;
292 // layoutData.grabVertical = true;
296 public static final TableWrapData
LEFT(){
297 return new TableWrapData(TableWrapData
.LEFT
, TableWrapData
.TOP
);
300 public static final TableWrapData
RIGHT(){
301 return new TableWrapData(TableWrapData
.RIGHT
, TableWrapData
.TOP
);
308 public static final TableWrapData
FILL_HORIZONTALLY(){
309 return FILL_HORIZONTALLY(1, 1);
314 * @param horizontalSpan
315 * @param verticalSpan
318 public static final TableWrapData
FILL_HORIZONTALLY(int horizontalSpan
, int verticalSpan
){
319 TableWrapData layoutData
= new TableWrapData(TableWrapData
.FILL_GRAB
, TableWrapData
.TOP
);
320 layoutData
.colspan
= horizontalSpan
;
321 layoutData
.rowspan
= verticalSpan
;
325 public static ISelection EMPTY_SELECTION
= new ISelection() {
326 public boolean isEmpty() {
331 private class SelectionMouseHandler
extends MouseAdapter
{
333 public void mouseDown(MouseEvent e
) {
334 notifySelectionListeners(e
);
338 private class SelectionFocusHandler
extends FocusAdapter
{
340 public void focusGained(FocusEvent e
) {
341 notifySelectionListeners(e
);
345 private void notifySelectionListeners(TypedEvent e
){
346 Event event
= new Event();
347 event
.widget
= e
.widget
;
348 SelectionEvent selectionEvent
= new SelectionEvent(event
);
350 for(Object listener
: selectionListenerList
.getListeners()){
351 ((SelectionListener
) listener
).widgetSelected(selectionEvent
);
358 * @param selectionProvider
360 public CdmFormFactory(Display display
, ISelectionProvider selectionProvider
) {
362 this.selectionProvider
= selectionProvider
;
370 public CdmFormFactory(Display display
){
378 private void init() {
379 boldFontHolder2
= new BoldFontHolder2();
380 selectionMouseHandler
= new SelectionMouseHandler();
381 selectionFocusHandler
= new SelectionFocusHandler();
385 * Creates an instance initialized with the correct selectionProvider
387 * Make sure to remove the instance when the entityComposite disposes via
388 * destroySelectionArbitrator(..)
391 public SelectionArbitrator
createSelectionArbitrator(IEntityElement entityElement
){
392 SelectionArbitrator selectionArbitrator
= new SelectionArbitrator(entityElement
);
393 selectionArbitrator
.addSelectionProvider(selectionProvider
);
394 selectionProvider
.addSelectionChangedListener(selectionArbitrator
);
395 addSelectionListener(selectionArbitrator
);
396 return selectionArbitrator
;
399 public void destroySelectionArbitrator(SelectionArbitrator selectionArbitrator
){
400 removeSelectionListener(selectionArbitrator
);
401 selectionProvider
.removeSelectionChangedListener(selectionArbitrator
);
405 public void adapt(Composite composite
) {
406 composite
.addMouseListener(selectionMouseHandler
);
407 super.adapt(composite
);
410 public void adapt(AbstractCdmFormElement formElement
){
411 formElement
.setPropertyChangeListeners(propertyChangeListeners
);
415 public void adapt(Control control
, boolean trackFocus
, boolean trackKeyboard
) {
417 control
.addFocusListener(selectionFocusHandler
);
419 super.adapt(control
, trackFocus
, trackKeyboard
);
422 public void destroyElement(ICdmFormElement formElement
){
423 // return if element was not initialized
424 if(formElement
== null){
427 // destroy selection arbitrator, if any
428 if(formElement
instanceof ISelectableElement
){
429 destroySelectionArbitrator(((ISelectableElement
) formElement
).getSelectionArbitrator());
431 // remove this element form its parents list of elements
432 // ICdmFormElement parentElement = formElement.getParentElement();
433 // if(parentElement != null){
434 // parentElement.removeElement(formElement);
436 // call destroy on child elements recursively
437 for(ICdmFormElement childElement
: formElement
.getElements()){
438 destroyElement(childElement
);
440 // dispose of the controls
441 for(Control control
: formElement
.getControls()){
442 // we added the layoutComposite of the parental element as the layout composite to this formElement
443 // but we do not want to destroy it.
444 if(control
.equals(formElement
.getLayoutComposite())){
454 public Label
createEmptyCell(Composite parent
){
455 return this.createLabel(parent
, null);
466 public TextWithLabelElement
createMultilineTextWithLabel(ICdmFormElement parentElement
, String labelString
, int textHeight
, int style
){
467 TextWithLabelElement element
= new TextWithLabelElement(this, parentElement
, labelString
, "", textHeight
, style
);
469 parentElement
.addElement(element
);
482 public TextWithLabelElement
createTextWithLabelElement(ICdmFormElement parentElement
, String labelString
, String initialText
, int style
){
483 TextWithLabelElement element
= new TextWithLabelElement(this, parentElement
, labelString
, initialText
, null, style
);
485 parentElement
.addElement(element
);
489 public NumberWithLabelElement
createIntegerTextWithLabelElement(ICdmFormElement parentElement
, String labelString
, Integer initialInteger
, int style
){
490 NumberWithLabelElement element
= new NumberWithLabelElement(this, parentElement
, labelString
, initialInteger
, style
);
492 parentElement
.addElement(element
);
497 public NumberWithLabelElement
createFloatTextWithLabelElement(
498 ICdmFormElement parentElement
, String labelString
, float initialFloat
,
500 NumberWithLabelElement element
= new NumberWithLabelElement(this, parentElement
, labelString
, initialFloat
, style
);
502 parentElement
.addElement(element
);
506 public LanguageStringWithLabelElement
createLanguageStringWithLabelElement(ICdmFormElement parentElement
, String labelString
, LanguageString languageString
, int style
){
507 LanguageStringWithLabelElement element
= new LanguageStringWithLabelElement(this, parentElement
, labelString
, languageString
, style
);
509 parentElement
.addElement(element
);
513 public LanguageStringWithLabelElement
createLanguageStringWithLabelElement(ICdmFormElement parentElement
, String labelString
, LanguageString languageString
, int height
, int style
){
514 LanguageStringWithLabelElement element
= new LanguageStringWithLabelElement(this, parentElement
, labelString
, languageString
, height
, style
);
516 parentElement
.addElement(element
);
522 * @param parentElement
528 public TextWithLabelElement
createTextElement(ICdmFormElement parentElement
, String initialText
, int style
){
529 TextWithLabelElement element
= new TextWithLabelElement(this, parentElement
, null, initialText
, null, style
);
531 parentElement
.addElement(element
);
535 public KeyValueViewerElement
createKeyValueViewerElement(ICdmFormElement parentElement
, String keyHeading
, String valueHeading
, Map
<Object
, Object
> map
){
536 KeyValueViewerElement element
= new KeyValueViewerElement(this, parentElement
, keyHeading
, valueHeading
, map
);
538 parentElement
.addElement(element
);
543 public static enum TermComboType
{
547 NOMENCLATURALSTATUSTYPE
,
552 PRESENCEABSENCESTATUS
,
554 NAMETYPEDESIGNATIONSTATUS
,
555 SPECIMENTYPEDESIGNATIONSTATUS
,
566 public AbstractTermComboElement
createTermComboElement(TermComboType termComboType
, ICdmFormElement parentElement
, DefinedTermBase selection
, int style
){
567 AbstractTermComboElement element
= null;
569 switch(termComboType
){
571 element
= new ExtensionTypeComboElement(this, parentElement
, null, (ExtensionType
) selection
, style
);
574 element
= new LanguageComboElement(this, parentElement
, "Language", (Language
) selection
, style
);
577 element
= new MarkerTypeComboElement(this, parentElement
, null, (MarkerType
) selection
, style
);
579 case NOMENCLATURALSTATUSTYPE
:
580 element
= new NomenclaturalStatusTypeComboElement(this, parentElement
, "Nomenclatural Status Type", (NomenclaturalStatusType
) selection
, style
);
583 element
= new RankComboElement(this, parentElement
, "Rank", (Rank
) selection
, style
);
586 element
= new RightsTypeComboElement(this, parentElement
, "Rights Type", (RightsTerm
) selection
, style
);
588 case NAMERELATIONSHIP
:
589 element
= new NameRelationshipTypeComboElement(this, parentElement
, "Name Relationship Type", (NameRelationshipType
) selection
, style
);
592 element
= new NamedAreaTypeComboElement(this, parentElement
, "Named Area Type", (NamedAreaType
) selection
, style
);
595 element
= new AnnotationTypeComboElement(this, parentElement
, "Annotation Type", (AnnotationType
) selection
, style
);
597 case PRESENCEABSENCESTATUS
:
598 element
= new PresenceAbsenceTermComboElement(this, parentElement
, "Distribution Status", (PresenceAbsenceTermBase
) selection
, style
);
600 case NAMETYPEDESIGNATIONSTATUS
:
601 element
= new NameTypeDesignationStatusComboElement(this, parentElement
, "Designation Status", (NameTypeDesignationStatus
) selection
, style
);
603 case SPECIMENTYPEDESIGNATIONSTATUS
:
604 element
= new SpecimenTypeDesignationStatusComboElement(this, parentElement
, "Designation Status", (SpecimenTypeDesignationStatus
) selection
, style
);
607 element
= new SexComboElement(this, parentElement
, "Sex", (Sex
) selection
, style
);
610 element
= new StageComboElement(this, parentElement
, "Life Stage", (Stage
) selection
, style
);
612 case PRESERVATION_METHOD
:
613 element
= new PreservationMethodComboElement(this, parentElement
, "Preservation Method", (PreservationMethod
) selection
, style
);
614 case MEASUREMENT_UNIT
:
615 element
= new MeasurementUnitComboElement(this, parentElement
, "Measurement Unit", (MeasurementUnit
) selection
, style
);
618 element
= new StateComboElement(this, parentElement
, "State", (State
) selection
, style
);
621 element
= new ScopeComboElement(this, parentElement
, "Scope", (Scope
) selection
, style
);
624 element
= new ModifierComboElement(this, parentElement
, "Modifier", (Modifier
) selection
, style
);
626 case STATISTICAL_MEASURE
:
627 element
= new StatisticalMeasureComboElement(this, parentElement
, "Statistical Measure", (StatisticalMeasure
) selection
, style
);
632 parentElement
.addElement(element
);
636 public static enum EnumComboType
{
641 public AbstractEnumComboElement
createEnumComboElement(EnumComboType enumComboType
, ICdmFormElement parentElement
, int style
){
642 AbstractEnumComboElement element
= null;
644 switch(enumComboType
){
646 element
= new ReferenceTypeComboElement(this, parentElement
, "Reference Type", null, style
);
648 case NOMENCLATURALCODE
:
649 element
= new NomenclaturalCodeComboElement(this, parentElement
, "Nomenclatural Code", null, style
);
653 parentElement
.addElement(element
);
664 public ImageElement
createImageElement(ICdmFormElement parentElement
, URI imageUri
, int style
){
665 ImageElement element
= new ImageElement(this, parentElement
, imageUri
, style
);
667 parentElement
.addElement(element
);
679 public TextActionElement
createTextActionElement(ICdmFormElement parentElement
, String labelString
, String buttonLabel
, String initialText
, int style
){
680 TextActionElement element
= new TextActionElement(this, parentElement
, labelString
, buttonLabel
, initialText
, style
);
682 parentElement
.addElement(element
);
689 * @created Mar 5, 2010
692 public static enum SelectionType
{
710 * @param taxonBasePropertySection
713 public CheckboxElement
createCheckbox(ICdmFormElement parentElement
, String label
, boolean initialState
, int style
) {
714 CheckboxElement element
= new CheckboxElement(this, parentElement
, label
, initialState
, style
| orientation
);
716 parentElement
.addElement(element
);
723 * Creates a section as a part of the form.
727 * @param sectionStyle
729 * @return the section widget
731 public Section
adapt(AbstractFormSection section
) {
732 section
.setMenu(section
.getLayoutComposite().getMenu());
733 adapt(section
, true, true);
735 // handle focus and property change events for cdm use
736 section
.addFocusListener(selectionFocusHandler
);
737 section
.setPropertyChangeListeners(propertyChangeListeners
);
739 if (section
.getToggle() != null) {
740 section
.getToggle().setHoverDecorationColor(getColors()
741 .getColor(IFormColors
.TB_TOGGLE_HOVER
));
742 section
.getToggle().setDecorationColor(getColors()
743 .getColor(IFormColors
.TB_TOGGLE
));
746 section
.setFont(boldFontHolder2
.getBoldFont(section
.getLayoutComposite().getFont()));
748 if ((section
.getStyle() & Section
.TITLE_BAR
) != 0
749 || (section
.getStyle() & Section
.SHORT_TITLE_BAR
) != 0) {
750 getColors().initializeSectionToolBarColors();
751 section
.setTitleBarBackground(getColors().getColor(IFormColors
.TB_BG
));
752 section
.setTitleBarBorderColor(getColors()
753 .getColor(IFormColors
.TB_BORDER
));
755 // call setTitleBarForeground regardless as it also sets the label color
756 section
.setTitleBarForeground(getColors()
757 .getColor(IFormColors
.TB_TOGGLE
));
761 private class BoldFontHolder2
{
762 private Font normalFont
;
764 private Font boldFont
;
766 public BoldFontHolder2() {
769 public Font
getBoldFont(Font font
) {
770 createBoldFont(font
);
774 private void createBoldFont(Font font
) {
775 if (normalFont
== null || !normalFont
.equals(font
)) {
779 if (boldFont
== null) {
780 boldFont
= FormFonts
.getInstance().getBoldFont(getColors().getDisplay(),
785 public void dispose() {
786 if (boldFont
!= null) {
787 FormFonts
.getInstance().markFinished(boldFont
, getColors().getDisplay());
793 public ToggleableTextElement
createToggleableTextField(ICdmFormElement parentElement
,
794 String labelString
, String initialText
, boolean initialState
, int style
) {
795 ToggleableTextElement element
= new ToggleableTextElement(this, parentElement
,
796 labelString
, initialText
, initialState
, style
| orientation
);
798 parentElement
.addElement(element
);
802 public TimePeriodElement
createTimePeriodElement(
803 ICdmFormElement parentElement
, String labelString
, TimePeriod timePeriod
, int style
) {
804 TimePeriodElement element
= new TimePeriodElement(this, parentElement
, labelString
, timePeriod
, style
);
806 parentElement
.addElement(element
);
810 public DateDetailSection
createDateDetailSection(ICdmFormElement parentElement
, int style
){
811 DateDetailSection section
= new DateDetailSection(this, parentElement
, style
);
812 parentElement
.addElement(section
);
817 public PartialElement
createPartialElement(ICdmFormElement parentElement
, String labelString
, Partial partial
, int style
){
818 PartialElement element
= new PartialElement(this, parentElement
, labelString
, style
);
820 parentElement
.addElement(element
);
824 public void addSelectionListener(SelectionListener listener
){
825 selectionListenerList
.add(listener
);
828 public void removeSelectionListener(SelectionListener listener
){
829 if(listener
== null){
830 logger
.error("Tried to remove a selection listener from this factories listeners but was null");
832 selectionListenerList
.remove(listener
);
836 public void addPropertyChangeListener(IPropertyChangeListener listener
) {
837 propertyChangeListeners
.add(listener
);
840 public void removePropertyChangeListener(IPropertyChangeListener listener
){
841 propertyChangeListeners
.remove(listener
);
846 public Label
createHorizontalSeparator(ICdmFormElement parentElement
, int style
) {
847 Label separator
= this.createSeparator(parentElement
.getLayoutComposite(), SWT
.HORIZONTAL
| style
);
848 separator
.setLayoutData(FILL_HORIZONTALLY());
852 public VersionElement
createVersionElement(ICdmFormElement parentElement
, VersionableEntity entity
,
854 VersionElement element
= new VersionElement(this, parentElement
, entity
, style
);
856 parentElement
.addElement(element
);
860 public VersionSection
createVersionSection(ICdmFormElement parentElement
, int style
) {
861 VersionSection section
= new VersionSection(this, parentElement
, style
);
862 parentElement
.addElement(section
);
867 public EmptyElement
createEmptyElement(ICdmFormElement parentElement
) {
868 EmptyElement element
= new EmptyElement(this, parentElement
, null, SWT
.NULL
);
870 parentElement
.addElement(element
);
874 public HeadlineSection
createHeadlineSection(ICdmFormElement parentElement
) {
875 HeadlineSection section
= new HeadlineSection(this, parentElement
, SWT
.NULL
);
876 parentElement
.addElement(section
);
882 public ParsingMessageElement
createParsingMessageElement(
883 ICdmFormElement parentElement
, ParserProblem parserProblem
, int style
) {
884 ParsingMessageElement element
= new ParsingMessageElement(this, parentElement
, parserProblem
, style
);
886 parentElement
.addElement(element
);
896 public static enum DetailType
{
900 NOMENCLATURALREFERENCE
,
914 DERIVED_UNIT
, NATURAL_LANGUAGE
920 * @param parentElement
921 * @param selectionProvider
925 public AbstractFormSection
createCdmDetailSection(DetailType detailType
, ConversationHolder conversation
, ICdmFormElement parentElement
, ISelectionProvider selectionProvider
, int style
){
926 AbstractFormSection section
= null;
930 section
= new NameDetailSection(this, conversation
, parentElement
, selectionProvider
, style
);
933 section
= new ReferenceBaseDetailSection(this, conversation
, parentElement
, selectionProvider
, style
);
935 case NOMENCLATURALREFERENCE
:
936 section
= new NomenclaturalReferenceDetailSection(this, conversation
, parentElement
, selectionProvider
, style
);
939 section
= new TaxonBaseDetailSection(this, conversation
, parentElement
, selectionProvider
, style
);
942 section
= new AuthorshipDetailSection(this, conversation
, parentElement
, selectionProvider
, style
);
944 case TEAMORPERSONBASE
:
945 section
= new TeamOrPersonBaseDetailSection(this, conversation
, parentElement
, selectionProvider
, style
);
948 section
= new TeamDetailSection(this, conversation
, parentElement
, null, style
);
951 section
= new PersonDetailSection(this, conversation
, parentElement
, null, style
);
954 section
= new DescriptionDetailSection(this, conversation
, parentElement
, selectionProvider
, style
);
956 case DESCRIPTIONELEMENT
:
957 section
= new DescriptionElementDetailSection(this, conversation
, parentElement
, selectionProvider
, style
);
960 section
= new ParsingMessagesSection(this, conversation
, parentElement
, selectionProvider
, style
);
963 section
= new NonViralNameDetailSection(this, conversation
, parentElement
, selectionProvider
, style
);
966 section
= new eu
.etaxonomy
.taxeditor
.section
.description
.MediaDetailsSection(this, conversation
, parentElement
, selectionProvider
, style
);
968 case DERIVED_UNIT_FACADE
:
969 section
= new DerivedUnitFacadeDetailSection(this, conversation
, parentElement
, selectionProvider
, style
);
971 case FIELD_OBSERVATION
:
972 section
= new FieldObservationDetailSection(this, conversation
, parentElement
, selectionProvider
, style
);
974 case GATHERING_EVENT
:
975 section
= new GatheringEventDetailSection(this, conversation
, parentElement
, selectionProvider
, style
);
978 section
= new DerivedUnitBaseDetailSection(this, conversation
, parentElement
, selectionProvider
, style
);
980 case NATURAL_LANGUAGE
:
981 section
= new NaturalLanguageSection(this, conversation
, parentElement
, selectionProvider
, style
);
984 parentElement
.addElement(section
);
996 public AbstractCdmDetailElement
createCdmDetailElement(DetailType detailType
, ICdmFormElement parentElement
, int style
){
997 AbstractCdmDetailElement element
= null;
1000 case SCIENTIFICNAME
:
1001 element
= new NameDetailElement(this, parentElement
, style
);
1004 element
= new ReferenceBaseDetailElement(this, parentElement
, style
);
1006 case NOMENCLATURALREFERENCE
:
1007 element
= new NomenclaturalReferenceDetailElement(this, parentElement
, style
);
1010 element
= new TaxonBaseDetailElement(this, parentElement
, style
);
1013 element
= new AuthorshipDetailElement(this, parentElement
, style
);
1016 element
= new TeamDetailElement(this, parentElement
, style
);
1019 element
= new PersonDetailElement(this, parentElement
, style
);
1022 element
= new DescriptionDetailElement(this, parentElement
, style
);
1024 case DESCRIPTIONELEMENT
:
1025 element
= new DescriptionElementDetailElement(this, parentElement
, style
);
1028 element
= new NonViralNameDetailElement(this, parentElement
);
1030 case DERIVED_UNIT_FACADE
:
1031 element
= new DerivedUnitFacadeDetailElement(this, parentElement
);
1033 case FIELD_OBSERVATION
:
1034 element
= new FieldObservationDetailElement(this, parentElement
);
1036 case GATHERING_EVENT
:
1037 element
= new GatheringEventDetailElement(this, parentElement
);
1040 element
= new DerivedUnitBaseDetailElement(this, parentElement
);
1042 case NATURAL_LANGUAGE
:
1043 element
= new NaturalLanguageDetailElement(this, parentElement
);
1048 parentElement
.addElement(element
);
1054 * @author n.hoffmann
1055 * @created Mar 5, 2010
1058 public static enum EntityDetailType
{
1063 DESCRIPTIONELEMENTSOURCE
,
1067 DESCRIPTIONELEMENTMEDIA
,
1068 MEDIAREPRESENTATION
,
1069 MEDIAREPRESENTATIONPART
,
1071 NOMENCLATURALSTATUS
,
1080 STATISTICAL_MEASUREMENT_VALUE
,
1086 * @param entityDetailType
1091 public AbstractFormSection
createEntityDetailSection(EntityDetailType entityDetailType
, ConversationHolder conversation
, ICdmFormElement parentElement
, int style
){
1092 AbstractFormSection section
= null;
1094 switch(entityDetailType
){
1096 section
= new TeamDetailSection(this, conversation
, parentElement
, null, style
);
1099 section
= new TeamMemberSection(this, conversation
, parentElement
, style
);
1102 section
= new AnnotationSection(this, conversation
, parentElement
, style
);
1105 section
= new CreditSection(this, conversation
, parentElement
, style
);
1107 case DESCRIPTIONELEMENTSOURCE
:
1108 section
= new DescriptionElementSourceSection(this, conversation
, parentElement
, style
);
1111 section
= new ExtensionSection(this, conversation
, parentElement
, style
);
1114 section
= new MarkerSection(this, conversation
, parentElement
, style
);
1117 section
= new MediaSection(this, conversation
, parentElement
, style
);
1119 case DESCRIPTIONELEMENTMEDIA
:
1120 section
= new DescriptionElementMediaSection(this, conversation
, parentElement
, style
);
1122 case MEDIAREPRESENTATION
:
1123 section
= new MediaRepresentationSection(this, conversation
, parentElement
, style
);
1125 case MEDIAREPRESENTATIONPART
:
1126 section
= new MediaRepresentationPartSection(this, conversation
, parentElement
, style
);
1129 section
= new ModifierSection(this, conversation
, parentElement
, style
);
1131 case NOMENCLATURALSTATUS
:
1132 section
= new NomenclaturalStatusSection(this, conversation
, parentElement
, style
);
1134 case NAME_RELATIONSHIP
:
1135 section
= new NameRelationshipDetailSection(this, conversation
, parentElement
, style
);
1138 section
= new ProtologueSection(this, conversation
, parentElement
, style
);
1141 section
= new RightsSection(this, conversation
, parentElement
, style
);
1144 section
= new SourceSection(this, conversation
, parentElement
, style
);
1147 section
= new ScopeSection(this, conversation
, parentElement
, style
);
1149 case DESCRIPTIONSOURCE
:
1150 section
= new DescriptionSourceSection(this, conversation
, parentElement
, style
);
1152 case TYPEDESIGNATION
:
1153 section
= new TypeDesignationSection(this, conversation
, parentElement
, style
);
1156 section
= new StateDataSection(this, conversation
, parentElement
, style
);
1158 case STATISTICAL_MEASUREMENT_VALUE
:
1159 section
= new StatisticalMeasurementValueSection(this, conversation
, parentElement
, style
);
1161 case DESCRIBED_SPECIMEN
:
1162 section
= new DescribedSpecimenSection(this, conversation
, parentElement
, style
);
1165 parentElement
.addElement(section
);
1174 * @param removeListener
1178 public AbstractEntityCollectionElement
createEntityCollectionElement(AbstractFormSection parentElement
, IVersionableEntity versionableEntity
, SelectionListener removeListener
, Color backgroundColor
, int style
){
1179 AbstractEntityCollectionElement element
= null;
1181 VersionableEntity entity
= (VersionableEntity
) HibernateProxyHelper
.deproxy(versionableEntity
);
1183 if(entity
instanceof Annotation
){
1184 element
= new AnnotationElement(this, parentElement
, (Annotation
) entity
, removeListener
, style
);
1186 else if(entity
instanceof Person
){
1187 element
= new TeamMemberElement(this, parentElement
, (Person
) entity
, removeListener
, style
);
1189 else if(entity
instanceof Credit
){
1190 element
= new CreditElement(this, parentElement
, (Credit
) entity
, removeListener
, style
);
1192 else if(entity
instanceof Extension
){
1193 element
= new ExtensionElement(this, parentElement
, (Extension
) entity
, removeListener
, style
);
1195 else if(entity
instanceof Marker
){
1196 element
= new MarkerElement(this, parentElement
, (Marker
) entity
, removeListener
, style
);
1198 else if(entity
instanceof Media
){
1199 element
= new MediaElement(this, parentElement
, (Media
) entity
, removeListener
, style
);
1201 else if(entity
instanceof MediaRepresentation
){
1202 element
= new MediaRepresentationElement(this, parentElement
, (MediaRepresentation
) entity
, removeListener
, style
);
1204 else if(entity
instanceof ImageFile
){
1205 element
= new ImageFileElement(this, parentElement
, (ImageFile
) entity
, removeListener
, style
);
1207 else if(entity
instanceof NomenclaturalStatus
){
1208 element
= new NomenclaturalStatusElement(this, parentElement
, (NomenclaturalStatus
) entity
, removeListener
, style
);
1210 else if(entity
instanceof Rights
){
1211 element
= new RightsElement(this, parentElement
, (Rights
) entity
, removeListener
, style
);
1213 else if(entity
instanceof DescriptionElementSource
){
1214 element
= new DescriptionElementSourceElement(this, parentElement
, (DescriptionElementSource
) entity
, removeListener
, style
);
1216 else if(entity
instanceof IdentifiableSource
){
1217 element
= new IdentifiableSourceElement(this, parentElement
, (IdentifiableSource
) entity
, removeListener
, style
);
1219 else if(entity
instanceof Scope
){
1220 element
= new ScopeElement(this, parentElement
, (Scope
) entity
, removeListener
, style
);
1222 else if(entity
instanceof Modifier
){
1223 element
= new ModifierElement(this, parentElement
, (Modifier
) entity
, removeListener
, style
);
1225 else if(entity
instanceof ReferenceBase
){
1226 element
= new DescriptionSourceElement(this, parentElement
, (ReferenceBase
) entity
, removeListener
, style
);
1228 else if(entity
instanceof NameTypeDesignation
){
1229 element
= new NameTypeDesignationElement(this, parentElement
, (NameTypeDesignation
) entity
, removeListener
, style
);
1231 else if(entity
instanceof NameRelationship
){
1232 element
= new NameRelationshipDetailElement(this, parentElement
, (NameRelationship
) entity
, removeListener
, style
);
1234 else if(entity
instanceof SpecimenTypeDesignation
){
1235 element
= new SpecimenTypeDesignationElement(this, parentElement
, (SpecimenTypeDesignation
) entity
, removeListener
, style
);
1237 else if(entity
instanceof StateData
){
1238 element
= new StateDataElement(this, parentElement
, (StateData
) entity
, removeListener
, style
);
1240 else if(entity
instanceof StatisticalMeasurementValue
){
1241 element
= new StatisticalMeasurementValueElement(this, parentElement
, (StatisticalMeasurementValue
) entity
, removeListener
, style
);
1243 else if(entity
instanceof DerivedUnit
){
1244 element
= new DerivedUnitElement(this, parentElement
, (DerivedUnit
) entity
, removeListener
, style
);
1247 else if(entity
instanceof DescriptionElementBase
){
1248 // this is the special case for protologs, maybe we can do this differently when API improves
1249 DescriptionElementBase descriptionElement
= (DescriptionElementBase
) entity
;
1250 if(descriptionElement
.getFeature().equals(Feature
.PROTOLOGUE())){
1251 element
= new ProtologueElement(this, parentElement
, descriptionElement
, removeListener
, style
);
1255 Assert
.isNotNull(element
, "Could not generate composite for entity. Looks like the case is not handled already. Check implementation. Entity: " + entity
);
1257 if(backgroundColor
!= null && !backgroundColor
.isDisposed()){
1258 element
.setBackgroundColor(backgroundColor
);
1262 parentElement
.addElement(element
);
1268 * @param selectionType
1269 * @param parentElement
1270 * @param labelString
1275 public AbstractSelectionElement
createSelectionElement(SelectionType selectionType
, ConversationHolder conversation
, ICdmFormElement parentElement
, String labelString
, IdentifiableEntity selection
, int style
){
1276 AbstractSelectionElement element
= null;
1278 IdentifiableEntity entity
= (IdentifiableEntity
) HibernateProxyHelper
.deproxy(selection
);
1280 switch (selectionType
) {
1282 element
= new AgentSelectionElement(this, conversation
, parentElement
, labelString
, (TeamOrPersonBase
) entity
, style
);
1285 element
= new PersonSelectionElement(this, conversation
, parentElement
, labelString
, (Person
) entity
, style
);
1288 element
= new TeamSelectionElement(this, conversation
, parentElement
, labelString
, (Team
) entity
, style
);
1291 element
= new NomenclaturalAuthorTeamSelectionElement(this, conversation
, parentElement
, labelString
, (Team
) entity
, style
);
1294 element
= new InstitutionSelectionElement(this, conversation
, parentElement
, labelString
, (Institution
) entity
, style
);
1297 element
= new NameSelectionElement(this, conversation
, parentElement
, labelString
, (TaxonNameBase
) entity
, style
);
1300 element
= new ReferenceSelectionElement(this, conversation
, parentElement
, labelString
, (ReferenceBase
) entity
, style
);
1303 element
= new TaxonSelectionElement(this, conversation
, parentElement
, labelString
, (TaxonBase
) entity
, style
);
1306 element
= new DerivedUnitBaseSelectionElement(this, conversation
, parentElement
, labelString
, (DerivedUnitBase
) entity
, style
);
1308 case FIELD_OBSERVATION
:
1309 element
= new FieldObservationSelectionElement(this, conversation
, parentElement
, labelString
, (FieldObservation
) entity
, style
);
1312 element
= new FeatureTreeSelectionElement(this, conversation
, parentElement
, labelString
, (FeatureTree
) entity
, style
);
1315 new RuntimeException("There is no selection composite for the desired selection type.");
1320 parentElement
.addElement(element
);
1324 public NamedAreaSelectionElement
createNamedAreaSelectionElement(ICdmFormElement parentElement
, ConversationHolder conversation
, String labelString
, NamedArea selection
, int style
){
1325 NamedAreaSelectionElement element
= new NamedAreaSelectionElement(this, conversation
, parentElement
, labelString
, selection
, style
);
1327 parentElement
.addElement(element
);
1331 public LabelElement
createLabel(ICdmFormElement parentElement
, String text
) {
1332 LabelElement labelElement
= new LabelElement(this, parentElement
, text
);
1333 adapt(labelElement
);
1334 parentElement
.addElement(labelElement
);
1335 return labelElement
;
1338 public ISelectionProvider
getSelectionProvider() {
1339 return selectionProvider
;
1342 public AbstractDetailedDescriptionDetailElement
createDetailedDescriptionDetailElement(
1343 ICdmFormElement parentElement
, DescriptionElementBase entity
, int style
) {
1344 AbstractDetailedDescriptionDetailElement detailedDescriptionElement
= null;
1347 if(entity
instanceof CategoricalData
){
1348 detailedDescriptionElement
= new CategoricalDataDetailElement(this, parentElement
, (CategoricalData
) entity
, style
);
1350 else if(entity
instanceof CommonTaxonName
){
1351 detailedDescriptionElement
= new CommonNameDetailElement(this, parentElement
, (CommonTaxonName
) entity
, style
);
1353 else if(entity
instanceof Distribution
){
1354 detailedDescriptionElement
= new DistributionDetailElement(this, parentElement
, (Distribution
) entity
, style
);
1356 else if(entity
instanceof IndividualsAssociation
){
1357 detailedDescriptionElement
= new IndividualsAssociationDetailElement(this, parentElement
, (IndividualsAssociation
) entity
, style
);
1359 else if(entity
instanceof QuantitativeData
){
1360 detailedDescriptionElement
= new QuantitativeDataDetailElement(this, parentElement
, (QuantitativeData
) entity
, style
);
1362 else if(entity
instanceof TaxonInteraction
){
1363 detailedDescriptionElement
= new TaxonInteractionDetailElement(this, parentElement
, (TaxonInteraction
) entity
, style
);
1365 else if(entity
instanceof TextData
){
1366 detailedDescriptionElement
= new TextDataDetailElement(this, parentElement
, (TextData
) entity
, style
);
1369 throw new IllegalStateException("There is no interface for the given description element");
1371 adapt(detailedDescriptionElement
);
1372 parentElement
.addElement(detailedDescriptionElement
);
1373 return detailedDescriptionElement
;