Project

General

Profile

Download (88.9 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
 * 
3
 */
4
package eu.etaxonomy.taxeditor.singlesource.ui.forms;
5

    
6
import java.net.URI;
7
import java.util.ArrayList;
8
import java.util.HashSet;
9
import java.util.List;
10
import java.util.Map;
11
import java.util.Set;
12

    
13
import org.apache.log4j.Logger;
14
import org.eclipse.jface.util.IPropertyChangeListener;
15
import org.eclipse.jface.viewers.ISelection;
16
import org.eclipse.jface.viewers.ISelectionProvider;
17
import org.eclipse.jface.window.Window;
18
import org.eclipse.swt.SWT;
19
import org.eclipse.swt.events.FocusAdapter;
20
import org.eclipse.swt.events.FocusEvent;
21
import org.eclipse.swt.events.FocusListener;
22
import org.eclipse.swt.events.MouseAdapter;
23
import org.eclipse.swt.events.MouseEvent;
24
import org.eclipse.swt.events.MouseListener;
25
import org.eclipse.swt.events.SelectionEvent;
26
import org.eclipse.swt.events.SelectionListener;
27
import org.eclipse.swt.events.TypedEvent;
28
import org.eclipse.swt.graphics.Color;
29
import org.eclipse.swt.graphics.Font;
30
import org.eclipse.swt.widgets.Composite;
31
import org.eclipse.swt.widgets.Control;
32
import org.eclipse.swt.widgets.Display;
33
import org.eclipse.swt.widgets.Event;
34
import org.eclipse.swt.widgets.Label;
35
import org.eclipse.ui.forms.IFormColors;
36
import org.eclipse.ui.forms.widgets.FormToolkit;
37
import org.eclipse.ui.forms.widgets.Section;
38
import org.eclipse.ui.forms.widgets.TableWrapData;
39
import org.eclipse.ui.forms.widgets.TableWrapLayout;
40
import org.eclipse.ui.internal.forms.widgets.FormFonts;
41
import org.joda.time.Partial;
42
import org.springframework.security.core.GrantedAuthority;
43

    
44
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
45
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
46
import eu.etaxonomy.cdm.model.agent.Institution;
47
import eu.etaxonomy.cdm.model.agent.Person;
48
import eu.etaxonomy.cdm.model.agent.Team;
49
import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase;
50
import eu.etaxonomy.cdm.model.common.Annotation;
51
import eu.etaxonomy.cdm.model.common.AnnotationType;
52
import eu.etaxonomy.cdm.model.common.Credit;
53
import eu.etaxonomy.cdm.model.common.DefinedTermBase;
54
import eu.etaxonomy.cdm.model.common.DescriptionElementSource;
55
import eu.etaxonomy.cdm.model.common.Extension;
56
import eu.etaxonomy.cdm.model.common.ExtensionType;
57
import eu.etaxonomy.cdm.model.common.Group;
58
import eu.etaxonomy.cdm.model.common.IAnnotatableEntity;
59
import eu.etaxonomy.cdm.model.common.ICdmBase;
60
import eu.etaxonomy.cdm.model.common.IdentifiableSource;
61
import eu.etaxonomy.cdm.model.common.Language;
62
import eu.etaxonomy.cdm.model.common.LanguageString;
63
import eu.etaxonomy.cdm.model.common.Marker;
64
import eu.etaxonomy.cdm.model.common.MarkerType;
65
import eu.etaxonomy.cdm.model.common.TimePeriod;
66
import eu.etaxonomy.cdm.model.common.User;
67
import eu.etaxonomy.cdm.model.common.VersionableEntity;
68
import eu.etaxonomy.cdm.model.description.CategoricalData;
69
import eu.etaxonomy.cdm.model.description.CommonTaxonName;
70
import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
71
import eu.etaxonomy.cdm.model.description.Distribution;
72
import eu.etaxonomy.cdm.model.description.Feature;
73
import eu.etaxonomy.cdm.model.description.FeatureTree;
74
import eu.etaxonomy.cdm.model.description.IndividualsAssociation;
75
import eu.etaxonomy.cdm.model.description.KeyStatement;
76
import eu.etaxonomy.cdm.model.description.MeasurementUnit;
77
import eu.etaxonomy.cdm.model.description.Modifier;
78
import eu.etaxonomy.cdm.model.description.PolytomousKey;
79
import eu.etaxonomy.cdm.model.description.PolytomousKeyNode;
80
import eu.etaxonomy.cdm.model.description.PresenceAbsenceTermBase;
81
import eu.etaxonomy.cdm.model.description.QuantitativeData;
82
import eu.etaxonomy.cdm.model.description.Scope;
83
import eu.etaxonomy.cdm.model.description.Sex;
84
import eu.etaxonomy.cdm.model.description.Stage;
85
import eu.etaxonomy.cdm.model.description.State;
86
import eu.etaxonomy.cdm.model.description.StateData;
87
import eu.etaxonomy.cdm.model.description.StatisticalMeasure;
88
import eu.etaxonomy.cdm.model.description.StatisticalMeasurementValue;
89
import eu.etaxonomy.cdm.model.description.TaxonInteraction;
90
import eu.etaxonomy.cdm.model.description.TextData;
91
import eu.etaxonomy.cdm.model.location.NamedArea;
92
import eu.etaxonomy.cdm.model.location.NamedAreaType;
93
import eu.etaxonomy.cdm.model.location.Point;
94
import eu.etaxonomy.cdm.model.location.ReferenceSystem;
95
import eu.etaxonomy.cdm.model.media.ImageFile;
96
import eu.etaxonomy.cdm.model.media.Media;
97
import eu.etaxonomy.cdm.model.media.MediaRepresentation;
98
import eu.etaxonomy.cdm.model.media.Rights;
99
import eu.etaxonomy.cdm.model.media.RightsTerm;
100
import eu.etaxonomy.cdm.model.name.NameRelationship;
101
import eu.etaxonomy.cdm.model.name.NameRelationshipType;
102
import eu.etaxonomy.cdm.model.name.NameTypeDesignation;
103
import eu.etaxonomy.cdm.model.name.NameTypeDesignationStatus;
104
import eu.etaxonomy.cdm.model.name.NomenclaturalStatus;
105
import eu.etaxonomy.cdm.model.name.NomenclaturalStatusType;
106
import eu.etaxonomy.cdm.model.name.Rank;
107
import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignation;
108
import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignationStatus;
109
import eu.etaxonomy.cdm.model.name.TaxonNameBase;
110
import eu.etaxonomy.cdm.model.occurrence.Collection;
111
import eu.etaxonomy.cdm.model.occurrence.DerivedUnit;
112
import eu.etaxonomy.cdm.model.occurrence.DerivedUnitBase;
113
import eu.etaxonomy.cdm.model.occurrence.DeterminationEvent;
114
import eu.etaxonomy.cdm.model.occurrence.DeterminationModifier;
115
import eu.etaxonomy.cdm.model.occurrence.FieldObservation;
116
import eu.etaxonomy.cdm.model.occurrence.PreservationMethod;
117
import eu.etaxonomy.cdm.model.occurrence.Specimen;
118
import eu.etaxonomy.cdm.model.reference.Reference;
119
import eu.etaxonomy.cdm.model.taxon.Classification;
120
import eu.etaxonomy.cdm.model.taxon.Synonym;
121
import eu.etaxonomy.cdm.model.taxon.Taxon;
122
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
123
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
124
import eu.etaxonomy.cdm.strategy.parser.ParserProblem;
125
import eu.etaxonomy.taxeditor.singlesource.ImplementationLoader;
126
import eu.etaxonomy.taxeditor.singlesource.org.eclipse.swt.widgets.DisplayProxy;
127
import eu.etaxonomy.taxeditor.store.StoreUtil;
128
import eu.etaxonomy.taxeditor.ui.forms.AbstractCdmFormElement;
129
import eu.etaxonomy.taxeditor.ui.forms.AbstractFormSection;
130
import eu.etaxonomy.taxeditor.ui.forms.BrowserElement;
131
import eu.etaxonomy.taxeditor.ui.forms.CheckboxElement;
132
import eu.etaxonomy.taxeditor.ui.forms.DateDetailSection;
133
import eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement;
134
import eu.etaxonomy.taxeditor.ui.forms.IEntityElement;
135
import eu.etaxonomy.taxeditor.ui.forms.ISelectableElement;
136
import eu.etaxonomy.taxeditor.ui.forms.ImageElement;
137
import eu.etaxonomy.taxeditor.ui.forms.KeyStatementElement;
138
import eu.etaxonomy.taxeditor.ui.forms.KeyValueViewerElement;
139
import eu.etaxonomy.taxeditor.ui.forms.LabelElement;
140
import eu.etaxonomy.taxeditor.ui.forms.MultilanguageTextElement;
141
import eu.etaxonomy.taxeditor.ui.forms.PartialElement;
142
import eu.etaxonomy.taxeditor.ui.forms.PointElement;
143
import eu.etaxonomy.taxeditor.ui.forms.SelectionArbitrator;
144
import eu.etaxonomy.taxeditor.ui.forms.TextActionElement;
145
import eu.etaxonomy.taxeditor.ui.forms.TimePeriodElement;
146
import eu.etaxonomy.taxeditor.ui.forms.ToggleableTextElement;
147
import eu.etaxonomy.taxeditor.ui.forms.password.EditPasswordElement;
148
import eu.etaxonomy.taxeditor.ui.openurl.IOpenUrlEnabled;
149
import eu.etaxonomy.taxeditor.ui.openurl.OpenUrlSelectorElement;
150
import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement;
151
import eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionElement;
152
import eu.etaxonomy.taxeditor.ui.section.EmptyElement;
153
import eu.etaxonomy.taxeditor.ui.section.agent.InstitutionDetailElement;
154
import eu.etaxonomy.taxeditor.ui.section.agent.InstitutionDetailSection;
155
import eu.etaxonomy.taxeditor.ui.section.agent.PersonDetailElement;
156
import eu.etaxonomy.taxeditor.ui.section.agent.PersonDetailSection;
157
import eu.etaxonomy.taxeditor.ui.section.agent.TeamDetailElement;
158
import eu.etaxonomy.taxeditor.ui.section.agent.TeamDetailSection;
159
import eu.etaxonomy.taxeditor.ui.section.agent.TeamMemberElement;
160
import eu.etaxonomy.taxeditor.ui.section.agent.TeamMemberSection;
161
import eu.etaxonomy.taxeditor.ui.section.agent.TeamOrPersonBaseDetailSection;
162
import eu.etaxonomy.taxeditor.ui.section.classification.ClassificationDetailElement;
163
import eu.etaxonomy.taxeditor.ui.section.classification.ClassificationDetailSection;
164
import eu.etaxonomy.taxeditor.ui.section.classification.TaxonNodeDetailElement;
165
import eu.etaxonomy.taxeditor.ui.section.classification.TaxonNodeDetailSection;
166
import eu.etaxonomy.taxeditor.ui.section.description.DerivedUnitElement;
167
import eu.etaxonomy.taxeditor.ui.section.description.DescribedSpecimenSection;
168
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionDetailElement;
169
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionDetailSection;
170
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionElementDetailElement;
171
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionElementDetailSection;
172
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionElementMediaSection;
173
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionElementSourceElement;
174
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionElementSourceSection;
175
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionSourceElement;
176
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionSourceSection;
177
import eu.etaxonomy.taxeditor.ui.section.description.ModifierElement;
178
import eu.etaxonomy.taxeditor.ui.section.description.ModifierSection;
179
import eu.etaxonomy.taxeditor.ui.section.description.NaturalLanguageDetailElement;
180
import eu.etaxonomy.taxeditor.ui.section.description.NaturalLanguageSection;
181
import eu.etaxonomy.taxeditor.ui.section.description.ScopeElement;
182
import eu.etaxonomy.taxeditor.ui.section.description.ScopeSection;
183
import eu.etaxonomy.taxeditor.ui.section.description.StateDataElement;
184
import eu.etaxonomy.taxeditor.ui.section.description.StateDataSection;
185
import eu.etaxonomy.taxeditor.ui.section.description.StatisticalMeasurementValueElement;
186
import eu.etaxonomy.taxeditor.ui.section.description.StatisticalMeasurementValueSection;
187
import eu.etaxonomy.taxeditor.ui.section.description.detail.AbstractDetailedDescriptionDetailElement;
188
import eu.etaxonomy.taxeditor.ui.section.description.detail.CategoricalDataDetailElement;
189
import eu.etaxonomy.taxeditor.ui.section.description.detail.CommonNameDetailElement;
190
import eu.etaxonomy.taxeditor.ui.section.description.detail.DistributionDetailElement;
191
import eu.etaxonomy.taxeditor.ui.section.description.detail.IndividualsAssociationDetailElement;
192
import eu.etaxonomy.taxeditor.ui.section.description.detail.QuantitativeDataDetailElement;
193
import eu.etaxonomy.taxeditor.ui.section.description.detail.TaxonInteractionDetailElement;
194
import eu.etaxonomy.taxeditor.ui.section.description.detail.TextDataDetailElement;
195
import eu.etaxonomy.taxeditor.ui.section.feature.FeatureDistributionDetailElement;
196
import eu.etaxonomy.taxeditor.ui.section.feature.FeatureDistributionDetailSection;
197
import eu.etaxonomy.taxeditor.ui.section.group.GrantedAuthorityDetailElement;
198
import eu.etaxonomy.taxeditor.ui.section.group.GrantedAuthorityDetailSection;
199
import eu.etaxonomy.taxeditor.ui.section.group.GroupDetailElement;
200
import eu.etaxonomy.taxeditor.ui.section.group.GroupDetailSection;
201
import eu.etaxonomy.taxeditor.ui.section.group.MemberDetailElement;
202
import eu.etaxonomy.taxeditor.ui.section.group.MemberDetailSection;
203
import eu.etaxonomy.taxeditor.ui.section.key.GeographicalScopeDetailSection;
204
import eu.etaxonomy.taxeditor.ui.section.key.PolytomousKeyDetailElement;
205
import eu.etaxonomy.taxeditor.ui.section.key.PolytomousKeyDetailSection;
206
import eu.etaxonomy.taxeditor.ui.section.key.PolytomousKeyNodeDetailElement;
207
import eu.etaxonomy.taxeditor.ui.section.key.PolytomousKeyNodeDetailSection;
208
import eu.etaxonomy.taxeditor.ui.section.key.ScopeRestrictionSection;
209
import eu.etaxonomy.taxeditor.ui.section.key.TaxonomicScopeSection;
210
import eu.etaxonomy.taxeditor.ui.section.media.ImageFileElement;
211
import eu.etaxonomy.taxeditor.ui.section.media.MediaElement;
212
import eu.etaxonomy.taxeditor.ui.section.media.MediaRepresentationElement;
213
import eu.etaxonomy.taxeditor.ui.section.media.MediaRepresentationPartSection;
214
import eu.etaxonomy.taxeditor.ui.section.media.MediaRepresentationSection;
215
import eu.etaxonomy.taxeditor.ui.section.media.MediaSection;
216
import eu.etaxonomy.taxeditor.ui.section.name.AuthorshipDetailElement;
217
import eu.etaxonomy.taxeditor.ui.section.name.AuthorshipDetailSection;
218
import eu.etaxonomy.taxeditor.ui.section.name.HybridDetailElement;
219
import eu.etaxonomy.taxeditor.ui.section.name.HybridDetailSection;
220
import eu.etaxonomy.taxeditor.ui.section.name.NameDetailElement;
221
import eu.etaxonomy.taxeditor.ui.section.name.NameDetailSection;
222
import eu.etaxonomy.taxeditor.ui.section.name.NameRelationshipDetailElement;
223
import eu.etaxonomy.taxeditor.ui.section.name.NameRelationshipDetailSection;
224
import eu.etaxonomy.taxeditor.ui.section.name.NameTypeDesignationElement;
225
import eu.etaxonomy.taxeditor.ui.section.name.NomenclaturalStatusElement;
226
import eu.etaxonomy.taxeditor.ui.section.name.NomenclaturalStatusSection;
227
import eu.etaxonomy.taxeditor.ui.section.name.NonViralNameDetailElement;
228
import eu.etaxonomy.taxeditor.ui.section.name.NonViralNameDetailSection;
229
import eu.etaxonomy.taxeditor.ui.section.name.ProtologueElement;
230
import eu.etaxonomy.taxeditor.ui.section.name.ProtologueSection;
231
import eu.etaxonomy.taxeditor.ui.section.name.SpecimenTypeDesignationElement;
232
import eu.etaxonomy.taxeditor.ui.section.name.TypeDesignationSection;
233
import eu.etaxonomy.taxeditor.ui.section.occurrence.CollectingAreasDetailSection;
234
import eu.etaxonomy.taxeditor.ui.section.occurrence.CollectionDetailElement;
235
import eu.etaxonomy.taxeditor.ui.section.occurrence.CurrentDeterminationDetailSection;
236
import eu.etaxonomy.taxeditor.ui.section.occurrence.DerivedUnitBaseDetailElement;
237
import eu.etaxonomy.taxeditor.ui.section.occurrence.DerivedUnitBaseDetailSection;
238
import eu.etaxonomy.taxeditor.ui.section.occurrence.DerivedUnitFacadeDetailElement;
239
import eu.etaxonomy.taxeditor.ui.section.occurrence.DerivedUnitFacadeDetailSection;
240
import eu.etaxonomy.taxeditor.ui.section.occurrence.DeterminationDetailElement;
241
import eu.etaxonomy.taxeditor.ui.section.occurrence.DeterminationDetailSection;
242
import eu.etaxonomy.taxeditor.ui.section.occurrence.DeterminationEventDetailElement;
243
import eu.etaxonomy.taxeditor.ui.section.occurrence.DeterminationHistoryDetailSection;
244
import eu.etaxonomy.taxeditor.ui.section.occurrence.FieldObservationDetailElement;
245
import eu.etaxonomy.taxeditor.ui.section.occurrence.FieldObservationDetailSection;
246
import eu.etaxonomy.taxeditor.ui.section.occurrence.GatheringEventDetailElement;
247
import eu.etaxonomy.taxeditor.ui.section.occurrence.GatheringEventDetailSection;
248
import eu.etaxonomy.taxeditor.ui.section.occurrence.GeneralDetailElement;
249
import eu.etaxonomy.taxeditor.ui.section.occurrence.GeneralDetailSection;
250
import eu.etaxonomy.taxeditor.ui.section.occurrence.NamedAreaDetailElement;
251
import eu.etaxonomy.taxeditor.ui.section.occurrence.SourceCollectionDetailSection;
252
import eu.etaxonomy.taxeditor.ui.section.occurrence.SpecimenCollectionDetailElement;
253
import eu.etaxonomy.taxeditor.ui.section.occurrence.SpecimenCollectionDetailSection;
254
import eu.etaxonomy.taxeditor.ui.section.reference.NomenclaturalReferenceDetailElement;
255
import eu.etaxonomy.taxeditor.ui.section.reference.NomenclaturalReferenceDetailSection;
256
import eu.etaxonomy.taxeditor.ui.section.reference.ReferenceDetailElement;
257
import eu.etaxonomy.taxeditor.ui.section.reference.ReferenceDetailSection;
258
import eu.etaxonomy.taxeditor.ui.section.supplemental.AnnotationElement;
259
import eu.etaxonomy.taxeditor.ui.section.supplemental.AnnotationSection;
260
import eu.etaxonomy.taxeditor.ui.section.supplemental.CreditElement;
261
import eu.etaxonomy.taxeditor.ui.section.supplemental.CreditSection;
262
import eu.etaxonomy.taxeditor.ui.section.supplemental.ExtensionElement;
263
import eu.etaxonomy.taxeditor.ui.section.supplemental.ExtensionSection;
264
import eu.etaxonomy.taxeditor.ui.section.supplemental.HeadlineSection;
265
import eu.etaxonomy.taxeditor.ui.section.supplemental.IdentifiableSourceElement;
266
import eu.etaxonomy.taxeditor.ui.section.supplemental.MarkerElement;
267
import eu.etaxonomy.taxeditor.ui.section.supplemental.MarkerSection;
268
import eu.etaxonomy.taxeditor.ui.section.supplemental.RightsElement;
269
import eu.etaxonomy.taxeditor.ui.section.supplemental.RightsSection;
270
import eu.etaxonomy.taxeditor.ui.section.supplemental.SourceSection;
271
import eu.etaxonomy.taxeditor.ui.section.supplemental.VersionElement;
272
import eu.etaxonomy.taxeditor.ui.section.supplemental.VersionSection;
273
import eu.etaxonomy.taxeditor.ui.section.taxon.ParsingMessageElement;
274
import eu.etaxonomy.taxeditor.ui.section.taxon.ParsingMessagesSection;
275
import eu.etaxonomy.taxeditor.ui.section.taxon.TaxonBaseDetailElement;
276
import eu.etaxonomy.taxeditor.ui.section.taxon.TaxonBaseDetailSection;
277
import eu.etaxonomy.taxeditor.ui.section.taxon.TaxonDetailElement;
278
import eu.etaxonomy.taxeditor.ui.section.user.GroupsByUserDetailElement;
279
import eu.etaxonomy.taxeditor.ui.section.user.GroupsByUserDetailSection;
280
import eu.etaxonomy.taxeditor.ui.section.user.UserDetailElement;
281
import eu.etaxonomy.taxeditor.ui.section.user.UserDetailSection;
282
import eu.etaxonomy.taxeditor.ui.selection.AbstractSelectionElement;
283
import eu.etaxonomy.taxeditor.ui.selection.AgentSelectionElement;
284
import eu.etaxonomy.taxeditor.ui.selection.ClassificationSelectionElement;
285
import eu.etaxonomy.taxeditor.ui.selection.CollectionSelectionElement;
286
import eu.etaxonomy.taxeditor.ui.selection.DerivedUnitBaseSelectionElement;
287
import eu.etaxonomy.taxeditor.ui.selection.FeatureSelectionElement;
288
import eu.etaxonomy.taxeditor.ui.selection.FeatureTreeSelectionElement;
289
import eu.etaxonomy.taxeditor.ui.selection.FieldObservationSelectionElement;
290
import eu.etaxonomy.taxeditor.ui.selection.GroupSelectionElement;
291
import eu.etaxonomy.taxeditor.ui.selection.InstitutionSelectionElement;
292
import eu.etaxonomy.taxeditor.ui.selection.NameSelectionElement;
293
import eu.etaxonomy.taxeditor.ui.selection.NamedAreaSelectionElement;
294
import eu.etaxonomy.taxeditor.ui.selection.NomenclaturalAuthorTeamSelectionElement;
295
import eu.etaxonomy.taxeditor.ui.selection.PersonSelectionElement;
296
import eu.etaxonomy.taxeditor.ui.selection.PolytomousKeyNodeSelectionElement;
297
import eu.etaxonomy.taxeditor.ui.selection.PolytomousKeySelectionElement;
298
import eu.etaxonomy.taxeditor.ui.selection.ReferenceSelectionElement;
299
import eu.etaxonomy.taxeditor.ui.selection.SynonymSelectionElement;
300
import eu.etaxonomy.taxeditor.ui.selection.TaxonBaseSelectionElement;
301
import eu.etaxonomy.taxeditor.ui.selection.TaxonNodeSelectionElement;
302
import eu.etaxonomy.taxeditor.ui.selection.TaxonSelectionElement;
303
import eu.etaxonomy.taxeditor.ui.selection.TeamSelectionElement;
304
import eu.etaxonomy.taxeditor.ui.selection.UserSelectionElement;
305
import eu.etaxonomy.taxeditor.ui.term.AbstractEnumComboElement;
306
import eu.etaxonomy.taxeditor.ui.term.AbstractTermComboElement;
307
import eu.etaxonomy.taxeditor.ui.term.AnnotationTypeComboElement;
308
import eu.etaxonomy.taxeditor.ui.term.DeterminationModifierComboElement;
309
import eu.etaxonomy.taxeditor.ui.term.EmptyComboElement;
310
import eu.etaxonomy.taxeditor.ui.term.ExtensionTypeComboElement;
311
import eu.etaxonomy.taxeditor.ui.term.LanguageComboElement;
312
import eu.etaxonomy.taxeditor.ui.term.MarkerTypeComboElement;
313
import eu.etaxonomy.taxeditor.ui.term.MeasurementUnitComboElement;
314
import eu.etaxonomy.taxeditor.ui.term.ModifierComboElement;
315
import eu.etaxonomy.taxeditor.ui.term.NameRelationshipTypeComboElement;
316
import eu.etaxonomy.taxeditor.ui.term.NameTypeDesignationStatusComboElement;
317
import eu.etaxonomy.taxeditor.ui.term.NamedAreaTypeComboElement;
318
import eu.etaxonomy.taxeditor.ui.term.NomenclaturalCodeComboElement;
319
import eu.etaxonomy.taxeditor.ui.term.NomenclaturalStatusTypeComboElement;
320
import eu.etaxonomy.taxeditor.ui.term.PresenceAbsenceTermComboElement;
321
import eu.etaxonomy.taxeditor.ui.term.PreservationMethodComboElement;
322
import eu.etaxonomy.taxeditor.ui.term.RankComboElement;
323
import eu.etaxonomy.taxeditor.ui.term.ReferenceSystemComboElement;
324
import eu.etaxonomy.taxeditor.ui.term.ReferenceTypeComboElement;
325
import eu.etaxonomy.taxeditor.ui.term.RightsTypeComboElement;
326
import eu.etaxonomy.taxeditor.ui.term.ScopeComboElement;
327
import eu.etaxonomy.taxeditor.ui.term.SexComboElement;
328
import eu.etaxonomy.taxeditor.ui.term.SpecimenTypeDesignationStatusComboElement;
329
import eu.etaxonomy.taxeditor.ui.term.StageComboElement;
330
import eu.etaxonomy.taxeditor.ui.term.StateComboElement;
331
import eu.etaxonomy.taxeditor.ui.term.StatisticalMeasureComboElement;
332

    
333
/**
334
 * <p>
335
 * CdmFormFactory class.
336
 * </p>
337
 * 
338
 * @author n.hoffmann
339
 * @created Feb 24, 2010
340
 * @version 1.0
341
 */
342
public abstract class CdmFormFactoryFacade extends FormToolkit {
343
	private static final Logger logger = Logger.getLogger(CdmFormFactoryFacade.class);
344
	
345
	private static CdmFormFactoryFacade IMPL;
346
	static{
347
		IMPL = (CdmFormFactoryFacade) ImplementationLoader.newInstance(CdmFormFactoryFacade.class);
348
	}
349

    
350
	private BoldFontHolder2 boldFontHolder2;
351
	private MouseListener selectionMouseHandler;
352
	private FocusListener selectionFocusHandler;
353

    
354
	private final Set selectionListenerList = new HashSet();
355

    
356
	private final List<IPropertyChangeListener> propertyChangeListeners = new ArrayList<IPropertyChangeListener>();
357

    
358
	private final int orientation = Window.getDefaultOrientation();
359
	private ISelectionProvider selectionProvider;
360

    
361
	/**
362
	 * <p>
363
	 * LAYOUT
364
	 * </p>
365
	 * 
366
	 * @return a {@link org.eclipse.ui.forms.widgets.TableWrapLayout} object.
367
	 */
368
	public static final TableWrapLayout LAYOUT() {
369
		return LAYOUT(1, false);
370
	}
371

    
372
	/**
373
	 * <p>
374
	 * LAYOUT
375
	 * </p>
376
	 * 
377
	 * @param columns
378
	 *            a int.
379
	 * @param equalWidth
380
	 *            a boolean.
381
	 * @return a {@link org.eclipse.ui.forms.widgets.TableWrapLayout} object.
382
	 */
383
	public static final TableWrapLayout LAYOUT(int columns, boolean equalWidth) {
384
		TableWrapLayout layout = new TableWrapLayout();
385
		layout.topMargin = 0;
386
		layout.rightMargin = 0;
387
		layout.bottomMargin = 0;
388
		layout.leftMargin = 0;
389
		layout.numColumns = columns;
390
		layout.makeColumnsEqualWidth = equalWidth;
391
		layout.verticalSpacing = 0;
392
		layout.horizontalSpacing = 0;
393
		return layout;
394
	}
395

    
396
	/**
397
	 * <p>
398
	 * FILL
399
	 * </p>
400
	 * 
401
	 * @return a {@link org.eclipse.ui.forms.widgets.TableWrapData} object.
402
	 */
403
	public static final TableWrapData FILL() {
404
		return FILL(1, 1);
405
	}
406

    
407
	/**
408
	 * <p>
409
	 * FILL
410
	 * </p>
411
	 * 
412
	 * @param horizontalSpan
413
	 *            a int.
414
	 * @param verticalSpan
415
	 *            a int.
416
	 * @return a {@link org.eclipse.ui.forms.widgets.TableWrapData} object.
417
	 */
418
	public static final TableWrapData FILL(int horizontalSpan, int verticalSpan) {
419
		TableWrapData layoutData = new TableWrapData(TableWrapData.FILL_GRAB,
420
				TableWrapData.FILL_GRAB);
421
		layoutData.colspan = horizontalSpan;
422
		layoutData.rowspan = verticalSpan;
423
		return layoutData;
424
	}
425

    
426
	/**
427
	 * <p>
428
	 * LEFT
429
	 * </p>
430
	 * 
431
	 * @return a {@link org.eclipse.ui.forms.widgets.TableWrapData} object.
432
	 */
433
	public static final TableWrapData LEFT() {
434
		return new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP);
435
	}
436

    
437
	/**
438
	 * <p>
439
	 * RIGHT
440
	 * </p>
441
	 * 
442
	 * @return a {@link org.eclipse.ui.forms.widgets.TableWrapData} object.
443
	 */
444
	public static final TableWrapData RIGHT() {
445
		return new TableWrapData(TableWrapData.RIGHT, TableWrapData.TOP);
446
	}
447

    
448
	/**
449
	 * <p>
450
	 * FILL_HORIZONTALLY
451
	 * </p>
452
	 * 
453
	 * @return a {@link org.eclipse.ui.forms.widgets.TableWrapData} object.
454
	 */
455
	public static final TableWrapData FILL_HORIZONTALLY() {
456
		return FILL_HORIZONTALLY(1, 1);
457
	}
458

    
459
	/**
460
	 * <p>
461
	 * FILL_HORIZONTALLY
462
	 * </p>
463
	 * 
464
	 * @param horizontalSpan
465
	 *            a int.
466
	 * @param verticalSpan
467
	 *            a int.
468
	 * @return a {@link org.eclipse.ui.forms.widgets.TableWrapData} object.
469
	 */
470
	public static final TableWrapData FILL_HORIZONTALLY(int horizontalSpan,
471
			int verticalSpan) {
472
		TableWrapData layoutData = new TableWrapData(TableWrapData.FILL_GRAB,
473
				TableWrapData.TOP);
474
		layoutData.colspan = horizontalSpan;
475
		layoutData.rowspan = verticalSpan;
476
		return layoutData;
477
	}
478

    
479
	/** Constant <code>EMPTY_SELECTION</code> */
480
	public static ISelection EMPTY_SELECTION = new ISelection() {
481
		@Override
482
		public boolean isEmpty() {
483
			return true;
484
		}
485
	};
486

    
487
	private class SelectionMouseHandler extends MouseAdapter {
488
		@Override
489
		public void mouseDown(MouseEvent e) {
490
			notifySelectionListeners(e);
491
		}
492
	}
493

    
494
	private class SelectionFocusHandler extends FocusAdapter {
495
		@Override
496
		public void focusGained(FocusEvent e) {
497
			notifySelectionListeners(e);
498
		}
499
	}
500

    
501
	private void notifySelectionListeners(TypedEvent e) {
502
		Event event = new Event();
503
		event.widget = e.widget;
504
		SelectionEvent selectionEvent = new SelectionEvent(event);
505

    
506
		for (Object listener : selectionListenerList) {
507
			((SelectionListener) listener).widgetSelected(selectionEvent);
508
		}
509
	}
510

    
511
	protected CdmFormFactoryFacade(){
512
		super(DisplayProxy.getDefault());
513
	}
514

    
515

    
516
	/**
517
	 * <p>
518
	 * Constructor for CdmFormFactory.
519
	 * </p>
520
	 * 
521
	 * @param display
522
	 *            a {@link org.eclipse.swt.widgets.Display} object.
523
	 * @param selectionProvider
524
	 *            a {@link org.eclipse.jface.viewers.ISelectionProvider} object.
525
	 */
526
	protected CdmFormFactoryFacade(Display display, ISelectionProvider selectionProvider) {
527
		super(display);
528
		this.selectionProvider = selectionProvider;
529
		init();
530
	}
531

    
532
	public static CdmFormFactoryFacade getInstance(Display display, ISelectionProvider selectionProvider)
533
	{
534
		return (CdmFormFactoryFacade)IMPL.getInstanceInternal(display,selectionProvider);
535
	}
536
	
537
	protected abstract Object getInstanceInternal(Display display, ISelectionProvider selectionProvider);
538

    
539
	/**
540
	 * <p>
541
	 * Constructor for CdmFormFactory.
542
	 * </p>
543
	 * 
544
	 * @param display
545
	 *            a {@link org.eclipse.swt.widgets.Display} object.
546
	 */
547
	protected CdmFormFactoryFacade(Display display) {
548
		super(display);
549
		init();
550
	}
551

    
552
	public static CdmFormFactoryFacade getInstance(Display display)
553
	{
554
		return (CdmFormFactoryFacade)IMPL.getInstanceInternal(display);
555
	}
556

    
557
	protected abstract Object getInstanceInternal(Display display);
558

    
559
	/**
560
	 * 
561
	 */
562
	private void init() {
563
		boldFontHolder2 = new BoldFontHolder2();
564
		selectionMouseHandler = new SelectionMouseHandler();
565
		selectionFocusHandler = new SelectionFocusHandler();
566
	}
567

    
568
	/**
569
	 * Creates an instance initialized with the correct selectionProvider
570
	 * 
571
	 * Make sure to remove the instance when the entityComposite disposes via
572
	 * destroySelectionArbitrator(..)
573
	 * 
574
	 * @param entityElement
575
	 *            a {@link eu.etaxonomy.taxeditor.ui.forms.IEntityElement}
576
	 *            object.
577
	 * @return a {@link eu.etaxonomy.taxeditor.ui.forms.SelectionArbitrator}
578
	 *         object.
579
	 */
580
	public SelectionArbitrator createSelectionArbitrator(
581
			IEntityElement entityElement) {
582
		SelectionArbitrator selectionArbitrator = new SelectionArbitrator(
583
				entityElement);
584
		selectionArbitrator.addSelectionProvider(selectionProvider);
585
		selectionProvider.addSelectionChangedListener(selectionArbitrator);
586
		addSelectionListener(selectionArbitrator);
587
		return selectionArbitrator;
588
	}
589

    
590
	/**
591
	 * <p>
592
	 * destroySelectionArbitrator
593
	 * </p>
594
	 * 
595
	 * @param selectionArbitrator
596
	 *            a {@link eu.etaxonomy.taxeditor.ui.forms.SelectionArbitrator}
597
	 *            object.
598
	 */
599
	public void destroySelectionArbitrator(
600
			SelectionArbitrator selectionArbitrator) {
601
		removeSelectionListener(selectionArbitrator);
602
		if (selectionProvider != null) {
603
			selectionProvider
604
					.removeSelectionChangedListener(selectionArbitrator);
605
		} else {
606
			StoreUtil
607
					.error(this.getClass(),
608
							"Tried to destroy a selection listener from this factories listeners but was null",
609
							null);
610
		}
611
	}
612

    
613
	/** {@inheritDoc} */
614
	@Override
615
	public void adapt(Composite composite) {
616
		composite.addMouseListener(selectionMouseHandler);
617
		super.adapt(composite);
618
	}
619

    
620
	/**
621
	 * <p>
622
	 * adapt
623
	 * </p>
624
	 * 
625
	 * @param formElement
626
	 *            a
627
	 *            {@link eu.etaxonomy.taxeditor.ui.forms.AbstractCdmFormElement}
628
	 *            object.
629
	 */
630
	public void adapt(AbstractCdmFormElement formElement) {
631
		formElement.setPropertyChangeListeners(propertyChangeListeners);
632
	}
633

    
634
	/** {@inheritDoc} */
635
	@Override
636
	public void adapt(Control control, boolean trackFocus, boolean trackKeyboard) {
637
		if (trackFocus) {
638
			control.addFocusListener(selectionFocusHandler);
639
		}
640
		super.adapt(control, trackFocus, trackKeyboard);
641
	}
642

    
643
	/**
644
	 * <p>
645
	 * destroyElement
646
	 * </p>
647
	 * 
648
	 * @param formElement
649
	 *            a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement}
650
	 *            object.
651
	 */
652
	public void destroyElement(ICdmFormElement formElement) {
653
		// return if element was not initialized
654
		if (formElement == null) {
655
			return;
656
		}
657
		// destroy selection arbitrator, if any
658
		if (formElement instanceof ISelectableElement) {
659
			destroySelectionArbitrator(((ISelectableElement) formElement)
660
					.getSelectionArbitrator());
661
		}
662
		// remove this element form its parents list of elements
663
		// ICdmFormElement parentElement = formElement.getParentElement();
664
		// if(parentElement != null){
665
		// parentElement.removeElement(formElement);
666
		// }
667
		// call destroy on child elements recursively
668
		for (ICdmFormElement childElement : formElement.getElements()) {
669
			destroyElement(childElement);
670
		}
671
		// dispose of the controls
672
		for (Control control : formElement.getControls()) {
673
			// we added the layoutComposite of the parental element as the
674
			// layout composite to this formElement
675
			// but we do not want to destroy it.
676
			if (control.equals(formElement.getLayoutComposite())) {
677
				continue;
678
			} else {
679
				control.dispose();
680
				control = null;
681
			}
682
		}
683
	}
684

    
685
	/**
686
	 * <p>
687
	 * createEmptyCell
688
	 * </p>
689
	 * 
690
	 * @param parent
691
	 *            a {@link org.eclipse.swt.widgets.Composite} object.
692
	 * @return a {@link org.eclipse.swt.widgets.Label} object.
693
	 */
694
	public Label createEmptyCell(Composite parent) {
695
		return this.createLabel(parent, null);
696
	}
697

    
698
	/**
699
	 * <p>
700
	 * createMultilineTextWithLabel
701
	 * </p>
702
	 * 
703
	 * @param labelString
704
	 *            a {@link java.lang.String} object.
705
	 * @param textHeight
706
	 *            a int.
707
	 * @param style
708
	 *            a int.
709
	 * @param parentElement
710
	 *            a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement}
711
	 *            object.
712
	 * @return a {@link eu.etaxonomy.taxeditor.ui.forms.TextWithLabelElementFacade}
713
	 *         object.
714
	 */
715
	public TextWithLabelElementFacade createMultilineTextWithLabel(
716
			ICdmFormElement parentElement, String labelString, int textHeight,
717
			int style) {
718
		TextWithLabelElementFacade element = TextWithLabelElementFacade.getInstance(this,
719
				parentElement, labelString, "", textHeight, style);
720
		adapt(element);
721
		parentElement.addElement(element);
722
		return element;
723
	}
724

    
725
	/**
726
	 * <p>
727
	 * createMultiLanguageTextElement
728
	 * </p>
729
	 * 
730
	 * @param parentElement
731
	 *            a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement}
732
	 *            object.
733
	 * @param labelString
734
	 *            a {@link java.lang.String} object.
735
	 * @param multilanguageText
736
	 *            a {@link java.util.Map} object.
737
	 * @param textHeight
738
	 *            a int.
739
	 * @param style
740
	 *            a int.
741
	 * @return a
742
	 *         {@link eu.etaxonomy.taxeditor.ui.forms.MultilanguageTextElement}
743
	 *         object.
744
	 */
745
	public MultilanguageTextElement createMultiLanguageTextElement(
746
			ICdmFormElement parentElement, String labelString,
747
			Map<Language, LanguageString> multilanguageText, int textHeight,
748
			int style) {
749
		MultilanguageTextElement element = new MultilanguageTextElement(this,
750
				parentElement, labelString, multilanguageText, textHeight,
751
				style);
752
		adapt(element);
753
		parentElement.addElement(element);
754
		return element;
755
	}
756

    
757
	public KeyStatementElement createKeyStatementElement(
758
			ICdmFormElement parentElement, String labelString,
759
			KeyStatement keyStatement, int textHeight, int style) {
760
		KeyStatementElement element = new KeyStatementElement(this,
761
				parentElement, labelString, keyStatement, textHeight, style);
762
		adapt(element);
763
		parentElement.addElement(element);
764
		return element;
765
	}
766

    
767
	/**
768
	 * <p>
769
	 * createTextWithLabelElement
770
	 * </p>
771
	 * 
772
	 * @param labelString
773
	 *            a {@link java.lang.String} object.
774
	 * @param initialText
775
	 *            a {@link java.lang.String} object.
776
	 * @param style
777
	 *            a int.
778
	 * @param parentElement
779
	 *            a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement}
780
	 *            object.
781
	 * @return a {@link eu.etaxonomy.taxeditor.ui.forms.TextWithLabelElementFacade}
782
	 *         object.
783
	 */
784
	public TextWithLabelElementFacade createTextWithLabelElement(
785
			ICdmFormElement parentElement, String labelString,
786
			String initialText, int style) {
787
		TextWithLabelElementFacade element = TextWithLabelElementFacade.getInstance(this,
788
				parentElement, labelString, initialText, null, style);
789
		adapt(element);
790
		parentElement.addElement(element);
791
		return element;
792
	}
793

    
794
	public UriWithLabelElementFacade createUriWithLabelElement(
795
			ICdmFormElement parentElement, String labelString, URI initialUri,
796
			int style) {
797
		UriWithLabelElementFacade element = UriWithLabelElementFacade.getInstance(this,
798
				parentElement, labelString, initialUri, null, style);
799
		
800
		adapt(element);
801
		parentElement.addElement(element);
802
		return element;
803
	}
804

    
805
	/**
806
	 * @param element
807
	 * @param string
808
	 * @param uri
809
	 * @param style
810
	 * @return
811
	 */
812
	public OpenUrlSelectorElement createOpenUrlSelectorElement(
813
			ICdmFormElement parentElement, String labelString,
814
			IOpenUrlEnabled openUrlEnabled, int style) {
815
		OpenUrlSelectorElement element = new OpenUrlSelectorElement(this,
816
				parentElement, labelString, openUrlEnabled, style);
817
		adapt(element);
818
		parentElement.addElement(element);
819
		return element;
820
	}
821

    
822
	/**
823
	 * 
824
	 * @param parentElement
825
	 * @param labelString
826
	 * @param conversationEnabled
827
	 * @param user
828
	 * @param style
829
	 * @return
830
	 */
831
	public EditPasswordElement createEditPasswordElement(
832
			ICdmFormElement parentElement, String labelString,
833
			ConversationHolder conversation, User user, int style) {
834
		EditPasswordElement element = new EditPasswordElement(this,
835
				parentElement, labelString, user, conversation);
836
		adapt(element);
837
		parentElement.addElement(element);
838
		return element;
839
	}
840

    
841
	/**
842
	 * <p>
843
	 * createIntegerTextWithLabelElement
844
	 * </p>
845
	 * 
846
	 * @param parentElement
847
	 *            a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement}
848
	 *            object.
849
	 * @param labelString
850
	 *            a {@link java.lang.String} object.
851
	 * @param initialInteger
852
	 *            a {@link java.lang.Integer} object.
853
	 * @param style
854
	 *            a int.
855
	 * @return a {@link eu.etaxonomy.taxeditor.ui.forms.NumberWithLabelElementFacade}
856
	 *         object.
857
	 */
858
	public NumberWithLabelElementFacade createIntegerTextWithLabelElement(
859
			ICdmFormElement parentElement, String labelString,
860
			Integer initialInteger, int style) {
861
		NumberWithLabelElementFacade element = NumberWithLabelElementFacade.getInstance(this,
862
				parentElement, labelString, initialInteger, style);
863
		adapt(element);
864
		parentElement.addElement(element);
865
		return element;
866
	}
867

    
868
	/**
869
	 * <p>
870
	 * createFloatTextWithLabelElement
871
	 * </p>
872
	 * 
873
	 * @param parentElement
874
	 *            a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement}
875
	 *            object.
876
	 * @param labelString
877
	 *            a {@link java.lang.String} object.
878
	 * @param initialFloat
879
	 *            a float.
880
	 * @param style
881
	 *            a int.
882
	 * @return a {@link eu.etaxonomy.taxeditor.ui.forms.NumberWithLabelElementFacade}
883
	 *         object.
884
	 */
885
	public NumberWithLabelElementFacade createFloatTextWithLabelElement(
886
			ICdmFormElement parentElement, String labelString,
887
			float initialFloat, int style) {
888
		NumberWithLabelElementFacade element = NumberWithLabelElementFacade.getInstance(this,
889
				parentElement, labelString, initialFloat, style);
890
		adapt(element);
891
		parentElement.addElement(element);
892
		return element;
893
	}
894

    
895
	/**
896
	 * <p>
897
	 * createLanguageStringWithLabelElement
898
	 * </p>
899
	 * 
900
	 * @param parentElement
901
	 *            a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement}
902
	 *            object.
903
	 * @param labelString
904
	 *            a {@link java.lang.String} object.
905
	 * @param languageString
906
	 *            a {@link eu.etaxonomy.cdm.model.common.LanguageString} object.
907
	 * @param style
908
	 *            a int.
909
	 * @return a
910
	 *         {@link eu.etaxonomy.taxeditor.ui.forms.LanguageStringWithLabelElementFacade}
911
	 *         object.
912
	 */
913
	public LanguageStringWithLabelElementFacade createLanguageStringWithLabelElement(
914
			ICdmFormElement parentElement, String labelString,
915
			LanguageString languageString, int style) {
916
		LanguageStringWithLabelElementFacade element = LanguageStringWithLabelElementFacade.getInstance(
917
				this, parentElement, labelString, languageString, style);
918
		adapt(element);
919
		parentElement.addElement(element);
920
		return element;
921
	}
922

    
923
	/**
924
	 * <p>
925
	 * createLanguageStringWithLabelElement
926
	 * </p>
927
	 * 
928
	 * @param parentElement
929
	 *            a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement}
930
	 *            object.
931
	 * @param labelString
932
	 *            a {@link java.lang.String} object.
933
	 * @param languageString
934
	 *            a {@link eu.etaxonomy.cdm.model.common.LanguageString} object.
935
	 * @param height
936
	 *            a int.
937
	 * @param style
938
	 *            a int.
939
	 * @return a
940
	 *         {@link eu.etaxonomy.taxeditor.ui.forms.LanguageStringWithLabelElementFacade}
941
	 *         object.
942
	 */
943
	public LanguageStringWithLabelElementFacade createLanguageStringWithLabelElement(
944
			ICdmFormElement parentElement, String labelString,
945
			LanguageString languageString, int height, int style) {
946
		LanguageStringWithLabelElementFacade element = LanguageStringWithLabelElementFacade.getInstance(
947
				this, parentElement, labelString, languageString, height, style);
948
		adapt(element);
949
		parentElement.addElement(element);
950
		return element;
951
	}
952

    
953
	/**
954
	 * <p>
955
	 * createTextElement
956
	 * </p>
957
	 * 
958
	 * @param parentElement
959
	 *            a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement}
960
	 *            object.
961
	 * @param initialText
962
	 *            a {@link java.lang.String} object.
963
	 * @param style
964
	 *            a int.
965
	 * @return a {@link eu.etaxonomy.taxeditor.ui.forms.TextWithLabelElementFacade}
966
	 *         object.
967
	 */
968
	public TextWithLabelElementFacade createTextElement(
969
			ICdmFormElement parentElement, String initialText, int style) {
970
		TextWithLabelElementFacade element = TextWithLabelElementFacade.getInstance(this,
971
				parentElement, null, initialText, null, style);
972
		adapt(element);
973
		parentElement.addElement(element);
974
		return element;
975
	}
976

    
977
	/**
978
	 * <p>
979
	 * createKeyValueViewerElement
980
	 * </p>
981
	 * 
982
	 * @param parentElement
983
	 *            a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement}
984
	 *            object.
985
	 * @param keyHeading
986
	 *            a {@link java.lang.String} object.
987
	 * @param valueHeading
988
	 *            a {@link java.lang.String} object.
989
	 * @param map
990
	 *            a {@link java.util.Map} object.
991
	 * @return a {@link eu.etaxonomy.taxeditor.ui.forms.KeyValueViewerElement}
992
	 *         object.
993
	 */
994
	public KeyValueViewerElement createKeyValueViewerElement(
995
			ICdmFormElement parentElement, String keyHeading,
996
			String valueHeading, Map<Object, Object> map) {
997
		KeyValueViewerElement element = new KeyValueViewerElement(this,
998
				parentElement, keyHeading, valueHeading, map);
999
		adapt(element);
1000
		parentElement.addElement(element);
1001
		return element;
1002
	}
1003

    
1004
	public static enum TermComboType {
1005
		EXTENSIONTYPE, LANGUAGE, MARKERTYPE, NOMENCLATURALSTATUSTYPE, RANK, RIGHTSTYPE, NAMERELATIONSHIP, NAMEDAREATYPE, PRESENCEABSENCESTATUS, ANNOTATIONTYPE, NAMETYPEDESIGNATIONSTATUS, SPECIMENTYPEDESIGNATIONSTATUS, SEX, STAGE, PRESERVATION_METHOD, MEASUREMENT_UNIT, STATE, MODIFIER, STATISTICAL_MEASURE, SCOPE, EMPTY, DETERMINATION_MODIFIER, REFERENCE_SYSTEM
1006
	}
1007

    
1008
	/**
1009
	 * <p>
1010
	 * createTermComboElement
1011
	 * </p>
1012
	 * 
1013
	 * @param termComboType
1014
	 *            a
1015
	 *            {@link eu.etaxonomy.taxeditor.singlesource.ui.forms.CdmFormFactoryFacade.TermComboType}
1016
	 *            object.
1017
	 * @param parentElement
1018
	 *            a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement}
1019
	 *            object.
1020
	 * @param labelString
1021
	 *            a {@link java.lang.String} object.
1022
	 * @param selection
1023
	 *            a {@link eu.etaxonomy.cdm.model.common.DefinedTermBase}
1024
	 *            object.
1025
	 * @param style
1026
	 *            a int.
1027
	 * @return a {@link eu.etaxonomy.taxeditor.ui.term.AbstractTermComboElement}
1028
	 *         object.
1029
	 */
1030
	public AbstractTermComboElement createTermComboElement(
1031
			TermComboType termComboType, ICdmFormElement parentElement,
1032
			String labelString, DefinedTermBase selection, int style) {
1033
		AbstractTermComboElement element = null;
1034

    
1035
		switch (termComboType) {
1036
		case EMPTY:
1037
			element = new EmptyComboElement<DefinedTermBase>(this,
1038
					parentElement, labelString, style);
1039
			break;
1040
		case EXTENSIONTYPE:
1041
			element = new ExtensionTypeComboElement(this, parentElement,
1042
					labelString, (ExtensionType) selection, style);
1043
			break;
1044
		case LANGUAGE:
1045
			element = new LanguageComboElement(this, parentElement,
1046
					labelString, (Language) selection, style);
1047
			break;
1048
		case MARKERTYPE:
1049
			element = new MarkerTypeComboElement(this, parentElement,
1050
					labelString, (MarkerType) selection, style);
1051
			break;
1052
		case NOMENCLATURALSTATUSTYPE:
1053
			element = new NomenclaturalStatusTypeComboElement(this,
1054
					parentElement, labelString,
1055
					(NomenclaturalStatusType) selection, style);
1056
			break;
1057
		case RANK:
1058
			element = new RankComboElement(this, parentElement, labelString,
1059
					(Rank) selection, style);
1060
			break;
1061
		case RIGHTSTYPE:
1062
			element = new RightsTypeComboElement(this, parentElement,
1063
					labelString, (RightsTerm) selection, style);
1064
			break;
1065
		case NAMERELATIONSHIP:
1066
			element = new NameRelationshipTypeComboElement(this, parentElement,
1067
					labelString, (NameRelationshipType) selection, style);
1068
			break;
1069
		case NAMEDAREATYPE:
1070
			element = new NamedAreaTypeComboElement(this, parentElement,
1071
					labelString, (NamedAreaType) selection, style);
1072
			break;
1073
		case ANNOTATIONTYPE:
1074
			element = new AnnotationTypeComboElement(this, parentElement,
1075
					labelString, (AnnotationType) selection, style);
1076
			break;
1077
		case PRESENCEABSENCESTATUS:
1078
			element = new PresenceAbsenceTermComboElement(this, parentElement,
1079
					labelString, (PresenceAbsenceTermBase) selection, style);
1080
			break;
1081
		case NAMETYPEDESIGNATIONSTATUS:
1082
			element = new NameTypeDesignationStatusComboElement(this,
1083
					parentElement, labelString,
1084
					(NameTypeDesignationStatus) selection, style);
1085
			break;
1086
		case SPECIMENTYPEDESIGNATIONSTATUS:
1087
			element = new SpecimenTypeDesignationStatusComboElement(this,
1088
					parentElement, labelString,
1089
					(SpecimenTypeDesignationStatus) selection, style);
1090
			break;
1091
		case SEX:
1092
			element = new SexComboElement(this, parentElement, labelString,
1093
					(Sex) selection, style);
1094
			break;
1095
		case STAGE:
1096
			element = new StageComboElement(this, parentElement, labelString,
1097
					(Stage) selection, style);
1098
			break;
1099
		case PRESERVATION_METHOD:
1100
			element = new PreservationMethodComboElement(this, parentElement,
1101
					labelString, (PreservationMethod) selection, style);
1102
			break;
1103
		case MEASUREMENT_UNIT:
1104
			element = new MeasurementUnitComboElement(this, parentElement,
1105
					labelString, (MeasurementUnit) selection, style);
1106
			break;
1107
		case STATE:
1108
			element = new StateComboElement(this, parentElement, labelString,
1109
					(State) selection, style);
1110
			break;
1111
		case SCOPE:
1112
			element = new ScopeComboElement(this, parentElement, labelString,
1113
					(Scope) selection, style);
1114
			break;
1115
		case MODIFIER:
1116
			element = new ModifierComboElement(this, parentElement,
1117
					labelString, (Modifier) selection, style);
1118
			break;
1119
		case STATISTICAL_MEASURE:
1120
			element = new StatisticalMeasureComboElement(this, parentElement,
1121
					labelString, (StatisticalMeasure) selection, style);
1122
			break;
1123
		case DETERMINATION_MODIFIER:
1124
			element = new DeterminationModifierComboElement(this,
1125
					parentElement, labelString,
1126
					(DeterminationModifier) selection, style);
1127
			break;
1128
		case REFERENCE_SYSTEM:
1129
			element = new ReferenceSystemComboElement(this, parentElement,
1130
					labelString, (ReferenceSystem) selection, style);
1131
			break;
1132
		}
1133

    
1134
		adapt(element);
1135
		parentElement.addElement(element);
1136
		return element;
1137
	}
1138

    
1139
	public static enum EnumComboType {
1140
		REFERENCETYPE, NOMENCLATURALCODE
1141
	}
1142

    
1143
	/**
1144
	 * <p>
1145
	 * createEnumComboElement
1146
	 * </p>
1147
	 * 
1148
	 * @param enumComboType
1149
	 *            a
1150
	 *            {@link eu.etaxonomy.taxeditor.singlesource.ui.forms.CdmFormFactoryFacade.EnumComboType}
1151
	 *            object.
1152
	 * @param parentElement
1153
	 *            a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement}
1154
	 *            object.
1155
	 * @param style
1156
	 *            a int.
1157
	 * @return a {@link eu.etaxonomy.taxeditor.ui.term.AbstractEnumComboElement}
1158
	 *         object.
1159
	 */
1160
	public AbstractEnumComboElement createEnumComboElement(
1161
			EnumComboType enumComboType, ICdmFormElement parentElement,
1162
			int style) {
1163
		AbstractEnumComboElement element = null;
1164

    
1165
		switch (enumComboType) {
1166
		case REFERENCETYPE:
1167
			element = new ReferenceTypeComboElement(this, parentElement,
1168
					"Reference Type", null, style);
1169
			break;
1170
		case NOMENCLATURALCODE:
1171
			element = new NomenclaturalCodeComboElement(this, parentElement,
1172
					"Nomenclatural Code", null, style);
1173
			break;
1174
		}
1175
		adapt(element);
1176
		parentElement.addElement(element);
1177
		return element;
1178
	}
1179

    
1180
	/**
1181
	 * <p>
1182
	 * createBrowserElement
1183
	 * </p>
1184
	 * 
1185
	 * @param imageUri
1186
	 *            a {@link java.net.URI} object.
1187
	 * @param style
1188
	 *            a int.
1189
	 * @param parentElement
1190
	 *            a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement}
1191
	 *            object.
1192
	 * @return a {@link eu.etaxonomy.taxeditor.ui.forms.BrowserElement} object.
1193
	 */
1194
	public BrowserElement createBrowserElement(ICdmFormElement parentElement,
1195
			URI imageUri, int style) {
1196
		BrowserElement element = new BrowserElement(this, parentElement,
1197
				imageUri, style);
1198
		adapt(element);
1199
		parentElement.addElement(element);
1200
		return element;
1201
	}
1202

    
1203
	/**
1204
	 * <p>
1205
	 * createImageElement
1206
	 * </p>
1207
	 * 
1208
	 * @param parentElement
1209
	 *            a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement}
1210
	 *            object.
1211
	 * @param imageUri
1212
	 *            a {@link java.net.URI} object.
1213
	 * @param style
1214
	 *            a int.
1215
	 * @return a {@link eu.etaxonomy.taxeditor.ui.forms.ImageElement} object.
1216
	 */
1217
	public ImageElement createImageElement(ICdmFormElement parentElement,
1218
			URI imageUri, int style) {
1219
		ImageElement element = new ImageElement(this, parentElement, imageUri,
1220
				style);
1221
		adapt(element);
1222
		parentElement.addElement(element);
1223
		return element;
1224
	}
1225

    
1226
	/**
1227
	 * <p>
1228
	 * createTextActionElement
1229
	 * </p>
1230
	 * 
1231
	 * @param labelString
1232
	 *            a {@link java.lang.String} object.
1233
	 * @param initialText
1234
	 *            a {@link java.lang.String} object.
1235
	 * @param style
1236
	 *            a int.
1237
	 * @param parentElement
1238
	 *            a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement}
1239
	 *            object.
1240
	 * @param buttonLabel
1241
	 *            a {@link java.lang.String} object.
1242
	 * @return a {@link eu.etaxonomy.taxeditor.ui.forms.TextActionElement}
1243
	 *         object.
1244
	 */
1245
	public TextActionElement createTextActionElement(
1246
			ICdmFormElement parentElement, String labelString,
1247
			String buttonLabel, String initialText, int style) {
1248
		TextActionElement element = new TextActionElement(this, parentElement,
1249
				labelString, buttonLabel, initialText, style);
1250
		adapt(element);
1251
		parentElement.addElement(element);
1252
		return element;
1253
	}
1254

    
1255
	/**
1256
	 * 
1257
	 * @author n.hoffmann
1258
	 * @created Mar 5, 2010
1259
	 * @version 1.0
1260
	 */
1261
	public static enum SelectionType {
1262
		AGENT, INSTITUTION, NAME, REFERENCE, TAXON_BASE, TAXON, SYNONYM, TEAM, AUTHOR_TEAM, PERSON, DERIVED_UNIT, FIELD_OBSERVATION, FEATURE_TREE, CLASSIFICATION, TAXON_NODE, COLLECTION, FEATURE, POLYTOMOUS_KEY, POLYTOMOUS_KEY_NODE, USER, GROUP
1263
	}
1264

    
1265
	/**
1266
	 * <p>
1267
	 * createCheckbox
1268
	 * </p>
1269
	 * 
1270
	 * @param parentElement
1271
	 *            a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement}
1272
	 *            object.
1273
	 * @param label
1274
	 *            a {@link java.lang.String} object.
1275
	 * @param initialState
1276
	 *            a boolean.
1277
	 * @param style
1278
	 *            a int.
1279
	 * @return a {@link eu.etaxonomy.taxeditor.ui.forms.CheckboxElement} object.
1280
	 */
1281
	public CheckboxElement createCheckbox(ICdmFormElement parentElement,
1282
			String label, boolean initialState, int style) {
1283
		CheckboxElement element = new CheckboxElement(this, parentElement,
1284
				label, initialState, style | orientation);
1285
		adapt(element);
1286
		parentElement.addElement(element);
1287
		return element;
1288
	}
1289

    
1290
	/**
1291
	 * Creates a section as a part of the form.
1292
	 * 
1293
	 * @return the section widget
1294
	 * @param section
1295
	 *            a {@link eu.etaxonomy.taxeditor.ui.forms.AbstractFormSection}
1296
	 *            object.
1297
	 */
1298
	public Section adapt(AbstractFormSection section) {
1299
		section.setMenu(section.getLayoutComposite().getMenu());
1300
		adapt(section, true, true);
1301

    
1302
		// handle focus and property change events for cdm use
1303
		section.addFocusListener(selectionFocusHandler);
1304
		section.setPropertyChangeListeners(propertyChangeListeners);
1305

    
1306
		if (section.getToggle() != null) {
1307
			section.getToggle().setHoverDecorationColor(
1308
					getColors().getColor(IFormColors.TB_TOGGLE_HOVER));
1309
			section.getToggle().setDecorationColor(
1310
					getColors().getColor(IFormColors.TB_TOGGLE));
1311
		}
1312

    
1313
		section.setFont(boldFontHolder2.getBoldFont(section
1314
				.getLayoutComposite().getFont()));
1315

    
1316
		if ((section.getStyle() & Section.TITLE_BAR) != 0
1317
				|| (section.getStyle() & Section.SHORT_TITLE_BAR) != 0) {
1318
			getColors().initializeSectionToolBarColors();
1319
			section.setTitleBarBackground(getColors().getColor(
1320
					IFormColors.TB_BG));
1321
			section.setTitleBarBorderColor(getColors().getColor(
1322
					IFormColors.TB_BORDER));
1323
		}
1324
		// call setTitleBarForeground regardless as it also sets the label color
1325
		section.setTitleBarForeground(getColors().getColor(
1326
				IFormColors.TB_TOGGLE));
1327
		return section;
1328
	}
1329
	
1330
	public void markFinished(Font font) {
1331
		IMPL.markFinishedInternal(font);
1332
	}
1333

    
1334
	protected abstract void markFinishedInternal(Font font);
1335
	
1336
	private class BoldFontHolder2 {
1337
		private Font normalFont;
1338

    
1339
		private Font boldFont;
1340

    
1341
		public BoldFontHolder2() {
1342
		}
1343

    
1344
		public Font getBoldFont(Font font) {
1345
			createBoldFont(font);
1346
			return boldFont;
1347
		}
1348

    
1349
		private void createBoldFont(Font font) {
1350
			if (normalFont == null || !normalFont.equals(font)) {
1351
				normalFont = font;
1352
				dispose();
1353
			}
1354
			if (boldFont == null) {
1355
				boldFont = FormFonts.getInstance().getBoldFont(
1356
						getColors().getDisplay(), normalFont);
1357
			}
1358
		}
1359

    
1360
		public void dispose() {
1361
			if (boldFont != null) {
1362
			/** RAPSS:Modify: Only one parameter required in Indigo				
1363
			FormFonts.getInstance().markFinished( boldFont, getColors().getDisplay());
1364
			 */						
1365
			/** RAPSS:Modify: Two parameter required in Helios				
1366
			FormFonts.getInstance().markFinished(boldFont);
1367
			*/
1368
			markFinished(boldFont);
1369
			boldFont = null;
1370
			}
1371
		}
1372
	}
1373

    
1374
	/**
1375
	 * <p>
1376
	 * createToggleableTextField
1377
	 * </p>
1378
	 * 
1379
	 * @param parentElement
1380
	 *            a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement}
1381
	 *            object.
1382
	 * @param labelString
1383
	 *            a {@link java.lang.String} object.
1384
	 * @param initialText
1385
	 *            a {@link java.lang.String} object.
1386
	 * @param initialState
1387
	 *            a boolean.
1388
	 * @param style
1389
	 *            a int.
1390
	 * @return a {@link eu.etaxonomy.taxeditor.ui.forms.ToggleableTextElement}
1391
	 *         object.
1392
	 */
1393
	public ToggleableTextElement createToggleableTextField(
1394
			ICdmFormElement parentElement, String labelString,
1395
			String initialText, boolean initialState, int style) {
1396
		ToggleableTextElement element = new ToggleableTextElement(this,
1397
				parentElement, labelString, initialText, initialState, style
1398
						| orientation);
1399
		adapt(element);
1400
		parentElement.addElement(element);
1401
		return element;
1402
	}
1403

    
1404
	/**
1405
	 * <p>
1406
	 * createTimePeriodElement
1407
	 * </p>
1408
	 * 
1409
	 * @param parentElement
1410
	 *            a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement}
1411
	 *            object.
1412
	 * @param labelString
1413
	 *            a {@link java.lang.String} object.
1414
	 * @param timePeriod
1415
	 *            a {@link eu.etaxonomy.cdm.model.common.TimePeriod} object.
1416
	 * @param style
1417
	 *            a int.
1418
	 * @return a {@link eu.etaxonomy.taxeditor.ui.forms.TimePeriodElement}
1419
	 *         object.
1420
	 */
1421
	public TimePeriodElement createTimePeriodElement(
1422
			ICdmFormElement parentElement, String labelString,
1423
			TimePeriod timePeriod, int style) {
1424
		TimePeriodElement element = new TimePeriodElement(this, parentElement,
1425
				labelString, timePeriod, style);
1426
		adapt(element);
1427
		parentElement.addElement(element);
1428
		return element;
1429
	}
1430

    
1431
	/**
1432
	 * <p>
1433
	 * createPointElement
1434
	 * </p>
1435
	 * 
1436
	 * @param style
1437
	 *            a int.
1438
	 * @param parentElement
1439
	 *            a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement}
1440
	 *            object.
1441
	 * @param point
1442
	 *            a {@link eu.etaxonomy.cdm.model.location.Point} object.
1443
	 * @return a {@link eu.etaxonomy.taxeditor.ui.forms.PointElement} object.
1444
	 */
1445
	public PointElement createPointElement(ICdmFormElement parentElement,
1446
			Point point, int style) {
1447
		PointElement element = new PointElement(this, parentElement, point,
1448
				style);
1449
		adapt(element);
1450
		parentElement.addElement(element);
1451
		return element;
1452
	}
1453

    
1454
	/**
1455
	 * <p>
1456
	 * createDateDetailSection
1457
	 * </p>
1458
	 * 
1459
	 * @param parentElement
1460
	 *            a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement}
1461
	 *            object.
1462
	 * @param style
1463
	 *            a int.
1464
	 * @return a {@link eu.etaxonomy.taxeditor.ui.forms.DateDetailSection}
1465
	 *         object.
1466
	 */
1467
	public DateDetailSection createDateDetailSection(
1468
			ICdmFormElement parentElement, int style) {
1469
		DateDetailSection section = new DateDetailSection(this, parentElement,
1470
				style);
1471
		parentElement.addElement(section);
1472
		adapt(section);
1473
		return section;
1474
	}
1475

    
1476
	/**
1477
	 * <p>
1478
	 * createPartialElement
1479
	 * </p>
1480
	 * 
1481
	 * @param parentElement
1482
	 *            a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement}
1483
	 *            object.
1484
	 * @param labelString
1485
	 *            a {@link java.lang.String} object.
1486
	 * @param partial
1487
	 *            a {@link org.joda.time.Partial} object.
1488
	 * @param style
1489
	 *            a int.
1490
	 * @return a {@link eu.etaxonomy.taxeditor.ui.forms.PartialElement} object.
1491
	 */
1492
	public PartialElement createPartialElement(ICdmFormElement parentElement,
1493
			String labelString, Partial partial, int style) {
1494
		PartialElement element = new PartialElement(this, parentElement,
1495
				labelString, style);
1496
		adapt(element);
1497
		parentElement.addElement(element);
1498
		return element;
1499
	}
1500

    
1501
	/**
1502
	 * <p>
1503
	 * addSelectionListener
1504
	 * </p>
1505
	 * 
1506
	 * @param listener
1507
	 *            a {@link org.eclipse.swt.events.SelectionListener} object.
1508
	 */
1509
	public void addSelectionListener(SelectionListener listener) {
1510
		selectionListenerList.add(listener);
1511
	}
1512

    
1513
	/**
1514
	 * <p>
1515
	 * removeSelectionListener
1516
	 * </p>
1517
	 * 
1518
	 * @param listener
1519
	 *            a {@link org.eclipse.swt.events.SelectionListener} object.
1520
	 */
1521
	public void removeSelectionListener(SelectionListener listener) {
1522
		if (listener == null) {
1523
			StoreUtil
1524
					.error(this.getClass(),
1525
							"Tried to remove a selection listener from this factories listeners but was null",
1526
							null);
1527
		} else {
1528
			selectionListenerList.remove(listener);
1529
		}
1530
	}
1531

    
1532
	/**
1533
	 * <p>
1534
	 * addPropertyChangeListener
1535
	 * </p>
1536
	 * 
1537
	 * @param listener
1538
	 *            a {@link org.eclipse.jface.util.IPropertyChangeListener}
1539
	 *            object.
1540
	 */
1541
	public void addPropertyChangeListener(IPropertyChangeListener listener) {
1542
		if(propertyChangeListeners.contains(listener)){
1543
			return;
1544
		}
1545
		propertyChangeListeners.add(0, listener);
1546
	}
1547

    
1548
	/**
1549
	 * <p>
1550
	 * removePropertyChangeListener
1551
	 * </p>
1552
	 * 
1553
	 * @param listener
1554
	 *            a {@link org.eclipse.jface.util.IPropertyChangeListener}
1555
	 *            object.
1556
	 */
1557
	public void removePropertyChangeListener(IPropertyChangeListener listener) {
1558
		propertyChangeListeners.remove(listener);
1559
	}
1560

    
1561
	/**
1562
	 * <p>
1563
	 * createHorizontalSeparator
1564
	 * </p>
1565
	 * 
1566
	 * @param parentElement
1567
	 *            a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement}
1568
	 *            object.
1569
	 * @param style
1570
	 *            a int.
1571
	 * @return a {@link org.eclipse.swt.widgets.Label} object.
1572
	 */
1573
	public Label createHorizontalSeparator(ICdmFormElement parentElement,
1574
			int style) {
1575
		Label separator = this.createSeparator(
1576
				parentElement.getLayoutComposite(), SWT.HORIZONTAL | style);
1577
		separator.setLayoutData(FILL_HORIZONTALLY());
1578
		return separator;
1579
	}
1580

    
1581
	/**
1582
	 * <p>
1583
	 * createVersionElement
1584
	 * </p>
1585
	 * 
1586
	 * @param parentElement
1587
	 *            a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement}
1588
	 *            object.
1589
	 * @param entity
1590
	 *            a {@link eu.etaxonomy.cdm.model.common.VersionableEntity}
1591
	 *            object.
1592
	 * @param style
1593
	 *            a int.
1594
	 * @return a
1595
	 *         {@link eu.etaxonomy.taxeditor.ui.section.supplemental.VersionElement}
1596
	 *         object.
1597
	 */
1598
	public VersionElement createVersionElement(ICdmFormElement parentElement,
1599
			VersionableEntity entity, int style) {
1600
		VersionElement element = new VersionElement(this, parentElement,
1601
				entity, style);
1602
		adapt(element);
1603
		parentElement.addElement(element);
1604
		return element;
1605
	}
1606

    
1607
	/**
1608
	 * <p>
1609
	 * createVersionSection
1610
	 * </p>
1611
	 * 
1612
	 * @param parentElement
1613
	 *            a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement}
1614
	 *            object.
1615
	 * @param style
1616
	 *            a int.
1617
	 * @return a
1618
	 *         {@link eu.etaxonomy.taxeditor.ui.section.supplemental.VersionSection}
1619
	 *         object.
1620
	 */
1621
	public VersionSection createVersionSection(ICdmFormElement parentElement,
1622
			int style) {
1623
		VersionSection section = new VersionSection(this, parentElement, style);
1624
		parentElement.addElement(section);
1625
		adapt(section);
1626
		return section;
1627
	}
1628

    
1629
	/**
1630
	 * <p>
1631
	 * createEmptyElement
1632
	 * </p>
1633
	 * 
1634
	 * @param parentElement
1635
	 *            a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement}
1636
	 *            object.
1637
	 * @return a {@link eu.etaxonomy.taxeditor.ui.section.EmptyElement} object.
1638
	 */
1639
	public EmptyElement createEmptyElement(ICdmFormElement parentElement) {
1640
		EmptyElement element = new EmptyElement(this, parentElement, null,
1641
				SWT.NULL);
1642
		adapt(element);
1643
		parentElement.addElement(element);
1644
		return element;
1645
	}
1646

    
1647
	/**
1648
	 * <p>
1649
	 * createHeadlineSection
1650
	 * </p>
1651
	 * 
1652
	 * @param parentElement
1653
	 *            a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement}
1654
	 *            object.
1655
	 * @return a
1656
	 *         {@link eu.etaxonomy.taxeditor.ui.section.supplemental.HeadlineSection}
1657
	 *         object.
1658
	 */
1659
	public HeadlineSection createHeadlineSection(ICdmFormElement parentElement) {
1660
		HeadlineSection section = new HeadlineSection(this, parentElement,
1661
				SWT.NULL);
1662
		parentElement.addElement(section);
1663
		adapt(section);
1664
		return section;
1665
	}
1666

    
1667
	/**
1668
	 * <p>
1669
	 * createParsingMessageElement
1670
	 * </p>
1671
	 * 
1672
	 * @param parentElement
1673
	 *            a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement}
1674
	 *            object.
1675
	 * @param parserProblem
1676
	 *            a {@link eu.etaxonomy.cdm.strategy.parser.ParserProblem}
1677
	 *            object.
1678
	 * @param style
1679
	 *            a int.
1680
	 * @return a
1681
	 *         {@link eu.etaxonomy.taxeditor.ui.section.taxon.ParsingMessageElement}
1682
	 *         object.
1683
	 */
1684
	public ParsingMessageElement createParsingMessageElement(
1685
			ICdmFormElement parentElement, ParserProblem parserProblem,
1686
			int style) {
1687
		ParsingMessageElement element = new ParsingMessageElement(this,
1688
				parentElement, parserProblem, style);
1689
		adapt(element);
1690
		parentElement.addElement(element);
1691
		return element;
1692
	}
1693

    
1694
	// SIMPLIFY
1695

    
1696
	/**
1697
	 * 
1698
	 */
1699
	public static enum DetailType {
1700
		NONVIRALNAME, 
1701
		SCIENTIFICNAME, 
1702
		REFERENCEBASE, 
1703
		NOMENCLATURALREFERENCE, 
1704
		TAXONBASE, 
1705
		AUTHORSHIP, 
1706
		TEAM, 
1707
		PERSON, 
1708
		DESCRIPTION, 
1709
		DESCRIPTIONELEMENT, 
1710
		PARSINGMESSAGE, 
1711
		NAMERELATIONSHIP, 
1712
		TEAMORPERSONBASE, 
1713
		MEDIA, 
1714
		FIELD_OBSERVATION, 
1715
		DERIVED_UNIT_FACADE, 
1716
		GATHERING_EVENT, 
1717
		DERIVED_UNIT, 
1718
		NATURAL_LANGUAGE, 
1719
		FEATURE_DISTRIBUTION, 
1720
		CLASSIFICATION, 
1721
		TAXON_NODE, 
1722
		COLLECTION, 
1723
		POLYTOMOUS_KEY, 
1724
		POLYTOMOUS_KEY_NODE, 
1725
		INSTITUTION, 
1726
		DERIVED_UNIT_GENERAL, 
1727
		HYBRID, 
1728
		USER, 
1729
		GROUP, 
1730
		DETERMINATION
1731
	}
1732

    
1733
	/**
1734
	 * <p>
1735
	 * createCdmDetailSection
1736
	 * </p>
1737
	 * 
1738
	 * @param detailType
1739
	 *            a
1740
	 *            {@link eu.etaxonomy.taxeditor.singlesource.ui.forms.CdmFormFactoryFacade.DetailType}
1741
	 *            object.
1742
	 * @param parentElement
1743
	 *            a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement}
1744
	 *            object.
1745
	 * @param selectionProvider
1746
	 *            a {@link org.eclipse.jface.viewers.ISelectionProvider} object.
1747
	 * @param style
1748
	 *            a int.
1749
	 * @param conversation
1750
	 *            a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder}
1751
	 *            object.
1752
	 * @return a {@link eu.etaxonomy.taxeditor.ui.forms.AbstractFormSection}
1753
	 *         object.
1754
	 */
1755
	public AbstractFormSection createCdmDetailSection(DetailType detailType,
1756
			ConversationHolder conversation, ICdmFormElement parentElement,
1757
			ISelectionProvider selectionProvider, int style) {
1758
		AbstractFormSection section = null;
1759

    
1760
		switch (detailType) {
1761
		case SCIENTIFICNAME:
1762
			section = new NameDetailSection(this, conversation, parentElement,
1763
					selectionProvider, style);
1764
			break;
1765
		case REFERENCEBASE:
1766
			section = new ReferenceDetailSection(this, conversation,
1767
					parentElement, selectionProvider, style);
1768
			break;
1769
		case NOMENCLATURALREFERENCE:
1770
			section = new NomenclaturalReferenceDetailSection(this,
1771
					conversation, parentElement, selectionProvider, style);
1772
			break;
1773
		case TAXONBASE:
1774
			section = new TaxonBaseDetailSection(this, conversation,
1775
					parentElement, selectionProvider, style);
1776
			break;
1777
		case AUTHORSHIP:
1778
			section = new AuthorshipDetailSection(this, conversation,
1779
					parentElement, selectionProvider, style);
1780
			break;
1781
		case TEAMORPERSONBASE:
1782
			section = new TeamOrPersonBaseDetailSection(this, conversation,
1783
					parentElement, selectionProvider, style);
1784
			break;
1785
		case TEAM:
1786
			section = new TeamDetailSection(this, conversation, parentElement,
1787
					null, style);
1788
			break;
1789
		case PERSON:
1790
			section = new PersonDetailSection(this, conversation,
1791
					parentElement, null, style);
1792
			break;
1793
		case DESCRIPTION:
1794
			section = new DescriptionDetailSection(this, conversation,
1795
					parentElement, selectionProvider, style);
1796
			break;
1797
		case DESCRIPTIONELEMENT:
1798
			section = new DescriptionElementDetailSection(this, conversation,
1799
					parentElement, selectionProvider, style);
1800
			break;
1801
		case PARSINGMESSAGE:
1802
			section = new ParsingMessagesSection(this, conversation,
1803
					parentElement, selectionProvider, style);
1804
			break;
1805
		case NONVIRALNAME:
1806
			section = new NonViralNameDetailSection(this, conversation,
1807
					parentElement, selectionProvider, style);
1808
			break;
1809
		case MEDIA:
1810
			section = new eu.etaxonomy.taxeditor.ui.section.description.MediaDetailsSection(
1811
					this, conversation, parentElement, selectionProvider, style);
1812
			break;
1813
		case DERIVED_UNIT_FACADE:
1814
			section = new DerivedUnitFacadeDetailSection(this, conversation,
1815
					parentElement, selectionProvider, style);
1816
			break;
1817
		case FIELD_OBSERVATION:
1818
			section = new FieldObservationDetailSection(this, conversation,
1819
					parentElement, selectionProvider, style);
1820
			break;
1821
		case GATHERING_EVENT:
1822
			section = new GatheringEventDetailSection(this, conversation,
1823
					parentElement, selectionProvider, style);
1824
			break;
1825
		case DERIVED_UNIT:
1826
			section = new DerivedUnitBaseDetailSection(this, conversation,
1827
					parentElement, selectionProvider, style);
1828
			break;
1829
		case NATURAL_LANGUAGE:
1830
			section = new NaturalLanguageSection(this, conversation,
1831
					parentElement, selectionProvider, style);
1832
			break;
1833
		case FEATURE_DISTRIBUTION:
1834
			section = new FeatureDistributionDetailSection(this, conversation,
1835
					parentElement, selectionProvider, style);
1836
			break;
1837
		case CLASSIFICATION:
1838
			section = new ClassificationDetailSection(this, conversation,
1839
					parentElement, selectionProvider, style);
1840
			break;
1841
		case TAXON_NODE:
1842
			section = new TaxonNodeDetailSection(this, conversation,
1843
					parentElement, selectionProvider, style);
1844
			break;
1845
		case POLYTOMOUS_KEY:
1846
			section = new PolytomousKeyDetailSection(this, conversation,
1847
					parentElement, selectionProvider, style);
1848
			break;
1849
		case POLYTOMOUS_KEY_NODE:
1850
			section = new PolytomousKeyNodeDetailSection(this, conversation,
1851
					parentElement, selectionProvider, style);
1852
			break;
1853
		case INSTITUTION:
1854
			section = new InstitutionDetailSection(this, conversation,
1855
					parentElement, selectionProvider, style);
1856
			break;
1857
		case DERIVED_UNIT_GENERAL:
1858
			section = new GeneralDetailSection(this, conversation,
1859
					parentElement, selectionProvider, style);
1860
			break;
1861
		case HYBRID:
1862
			section = new HybridDetailSection(this, conversation,
1863
					parentElement, selectionProvider, style);
1864
			break;
1865
		case USER:
1866
			section = new UserDetailSection(this, conversation, parentElement,
1867
					selectionProvider, style);
1868
			break;
1869
		case GROUP:
1870
			section = new GroupDetailSection(this, conversation, parentElement,
1871
					selectionProvider, style);
1872
			break;
1873
		case DETERMINATION:
1874
			section = new DeterminationDetailSection(this, conversation, parentElement,
1875
					selectionProvider, style);
1876
		}
1877

    
1878
		if (section == null) {
1879
			throw new RuntimeException(
1880
					"You tried to create a cdm detail section that is not implemented yet.");
1881
		}
1882

    
1883
		parentElement.addElement(section);
1884
		adapt(section);
1885
		return section;
1886
	}
1887

    
1888
	/**
1889
	 * <p>
1890
	 * createCdmDetailElement
1891
	 * </p>
1892
	 * 
1893
	 * @param detailType
1894
	 *            a
1895
	 *            {@link eu.etaxonomy.taxeditor.singlesource.ui.forms.CdmFormFactoryFacade.DetailType}
1896
	 *            object.
1897
	 * @param style
1898
	 *            a int.
1899
	 * @param parentElement
1900
	 *            a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement}
1901
	 *            object.
1902
	 * @return a
1903
	 *         {@link eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement}
1904
	 *         object.
1905
	 */
1906
	public AbstractCdmDetailElement createCdmDetailElement(
1907
			DetailType detailType, ICdmFormElement parentElement, int style) {
1908
		AbstractCdmDetailElement element = null;
1909

    
1910
		switch (detailType) {
1911
		case SCIENTIFICNAME:
1912
			element = new NameDetailElement(this, parentElement, style);
1913
			break;
1914
		case REFERENCEBASE:
1915
			element = new ReferenceDetailElement(this, parentElement, style);
1916
			break;
1917
		case NOMENCLATURALREFERENCE:
1918
			element = new NomenclaturalReferenceDetailElement(this,
1919
					parentElement, style);
1920
			break;
1921
		case TAXONBASE:
1922
			element = new TaxonBaseDetailElement(this, parentElement, style);
1923
			break;
1924
		case AUTHORSHIP:
1925
			element = new AuthorshipDetailElement(this, parentElement, style);
1926
			break;
1927
		case TEAM:
1928
			element = new TeamDetailElement(this, parentElement, style);
1929
			break;
1930
		case PERSON:
1931
			element = new PersonDetailElement(this, parentElement, style);
1932
			break;
1933
		case DESCRIPTION:
1934
			element = new DescriptionDetailElement(this, parentElement, style);
1935
			break;
1936
		case DESCRIPTIONELEMENT:
1937
			element = new DescriptionElementDetailElement(this, parentElement,
1938
					style);
1939
			break;
1940
		case NONVIRALNAME:
1941
			element = new NonViralNameDetailElement(this, parentElement);
1942
			break;
1943
		case DERIVED_UNIT_FACADE:
1944
			element = new DerivedUnitFacadeDetailElement(this, parentElement);
1945
			break;
1946
		case FIELD_OBSERVATION:
1947
			element = new FieldObservationDetailElement(this, parentElement);
1948
			break;
1949
		case GATHERING_EVENT:
1950
			element = new GatheringEventDetailElement(this, parentElement);
1951
			break;
1952
		case DERIVED_UNIT:
1953
			element = new DerivedUnitBaseDetailElement(this, parentElement);
1954
			break;
1955
		case NATURAL_LANGUAGE:
1956
			element = new NaturalLanguageDetailElement(this, parentElement);
1957
			break;
1958
		case FEATURE_DISTRIBUTION:
1959
			element = new FeatureDistributionDetailElement(this, parentElement);
1960
			break;
1961
		case CLASSIFICATION:
1962
			element = new ClassificationDetailElement(this, parentElement);
1963
			break;
1964
		case TAXON_NODE:
1965
			element = new TaxonNodeDetailElement(this, parentElement);
1966
			break;
1967
		case COLLECTION:
1968
			element = new CollectionDetailElement(this, parentElement);
1969
			break;
1970
		case POLYTOMOUS_KEY:
1971
			element = new PolytomousKeyDetailElement(this, parentElement);
1972
			break;
1973
		case POLYTOMOUS_KEY_NODE:
1974
			element = new PolytomousKeyNodeDetailElement(this, parentElement);
1975
			break;
1976
		case INSTITUTION:
1977
			element = new InstitutionDetailElement(this, parentElement);
1978
			break;
1979
		case DERIVED_UNIT_GENERAL:
1980
			element = new GeneralDetailElement(this, parentElement);
1981
			break;
1982
		case HYBRID:
1983
			element = new HybridDetailElement(this, parentElement);
1984
			break;
1985
		case USER:
1986
			element = new UserDetailElement(this, parentElement);
1987
			break;
1988
		case GROUP:
1989
			element = new GroupDetailElement(this, parentElement);
1990
			break;
1991
		case DETERMINATION:
1992
			element = new DeterminationDetailElement(this, parentElement);
1993
			break;
1994
		}
1995

    
1996
		if (element == null) {
1997
			StoreUtil
1998
					.error(this.getClass(),
1999
							"Detail element was not created. Seems like the case was not implemented for the requested detail type: "
2000
									+ detailType, null);
2001
		}
2002

    
2003
		adapt(element);
2004
		parentElement.addElement(element);
2005
		return element;
2006
	}
2007

    
2008
	/**
2009
	 * 
2010
	 * @author n.hoffmann
2011
	 * @created Mar 5, 2010
2012
	 * @version 1.0
2013
	 */
2014
	public static enum EntityDetailType {
2015
		TEAM, TEAMMEMBER, ANNOTATION, CREDIT, DESCRIPTIONELEMENTSOURCE, EXTENSION, MARKER, MEDIA, DESCRIPTIONELEMENTMEDIA, MEDIAREPRESENTATION, MEDIAREPRESENTATIONPART, MODIFIER, NOMENCLATURALSTATUS, NAME_RELATIONSHIP, PROTOLOG, RIGHTS, SOURCE, SCOPE, DESCRIPTIONSOURCE, TYPEDESIGNATION, STATE_DATA, STATISTICAL_MEASUREMENT_VALUE, DESCRIBED_SPECIMEN, COLLECTING_AREA, DETERMINATION_EVENT, SPECIMEN_COLLECTION, IDENTIFIABLE_SOURCE_COLLECTION, GEOGRAPHICAL_SCOPE, SCOPE_RESTRICTION, MEMBER, GRANTED_AUTHORITY, GROUPS_BY_USER, TAXONOMIC_SCOPE, DETERMINATION_CURRENT, DETERMINATION_HISTORY
2016
	}
2017

    
2018
	/**
2019
	 * <p>
2020
	 * createEntityDetailSection
2021
	 * </p>
2022
	 * 
2023
	 * @param entityDetailType
2024
	 *            a
2025
	 *            {@link eu.etaxonomy.taxeditor.singlesource.ui.forms.CdmFormFactoryFacade.EntityDetailType}
2026
	 *            object.
2027
	 * @param style
2028
	 *            a int.
2029
	 * @param conversation
2030
	 *            a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder}
2031
	 *            object.
2032
	 * @param parentElement
2033
	 *            a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement}
2034
	 *            object.
2035
	 * @return a {@link eu.etaxonomy.taxeditor.ui.forms.AbstractFormSection}
2036
	 *         object.
2037
	 */
2038
	public AbstractFormSection createEntityDetailSection(
2039
			EntityDetailType entityDetailType, ConversationHolder conversation,
2040
			ICdmFormElement parentElement, int style) {
2041
		AbstractFormSection section = null;
2042

    
2043
		switch (entityDetailType) {
2044
		case TEAM:
2045
			section = new TeamDetailSection(this, conversation, parentElement,
2046
					null, style);
2047
			break;
2048
		case TEAMMEMBER:
2049
			section = new TeamMemberSection(this, conversation, parentElement,
2050
					style);
2051
			break;
2052
		case ANNOTATION:
2053
			section = new AnnotationSection(this, conversation, parentElement,
2054
					style);
2055
			break;
2056
		case CREDIT:
2057
			section = new CreditSection(this, conversation, parentElement,
2058
					style);
2059
			break;
2060
		case DESCRIPTIONELEMENTSOURCE:
2061
			section = new DescriptionElementSourceSection(this, conversation,
2062
					parentElement, style);
2063
			break;
2064
		case EXTENSION:
2065
			section = new ExtensionSection(this, conversation, parentElement,
2066
					style);
2067
			break;
2068
		case MARKER:
2069
			section = new MarkerSection(this, conversation, parentElement,
2070
					style);
2071
			break;
2072
		case MEDIA:
2073
			section = new MediaSection(this, conversation, parentElement, style);
2074
			break;
2075
		case DESCRIPTIONELEMENTMEDIA:
2076
			section = new DescriptionElementMediaSection(this, conversation,
2077
					parentElement, style);
2078
			break;
2079
		case MEDIAREPRESENTATION:
2080
			section = new MediaRepresentationSection(this, conversation,
2081
					parentElement, style);
2082
			break;
2083
		case MEDIAREPRESENTATIONPART:
2084
			section = new MediaRepresentationPartSection(this, conversation,
2085
					parentElement, style);
2086
			break;
2087
		case MODIFIER:
2088
			section = new ModifierSection(this, conversation, parentElement,
2089
					style);
2090
			break;
2091
		case NOMENCLATURALSTATUS:
2092
			section = new NomenclaturalStatusSection(this, conversation,
2093
					parentElement, style);
2094
			break;
2095
		case NAME_RELATIONSHIP:
2096
			section = new NameRelationshipDetailSection(this, conversation,
2097
					parentElement, style);
2098
			break;
2099
		case PROTOLOG:
2100
			section = new ProtologueSection(this, conversation, parentElement,
2101
					style);
2102
			break;
2103
		case RIGHTS:
2104
			section = new RightsSection(this, conversation, parentElement,
2105
					style);
2106
			break;
2107
		case SOURCE:
2108
			section = new SourceSection(this, conversation, parentElement,
2109
					style);
2110
			break;
2111
		case SCOPE:
2112
			section = new ScopeSection(this, conversation, parentElement, style);
2113
			break;
2114
		case DESCRIPTIONSOURCE:
2115
			section = new DescriptionSourceSection(this, conversation,
2116
					parentElement, style);
2117
			break;
2118
		case TYPEDESIGNATION:
2119
			section = new TypeDesignationSection(this, conversation,
2120
					parentElement, style);
2121
			break;
2122
		case STATE_DATA:
2123
			section = new StateDataSection(this, conversation, parentElement,
2124
					style);
2125
			break;
2126
		case STATISTICAL_MEASUREMENT_VALUE:
2127
			section = new StatisticalMeasurementValueSection(this,
2128
					conversation, parentElement, style);
2129
			break;
2130
		case DESCRIBED_SPECIMEN:
2131
			section = new DescribedSpecimenSection(this, conversation,
2132
					parentElement, style);
2133
			break;
2134
		case COLLECTING_AREA:
2135
			section = new CollectingAreasDetailSection(this, conversation,
2136
					parentElement, style);
2137
			break;
2138
		case DETERMINATION_CURRENT:
2139
			section = new CurrentDeterminationDetailSection(this, conversation,
2140
					parentElement, style);
2141
			break;
2142
		case DETERMINATION_HISTORY:
2143
			section = new DeterminationHistoryDetailSection(this, conversation,
2144
					parentElement, style);
2145
			break;
2146
		case SPECIMEN_COLLECTION:
2147
			section = new SpecimenCollectionDetailSection(this, conversation,
2148
					parentElement, style);
2149
			break;
2150
		case IDENTIFIABLE_SOURCE_COLLECTION:
2151
			section = new SourceCollectionDetailSection(this, conversation,
2152
					parentElement, style);
2153
			break;
2154
		case GEOGRAPHICAL_SCOPE:
2155
			section = new GeographicalScopeDetailSection(this, conversation,
2156
					parentElement, style);
2157
			break;
2158
		case SCOPE_RESTRICTION:
2159
			section = new ScopeRestrictionSection(this, conversation,
2160
					parentElement, style);
2161
			break;
2162
		case MEMBER:
2163
			section = new MemberDetailSection(this, conversation,
2164
					parentElement, style);
2165
			break;
2166
		case GRANTED_AUTHORITY:
2167
			section = new GrantedAuthorityDetailSection(this, conversation,
2168
					parentElement, style);
2169
			break;
2170
		case GROUPS_BY_USER:
2171
			section = new GroupsByUserDetailSection(this, conversation,
2172
					parentElement, style);
2173
			break;
2174
		case TAXONOMIC_SCOPE:
2175
			section = new TaxonomicScopeSection(this, conversation,
2176
					parentElement, style);
2177
			break;
2178
		}
2179
		parentElement.addElement(section);
2180
		adapt(section);
2181
		return section;
2182
	}
2183

    
2184
	/**
2185
	 * <p>
2186
	 * createEntityCollectionElement
2187
	 * </p>
2188
	 * 
2189
	 * @param removeListener
2190
	 *            a {@link org.eclipse.swt.events.SelectionListener} object.
2191
	 * @param style
2192
	 *            a int.
2193
	 * @param parentElement
2194
	 *            a {@link eu.etaxonomy.taxeditor.ui.forms.AbstractFormSection}
2195
	 *            object.
2196
	 * @param versionableEntity
2197
	 *            a {@link eu.etaxonomy.cdm.model.common.IVersionableEntity}
2198
	 *            object.
2199
	 * @param backgroundColor
2200
	 *            a {@link org.eclipse.swt.graphics.Color} object.
2201
	 * @return a
2202
	 *         {@link eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionElement}
2203
	 *         object.
2204
	 */
2205
	public AbstractEntityCollectionElement createEntityCollectionElement(
2206
			AbstractFormSection parentElement, Object versionableEntity,
2207
			SelectionListener removeListener, Color backgroundColor, int style) {
2208
		AbstractEntityCollectionElement element = null;
2209

    
2210
		Object entity = HibernateProxyHelper.deproxy(versionableEntity);
2211

    
2212
		if (entity instanceof Annotation) {
2213
			element = new AnnotationElement(this, parentElement,
2214
					(Annotation) entity, removeListener, style);
2215
		} else if (entity instanceof Person) {
2216
			element = new TeamMemberElement(this, parentElement,
2217
					(Person) entity, removeListener, style);
2218
		} else if (entity instanceof Credit) {
2219
			element = new CreditElement(this, parentElement, (Credit) entity,
2220
					removeListener, style);
2221
		} else if (entity instanceof Extension) {
2222
			element = new ExtensionElement(this, parentElement,
2223
					(Extension) entity, removeListener, style);
2224
		} else if (entity instanceof Marker) {
2225
			element = new MarkerElement(this, parentElement, (Marker) entity,
2226
					removeListener, style);
2227
		} else if (entity instanceof Media) {
2228
			element = new MediaElement(this, parentElement, (Media) entity,
2229
					removeListener, style);
2230
		} else if (entity instanceof MediaRepresentation) {
2231
			element = new MediaRepresentationElement(this, parentElement,
2232
					(MediaRepresentation) entity, removeListener, style);
2233
		} else if (entity instanceof ImageFile) {
2234
			element = new ImageFileElement(this, parentElement,
2235
					(ImageFile) entity, removeListener, style);
2236
		} else if (entity instanceof NomenclaturalStatus) {
2237
			element = new NomenclaturalStatusElement(this, parentElement,
2238
					(NomenclaturalStatus) entity, removeListener, style);
2239
		} else if (entity instanceof Rights) {
2240
			element = new RightsElement(this, parentElement, (Rights) entity,
2241
					removeListener, style);
2242
		} else if (entity instanceof DescriptionElementSource) {
2243
			element = new DescriptionElementSourceElement(this, parentElement,
2244
					(DescriptionElementSource) entity, removeListener, style);
2245
		} else if (entity instanceof IdentifiableSource) {
2246
			element = new IdentifiableSourceElement(this, parentElement,
2247
					(IdentifiableSource) entity, removeListener, style);
2248
		} else if (entity instanceof Scope) {
2249
			element = new ScopeElement(this, parentElement, (Scope) entity,
2250
					removeListener, style);
2251
		} else if (entity instanceof Modifier) {
2252
			element = new ModifierElement(this, parentElement,
2253
					(Modifier) entity, removeListener, style);
2254
		} else if (entity instanceof Reference) {
2255
			element = new DescriptionSourceElement(this, parentElement,
2256
					(Reference) entity, removeListener, style);
2257
		} else if (entity instanceof NameTypeDesignation) {
2258
			element = new NameTypeDesignationElement(this, parentElement,
2259
					(NameTypeDesignation) entity, removeListener, style);
2260
		} else if (entity instanceof NameRelationship) {
2261
			element = new NameRelationshipDetailElement(this, parentElement,
2262
					(NameRelationship) entity, removeListener, style);
2263
		} else if (entity instanceof SpecimenTypeDesignation) {
2264
			element = new SpecimenTypeDesignationElement(this, parentElement,
2265
					(SpecimenTypeDesignation) entity, removeListener, style);
2266
		} else if (entity instanceof StateData) {
2267
			element = new StateDataElement(this, parentElement,
2268
					(StateData) entity, removeListener, style);
2269
		} else if (entity instanceof StatisticalMeasurementValue) {
2270
			element = new StatisticalMeasurementValueElement(this,
2271
					parentElement, (StatisticalMeasurementValue) entity,
2272
					removeListener, style);
2273
		} else if (entity instanceof DerivedUnit) {
2274
			element = new DerivedUnitElement(this, parentElement,
2275
					(DerivedUnit) entity, removeListener, style);
2276
		} else if (entity instanceof NamedArea) {
2277
			element = new NamedAreaDetailElement(this, parentElement,
2278
					(NamedArea) entity, removeListener, style);
2279
		} else if (entity instanceof DeterminationEvent) {
2280
			element = new DeterminationEventDetailElement(this, parentElement,
2281
					(DeterminationEvent) entity, removeListener, style);
2282
		} else if (entity instanceof Specimen) {
2283
			element = new SpecimenCollectionDetailElement(this, parentElement,
2284
					(Specimen) entity, removeListener, style);
2285
		} else if (entity instanceof User) {
2286
			element = new MemberDetailElement(this, parentElement,
2287
					(User) entity, removeListener, style);
2288
		} else if (entity instanceof GrantedAuthority) {
2289
			element = new GrantedAuthorityDetailElement(this, parentElement,
2290
					(GrantedAuthority) entity, removeListener, style);
2291
		} else if (entity instanceof Group) {
2292
			element = new GroupsByUserDetailElement(this, parentElement,
2293
					(Group) entity, removeListener, style);
2294
		} else if (entity instanceof Taxon) {
2295
			element = new TaxonDetailElement(this, parentElement,
2296
					(Taxon) entity, removeListener, style);
2297
		} else if (entity instanceof DescriptionElementBase) {
2298
			// this is the special case for protologs, maybe we can do this
2299
			// differently when API improves
2300
			DescriptionElementBase descriptionElement = (DescriptionElementBase) entity;
2301
			if (descriptionElement.getFeature().equals(Feature.PROTOLOGUE())) {
2302
				element = new ProtologueElement(this, parentElement,
2303
						descriptionElement, removeListener, style);
2304
			}
2305
		}
2306

    
2307
		if (element == null) {
2308
			StoreUtil
2309
					.errorDialog(
2310
							"No element for entity",
2311
							this,
2312
							"Could not generate element for entity. "
2313
									+ "Looks like the case is not handled already. Check implementation. Entity: "
2314
									+ entity, null);
2315
		}
2316

    
2317
		if (backgroundColor != null && !backgroundColor.isDisposed()) {
2318
			element.setBackgroundColor(backgroundColor);
2319
		}
2320

    
2321
		adapt(element);
2322
		parentElement.addElement(element);
2323
		return element;
2324
	}
2325

    
2326
	/**
2327
	 * <p>
2328
	 * createSelectionElement
2329
	 * </p>
2330
	 * 
2331
	 * @param selectionType
2332
	 *            a
2333
	 *            {@link eu.etaxonomy.taxeditor.singlesource.ui.forms.CdmFormFactoryFacade.SelectionType}
2334
	 *            object.
2335
	 * @param parentElement
2336
	 *            a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement}
2337
	 *            object.
2338
	 * @param labelString
2339
	 *            a {@link java.lang.String} object.
2340
	 * @param selectionType
2341
	 * @param selection
2342
	 *            a {@link eu.etaxonomy.cdm.model.common.IAnnotatableEntity}
2343
	 *            object.
2344
	 * @param style
2345
	 *            a int.
2346
	 * @param conversation
2347
	 *            a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder}
2348
	 *            object.
2349
	 * @return a
2350
	 *         {@link eu.etaxonomy.taxeditor.ui.selection.AbstractSelectionElement}
2351
	 *         object.
2352
	 */
2353
	public AbstractSelectionElement createSelectionElement(
2354
			SelectionType selectionType, ConversationHolder conversation,
2355
			ICdmFormElement parentElement, String labelString,
2356
			ICdmBase selection, int mode, int style) {
2357
		AbstractSelectionElement element = null;
2358

    
2359
		IAnnotatableEntity entity = (IAnnotatableEntity) HibernateProxyHelper
2360
				.deproxy(selection);
2361

    
2362
		switch (selectionType) {
2363
		case AGENT:
2364
			element = new AgentSelectionElement(this, conversation,
2365
					parentElement, labelString, (TeamOrPersonBase) entity,
2366
					mode, style);
2367
			break;
2368
		case PERSON:
2369
			element = new PersonSelectionElement(this, conversation,
2370
					parentElement, labelString, (Person) entity, mode, style);
2371
			break;
2372
		case TEAM:
2373
			element = new TeamSelectionElement(this, conversation,
2374
					parentElement, labelString, (Team) entity, mode, style);
2375
			break;
2376
		case AUTHOR_TEAM:
2377
			element = new NomenclaturalAuthorTeamSelectionElement(this,
2378
					conversation, parentElement, labelString, (Team) entity,
2379
					mode, style);
2380
			break;
2381
		case INSTITUTION:
2382
			element = new InstitutionSelectionElement(this, conversation,
2383
					parentElement, labelString, (Institution) entity, mode,
2384
					style);
2385
			break;
2386
		case NAME:
2387
			element = new NameSelectionElement(this, conversation,
2388
					parentElement, labelString, (TaxonNameBase) entity, mode,
2389
					style);
2390
			break;
2391
		case REFERENCE:
2392
			element = new ReferenceSelectionElement(this, conversation,
2393
					parentElement, labelString, (Reference) entity, mode, style);
2394
			break;
2395
		case TAXON_BASE:
2396
			element = new TaxonBaseSelectionElement(this, conversation,
2397
					parentElement, labelString, (TaxonBase) entity, mode, style);
2398
			break;
2399
		case TAXON:
2400
			element = new TaxonSelectionElement(this, conversation,
2401
					parentElement, labelString, (Taxon) entity, mode, style);
2402
			break;
2403
		case SYNONYM:
2404
			element = new SynonymSelectionElement(this, conversation,
2405
					parentElement, labelString, (Synonym) entity, mode, style);
2406
			break;
2407
		case DERIVED_UNIT:
2408
			element = new DerivedUnitBaseSelectionElement(this, conversation,
2409
					parentElement, labelString, (DerivedUnitBase) entity, mode,
2410
					style);
2411
			break;
2412
		case FIELD_OBSERVATION:
2413
			element = new FieldObservationSelectionElement(this, conversation,
2414
					parentElement, labelString, (FieldObservation) entity,
2415
					mode, style);
2416
			break;
2417
		case FEATURE_TREE:
2418
			element = new FeatureTreeSelectionElement(this, conversation,
2419
					parentElement, labelString, (FeatureTree) entity, mode,
2420
					style);
2421
			break;
2422
		case CLASSIFICATION:
2423
			element = new ClassificationSelectionElement(this, conversation,
2424
					parentElement, labelString, (Classification) entity, mode,
2425
					style);
2426
			break;
2427
		case TAXON_NODE:
2428
			element = new TaxonNodeSelectionElement(this, conversation,
2429
					parentElement, labelString, (TaxonNode) entity, mode, style);
2430
			break;
2431
		case COLLECTION:
2432
			element = new CollectionSelectionElement(this, conversation,
2433
					parentElement, labelString, (Collection) entity, mode,
2434
					style);
2435
			break;
2436
		case FEATURE:
2437
			element = new FeatureSelectionElement(this, conversation,
2438
					parentElement, labelString, (Feature) entity, mode, style);
2439
			break;
2440
		case POLYTOMOUS_KEY:
2441
			element = new PolytomousKeySelectionElement(this, conversation,
2442
					parentElement, labelString, (PolytomousKey) entity, mode,
2443
					style);
2444
			break;
2445
		case POLYTOMOUS_KEY_NODE:
2446
			element = new PolytomousKeyNodeSelectionElement(this, conversation,
2447
					parentElement, labelString, (PolytomousKeyNode) entity,
2448
					mode, style);
2449
			break;
2450
		case USER:
2451
			element = new UserSelectionElement(this, conversation,
2452
					parentElement, labelString, (User) entity, mode, style);
2453
			break;
2454
		case GROUP:
2455
			element = new GroupSelectionElement(this, conversation,
2456
					parentElement, labelString, (Group) entity, mode, style);
2457
			break;
2458
		default:
2459
			new RuntimeException(
2460
					"There is no selection composite for the desired selection type.");
2461
			break;
2462
		}
2463

    
2464
		adapt(element);
2465
		parentElement.addElement(element);
2466
		return element;
2467
	}
2468

    
2469
	/**
2470
	 * <p>
2471
	 * createNamedAreaSelectionElement
2472
	 * </p>
2473
	 * 
2474
	 * @param parentElement
2475
	 *            a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement}
2476
	 *            object.
2477
	 * @param conversation
2478
	 *            a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder}
2479
	 *            object.
2480
	 * @param labelString
2481
	 *            a {@link java.lang.String} object.
2482
	 * @param selection
2483
	 *            a {@link eu.etaxonomy.cdm.model.location.NamedArea} object.
2484
	 * @param style
2485
	 *            a int.
2486
	 * @return a
2487
	 *         {@link eu.etaxonomy.taxeditor.ui.selection.NamedAreaSelectionElement}
2488
	 *         object.
2489
	 */
2490
	public NamedAreaSelectionElement createNamedAreaSelectionElement(
2491
			ICdmFormElement parentElement, ConversationHolder conversation,
2492
			String labelString, NamedArea selection, int style) {
2493
		NamedAreaSelectionElement element = new NamedAreaSelectionElement(this,
2494
				conversation, parentElement, labelString, selection,
2495
				AbstractSelectionElement.NOTHING, style);
2496
		adapt(element);
2497
		parentElement.addElement(element);
2498
		return element;
2499
	}
2500

    
2501
	/** {@inheritDoc} */
2502
	public LabelElement createLabel(ICdmFormElement parentElement, String text) {
2503
		LabelElement labelElement = new LabelElement(this, parentElement, text);
2504
		adapt(labelElement);
2505
		parentElement.addElement(labelElement);
2506
		return labelElement;
2507
	}
2508

    
2509
	/**
2510
	 * <p>
2511
	 * Getter for the field <code>selectionProvider</code>.
2512
	 * </p>
2513
	 * 
2514
	 * @return a {@link org.eclipse.jface.viewers.ISelectionProvider} object.
2515
	 */
2516
	public ISelectionProvider getSelectionProvider() {
2517
		return selectionProvider;
2518
	}
2519

    
2520
	/**
2521
	 * <p>
2522
	 * createDetailedDescriptionDetailElement
2523
	 * </p>
2524
	 * 
2525
	 * @param parentElement
2526
	 *            a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement}
2527
	 *            object.
2528
	 * @param entity
2529
	 *            a
2530
	 *            {@link eu.etaxonomy.cdm.model.description.DescriptionElementBase}
2531
	 *            object.
2532
	 * @param style
2533
	 *            a int.
2534
	 * @return a
2535
	 *         {@link eu.etaxonomy.taxeditor.ui.section.description.detail.AbstractDetailedDescriptionDetailElement}
2536
	 *         object.
2537
	 */
2538
	public AbstractDetailedDescriptionDetailElement createDetailedDescriptionDetailElement(
2539
			ICdmFormElement parentElement, DescriptionElementBase entity,
2540
			int style) {
2541
		AbstractDetailedDescriptionDetailElement detailedDescriptionElement = null;
2542

    
2543
		if (entity instanceof CategoricalData) {
2544
			detailedDescriptionElement = new CategoricalDataDetailElement(this,
2545
					parentElement, (CategoricalData) entity, style);
2546
		} else if (entity instanceof CommonTaxonName) {
2547
			detailedDescriptionElement = new CommonNameDetailElement(this,
2548
					parentElement, (CommonTaxonName) entity, style);
2549
		} else if (entity instanceof Distribution) {
2550
			detailedDescriptionElement = new DistributionDetailElement(this,
2551
					parentElement, (Distribution) entity, style);
2552
		} else if (entity instanceof IndividualsAssociation) {
2553
			detailedDescriptionElement = new IndividualsAssociationDetailElement(
2554
					this, parentElement, (IndividualsAssociation) entity, style);
2555
		} else if (entity instanceof QuantitativeData) {
2556
			detailedDescriptionElement = new QuantitativeDataDetailElement(
2557
					this, parentElement, (QuantitativeData) entity, style);
2558
		} else if (entity instanceof TaxonInteraction) {
2559
			detailedDescriptionElement = new TaxonInteractionDetailElement(
2560
					this, parentElement, (TaxonInteraction) entity, style);
2561
		} else if (entity instanceof TextData) {
2562
			detailedDescriptionElement = new TextDataDetailElement(this,
2563
					parentElement, (TextData) entity, style);
2564
		} else {
2565
			throw new IllegalStateException(
2566
					"There is no interface for the given description element");
2567
		}
2568
		adapt(detailedDescriptionElement);
2569
		parentElement.addElement(detailedDescriptionElement);
2570
		return detailedDescriptionElement;
2571

    
2572
	}
2573

    
2574
	/**
2575
	 * Creates a styled text as a part of the form.
2576
	 * 
2577
	 * @param parent
2578
	 *            the text parent
2579
	 * @param value
2580
	 *            the text initial value
2581
	 * @param style
2582
	 *            the text style
2583
	 * @return the text widget
2584
	 */
2585
	
2586
/** RAPSS:Remove  This is never used anywhere */	
2587
//	public StyledText createStyledText(Composite parent, String value, int style) {
2588
//		StyledText text = new StyledText(parent, getBorderStyle() | style
2589
//				| getOrientation());
2590
//		if (value != null)
2591
//			text.setText(value);
2592
//		text.setForeground(getColors().getForeground());
2593
//		text.setBackground(getColors().getBackground());
2594
//		// text.addFocusListener(visibilityHandler);
2595
//		return text;
2596
//	}
2597
}
(1-1/5)