Project

General

Profile

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

    
308
/**
309
 * <p>CdmFormFactory class.</p>
310
 *
311
 * @author n.hoffmann
312
 * @created Feb 24, 2010
313
 * @version 1.0
314
 */
315
public class CdmFormFactory extends FormToolkit{
316
	
317
	private BoldFontHolder2 boldFontHolder2;
318
	private MouseListener selectionMouseHandler;
319
	private FocusListener selectionFocusHandler;
320
	
321
	private Set selectionListenerList = new HashSet();
322
	
323
	private List<IPropertyChangeListener> propertyChangeListeners = new ArrayList<IPropertyChangeListener>();
324
	
325
	private int orientation = Window.getDefaultOrientation();
326
	private ISelectionProvider selectionProvider;
327
	
328
	/**
329
	 * <p>LAYOUT</p>
330
	 *
331
	 * @return a {@link org.eclipse.ui.forms.widgets.TableWrapLayout} object.
332
	 */
333
	public static final TableWrapLayout LAYOUT(){
334
		return LAYOUT(1, false);
335
	}
336
	
337
	/**
338
	 * <p>LAYOUT</p>
339
	 *
340
	 * @param columns a int.
341
	 * @param equalWidth a boolean.
342
	 * @return a {@link org.eclipse.ui.forms.widgets.TableWrapLayout} object.
343
	 */
344
	public static final TableWrapLayout LAYOUT(int columns, boolean equalWidth){
345
		TableWrapLayout layout = new TableWrapLayout();
346
		layout.topMargin = 0;
347
		layout.rightMargin = 0;
348
		layout.bottomMargin = 0;
349
		layout.leftMargin = 0;
350
		layout.numColumns = columns;
351
		layout.makeColumnsEqualWidth = equalWidth;
352
		layout.verticalSpacing = 0;
353
		layout.horizontalSpacing = 0;
354
		return layout;
355
	}
356
	
357
	/**
358
	 * <p>FILL</p>
359
	 *
360
	 * @return a {@link org.eclipse.ui.forms.widgets.TableWrapData} object.
361
	 */
362
	public static final TableWrapData FILL(){
363
		return FILL(1, 1);
364
	}
365
	
366
	/**
367
	 * <p>FILL</p>
368
	 *
369
	 * @param horizontalSpan a int.
370
	 * @param verticalSpan a int.
371
	 * @return a {@link org.eclipse.ui.forms.widgets.TableWrapData} object.
372
	 */
373
	public static final TableWrapData FILL(int horizontalSpan, int verticalSpan){
374
		TableWrapData layoutData = new TableWrapData(TableWrapData.FILL_GRAB, TableWrapData.FILL_GRAB);
375
		layoutData.colspan = horizontalSpan;
376
		layoutData.rowspan = verticalSpan;
377
		return layoutData;
378
	}
379
	
380
	/**
381
	 * <p>LEFT</p>
382
	 *
383
	 * @return a {@link org.eclipse.ui.forms.widgets.TableWrapData} object.
384
	 */
385
	public static final TableWrapData LEFT(){
386
		return new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP);
387
	}
388
	
389
	/**
390
	 * <p>RIGHT</p>
391
	 *
392
	 * @return a {@link org.eclipse.ui.forms.widgets.TableWrapData} object.
393
	 */
394
	public static final TableWrapData RIGHT(){
395
		return new TableWrapData(TableWrapData.RIGHT, TableWrapData.TOP);
396
	}
397
	
398
	/**
399
	 * <p>FILL_HORIZONTALLY</p>
400
	 *
401
	 * @return a {@link org.eclipse.ui.forms.widgets.TableWrapData} object.
402
	 */
403
	public static final TableWrapData FILL_HORIZONTALLY(){
404
		return FILL_HORIZONTALLY(1, 1);
405
	}
406
	
407
	/**
408
	 * <p>FILL_HORIZONTALLY</p>
409
	 *
410
	 * @param horizontalSpan a int.
411
	 * @param verticalSpan a int.
412
	 * @return a {@link org.eclipse.ui.forms.widgets.TableWrapData} object.
413
	 */
414
	public static final TableWrapData FILL_HORIZONTALLY(int horizontalSpan, int verticalSpan){
415
		TableWrapData layoutData = new TableWrapData(TableWrapData.FILL_GRAB, TableWrapData.TOP);
416
		layoutData.colspan = horizontalSpan;
417
		layoutData.rowspan = verticalSpan;
418
		return layoutData;
419
	}
420
	
421
	/** Constant <code>EMPTY_SELECTION</code> */
422
	public static ISelection EMPTY_SELECTION = new ISelection() {
423
		public boolean isEmpty() {
424
			return true;
425
		}
426
	};
427
	
428
	private class SelectionMouseHandler extends MouseAdapter{
429
		@Override
430
		public void mouseDown(MouseEvent e) {
431
			notifySelectionListeners(e);
432
		}
433
	}
434
	
435
	private class SelectionFocusHandler extends FocusAdapter{
436
		@Override
437
		public void focusGained(FocusEvent e) {
438
			notifySelectionListeners(e);
439
		}
440
	}
441
	
442
	private void notifySelectionListeners(TypedEvent e){
443
		Event event = new Event();
444
		event.widget = e.widget;
445
		SelectionEvent selectionEvent = new SelectionEvent(event);
446
		
447
		for(Object listener : selectionListenerList){
448
			((SelectionListener) listener).widgetSelected(selectionEvent);
449
		}
450
	}
451
	
452
	/**
453
	 * <p>Constructor for CdmFormFactory.</p>
454
	 *
455
	 * @param display a {@link org.eclipse.swt.widgets.Display} object.
456
	 * @param selectionProvider a {@link org.eclipse.jface.viewers.ISelectionProvider} object.
457
	 */
458
	public CdmFormFactory(Display display, ISelectionProvider selectionProvider) {
459
		super(display);
460
		this.selectionProvider = selectionProvider;
461
		init();
462
	}
463
	
464
	/**
465
	 * <p>Constructor for CdmFormFactory.</p>
466
	 *
467
	 * @param display a {@link org.eclipse.swt.widgets.Display} object.
468
	 */
469
	public CdmFormFactory(Display display){
470
		super(display);
471
		init();
472
	}
473
	
474
	/**
475
	 * 
476
	 */
477
	private void init() {
478
		boldFontHolder2 = new BoldFontHolder2();
479
		selectionMouseHandler = new SelectionMouseHandler();
480
		selectionFocusHandler = new SelectionFocusHandler();
481
	}
482
	
483
	/**
484
	 * Creates an instance initialized with the correct selectionProvider
485
	 *
486
	 * Make sure to remove the instance when the entityComposite disposes via
487
	 * destroySelectionArbitrator(..)
488
	 *
489
	 * @param entityElement a {@link eu.etaxonomy.taxeditor.ui.forms.IEntityElement} object.
490
	 * @return a {@link eu.etaxonomy.taxeditor.ui.forms.SelectionArbitrator} object.
491
	 */
492
	public SelectionArbitrator createSelectionArbitrator(IEntityElement entityElement){
493
		SelectionArbitrator selectionArbitrator = new SelectionArbitrator(entityElement);
494
		selectionArbitrator.addSelectionProvider(selectionProvider);
495
		selectionProvider.addSelectionChangedListener(selectionArbitrator);
496
		addSelectionListener(selectionArbitrator);
497
		return selectionArbitrator;
498
	}
499
	
500
	/**
501
	 * <p>destroySelectionArbitrator</p>
502
	 *
503
	 * @param selectionArbitrator a {@link eu.etaxonomy.taxeditor.ui.forms.SelectionArbitrator} object.
504
	 */
505
	public void destroySelectionArbitrator(SelectionArbitrator selectionArbitrator){
506
		removeSelectionListener(selectionArbitrator);
507
		if(selectionProvider != null){
508
			selectionProvider.removeSelectionChangedListener(selectionArbitrator);
509
		}else{
510
			StoreUtil.error(this.getClass(), "Tried to destroy a selection listener from this factories listeners but was null", null);
511
		}
512
	}
513

    
514
	/** {@inheritDoc} */
515
	@Override
516
	public void adapt(Composite composite) {
517
		composite.addMouseListener(selectionMouseHandler);
518
		super.adapt(composite);
519
	}
520
	
521
	/**
522
	 * <p>adapt</p>
523
	 *
524
	 * @param formElement a {@link eu.etaxonomy.taxeditor.ui.forms.AbstractCdmFormElement} object.
525
	 */
526
	public void adapt(AbstractCdmFormElement formElement){		
527
		formElement.setPropertyChangeListeners(propertyChangeListeners);
528
	}
529
	
530
	/** {@inheritDoc} */
531
	@Override
532
	public void adapt(Control control, boolean trackFocus, boolean trackKeyboard) {
533
		if(trackFocus){
534
			control.addFocusListener(selectionFocusHandler);
535
		}
536
		super.adapt(control, trackFocus, trackKeyboard);
537
	}
538
	
539
	/**
540
	 * <p>destroyElement</p>
541
	 *
542
	 * @param formElement a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement} object.
543
	 */
544
	public void destroyElement(ICdmFormElement formElement){
545
		// return if element was not initialized
546
		if(formElement == null){
547
			return;
548
		}
549
		// destroy selection arbitrator, if any
550
		if(formElement instanceof ISelectableElement){
551
			destroySelectionArbitrator(((ISelectableElement) formElement).getSelectionArbitrator());
552
		}
553
		// remove this element form its parents list of elements
554
//		ICdmFormElement parentElement = formElement.getParentElement();
555
//		if(parentElement != null){
556
//			parentElement.removeElement(formElement);
557
//		}
558
		// call destroy on child elements recursively
559
		for(ICdmFormElement childElement : formElement.getElements()){
560
			destroyElement(childElement);
561
		}
562
		// dispose of the controls
563
		for(Control control : formElement.getControls()){
564
			// we added the layoutComposite of the parental element as the layout composite to this formElement
565
			// but we do not want to destroy it.
566
			if(control.equals(formElement.getLayoutComposite())){
567
				continue;
568
			}else{
569
				control.dispose();
570
				control = null;
571
			}
572
		}
573
	}
574
	
575
	
576
	/**
577
	 * <p>createEmptyCell</p>
578
	 *
579
	 * @param parent a {@link org.eclipse.swt.widgets.Composite} object.
580
	 * @return a {@link org.eclipse.swt.widgets.Label} object.
581
	 */
582
	public Label createEmptyCell(Composite parent){
583
		return this.createLabel(parent, null);
584
	}
585
	
586
	/**
587
	 * <p>createMultilineTextWithLabel</p>
588
	 *
589
	 * @param labelString a {@link java.lang.String} object.
590
	 * @param textHeight a int.
591
	 * @param style a int.
592
	 * @param parentElement a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement} object.
593
	 * @return a {@link eu.etaxonomy.taxeditor.ui.forms.TextWithLabelElement} object.
594
	 */
595
	public TextWithLabelElement createMultilineTextWithLabel(ICdmFormElement parentElement, String labelString, int textHeight, int style){
596
		TextWithLabelElement element = new TextWithLabelElement(this, parentElement, labelString, "", textHeight, style);
597
		adapt(element);
598
		parentElement.addElement(element);
599
		return element;
600
	}
601

    
602

    
603
	/**
604
	 * <p>createMultiLanguageTextElement</p>
605
	 *
606
	 * @param parentElement a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement} object.
607
	 * @param labelString a {@link java.lang.String} object.
608
	 * @param multilanguageText a {@link java.util.Map} object.
609
	 * @param textHeight a int.
610
	 * @param style a int.
611
	 * @return a {@link eu.etaxonomy.taxeditor.ui.forms.MultilanguageTextElement} object.
612
	 */
613
	public MultilanguageTextElement createMultiLanguageTextElement(
614
			ICdmFormElement parentElement, String labelString, Map<Language, LanguageString> multilanguageText, int textHeight,
615
			int style) {
616
		MultilanguageTextElement element = new MultilanguageTextElement(this, parentElement, labelString, multilanguageText, textHeight, style);
617
		adapt(element);
618
		parentElement.addElement(element);
619
		return element;
620
	}
621
	
622
	public KeyStatementElement createKeyStatementElement(ICdmFormElement parentElement, String labelString,
623
			KeyStatement keyStatement, int textHeight, int style){
624
		KeyStatementElement element = new KeyStatementElement(this, parentElement, labelString, keyStatement, textHeight, style);
625
		adapt(element);
626
		parentElement.addElement(element);
627
		return element;
628
	}
629
	
630
	
631
	/**
632
	 * <p>createTextWithLabelElement</p>
633
	 *
634
	 * @param labelString a {@link java.lang.String} object.
635
	 * @param initialText a {@link java.lang.String} object.
636
	 * @param style a int.
637
	 * @param parentElement a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement} object.
638
	 * @return a {@link eu.etaxonomy.taxeditor.ui.forms.TextWithLabelElement} object.
639
	 */
640
	public TextWithLabelElement createTextWithLabelElement(ICdmFormElement parentElement, String labelString, String initialText, int style){
641
		TextWithLabelElement element = new TextWithLabelElement(this, parentElement, labelString, initialText, null, style);
642
		adapt(element);
643
		parentElement.addElement(element);
644
		return element;
645
	}
646
	
647
	public UriWithLabelElement createUriWithLabelElement(ICdmFormElement parentElement, String labelString, URI initialUri, int style){
648
		UriWithLabelElement element = new UriWithLabelElement(this, parentElement, labelString, initialUri, null, style);
649
		adapt(element);
650
		parentElement.addElement(element);
651
		return element;
652
	}
653
	
654
	/**
655
	 * @param element
656
	 * @param string
657
	 * @param uri
658
	 * @param style
659
	 * @return
660
	 */
661
	public OpenUrlSelectorElement createOpenUrlSelectorElement(
662
			ICdmFormElement parentElement, String labelString, IOpenUrlEnabled openUrlEnabled, int style) {
663
		OpenUrlSelectorElement element = new OpenUrlSelectorElement(this, parentElement, labelString, openUrlEnabled, style);
664
		adapt(element);
665
		parentElement.addElement(element);
666
		return element;
667
	}
668
	
669
	/**
670
	 * 
671
	 * @param parentElement
672
	 * @param labelString
673
	 * @param conversationEnabled
674
	 * @param user
675
	 * @param style
676
	 * @return
677
	 */
678
	public EditPasswordElement createEditPasswordElement(ICdmFormElement parentElement, String labelString,
679
			ConversationHolder conversation, User user, int style){
680
		EditPasswordElement element = new EditPasswordElement(this, parentElement, labelString, user, conversation);
681
		adapt(element);
682
		parentElement.addElement(element);
683
		return element;
684
	}
685
	
686
	/**
687
	 * <p>createIntegerTextWithLabelElement</p>
688
	 *
689
	 * @param parentElement a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement} object.
690
	 * @param labelString a {@link java.lang.String} object.
691
	 * @param initialInteger a {@link java.lang.Integer} object.
692
	 * @param style a int.
693
	 * @return a {@link eu.etaxonomy.taxeditor.ui.forms.NumberWithLabelElement} object.
694
	 */
695
	public NumberWithLabelElement createIntegerTextWithLabelElement(ICdmFormElement parentElement, String labelString, Integer initialInteger, int style){
696
		NumberWithLabelElement element = new NumberWithLabelElement(this, parentElement, labelString, initialInteger, style);
697
		adapt(element);
698
		parentElement.addElement(element);
699
		return element;
700
	}
701
	
702

    
703
	/**
704
	 * <p>createFloatTextWithLabelElement</p>
705
	 *
706
	 * @param parentElement a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement} object.
707
	 * @param labelString a {@link java.lang.String} object.
708
	 * @param initialFloat a float.
709
	 * @param style a int.
710
	 * @return a {@link eu.etaxonomy.taxeditor.ui.forms.NumberWithLabelElement} object.
711
	 */
712
	public NumberWithLabelElement createFloatTextWithLabelElement(
713
			ICdmFormElement parentElement, String labelString, float initialFloat,
714
			int style) {
715
		NumberWithLabelElement element = new NumberWithLabelElement(this, parentElement, labelString, initialFloat, style);
716
		adapt(element);
717
		parentElement.addElement(element);
718
		return element;
719
	}
720
	
721
	/**
722
	 * <p>createLanguageStringWithLabelElement</p>
723
	 *
724
	 * @param parentElement a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement} object.
725
	 * @param labelString a {@link java.lang.String} object.
726
	 * @param languageString a {@link eu.etaxonomy.cdm.model.common.LanguageString} object.
727
	 * @param style a int.
728
	 * @return a {@link eu.etaxonomy.taxeditor.ui.forms.LanguageStringWithLabelElement} object.
729
	 */
730
	public LanguageStringWithLabelElement createLanguageStringWithLabelElement(ICdmFormElement parentElement, String labelString, LanguageString languageString, int style){
731
		LanguageStringWithLabelElement element = new LanguageStringWithLabelElement(this, parentElement, labelString, languageString, style);
732
		adapt(element);
733
		parentElement.addElement(element);
734
		return element;
735
	}
736
	
737
	/**
738
	 * <p>createLanguageStringWithLabelElement</p>
739
	 *
740
	 * @param parentElement a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement} object.
741
	 * @param labelString a {@link java.lang.String} object.
742
	 * @param languageString a {@link eu.etaxonomy.cdm.model.common.LanguageString} object.
743
	 * @param height a int.
744
	 * @param style a int.
745
	 * @return a {@link eu.etaxonomy.taxeditor.ui.forms.LanguageStringWithLabelElement} object.
746
	 */
747
	public LanguageStringWithLabelElement createLanguageStringWithLabelElement(ICdmFormElement parentElement, String labelString, LanguageString languageString, int height, int style){
748
		LanguageStringWithLabelElement element = new LanguageStringWithLabelElement(this, parentElement, labelString, languageString, height, style);
749
		adapt(element);
750
		parentElement.addElement(element);
751
		return element;
752
	}
753
	
754
	/**
755
	 * <p>createTextElement</p>
756
	 *
757
	 * @param parentElement a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement} object.
758
	 * @param initialText a {@link java.lang.String} object.
759
	 * @param style a int.
760
	 * @return a {@link eu.etaxonomy.taxeditor.ui.forms.TextWithLabelElement} object.
761
	 */
762
	public TextWithLabelElement createTextElement(ICdmFormElement parentElement, String initialText, int style){
763
		TextWithLabelElement element = new TextWithLabelElement(this, parentElement, null, initialText, null, style);
764
		adapt(element);
765
		parentElement.addElement(element);
766
		return element;
767
	}
768
	
769
	/**
770
	 * <p>createKeyValueViewerElement</p>
771
	 *
772
	 * @param parentElement a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement} object.
773
	 * @param keyHeading a {@link java.lang.String} object.
774
	 * @param valueHeading a {@link java.lang.String} object.
775
	 * @param map a {@link java.util.Map} object.
776
	 * @return a {@link eu.etaxonomy.taxeditor.ui.forms.KeyValueViewerElement} object.
777
	 */
778
	public KeyValueViewerElement createKeyValueViewerElement(ICdmFormElement parentElement, String keyHeading, String valueHeading, Map<Object, Object> map){
779
		KeyValueViewerElement element = new KeyValueViewerElement(this, parentElement, keyHeading, valueHeading, map);
780
		adapt(element);
781
		parentElement.addElement(element);
782
		return element;
783
	}
784
	
785
	
786
	public static enum TermComboType{
787
		EXTENSIONTYPE,
788
		LANGUAGE,
789
		MARKERTYPE,
790
		NOMENCLATURALSTATUSTYPE,
791
		RANK,
792
		RIGHTSTYPE, 
793
		NAMERELATIONSHIP, 
794
		NAMEDAREATYPE, 
795
		PRESENCEABSENCESTATUS, 
796
		ANNOTATIONTYPE,
797
		NAMETYPEDESIGNATIONSTATUS,
798
		SPECIMENTYPEDESIGNATIONSTATUS,
799
		SEX,
800
		STAGE,
801
		PRESERVATION_METHOD,
802
		MEASUREMENT_UNIT,
803
		STATE, 
804
		MODIFIER, 
805
		STATISTICAL_MEASURE, 
806
		SCOPE,
807
		EMPTY, 
808
		DETERMINATION_MODIFIER, 
809
		REFERENCE_SYSTEM
810
	}
811
	
812
	/**
813
	 * <p>createTermComboElement</p>
814
	 *
815
	 * @param termComboType a {@link eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory.TermComboType} object.
816
	 * @param parentElement a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement} object.
817
	 * @param labelString a {@link java.lang.String} object.
818
	 * @param selection a {@link eu.etaxonomy.cdm.model.common.DefinedTermBase} object.
819
	 * @param style a int.
820
	 * @return a {@link eu.etaxonomy.taxeditor.ui.term.AbstractTermComboElement} object.
821
	 */
822
	public AbstractTermComboElement createTermComboElement(TermComboType termComboType, ICdmFormElement parentElement, String labelString, DefinedTermBase selection, int style){
823
		AbstractTermComboElement element = null;
824
		
825
		switch(termComboType){
826
		case EMPTY:
827
			element = new EmptyComboElement<DefinedTermBase>(this, parentElement, labelString, style);
828
			break;
829
		case EXTENSIONTYPE:
830
			element = new ExtensionTypeComboElement(this, parentElement, labelString, (ExtensionType) selection, style);
831
			break;
832
		case LANGUAGE:
833
			element = new LanguageComboElement(this, parentElement, labelString, (Language) selection, style);
834
			break;
835
		case MARKERTYPE:
836
			element = new MarkerTypeComboElement(this, parentElement, labelString, (MarkerType) selection, style);
837
			break;
838
		case NOMENCLATURALSTATUSTYPE:
839
			element = new NomenclaturalStatusTypeComboElement(this, parentElement, labelString, (NomenclaturalStatusType) selection, style);
840
			break;
841
		case RANK:
842
			element = new RankComboElement(this, parentElement, labelString, (Rank) selection, style);
843
			break;
844
		case RIGHTSTYPE:
845
			element = new RightsTypeComboElement(this, parentElement, labelString, (RightsTerm) selection, style);
846
			break;
847
		case NAMERELATIONSHIP:
848
			element = new NameRelationshipTypeComboElement(this, parentElement, labelString, (NameRelationshipType) selection, style);
849
			break;
850
		case NAMEDAREATYPE:
851
			element = new NamedAreaTypeComboElement(this, parentElement, labelString, (NamedAreaType) selection, style);
852
			break;
853
		case ANNOTATIONTYPE:
854
			element = new AnnotationTypeComboElement(this, parentElement, labelString, (AnnotationType) selection, style);
855
			break;
856
		case PRESENCEABSENCESTATUS:
857
			element = new PresenceAbsenceTermComboElement(this, parentElement, labelString, (PresenceAbsenceTermBase) selection, style);
858
			break;
859
		case NAMETYPEDESIGNATIONSTATUS:
860
			element = new NameTypeDesignationStatusComboElement(this, parentElement, labelString, (NameTypeDesignationStatus) selection, style);
861
			break;
862
		case SPECIMENTYPEDESIGNATIONSTATUS:
863
			element = new SpecimenTypeDesignationStatusComboElement(this, parentElement, labelString, (SpecimenTypeDesignationStatus) selection, style);
864
			break;
865
		case SEX:
866
			element = new SexComboElement(this, parentElement, labelString, (Sex) selection, style);
867
			break;
868
		case STAGE:
869
			element = new StageComboElement(this, parentElement, labelString, (Stage) selection, style);
870
			break;
871
		case PRESERVATION_METHOD:
872
			element = new PreservationMethodComboElement(this, parentElement, labelString, (PreservationMethod) selection, style);
873
			break;
874
		case MEASUREMENT_UNIT:
875
			element = new MeasurementUnitComboElement(this, parentElement, labelString, (MeasurementUnit) selection, style);
876
			break;
877
		case STATE:
878
			element = new StateComboElement(this, parentElement, labelString, (State) selection, style);
879
			break;
880
		case SCOPE:
881
			element = new ScopeComboElement(this, parentElement, labelString, (Scope) selection, style);
882
			break;
883
		case MODIFIER:
884
			element = new ModifierComboElement(this, parentElement, labelString, (Modifier) selection, style);
885
			break;
886
		case STATISTICAL_MEASURE:
887
			element = new StatisticalMeasureComboElement(this, parentElement, labelString, (StatisticalMeasure) selection, style);
888
			break;
889
		case DETERMINATION_MODIFIER:
890
			element = new DeterminationModifierComboElement(this, parentElement, labelString, (DeterminationModifier) selection, style);
891
			break;
892
		case REFERENCE_SYSTEM:
893
			element = new ReferenceSystemComboElement(this, parentElement, labelString, (ReferenceSystem) selection, style);
894
			break;
895
		}
896
		
897
		adapt(element);
898
		parentElement.addElement(element);
899
		return element;
900
	}
901
	
902
	public static enum EnumComboType{
903
		REFERENCETYPE, 
904
		NOMENCLATURALCODE
905
	}
906
	
907
	/**
908
	 * <p>createEnumComboElement</p>
909
	 *
910
	 * @param enumComboType a {@link eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory.EnumComboType} object.
911
	 * @param parentElement a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement} object.
912
	 * @param style a int.
913
	 * @return a {@link eu.etaxonomy.taxeditor.ui.term.AbstractEnumComboElement} object.
914
	 */
915
	public AbstractEnumComboElement createEnumComboElement(EnumComboType enumComboType, ICdmFormElement parentElement, int style){
916
		AbstractEnumComboElement element = null;
917

    
918
		switch(enumComboType){
919
		case REFERENCETYPE:
920
			element = new ReferenceTypeComboElement(this, parentElement, "Reference Type", null, style);
921
			break;
922
		case NOMENCLATURALCODE:
923
			element = new NomenclaturalCodeComboElement(this, parentElement, "Nomenclatural Code", null, style);
924
			break;
925
		}
926
		adapt(element);
927
		parentElement.addElement(element);
928
		return element;
929
	}	
930
	
931
	/**
932
	 * <p>createBrowserElement</p>
933
	 *
934
	 * @param imageUri a {@link java.net.URI} object.
935
	 * @param style a int.
936
	 * @param parentElement a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement} object.
937
	 * @return a {@link eu.etaxonomy.taxeditor.ui.forms.BrowserElement} object.
938
	 */
939
	public BrowserElement createBrowserElement(ICdmFormElement parentElement, URI imageUri, int style){
940
		BrowserElement element = new BrowserElement(this, parentElement, imageUri, style);
941
		adapt(element);
942
		parentElement.addElement(element);
943
		return element;
944
	}
945
	
946
	/**
947
	 * <p>createImageElement</p>
948
	 *
949
	 * @param parentElement a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement} object.
950
	 * @param imageUri a {@link java.net.URI} object.
951
	 * @param style a int.
952
	 * @return a {@link eu.etaxonomy.taxeditor.ui.forms.ImageElement} object.
953
	 */
954
	public ImageElement createImageElement(ICdmFormElement parentElement, URI imageUri, int style) {
955
		ImageElement element = new ImageElement(this, parentElement, imageUri, style);
956
		adapt(element);
957
		parentElement.addElement(element);
958
		return element;
959
	}
960
	
961
	/**
962
	 * <p>createTextActionElement</p>
963
	 *
964
	 * @param labelString a {@link java.lang.String} object.
965
	 * @param initialText a {@link java.lang.String} object.
966
	 * @param style a int.
967
	 * @param parentElement a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement} object.
968
	 * @param buttonLabel a {@link java.lang.String} object.
969
	 * @return a {@link eu.etaxonomy.taxeditor.ui.forms.TextActionElement} object.
970
	 */
971
	public TextActionElement createTextActionElement(ICdmFormElement parentElement, String labelString, String buttonLabel, String initialText, int style){
972
		TextActionElement element = new TextActionElement(this, parentElement, labelString, buttonLabel, initialText, style);
973
		adapt(element);
974
		parentElement.addElement(element);
975
		return element;
976
	}
977
	
978
	/**
979
	 * 	
980
	 * @author n.hoffmann
981
	 * @created Mar 5, 2010
982
	 * @version 1.0
983
	 */
984
	public static enum SelectionType{
985
		AGENT,
986
		INSTITUTION,
987
		NAME,
988
		REFERENCE,
989
		TAXON_BASE,
990
		TAXON,
991
		SYNONYM,
992
		TEAM, 
993
		AUTHOR_TEAM,
994
		PERSON, 
995
		DERIVED_UNIT, 
996
		FIELD_OBSERVATION, 
997
		FEATURE_TREE,
998
		CLASSIFICATION,
999
		TAXON_NODE,
1000
		COLLECTION, 
1001
		FEATURE, 
1002
		POLYTOMOUS_KEY, 
1003
		POLYTOMOUS_KEY_NODE, 
1004
		USER, 
1005
		GROUP
1006
	}	
1007
		
1008
	/**
1009
	 * <p>createCheckbox</p>
1010
	 *
1011
	 * @param parentElement a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement} object.
1012
	 * @param label a {@link java.lang.String} object.
1013
	 * @param initialState a boolean.
1014
	 * @param style a int.
1015
	 * @return a {@link eu.etaxonomy.taxeditor.ui.forms.CheckboxElement} object.
1016
	 */
1017
	public CheckboxElement createCheckbox(ICdmFormElement parentElement, String label, boolean initialState, int style) {
1018
		CheckboxElement element = new CheckboxElement(this, parentElement, label, initialState, style | orientation);
1019
		adapt(element);
1020
		parentElement.addElement(element);
1021
		return element;
1022
	}
1023

    
1024
	
1025
	
1026
	/**
1027
	 * Creates a section as a part of the form.
1028
	 *
1029
	 * @return the section widget
1030
	 * @param section a {@link eu.etaxonomy.taxeditor.ui.forms.AbstractFormSection} object.
1031
	 */
1032
	public Section adapt(AbstractFormSection section) {
1033
		section.setMenu(section.getLayoutComposite().getMenu());
1034
		adapt(section, true, true);
1035
		
1036
		// handle focus and property change events for cdm use
1037
		section.addFocusListener(selectionFocusHandler);
1038
		section.setPropertyChangeListeners(propertyChangeListeners);
1039
		
1040
		if (section.getToggle() != null) {
1041
			section.getToggle().setHoverDecorationColor(getColors()
1042
					.getColor(IFormColors.TB_TOGGLE_HOVER));
1043
			section.getToggle().setDecorationColor(getColors()
1044
					.getColor(IFormColors.TB_TOGGLE));
1045
		}
1046
		
1047
		section.setFont(boldFontHolder2.getBoldFont(section.getLayoutComposite().getFont()));
1048

    
1049
		if ((section.getStyle() & Section.TITLE_BAR) != 0
1050
				|| (section.getStyle() & Section.SHORT_TITLE_BAR) != 0) {
1051
			getColors().initializeSectionToolBarColors();
1052
			section.setTitleBarBackground(getColors().getColor(IFormColors.TB_BG));
1053
			section.setTitleBarBorderColor(getColors()
1054
					.getColor(IFormColors.TB_BORDER));
1055
		}
1056
		// call setTitleBarForeground regardless as it also sets the label color
1057
		section.setTitleBarForeground(getColors()
1058
				.getColor(IFormColors.TB_TOGGLE));
1059
		return section;
1060
	}
1061
	
1062
	private class BoldFontHolder2 {
1063
		private Font normalFont;
1064

    
1065
		private Font boldFont;
1066

    
1067
		public BoldFontHolder2() {
1068
		}
1069

    
1070
		public Font getBoldFont(Font font) {
1071
			createBoldFont(font);
1072
			return boldFont;
1073
		}
1074

    
1075
		private void createBoldFont(Font font) {
1076
			if (normalFont == null || !normalFont.equals(font)) {
1077
				normalFont = font;
1078
				dispose();
1079
			}
1080
			if (boldFont == null) {
1081
				boldFont = FormFonts.getInstance().getBoldFont(getColors().getDisplay(),
1082
						normalFont);
1083
			}
1084
		}
1085

    
1086
		public void dispose() {
1087
			if (boldFont != null) {
1088
				FormFonts.getInstance().markFinished(boldFont, getColors().getDisplay());
1089
				boldFont = null;
1090
			}
1091
		}
1092
	}
1093
	
1094
	/**
1095
	 * <p>createToggleableTextField</p>
1096
	 *
1097
	 * @param parentElement a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement} object.
1098
	 * @param labelString a {@link java.lang.String} object.
1099
	 * @param initialText a {@link java.lang.String} object.
1100
	 * @param initialState a boolean.
1101
	 * @param style a int.
1102
	 * @return a {@link eu.etaxonomy.taxeditor.ui.forms.ToggleableTextElement} object.
1103
	 */
1104
	public ToggleableTextElement createToggleableTextField(ICdmFormElement parentElement,
1105
			String labelString,	String initialText, boolean initialState, int style) {
1106
		ToggleableTextElement element = new ToggleableTextElement(this, parentElement,
1107
				labelString, initialText, initialState, style | orientation);
1108
		adapt(element);
1109
		parentElement.addElement(element);
1110
		return element;
1111
	}
1112
	
1113
	/**
1114
	 * <p>createTimePeriodElement</p>
1115
	 *
1116
	 * @param parentElement a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement} object.
1117
	 * @param labelString a {@link java.lang.String} object.
1118
	 * @param timePeriod a {@link eu.etaxonomy.cdm.model.common.TimePeriod} object.
1119
	 * @param style a int.
1120
	 * @return a {@link eu.etaxonomy.taxeditor.ui.forms.TimePeriodElement} object.
1121
	 */
1122
	public TimePeriodElement createTimePeriodElement(
1123
			ICdmFormElement parentElement, String labelString, TimePeriod timePeriod, int style) {
1124
		TimePeriodElement element = new TimePeriodElement(this, parentElement, labelString, timePeriod, style);
1125
		adapt(element);
1126
		parentElement.addElement(element);
1127
		return element;
1128
	}
1129
	
1130

    
1131
	/**
1132
	 * <p>createPointElement</p>
1133
	 *
1134
	 * @param style a int.
1135
	 * @param parentElement a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement} object.
1136
	 * @param point a {@link eu.etaxonomy.cdm.model.location.Point} object.
1137
	 * @return a {@link eu.etaxonomy.taxeditor.ui.forms.PointElement} object.
1138
	 */
1139
	public PointElement createPointElement(ICdmFormElement parentElement,
1140
			Point point, int style) {
1141
		PointElement element = new PointElement(this, parentElement, point, style);
1142
		adapt(element);
1143
		parentElement.addElement(element);
1144
		return element;
1145
	}
1146
	
1147
	/**
1148
	 * <p>createDateDetailSection</p>
1149
	 *
1150
	 * @param parentElement a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement} object.
1151
	 * @param style a int.
1152
	 * @return a {@link eu.etaxonomy.taxeditor.ui.forms.DateDetailSection} object.
1153
	 */
1154
	public DateDetailSection createDateDetailSection(ICdmFormElement parentElement, int style){
1155
		DateDetailSection section = new DateDetailSection(this, parentElement, style);
1156
		parentElement.addElement(section);
1157
		adapt(section);
1158
		return section;
1159
	}
1160
	
1161
	/**
1162
	 * <p>createPartialElement</p>
1163
	 *
1164
	 * @param parentElement a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement} object.
1165
	 * @param labelString a {@link java.lang.String} object.
1166
	 * @param partial a {@link org.joda.time.Partial} object.
1167
	 * @param style a int.
1168
	 * @return a {@link eu.etaxonomy.taxeditor.ui.forms.PartialElement} object.
1169
	 */
1170
	public PartialElement createPartialElement(ICdmFormElement parentElement, String labelString, Partial partial, int style){
1171
		PartialElement element = new PartialElement(this, parentElement, labelString, style);
1172
		adapt(element);
1173
		parentElement.addElement(element);
1174
		return element;
1175
	}
1176

    
1177
	/**
1178
	 * <p>addSelectionListener</p>
1179
	 *
1180
	 * @param listener a {@link org.eclipse.swt.events.SelectionListener} object.
1181
	 */
1182
	public void addSelectionListener(SelectionListener listener){
1183
		selectionListenerList.add(listener);
1184
	}
1185
	
1186
	/**
1187
	 * <p>removeSelectionListener</p>
1188
	 *
1189
	 * @param listener a {@link org.eclipse.swt.events.SelectionListener} object.
1190
	 */
1191
	public void removeSelectionListener(SelectionListener listener){
1192
		if(listener == null){
1193
			StoreUtil.error(this.getClass(), "Tried to remove a selection listener from this factories listeners but was null", null);
1194
		}else{
1195
			selectionListenerList.remove(listener);
1196
		}
1197
	}
1198
	
1199
	/**
1200
	 * <p>addPropertyChangeListener</p>
1201
	 *
1202
	 * @param listener a {@link org.eclipse.jface.util.IPropertyChangeListener} object.
1203
	 */
1204
	public void addPropertyChangeListener(IPropertyChangeListener listener) {
1205
		propertyChangeListeners.add(0, listener);
1206
	}
1207
	
1208
	/**
1209
	 * <p>removePropertyChangeListener</p>
1210
	 *
1211
	 * @param listener a {@link org.eclipse.jface.util.IPropertyChangeListener} object.
1212
	 */
1213
	public void removePropertyChangeListener(IPropertyChangeListener listener){
1214
		propertyChangeListeners.remove(listener);
1215
	}
1216

    
1217

    
1218

    
1219
	/**
1220
	 * <p>createHorizontalSeparator</p>
1221
	 *
1222
	 * @param parentElement a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement} object.
1223
	 * @param style a int.
1224
	 * @return a {@link org.eclipse.swt.widgets.Label} object.
1225
	 */
1226
	public Label createHorizontalSeparator(ICdmFormElement parentElement, int style) {
1227
		Label separator = this.createSeparator(parentElement.getLayoutComposite(), SWT.HORIZONTAL | style);
1228
		separator.setLayoutData(FILL_HORIZONTALLY());
1229
		return separator;
1230
	}
1231
	
1232
	/**
1233
	 * <p>createVersionElement</p>
1234
	 *
1235
	 * @param parentElement a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement} object.
1236
	 * @param entity a {@link eu.etaxonomy.cdm.model.common.VersionableEntity} object.
1237
	 * @param style a int.
1238
	 * @return a {@link eu.etaxonomy.taxeditor.ui.section.supplemental.VersionElement} object.
1239
	 */
1240
	public VersionElement createVersionElement(ICdmFormElement parentElement, VersionableEntity entity,
1241
			int style) {
1242
		VersionElement element = new VersionElement(this, parentElement, entity, style);
1243
		adapt(element);
1244
		parentElement.addElement(element);
1245
		return element;
1246
	}
1247

    
1248
	/**
1249
	 * <p>createVersionSection</p>
1250
	 *
1251
	 * @param parentElement a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement} object.
1252
	 * @param style a int.
1253
	 * @return a {@link eu.etaxonomy.taxeditor.ui.section.supplemental.VersionSection} object.
1254
	 */
1255
	public VersionSection createVersionSection(ICdmFormElement parentElement, int style) {
1256
		VersionSection section = new VersionSection(this, parentElement, style);
1257
		parentElement.addElement(section);
1258
		adapt(section);
1259
		return section;
1260
	}
1261
	
1262
	/**
1263
	 * <p>createEmptyElement</p>
1264
	 *
1265
	 * @param parentElement a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement} object.
1266
	 * @return a {@link eu.etaxonomy.taxeditor.ui.section.EmptyElement} object.
1267
	 */
1268
	public EmptyElement createEmptyElement(ICdmFormElement parentElement) {
1269
		EmptyElement element = new EmptyElement(this, parentElement, null, SWT.NULL);
1270
		adapt(element);
1271
		parentElement.addElement(element);
1272
		return element;
1273
	}
1274
	
1275
	/**
1276
	 * <p>createHeadlineSection</p>
1277
	 *
1278
	 * @param parentElement a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement} object.
1279
	 * @return a {@link eu.etaxonomy.taxeditor.ui.section.supplemental.HeadlineSection} object.
1280
	 */
1281
	public HeadlineSection createHeadlineSection(ICdmFormElement parentElement) {
1282
		HeadlineSection section = new HeadlineSection(this, parentElement, SWT.NULL);
1283
		parentElement.addElement(section);
1284
		adapt(section);
1285
		return section;
1286
	}
1287

    
1288

    
1289
	/**
1290
	 * <p>createParsingMessageElement</p>
1291
	 *
1292
	 * @param parentElement a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement} object.
1293
	 * @param parserProblem a {@link eu.etaxonomy.cdm.strategy.parser.ParserProblem} object.
1294
	 * @param style a int.
1295
	 * @return a {@link eu.etaxonomy.taxeditor.ui.section.taxon.ParsingMessageElement} object.
1296
	 */
1297
	public ParsingMessageElement createParsingMessageElement(
1298
			ICdmFormElement parentElement, ParserProblem parserProblem, int style) {
1299
		ParsingMessageElement element = new ParsingMessageElement(this, parentElement, parserProblem, style);
1300
		adapt(element);
1301
		parentElement.addElement(element);
1302
		return element;
1303
	}
1304

    
1305
	
1306
	// SIMPLIFY
1307
	
1308
	/**
1309
	 * 
1310
	 */
1311
	public static enum DetailType{
1312
		NONVIRALNAME,
1313
		SCIENTIFICNAME,
1314
		REFERENCEBASE,
1315
		NOMENCLATURALREFERENCE,
1316
		TAXONBASE,
1317
		AUTHORSHIP,
1318
		TEAM,
1319
		PERSON,
1320
		DESCRIPTION,
1321
		DESCRIPTIONELEMENT, 
1322
		PARSINGMESSAGE,
1323
		NAMERELATIONSHIP, 
1324
		TEAMORPERSONBASE,
1325
		MEDIA, 
1326
		FIELD_OBSERVATION, 
1327
		DERIVED_UNIT_FACADE, 
1328
		GATHERING_EVENT, 
1329
		DERIVED_UNIT, NATURAL_LANGUAGE, 
1330
		FEATURE_DISTRIBUTION,
1331
		CLASSIFICATION,
1332
		TAXON_NODE, 
1333
		COLLECTION, 
1334
		POLYTOMOUS_KEY, 
1335
		POLYTOMOUS_KEY_NODE, 
1336
		INSTITUTION, 
1337
		DERIVED_UNIT_GENERAL, 
1338
		HYBRID, 
1339
		USER,
1340
		GROUP
1341
	}
1342
	
1343
	/**
1344
	 * <p>createCdmDetailSection</p>
1345
	 *
1346
	 * @param detailType a {@link eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory.DetailType} object.
1347
	 * @param parentElement a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement} object.
1348
	 * @param selectionProvider a {@link org.eclipse.jface.viewers.ISelectionProvider} object.
1349
	 * @param style a int.
1350
	 * @param conversation a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
1351
	 * @return a {@link eu.etaxonomy.taxeditor.ui.forms.AbstractFormSection} object.
1352
	 */
1353
	public AbstractFormSection createCdmDetailSection(DetailType detailType, ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
1354
		AbstractFormSection section = null;
1355
		
1356
		switch(detailType){
1357
		case SCIENTIFICNAME:
1358
			section = new NameDetailSection(this, conversation, parentElement, selectionProvider, style);
1359
			break;
1360
		case REFERENCEBASE:
1361
			section = new ReferenceDetailSection(this, conversation, parentElement, selectionProvider, style);
1362
			break;
1363
		case NOMENCLATURALREFERENCE:
1364
			section = new NomenclaturalReferenceDetailSection(this, conversation, parentElement, selectionProvider, style);
1365
			break;
1366
		case TAXONBASE:
1367
			section = new TaxonBaseDetailSection(this, conversation, parentElement, selectionProvider, style);
1368
			break;
1369
		case AUTHORSHIP:
1370
			section = new AuthorshipDetailSection(this, conversation, parentElement, selectionProvider, style);
1371
			break;
1372
		case TEAMORPERSONBASE:
1373
			section = new TeamOrPersonBaseDetailSection(this, conversation, parentElement, selectionProvider, style);
1374
			break;
1375
		case TEAM:
1376
			section = new TeamDetailSection(this, conversation, parentElement, null, style);
1377
			break;
1378
		case PERSON:
1379
			section = new PersonDetailSection(this, conversation, parentElement, null, style);
1380
			break;
1381
		case DESCRIPTION:
1382
			section = new DescriptionDetailSection(this, conversation, parentElement, selectionProvider, style);
1383
			break;
1384
		case DESCRIPTIONELEMENT:
1385
			section = new DescriptionElementDetailSection(this, conversation, parentElement, selectionProvider, style);
1386
			break;
1387
		case PARSINGMESSAGE:
1388
			section = new ParsingMessagesSection(this, conversation, parentElement, selectionProvider, style);
1389
			break;
1390
		case NONVIRALNAME:
1391
			section = new NonViralNameDetailSection(this, conversation, parentElement, selectionProvider, style);
1392
			break;
1393
		case MEDIA:
1394
			section = new eu.etaxonomy.taxeditor.ui.section.description.MediaDetailsSection(this, conversation, parentElement, selectionProvider, style);
1395
			break;
1396
		case DERIVED_UNIT_FACADE:
1397
			section = new DerivedUnitFacadeDetailSection(this, conversation, parentElement, selectionProvider, style);
1398
			break;
1399
		case FIELD_OBSERVATION:
1400
			section = new FieldObservationDetailSection(this, conversation, parentElement, selectionProvider, style);
1401
			break;
1402
		case GATHERING_EVENT:
1403
			section = new GatheringEventDetailSection(this, conversation, parentElement, selectionProvider, style);
1404
			break;
1405
		case DERIVED_UNIT:
1406
			section = new DerivedUnitBaseDetailSection(this, conversation, parentElement, selectionProvider, style);
1407
			break;
1408
		case NATURAL_LANGUAGE:
1409
			section = new NaturalLanguageSection(this, conversation, parentElement, selectionProvider, style);
1410
			break;
1411
		case FEATURE_DISTRIBUTION:
1412
			section = new FeatureDistributionDetailSection(this, conversation, parentElement, selectionProvider, style);
1413
			break;
1414
		case CLASSIFICATION:
1415
			section = new ClassificationDetailSection(this, conversation, parentElement, selectionProvider, style);
1416
			break;
1417
		case TAXON_NODE:
1418
			section = new TaxonNodeDetailSection(this, conversation, parentElement, selectionProvider, style);
1419
			break;
1420
		case POLYTOMOUS_KEY:
1421
			section = new PolytomousKeyDetailSection(this, conversation, parentElement, selectionProvider, style);
1422
			break;
1423
		case POLYTOMOUS_KEY_NODE:
1424
			section = new PolytomousKeyNodeDetailSection(this, conversation, parentElement, selectionProvider, style);
1425
			break;
1426
		case INSTITUTION:
1427
			section = new InstitutionDetailSection(this, conversation, parentElement, selectionProvider, style);
1428
			break;
1429
		case DERIVED_UNIT_GENERAL:
1430
			section = new GeneralDetailSection(this, conversation, parentElement, selectionProvider, style);
1431
			break;
1432
		case HYBRID:
1433
			section = new HybridDetailSection(this, conversation, parentElement, selectionProvider, style);
1434
			break;
1435
		case USER:
1436
			section = new UserDetailSection(this, conversation, parentElement, selectionProvider, style);
1437
			break;
1438
		case GROUP:
1439
			section = new GroupDetailSection(this, conversation, parentElement, selectionProvider, style);
1440
			break;
1441
		}
1442
		
1443
		if(section == null){
1444
			throw new RuntimeException("You tried to create a cdm detail section that is not implemented yet.");
1445
		}
1446
		
1447
		parentElement.addElement(section);
1448
		adapt(section);
1449
		return section;
1450
	}
1451
	
1452
	/**
1453
	 * <p>createCdmDetailElement</p>
1454
	 *
1455
	 * @param detailType a {@link eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory.DetailType} object.
1456
	 * @param style a int.
1457
	 * @param parentElement a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement} object.
1458
	 * @return a {@link eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement} object.
1459
	 */
1460
	public AbstractCdmDetailElement createCdmDetailElement(DetailType detailType, ICdmFormElement parentElement, int style){
1461
		AbstractCdmDetailElement element = null;
1462
		
1463
		switch(detailType){
1464
		case SCIENTIFICNAME:
1465
			element = new NameDetailElement(this, parentElement, style);
1466
			break;
1467
		case REFERENCEBASE:
1468
			element = new ReferenceDetailElement(this, parentElement, style);
1469
			break;
1470
		case NOMENCLATURALREFERENCE:
1471
			element = new NomenclaturalReferenceDetailElement(this, parentElement, style);
1472
			break;
1473
		case TAXONBASE:
1474
			element = new TaxonBaseDetailElement(this, parentElement, style);
1475
			break;
1476
		case AUTHORSHIP:
1477
			element = new AuthorshipDetailElement(this, parentElement, style);
1478
			break;
1479
		case TEAM:
1480
			element = new TeamDetailElement(this, parentElement, style);
1481
			break;
1482
		case PERSON:
1483
			element = new PersonDetailElement(this, parentElement, style);
1484
			break;
1485
		case DESCRIPTION:
1486
			element = new DescriptionDetailElement(this, parentElement, style);
1487
			break;
1488
		case DESCRIPTIONELEMENT:
1489
			element = new DescriptionElementDetailElement(this, parentElement, style);
1490
			break;
1491
		case NONVIRALNAME:
1492
			element = new NonViralNameDetailElement(this, parentElement);
1493
			break;
1494
		case DERIVED_UNIT_FACADE:
1495
			element = new DerivedUnitFacadeDetailElement(this, parentElement);
1496
			break;
1497
		case FIELD_OBSERVATION:
1498
			element = new FieldObservationDetailElement(this, parentElement);
1499
			break;
1500
		case GATHERING_EVENT:
1501
			element = new GatheringEventDetailElement(this, parentElement);
1502
			break;
1503
		case DERIVED_UNIT:
1504
			element = new DerivedUnitBaseDetailElement(this, parentElement);
1505
			break;
1506
		case NATURAL_LANGUAGE:
1507
			element = new NaturalLanguageDetailElement(this, parentElement);
1508
			break;
1509
		case FEATURE_DISTRIBUTION:
1510
			element = new FeatureDistributionDetailElement(this, parentElement);
1511
			break;
1512
		case CLASSIFICATION:
1513
			element = new ClassificationDetailElement(this, parentElement);
1514
			break;
1515
		case TAXON_NODE:
1516
			element = new TaxonNodeDetailElement(this, parentElement);
1517
			break;
1518
		case COLLECTION:
1519
			element = new CollectionDetailElement(this, parentElement);
1520
			break;
1521
		case POLYTOMOUS_KEY:
1522
			element = new PolytomousKeyDetailElement(this, parentElement);
1523
			break;
1524
		case POLYTOMOUS_KEY_NODE:
1525
			element = new PolytomousKeyNodeDetailElement(this, parentElement);
1526
			break;
1527
		case INSTITUTION:
1528
			element = new InstitutionDetailElement(this, parentElement);
1529
			break;
1530
		case DERIVED_UNIT_GENERAL:
1531
			element = new GeneralDetailElement(this, parentElement);
1532
			break;
1533
		case HYBRID:
1534
			element = new HybridDetailElement(this, parentElement);
1535
			break;
1536
		case USER:
1537
			element = new UserDetailElement(this, parentElement);
1538
			break;
1539
		case GROUP:
1540
			element = new GroupDetailElement(this, parentElement);
1541
			break;
1542
		}
1543
		
1544
		if(element == null){
1545
			StoreUtil.error(this.getClass(), "Detail element was not created. Seems like the case was not implemented for the requested detail type: " + detailType, null);
1546
		}
1547
		
1548
		adapt(element);
1549
		parentElement.addElement(element);
1550
		return element;
1551
	}
1552
	
1553
	/**
1554
	 * 
1555
	 * @author n.hoffmann
1556
	 * @created Mar 5, 2010
1557
	 * @version 1.0
1558
	 */
1559
	public static enum EntityDetailType{
1560
		TEAM,
1561
		TEAMMEMBER,
1562
		ANNOTATION,
1563
		CREDIT,
1564
		DESCRIPTIONELEMENTSOURCE,
1565
		EXTENSION,
1566
		MARKER,
1567
		MEDIA, 
1568
		DESCRIPTIONELEMENTMEDIA,
1569
		MEDIAREPRESENTATION,
1570
		MEDIAREPRESENTATIONPART,
1571
		MODIFIER,
1572
		NOMENCLATURALSTATUS,
1573
		NAME_RELATIONSHIP,
1574
		PROTOLOG,
1575
		RIGHTS,
1576
		SOURCE, 
1577
		SCOPE, 
1578
		DESCRIPTIONSOURCE, 
1579
		TYPEDESIGNATION,
1580
		STATE_DATA, 
1581
		STATISTICAL_MEASUREMENT_VALUE, 
1582
		DESCRIBED_SPECIMEN, 
1583
		COLLECTING_AREA, 
1584
		DETERMINATION_EVENT, 
1585
		SPECIMEN_COLLECTION, 
1586
		IDENTIFIABLE_SOURCE_COLLECTION, 
1587
		GEOGRAPHICAL_SCOPE, 
1588
		SCOPE_RESTRICTION,
1589
		MEMBER, 
1590
		GRANTED_AUTHORITY, 
1591
		GROUPS_BY_USER
1592
	}
1593
	
1594
	/**
1595
	 * <p>createEntityDetailSection</p>
1596
	 *
1597
	 * @param entityDetailType a {@link eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory.EntityDetailType} object.
1598
	 * @param style a int.
1599
	 * @param conversation a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
1600
	 * @param parentElement a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement} object.
1601
	 * @return a {@link eu.etaxonomy.taxeditor.ui.forms.AbstractFormSection} object.
1602
	 */
1603
	public AbstractFormSection createEntityDetailSection(EntityDetailType entityDetailType, ConversationHolder conversation, ICdmFormElement parentElement, int style){
1604
		AbstractFormSection section = null;
1605
		
1606
		switch(entityDetailType){
1607
		case TEAM:
1608
			section = new TeamDetailSection(this, conversation, parentElement, null, style);
1609
			break;
1610
		case TEAMMEMBER:
1611
			section = new TeamMemberSection(this, conversation, parentElement, style);
1612
			break;
1613
		case ANNOTATION:
1614
			section = new AnnotationSection(this, conversation, parentElement, style);
1615
			break;
1616
		case CREDIT:
1617
			section = new CreditSection(this, conversation, parentElement, style);
1618
			break;
1619
		case DESCRIPTIONELEMENTSOURCE:
1620
			section = new DescriptionElementSourceSection(this, conversation, parentElement, style);
1621
			break;
1622
		case EXTENSION:
1623
			section = new ExtensionSection(this, conversation, parentElement, style);
1624
			break;
1625
		case MARKER:
1626
			section = new MarkerSection(this, conversation, parentElement, style);
1627
			break;
1628
		case MEDIA:
1629
			section = new MediaSection(this, conversation, parentElement, style);
1630
			break;
1631
		case DESCRIPTIONELEMENTMEDIA:
1632
			section = new DescriptionElementMediaSection(this, conversation, parentElement, style);
1633
			break;
1634
		case MEDIAREPRESENTATION:
1635
			section = new MediaRepresentationSection(this, conversation, parentElement, style);
1636
			break;
1637
		case MEDIAREPRESENTATIONPART:
1638
			section = new MediaRepresentationPartSection(this, conversation, parentElement, style);
1639
			break;
1640
		case MODIFIER:
1641
			section = new ModifierSection(this, conversation, parentElement, style);
1642
			break;
1643
		case NOMENCLATURALSTATUS:
1644
			section = new NomenclaturalStatusSection(this, conversation, parentElement, style);
1645
			break;
1646
		case NAME_RELATIONSHIP:
1647
			section = new NameRelationshipDetailSection(this, conversation, parentElement, style);
1648
			break;
1649
		case PROTOLOG:
1650
			section = new ProtologueSection(this, conversation, parentElement, style);
1651
			break;
1652
		case RIGHTS:
1653
			section = new RightsSection(this, conversation, parentElement, style);
1654
			break;
1655
		case SOURCE:
1656
			section = new SourceSection(this, conversation, parentElement, style);
1657
			break;
1658
		case SCOPE:
1659
			section = new ScopeSection(this, conversation, parentElement, style);
1660
			break;
1661
		case DESCRIPTIONSOURCE:
1662
			section = new DescriptionSourceSection(this, conversation, parentElement, style);
1663
			break;
1664
		case TYPEDESIGNATION:
1665
			section = new TypeDesignationSection(this, conversation, parentElement, style);
1666
			break;
1667
		case STATE_DATA:
1668
			section = new StateDataSection(this, conversation, parentElement, style);
1669
			break;
1670
		case STATISTICAL_MEASUREMENT_VALUE:
1671
			section = new StatisticalMeasurementValueSection(this, conversation, parentElement, style);
1672
			break;
1673
		case DESCRIBED_SPECIMEN:
1674
			section = new DescribedSpecimenSection(this, conversation, parentElement, style);
1675
			break;
1676
		case COLLECTING_AREA:
1677
			section = new CollectingAreasDetailSection(this, conversation, parentElement, style);
1678
			break;
1679
		case DETERMINATION_EVENT:
1680
			section = new DeterminationEventDetailSection(this, conversation, parentElement, style);
1681
			break;
1682
		case SPECIMEN_COLLECTION:
1683
			section = new SpecimenCollectionDetailSection(this, conversation, parentElement, style);
1684
			break;
1685
		case IDENTIFIABLE_SOURCE_COLLECTION:
1686
			section = new SourceCollectionDetailSection(this, conversation, parentElement, style);
1687
			break;
1688
		case GEOGRAPHICAL_SCOPE:
1689
			section = new GeographicalScopeDetailSection(this, conversation, parentElement, style);
1690
			break;
1691
		case SCOPE_RESTRICTION:
1692
			section = new ScopeRestrictionSection(this, conversation, parentElement, style);
1693
			break;
1694
		case MEMBER:
1695
			section = new MemberDetailSection(this, conversation, parentElement, style);
1696
			break;
1697
		case GRANTED_AUTHORITY:
1698
			section = new GrantedAuthorityDetailSection(this, conversation, parentElement, style);
1699
			break;
1700
		case GROUPS_BY_USER:
1701
			section = new GroupsByUserDetailSection(this, conversation, parentElement, style);
1702
			break;
1703
		}
1704
		parentElement.addElement(section);
1705
		adapt(section);
1706
		return section;
1707
	}
1708
	
1709
	/**
1710
	 * <p>createEntityCollectionElement</p>
1711
	 *
1712
	 * @param removeListener a {@link org.eclipse.swt.events.SelectionListener} object.
1713
	 * @param style a int.
1714
	 * @param parentElement a {@link eu.etaxonomy.taxeditor.ui.forms.AbstractFormSection} object.
1715
	 * @param versionableEntity a {@link eu.etaxonomy.cdm.model.common.IVersionableEntity} object.
1716
	 * @param backgroundColor a {@link org.eclipse.swt.graphics.Color} object.
1717
	 * @return a {@link eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionElement} object.
1718
	 */
1719
	public AbstractEntityCollectionElement createEntityCollectionElement(AbstractFormSection parentElement, Object versionableEntity, SelectionListener removeListener, Color backgroundColor, int style){
1720
		AbstractEntityCollectionElement element = null;
1721
		
1722
		Object entity = HibernateProxyHelper.deproxy(versionableEntity);
1723
		
1724
		if(entity instanceof Annotation){
1725
			element = new AnnotationElement(this, parentElement, (Annotation) entity, removeListener, style);
1726
		}
1727
		else if(entity instanceof Person){
1728
			element = new TeamMemberElement(this, parentElement, (Person) entity, removeListener, style);
1729
		}
1730
		else if(entity instanceof Credit){
1731
			element = new CreditElement(this, parentElement, (Credit) entity, removeListener, style);
1732
		}
1733
		else if(entity instanceof Extension){
1734
			element = new ExtensionElement(this, parentElement, (Extension) entity, removeListener, style);
1735
		}
1736
		else if(entity instanceof Marker){
1737
			element = new MarkerElement(this, parentElement, (Marker) entity, removeListener, style);
1738
		}
1739
		else if(entity instanceof Media){
1740
			element = new MediaElement(this, parentElement, (Media) entity, removeListener, style);
1741
		}
1742
		else if(entity instanceof MediaRepresentation){
1743
			element = new MediaRepresentationElement(this, parentElement, (MediaRepresentation) entity, removeListener, style);
1744
		}
1745
		else if(entity instanceof ImageFile){
1746
			element = new ImageFileElement(this, parentElement, (ImageFile) entity, removeListener, style);
1747
		}
1748
		else if(entity instanceof NomenclaturalStatus){
1749
			element = new NomenclaturalStatusElement(this, parentElement, (NomenclaturalStatus) entity, removeListener, style);
1750
		}
1751
		else if(entity instanceof Rights){
1752
			element = new RightsElement(this, parentElement, (Rights) entity, removeListener, style);
1753
		}
1754
		else if(entity instanceof DescriptionElementSource){
1755
			element = new DescriptionElementSourceElement(this, parentElement, (DescriptionElementSource) entity, removeListener, style);
1756
		}
1757
		else if(entity instanceof IdentifiableSource){
1758
			element = new IdentifiableSourceElement(this, parentElement, (IdentifiableSource) entity, removeListener, style);
1759
		}
1760
		else if(entity instanceof Scope){
1761
			element = new ScopeElement(this, parentElement, (Scope) entity, removeListener, style);
1762
		}
1763
		else if(entity instanceof Modifier){
1764
			element = new ModifierElement(this, parentElement, (Modifier) entity, removeListener, style);
1765
		}
1766
		else if(entity instanceof Reference){
1767
			element = new DescriptionSourceElement(this, parentElement, (Reference) entity, removeListener, style);
1768
		}
1769
		else if(entity instanceof NameTypeDesignation){
1770
			element = new NameTypeDesignationElement(this, parentElement, (NameTypeDesignation) entity, removeListener, style);
1771
		}
1772
		else if(entity instanceof NameRelationship){
1773
			element = new NameRelationshipDetailElement(this, parentElement, (NameRelationship) entity, removeListener, style);
1774
		}
1775
		else if(entity instanceof SpecimenTypeDesignation){
1776
			element = new SpecimenTypeDesignationElement(this, parentElement, (SpecimenTypeDesignation) entity, removeListener, style);
1777
		}
1778
		else if(entity instanceof StateData){
1779
			element = new StateDataElement(this, parentElement, (StateData) entity, removeListener, style);
1780
		}
1781
		else if(entity instanceof StatisticalMeasurementValue){
1782
			element = new StatisticalMeasurementValueElement(this, parentElement, (StatisticalMeasurementValue) entity, removeListener, style);
1783
		}
1784
		else if(entity instanceof DerivedUnit){
1785
			element = new DerivedUnitElement(this, parentElement, (DerivedUnit) entity, removeListener,  style);
1786
		}
1787
		else if(entity instanceof NamedArea){
1788
			element = new NamedAreaDetailElement(this, parentElement, (NamedArea) entity, removeListener, style);
1789
		}
1790
		else if(entity instanceof DeterminationEvent){
1791
			element = new DeterminationEventDetailElement(this, parentElement, (DeterminationEvent) entity, removeListener, style);
1792
		}
1793
		else if(entity instanceof Specimen){
1794
			element = new SpecimenCollectionDetailElement(this, parentElement, (Specimen) entity, removeListener, style);
1795
		}
1796
		else if(entity instanceof User){
1797
			element = new MemberDetailElement(this, parentElement, (User) entity, removeListener, style);
1798
		}
1799
		else if(entity instanceof GrantedAuthority){
1800
			element = new GrantedAuthorityDetailElement(this, parentElement, (GrantedAuthority) entity, removeListener, style);
1801
		}
1802
		else if(entity instanceof Group){
1803
			element = new GroupsByUserDetailElement(this, parentElement, (Group) entity, removeListener, style);
1804
		}
1805
		else if(entity instanceof DescriptionElementBase){
1806
			// this is the special case for protologs, maybe we can do this differently when API improves
1807
			DescriptionElementBase descriptionElement = (DescriptionElementBase) entity;
1808
			if(descriptionElement.getFeature().equals(Feature.PROTOLOGUE())){
1809
				element = new ProtologueElement(this, parentElement, descriptionElement, removeListener, style);
1810
			}
1811
		}
1812
		
1813
		if(element == null){
1814
			StoreUtil.errorDialog("No element for entity", this, "Could not generate element for entity. " +
1815
					"Looks like the case is not handled already. Check implementation. Entity: " + entity, null);
1816
		}
1817
		
1818
		if(backgroundColor != null && !backgroundColor.isDisposed()){
1819
			element.setBackgroundColor(backgroundColor);
1820
		}
1821
		
1822
		adapt(element);
1823
		parentElement.addElement(element);
1824
		return element;
1825
	}
1826
	
1827
	/**
1828
	 * <p>createSelectionElement</p>
1829
	 *
1830
	 * @param selectionType a {@link eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory.SelectionType} object.
1831
	 * @param parentElement a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement} object.
1832
	 * @param labelString a {@link java.lang.String} object.
1833
	 * @param selectionType
1834
	 * @param selection a {@link eu.etaxonomy.cdm.model.common.IAnnotatableEntity} object.
1835
	 * @param style a int.
1836
	 * @param conversation a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
1837
	 * @return a {@link eu.etaxonomy.taxeditor.ui.selection.AbstractSelectionElement} object.
1838
	 */
1839
	public AbstractSelectionElement createSelectionElement(SelectionType selectionType,  ConversationHolder conversation, ICdmFormElement parentElement, String labelString, ICdmBase selection, int style){
1840
		AbstractSelectionElement element = null;
1841
		
1842
		IAnnotatableEntity entity = (IAnnotatableEntity) HibernateProxyHelper.deproxy(selection);
1843
		
1844
		switch (selectionType) {
1845
		case AGENT:
1846
			element = new AgentSelectionElement(this, conversation, parentElement, labelString, (TeamOrPersonBase) entity, style);
1847
			break;
1848
		case PERSON:
1849
			element = new PersonSelectionElement(this, conversation, parentElement, labelString, (Person) entity, style);
1850
			break;
1851
		case TEAM:
1852
			element = new TeamSelectionElement(this, conversation, parentElement, labelString, (Team) entity, style);
1853
			break;
1854
		case AUTHOR_TEAM:
1855
			element = new NomenclaturalAuthorTeamSelectionElement(this, conversation, parentElement, labelString, (Team) entity, style);
1856
			break;
1857
		case INSTITUTION:
1858
			element = new InstitutionSelectionElement(this, conversation, parentElement, labelString, (Institution) entity, style);
1859
			break;
1860
		case NAME:
1861
			element = new NameSelectionElement(this, conversation, parentElement, labelString, (TaxonNameBase) entity, style);
1862
			break;
1863
		case REFERENCE:
1864
			element = new ReferenceSelectionElement(this, conversation, parentElement, labelString, (Reference) entity, style);
1865
			break;
1866
		case TAXON_BASE:
1867
			element = new TaxonBaseSelectionElement(this, conversation, parentElement, labelString, (TaxonBase) entity, style);
1868
			break;
1869
		case TAXON:
1870
			element = new TaxonSelectionElement(this, conversation, parentElement, labelString, (Taxon) entity, style);
1871
			break;
1872
		case SYNONYM:
1873
			element = new SynonymSelectionElement(this, conversation, parentElement, labelString, (Synonym) entity, style);
1874
			break;
1875
		case DERIVED_UNIT:
1876
			element = new DerivedUnitBaseSelectionElement(this, conversation, parentElement, labelString, (DerivedUnitBase) entity, style);
1877
			break;
1878
		case FIELD_OBSERVATION:
1879
			element = new FieldObservationSelectionElement(this, conversation, parentElement, labelString, (FieldObservation) entity, style);
1880
			break;
1881
		case FEATURE_TREE:
1882
			element = new FeatureTreeSelectionElement(this, conversation, parentElement, labelString, (FeatureTree) entity, style);
1883
			break;
1884
		case CLASSIFICATION:
1885
			element = new ClassificationSelectionElement(this, conversation, parentElement, labelString, (Classification) entity, style);
1886
			break;
1887
		case TAXON_NODE:
1888
			element = new TaxonNodeSelectionElement(this, conversation, parentElement, labelString, (TaxonNode) entity, style);
1889
			break;
1890
		case COLLECTION:
1891
			element = new CollectionSelectionElement(this, conversation, parentElement, labelString, (Collection) entity, style);
1892
			break;
1893
		case FEATURE:
1894
			element = new FeatureSelectionElement(this, conversation, parentElement, labelString, (Feature) entity, style);
1895
			break;
1896
		case POLYTOMOUS_KEY:
1897
			element = new PolytomousKeySelectionElement(this, conversation, parentElement, labelString, (PolytomousKey) entity, style);
1898
			break;
1899
		case POLYTOMOUS_KEY_NODE:
1900
			element = new PolytomousKeyNodeSelectionElement(this, conversation, parentElement, labelString, (PolytomousKeyNode) entity, style);
1901
			break;
1902
		case USER:
1903
			element = new UserSelectionElement(this, conversation, parentElement, labelString, (User) entity, style);
1904
			break;
1905
		case GROUP:
1906
			element = new GroupSelectionElement(this, conversation, parentElement, labelString, (Group) entity, style);
1907
			break;
1908
		default:
1909
			new RuntimeException("There is no selection composite for the desired selection type.");
1910
			break;
1911
		}
1912
		
1913
		adapt(element);
1914
		parentElement.addElement(element);
1915
		return element;
1916
	}
1917
	
1918
	/**
1919
	 * <p>createNamedAreaSelectionElement</p>
1920
	 *
1921
	 * @param parentElement a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement} object.
1922
	 * @param conversation a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
1923
	 * @param labelString a {@link java.lang.String} object.
1924
	 * @param selection a {@link eu.etaxonomy.cdm.model.location.NamedArea} object.
1925
	 * @param style a int.
1926
	 * @return a {@link eu.etaxonomy.taxeditor.ui.selection.NamedAreaSelectionElement} object.
1927
	 */
1928
	public NamedAreaSelectionElement createNamedAreaSelectionElement(ICdmFormElement parentElement, ConversationHolder conversation, String labelString, NamedArea selection, int style){
1929
		NamedAreaSelectionElement element = new NamedAreaSelectionElement(this, conversation, parentElement, labelString, selection, style);
1930
		adapt(element);
1931
		parentElement.addElement(element);
1932
		return element;
1933
	}
1934

    
1935
	/** {@inheritDoc} */
1936
	public LabelElement createLabel(ICdmFormElement parentElement, String text) {
1937
		LabelElement labelElement = new LabelElement(this, parentElement, text);
1938
		adapt(labelElement);
1939
		parentElement.addElement(labelElement);
1940
		return labelElement;
1941
	}
1942

    
1943
	/**
1944
	 * <p>Getter for the field <code>selectionProvider</code>.</p>
1945
	 *
1946
	 * @return a {@link org.eclipse.jface.viewers.ISelectionProvider} object.
1947
	 */
1948
	public ISelectionProvider getSelectionProvider() {
1949
		return selectionProvider;
1950
	}
1951

    
1952
	/**
1953
	 * <p>createDetailedDescriptionDetailElement</p>
1954
	 *
1955
	 * @param parentElement a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement} object.
1956
	 * @param entity a {@link eu.etaxonomy.cdm.model.description.DescriptionElementBase} object.
1957
	 * @param style a int.
1958
	 * @return a {@link eu.etaxonomy.taxeditor.ui.section.description.detail.AbstractDetailedDescriptionDetailElement} object.
1959
	 */
1960
	public AbstractDetailedDescriptionDetailElement createDetailedDescriptionDetailElement(
1961
			ICdmFormElement parentElement, DescriptionElementBase entity, int style) {
1962
		AbstractDetailedDescriptionDetailElement detailedDescriptionElement = null;
1963
		
1964
		
1965
		if(entity instanceof CategoricalData){
1966
			detailedDescriptionElement = new CategoricalDataDetailElement(this, parentElement, (CategoricalData) entity, style);
1967
		}
1968
		else if(entity instanceof CommonTaxonName){
1969
			detailedDescriptionElement = new CommonNameDetailElement(this, parentElement, (CommonTaxonName) entity, style);
1970
		}
1971
		else if(entity instanceof Distribution){
1972
			detailedDescriptionElement = new DistributionDetailElement(this, parentElement, (Distribution) entity, style);
1973
		}
1974
		else if(entity instanceof IndividualsAssociation){
1975
			detailedDescriptionElement = new IndividualsAssociationDetailElement(this, parentElement, (IndividualsAssociation) entity, style);
1976
		}
1977
		else if(entity instanceof QuantitativeData){
1978
			detailedDescriptionElement = new QuantitativeDataDetailElement(this, parentElement, (QuantitativeData) entity, style);
1979
		}
1980
		else if(entity instanceof TaxonInteraction){
1981
			detailedDescriptionElement = new TaxonInteractionDetailElement(this, parentElement, (TaxonInteraction) entity, style);
1982
		}
1983
		else if(entity instanceof TextData){
1984
			detailedDescriptionElement = new TextDataDetailElement(this, parentElement, (TextData) entity, style);
1985
		}
1986
		else{
1987
			throw new IllegalStateException("There is no interface for the given description element");
1988
		}
1989
		adapt(detailedDescriptionElement);
1990
		parentElement.addElement(detailedDescriptionElement);
1991
		return detailedDescriptionElement;
1992
		
1993
	}
1994

    
1995
	
1996
	/**
1997
	 * Creates a styled text as a part of the form.
1998
	 *
1999
	 * @param parent
2000
	 *            the text parent
2001
	 * @param value
2002
	 *            the text initial value
2003
	 * @param style
2004
	 *            the text style
2005
	 * @return the text widget
2006
	 */
2007
	public StyledText createStyledText(Composite parent, String value, int style) {
2008
		StyledText text = new StyledText(parent, getBorderStyle() | style | getOrientation());
2009
		if (value != null)
2010
			text.setText(value);
2011
		text.setForeground(getColors().getForeground());
2012
		text.setBackground(getColors().getBackground());
2013
//		text.addFocusListener(visibilityHandler);
2014
		return text;
2015
	}
2016
}
(6-6/35)