Fixes #2312
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / ui / forms / CdmFormFactory.java
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.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.store.StoreUtil;
126 import eu.etaxonomy.taxeditor.ui.forms.password.EditPasswordElement;
127 import eu.etaxonomy.taxeditor.ui.openurl.IOpenUrlEnabled;
128 import eu.etaxonomy.taxeditor.ui.openurl.OpenUrlSelectorElement;
129 import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement;
130 import eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionElement;
131 import eu.etaxonomy.taxeditor.ui.section.EmptyElement;
132 import eu.etaxonomy.taxeditor.ui.section.agent.InstitutionDetailElement;
133 import eu.etaxonomy.taxeditor.ui.section.agent.InstitutionDetailSection;
134 import eu.etaxonomy.taxeditor.ui.section.agent.PersonDetailElement;
135 import eu.etaxonomy.taxeditor.ui.section.agent.PersonDetailSection;
136 import eu.etaxonomy.taxeditor.ui.section.agent.TeamDetailElement;
137 import eu.etaxonomy.taxeditor.ui.section.agent.TeamDetailSection;
138 import eu.etaxonomy.taxeditor.ui.section.agent.TeamMemberElement;
139 import eu.etaxonomy.taxeditor.ui.section.agent.TeamMemberSection;
140 import eu.etaxonomy.taxeditor.ui.section.agent.TeamOrPersonBaseDetailSection;
141 import eu.etaxonomy.taxeditor.ui.section.classification.ClassificationDetailElement;
142 import eu.etaxonomy.taxeditor.ui.section.classification.ClassificationDetailSection;
143 import eu.etaxonomy.taxeditor.ui.section.classification.TaxonNodeDetailElement;
144 import eu.etaxonomy.taxeditor.ui.section.classification.TaxonNodeDetailSection;
145 import eu.etaxonomy.taxeditor.ui.section.description.DerivedUnitElement;
146 import eu.etaxonomy.taxeditor.ui.section.description.DescribedSpecimenSection;
147 import eu.etaxonomy.taxeditor.ui.section.description.DescriptionDetailElement;
148 import eu.etaxonomy.taxeditor.ui.section.description.DescriptionDetailSection;
149 import eu.etaxonomy.taxeditor.ui.section.description.DescriptionElementDetailElement;
150 import eu.etaxonomy.taxeditor.ui.section.description.DescriptionElementDetailSection;
151 import eu.etaxonomy.taxeditor.ui.section.description.DescriptionElementMediaSection;
152 import eu.etaxonomy.taxeditor.ui.section.description.DescriptionElementSourceElement;
153 import eu.etaxonomy.taxeditor.ui.section.description.DescriptionElementSourceSection;
154 import eu.etaxonomy.taxeditor.ui.section.description.DescriptionSourceElement;
155 import eu.etaxonomy.taxeditor.ui.section.description.DescriptionSourceSection;
156 import eu.etaxonomy.taxeditor.ui.section.description.ModifierElement;
157 import eu.etaxonomy.taxeditor.ui.section.description.ModifierSection;
158 import eu.etaxonomy.taxeditor.ui.section.description.NaturalLanguageDetailElement;
159 import eu.etaxonomy.taxeditor.ui.section.description.NaturalLanguageSection;
160 import eu.etaxonomy.taxeditor.ui.section.description.ScopeElement;
161 import eu.etaxonomy.taxeditor.ui.section.description.ScopeSection;
162 import eu.etaxonomy.taxeditor.ui.section.description.StateDataElement;
163 import eu.etaxonomy.taxeditor.ui.section.description.StateDataSection;
164 import eu.etaxonomy.taxeditor.ui.section.description.StatisticalMeasurementValueElement;
165 import eu.etaxonomy.taxeditor.ui.section.description.StatisticalMeasurementValueSection;
166 import eu.etaxonomy.taxeditor.ui.section.description.detail.AbstractDetailedDescriptionDetailElement;
167 import eu.etaxonomy.taxeditor.ui.section.description.detail.CategoricalDataDetailElement;
168 import eu.etaxonomy.taxeditor.ui.section.description.detail.CommonNameDetailElement;
169 import eu.etaxonomy.taxeditor.ui.section.description.detail.DistributionDetailElement;
170 import eu.etaxonomy.taxeditor.ui.section.description.detail.IndividualsAssociationDetailElement;
171 import eu.etaxonomy.taxeditor.ui.section.description.detail.QuantitativeDataDetailElement;
172 import eu.etaxonomy.taxeditor.ui.section.description.detail.TaxonInteractionDetailElement;
173 import eu.etaxonomy.taxeditor.ui.section.description.detail.TextDataDetailElement;
174 import eu.etaxonomy.taxeditor.ui.section.feature.FeatureDistributionDetailElement;
175 import eu.etaxonomy.taxeditor.ui.section.feature.FeatureDistributionDetailSection;
176 import eu.etaxonomy.taxeditor.ui.section.group.GrantedAuthorityDetailElement;
177 import eu.etaxonomy.taxeditor.ui.section.group.GrantedAuthorityDetailSection;
178 import eu.etaxonomy.taxeditor.ui.section.group.GroupDetailElement;
179 import eu.etaxonomy.taxeditor.ui.section.group.GroupDetailSection;
180 import eu.etaxonomy.taxeditor.ui.section.group.MemberDetailElement;
181 import eu.etaxonomy.taxeditor.ui.section.group.MemberDetailSection;
182 import eu.etaxonomy.taxeditor.ui.section.key.GeographicalScopeDetailSection;
183 import eu.etaxonomy.taxeditor.ui.section.key.PolytomousKeyDetailElement;
184 import eu.etaxonomy.taxeditor.ui.section.key.PolytomousKeyDetailSection;
185 import eu.etaxonomy.taxeditor.ui.section.key.PolytomousKeyNodeDetailElement;
186 import eu.etaxonomy.taxeditor.ui.section.key.PolytomousKeyNodeDetailSection;
187 import eu.etaxonomy.taxeditor.ui.section.key.ScopeRestrictionSection;
188 import eu.etaxonomy.taxeditor.ui.section.key.TaxonomicScopeSection;
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.taxon.TaxonDetailElement;
254 import eu.etaxonomy.taxeditor.ui.section.user.GroupsByUserDetailElement;
255 import eu.etaxonomy.taxeditor.ui.section.user.GroupsByUserDetailSection;
256 import eu.etaxonomy.taxeditor.ui.section.user.UserDetailElement;
257 import eu.etaxonomy.taxeditor.ui.section.user.UserDetailSection;
258 import eu.etaxonomy.taxeditor.ui.selection.AbstractSelectionElement;
259 import eu.etaxonomy.taxeditor.ui.selection.AgentSelectionElement;
260 import eu.etaxonomy.taxeditor.ui.selection.ClassificationSelectionElement;
261 import eu.etaxonomy.taxeditor.ui.selection.CollectionSelectionElement;
262 import eu.etaxonomy.taxeditor.ui.selection.DerivedUnitBaseSelectionElement;
263 import eu.etaxonomy.taxeditor.ui.selection.FeatureSelectionElement;
264 import eu.etaxonomy.taxeditor.ui.selection.FeatureTreeSelectionElement;
265 import eu.etaxonomy.taxeditor.ui.selection.FieldObservationSelectionElement;
266 import eu.etaxonomy.taxeditor.ui.selection.GroupSelectionElement;
267 import eu.etaxonomy.taxeditor.ui.selection.InstitutionSelectionElement;
268 import eu.etaxonomy.taxeditor.ui.selection.NameSelectionElement;
269 import eu.etaxonomy.taxeditor.ui.selection.NamedAreaSelectionElement;
270 import eu.etaxonomy.taxeditor.ui.selection.NomenclaturalAuthorTeamSelectionElement;
271 import eu.etaxonomy.taxeditor.ui.selection.PersonSelectionElement;
272 import eu.etaxonomy.taxeditor.ui.selection.PolytomousKeyNodeSelectionElement;
273 import eu.etaxonomy.taxeditor.ui.selection.PolytomousKeySelectionElement;
274 import eu.etaxonomy.taxeditor.ui.selection.ReferenceSelectionElement;
275 import eu.etaxonomy.taxeditor.ui.selection.SynonymSelectionElement;
276 import eu.etaxonomy.taxeditor.ui.selection.TaxonBaseSelectionElement;
277 import eu.etaxonomy.taxeditor.ui.selection.TaxonNodeSelectionElement;
278 import eu.etaxonomy.taxeditor.ui.selection.TaxonSelectionElement;
279 import eu.etaxonomy.taxeditor.ui.selection.TeamSelectionElement;
280 import eu.etaxonomy.taxeditor.ui.selection.UserSelectionElement;
281 import eu.etaxonomy.taxeditor.ui.term.AbstractEnumComboElement;
282 import eu.etaxonomy.taxeditor.ui.term.AbstractTermComboElement;
283 import eu.etaxonomy.taxeditor.ui.term.AnnotationTypeComboElement;
284 import eu.etaxonomy.taxeditor.ui.term.DeterminationModifierComboElement;
285 import eu.etaxonomy.taxeditor.ui.term.EmptyComboElement;
286 import eu.etaxonomy.taxeditor.ui.term.ExtensionTypeComboElement;
287 import eu.etaxonomy.taxeditor.ui.term.LanguageComboElement;
288 import eu.etaxonomy.taxeditor.ui.term.MarkerTypeComboElement;
289 import eu.etaxonomy.taxeditor.ui.term.MeasurementUnitComboElement;
290 import eu.etaxonomy.taxeditor.ui.term.ModifierComboElement;
291 import eu.etaxonomy.taxeditor.ui.term.NameRelationshipTypeComboElement;
292 import eu.etaxonomy.taxeditor.ui.term.NameTypeDesignationStatusComboElement;
293 import eu.etaxonomy.taxeditor.ui.term.NamedAreaTypeComboElement;
294 import eu.etaxonomy.taxeditor.ui.term.NomenclaturalCodeComboElement;
295 import eu.etaxonomy.taxeditor.ui.term.NomenclaturalStatusTypeComboElement;
296 import eu.etaxonomy.taxeditor.ui.term.PresenceAbsenceTermComboElement;
297 import eu.etaxonomy.taxeditor.ui.term.PreservationMethodComboElement;
298 import eu.etaxonomy.taxeditor.ui.term.RankComboElement;
299 import eu.etaxonomy.taxeditor.ui.term.ReferenceSystemComboElement;
300 import eu.etaxonomy.taxeditor.ui.term.ReferenceTypeComboElement;
301 import eu.etaxonomy.taxeditor.ui.term.RightsTypeComboElement;
302 import eu.etaxonomy.taxeditor.ui.term.ScopeComboElement;
303 import eu.etaxonomy.taxeditor.ui.term.SexComboElement;
304 import eu.etaxonomy.taxeditor.ui.term.SpecimenTypeDesignationStatusComboElement;
305 import eu.etaxonomy.taxeditor.ui.term.StageComboElement;
306 import eu.etaxonomy.taxeditor.ui.term.StateComboElement;
307 import eu.etaxonomy.taxeditor.ui.term.StatisticalMeasureComboElement;
308
309 /**
310 * <p>
311 * CdmFormFactory class.
312 * </p>
313 *
314 * @author n.hoffmann
315 * @created Feb 24, 2010
316 * @version 1.0
317 */
318 public class CdmFormFactory extends FormToolkit {
319
320 private BoldFontHolder2 boldFontHolder2;
321 private MouseListener selectionMouseHandler;
322 private FocusListener selectionFocusHandler;
323
324 private final Set selectionListenerList = new HashSet();
325
326 private final List<IPropertyChangeListener> propertyChangeListeners = new ArrayList<IPropertyChangeListener>();
327
328 private final int orientation = Window.getDefaultOrientation();
329 private ISelectionProvider selectionProvider;
330
331 /**
332 * <p>
333 * LAYOUT
334 * </p>
335 *
336 * @return a {@link org.eclipse.ui.forms.widgets.TableWrapLayout} object.
337 */
338 public static final TableWrapLayout LAYOUT() {
339 return LAYOUT(1, false);
340 }
341
342 /**
343 * <p>
344 * LAYOUT
345 * </p>
346 *
347 * @param columns
348 * a int.
349 * @param equalWidth
350 * a boolean.
351 * @return a {@link org.eclipse.ui.forms.widgets.TableWrapLayout} object.
352 */
353 public static final TableWrapLayout LAYOUT(int columns, boolean equalWidth) {
354 TableWrapLayout layout = new TableWrapLayout();
355 layout.topMargin = 0;
356 layout.rightMargin = 0;
357 layout.bottomMargin = 0;
358 layout.leftMargin = 0;
359 layout.numColumns = columns;
360 layout.makeColumnsEqualWidth = equalWidth;
361 layout.verticalSpacing = 0;
362 layout.horizontalSpacing = 0;
363 return layout;
364 }
365
366 /**
367 * <p>
368 * FILL
369 * </p>
370 *
371 * @return a {@link org.eclipse.ui.forms.widgets.TableWrapData} object.
372 */
373 public static final TableWrapData FILL() {
374 return FILL(1, 1);
375 }
376
377 /**
378 * <p>
379 * FILL
380 * </p>
381 *
382 * @param horizontalSpan
383 * a int.
384 * @param verticalSpan
385 * a int.
386 * @return a {@link org.eclipse.ui.forms.widgets.TableWrapData} object.
387 */
388 public static final TableWrapData FILL(int horizontalSpan, int verticalSpan) {
389 TableWrapData layoutData = new TableWrapData(TableWrapData.FILL_GRAB,
390 TableWrapData.FILL_GRAB);
391 layoutData.colspan = horizontalSpan;
392 layoutData.rowspan = verticalSpan;
393 return layoutData;
394 }
395
396 /**
397 * <p>
398 * LEFT
399 * </p>
400 *
401 * @return a {@link org.eclipse.ui.forms.widgets.TableWrapData} object.
402 */
403 public static final TableWrapData LEFT() {
404 return new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP);
405 }
406
407 /**
408 * <p>
409 * RIGHT
410 * </p>
411 *
412 * @return a {@link org.eclipse.ui.forms.widgets.TableWrapData} object.
413 */
414 public static final TableWrapData RIGHT() {
415 return new TableWrapData(TableWrapData.RIGHT, TableWrapData.TOP);
416 }
417
418 /**
419 * <p>
420 * FILL_HORIZONTALLY
421 * </p>
422 *
423 * @return a {@link org.eclipse.ui.forms.widgets.TableWrapData} object.
424 */
425 public static final TableWrapData FILL_HORIZONTALLY() {
426 return FILL_HORIZONTALLY(1, 1);
427 }
428
429 /**
430 * <p>
431 * FILL_HORIZONTALLY
432 * </p>
433 *
434 * @param horizontalSpan
435 * a int.
436 * @param verticalSpan
437 * a int.
438 * @return a {@link org.eclipse.ui.forms.widgets.TableWrapData} object.
439 */
440 public static final TableWrapData FILL_HORIZONTALLY(int horizontalSpan,
441 int verticalSpan) {
442 TableWrapData layoutData = new TableWrapData(TableWrapData.FILL_GRAB,
443 TableWrapData.TOP);
444 layoutData.colspan = horizontalSpan;
445 layoutData.rowspan = verticalSpan;
446 return layoutData;
447 }
448
449 /** Constant <code>EMPTY_SELECTION</code> */
450 public static ISelection EMPTY_SELECTION = new ISelection() {
451 @Override
452 public boolean isEmpty() {
453 return true;
454 }
455 };
456
457 private class SelectionMouseHandler extends MouseAdapter {
458 @Override
459 public void mouseDown(MouseEvent e) {
460 notifySelectionListeners(e);
461 }
462 }
463
464 private class SelectionFocusHandler extends FocusAdapter {
465 @Override
466 public void focusGained(FocusEvent e) {
467 notifySelectionListeners(e);
468 }
469 }
470
471 private void notifySelectionListeners(TypedEvent e) {
472 Event event = new Event();
473 event.widget = e.widget;
474 SelectionEvent selectionEvent = new SelectionEvent(event);
475
476 for (Object listener : selectionListenerList) {
477 ((SelectionListener) listener).widgetSelected(selectionEvent);
478 }
479 }
480
481 /**
482 * <p>
483 * Constructor for CdmFormFactory.
484 * </p>
485 *
486 * @param display
487 * a {@link org.eclipse.swt.widgets.Display} object.
488 * @param selectionProvider
489 * a {@link org.eclipse.jface.viewers.ISelectionProvider} object.
490 */
491 public CdmFormFactory(Display display, ISelectionProvider selectionProvider) {
492 super(display);
493 this.selectionProvider = selectionProvider;
494 init();
495 }
496
497 /**
498 * <p>
499 * Constructor for CdmFormFactory.
500 * </p>
501 *
502 * @param display
503 * a {@link org.eclipse.swt.widgets.Display} object.
504 */
505 public CdmFormFactory(Display display) {
506 super(display);
507 init();
508 }
509
510 /**
511 *
512 */
513 private void init() {
514 boldFontHolder2 = new BoldFontHolder2();
515 selectionMouseHandler = new SelectionMouseHandler();
516 selectionFocusHandler = new SelectionFocusHandler();
517 }
518
519 /**
520 * Creates an instance initialized with the correct selectionProvider
521 *
522 * Make sure to remove the instance when the entityComposite disposes via
523 * destroySelectionArbitrator(..)
524 *
525 * @param entityElement
526 * a {@link eu.etaxonomy.taxeditor.ui.forms.IEntityElement}
527 * object.
528 * @return a {@link eu.etaxonomy.taxeditor.ui.forms.SelectionArbitrator}
529 * object.
530 */
531 public SelectionArbitrator createSelectionArbitrator(
532 IEntityElement entityElement) {
533 SelectionArbitrator selectionArbitrator = new SelectionArbitrator(
534 entityElement);
535 selectionArbitrator.addSelectionProvider(selectionProvider);
536 selectionProvider.addSelectionChangedListener(selectionArbitrator);
537 addSelectionListener(selectionArbitrator);
538 return selectionArbitrator;
539 }
540
541 /**
542 * <p>
543 * destroySelectionArbitrator
544 * </p>
545 *
546 * @param selectionArbitrator
547 * a {@link eu.etaxonomy.taxeditor.ui.forms.SelectionArbitrator}
548 * object.
549 */
550 public void destroySelectionArbitrator(
551 SelectionArbitrator selectionArbitrator) {
552 removeSelectionListener(selectionArbitrator);
553 if (selectionProvider != null) {
554 selectionProvider
555 .removeSelectionChangedListener(selectionArbitrator);
556 } else {
557 StoreUtil
558 .error(this.getClass(),
559 "Tried to destroy a selection listener from this factories listeners but was null",
560 null);
561 }
562 }
563
564 /** {@inheritDoc} */
565 @Override
566 public void adapt(Composite composite) {
567 composite.addMouseListener(selectionMouseHandler);
568 super.adapt(composite);
569 }
570
571 /**
572 * <p>
573 * adapt
574 * </p>
575 *
576 * @param formElement
577 * a
578 * {@link eu.etaxonomy.taxeditor.ui.forms.AbstractCdmFormElement}
579 * object.
580 */
581 public void adapt(AbstractCdmFormElement formElement) {
582 formElement.setPropertyChangeListeners(propertyChangeListeners);
583 }
584
585 /** {@inheritDoc} */
586 @Override
587 public void adapt(Control control, boolean trackFocus, boolean trackKeyboard) {
588 if (trackFocus) {
589 control.addFocusListener(selectionFocusHandler);
590 }
591 super.adapt(control, trackFocus, trackKeyboard);
592 }
593
594 /**
595 * <p>
596 * destroyElement
597 * </p>
598 *
599 * @param formElement
600 * a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement}
601 * object.
602 */
603 public void destroyElement(ICdmFormElement formElement) {
604 // return if element was not initialized
605 if (formElement == null) {
606 return;
607 }
608 // destroy selection arbitrator, if any
609 if (formElement instanceof ISelectableElement) {
610 destroySelectionArbitrator(((ISelectableElement) formElement)
611 .getSelectionArbitrator());
612 }
613 // remove this element form its parents list of elements
614 // ICdmFormElement parentElement = formElement.getParentElement();
615 // if(parentElement != null){
616 // parentElement.removeElement(formElement);
617 // }
618 // call destroy on child elements recursively
619 for (ICdmFormElement childElement : formElement.getElements()) {
620 destroyElement(childElement);
621 }
622 // dispose of the controls
623 for (Control control : formElement.getControls()) {
624 // we added the layoutComposite of the parental element as the
625 // layout composite to this formElement
626 // but we do not want to destroy it.
627 if (control.equals(formElement.getLayoutComposite())) {
628 continue;
629 } else {
630 control.dispose();
631 control = null;
632 }
633 }
634 }
635
636 /**
637 * <p>
638 * createEmptyCell
639 * </p>
640 *
641 * @param parent
642 * a {@link org.eclipse.swt.widgets.Composite} object.
643 * @return a {@link org.eclipse.swt.widgets.Label} object.
644 */
645 public Label createEmptyCell(Composite parent) {
646 return this.createLabel(parent, null);
647 }
648
649 /**
650 * <p>
651 * createMultilineTextWithLabel
652 * </p>
653 *
654 * @param labelString
655 * a {@link java.lang.String} object.
656 * @param textHeight
657 * a int.
658 * @param style
659 * a int.
660 * @param parentElement
661 * a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement}
662 * object.
663 * @return a {@link eu.etaxonomy.taxeditor.ui.forms.TextWithLabelElement}
664 * object.
665 */
666 public TextWithLabelElement createMultilineTextWithLabel(
667 ICdmFormElement parentElement, String labelString, int textHeight,
668 int style) {
669 TextWithLabelElement element = new TextWithLabelElement(this,
670 parentElement, labelString, "", textHeight, style);
671 adapt(element);
672 parentElement.addElement(element);
673 return element;
674 }
675
676 /**
677 * <p>
678 * createMultiLanguageTextElement
679 * </p>
680 *
681 * @param parentElement
682 * a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement}
683 * object.
684 * @param labelString
685 * a {@link java.lang.String} object.
686 * @param multilanguageText
687 * a {@link java.util.Map} object.
688 * @param textHeight
689 * a int.
690 * @param style
691 * a int.
692 * @return a
693 * {@link eu.etaxonomy.taxeditor.ui.forms.MultilanguageTextElement}
694 * object.
695 */
696 public MultilanguageTextElement createMultiLanguageTextElement(
697 ICdmFormElement parentElement, String labelString,
698 Map<Language, LanguageString> multilanguageText, int textHeight,
699 int style) {
700 MultilanguageTextElement element = new MultilanguageTextElement(this,
701 parentElement, labelString, multilanguageText, textHeight,
702 style);
703 adapt(element);
704 parentElement.addElement(element);
705 return element;
706 }
707
708 public KeyStatementElement createKeyStatementElement(
709 ICdmFormElement parentElement, String labelString,
710 KeyStatement keyStatement, int textHeight, int style) {
711 KeyStatementElement element = new KeyStatementElement(this,
712 parentElement, labelString, keyStatement, textHeight, style);
713 adapt(element);
714 parentElement.addElement(element);
715 return element;
716 }
717
718 /**
719 * <p>
720 * createTextWithLabelElement
721 * </p>
722 *
723 * @param labelString
724 * a {@link java.lang.String} object.
725 * @param initialText
726 * a {@link java.lang.String} object.
727 * @param style
728 * a int.
729 * @param parentElement
730 * a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement}
731 * object.
732 * @return a {@link eu.etaxonomy.taxeditor.ui.forms.TextWithLabelElement}
733 * object.
734 */
735 public TextWithLabelElement createTextWithLabelElement(
736 ICdmFormElement parentElement, String labelString,
737 String initialText, int style) {
738 TextWithLabelElement element = new TextWithLabelElement(this,
739 parentElement, labelString, initialText, null, style);
740 adapt(element);
741 parentElement.addElement(element);
742 return element;
743 }
744
745 public UriWithLabelElement createUriWithLabelElement(
746 ICdmFormElement parentElement, String labelString, URI initialUri,
747 int style) {
748 UriWithLabelElement element = new UriWithLabelElement(this,
749 parentElement, labelString, initialUri, null, style);
750 adapt(element);
751 parentElement.addElement(element);
752 return element;
753 }
754
755 /**
756 * @param element
757 * @param string
758 * @param uri
759 * @param style
760 * @return
761 */
762 public OpenUrlSelectorElement createOpenUrlSelectorElement(
763 ICdmFormElement parentElement, String labelString,
764 IOpenUrlEnabled openUrlEnabled, int style) {
765 OpenUrlSelectorElement element = new OpenUrlSelectorElement(this,
766 parentElement, labelString, openUrlEnabled, style);
767 adapt(element);
768 parentElement.addElement(element);
769 return element;
770 }
771
772 /**
773 *
774 * @param parentElement
775 * @param labelString
776 * @param conversationEnabled
777 * @param user
778 * @param style
779 * @return
780 */
781 public EditPasswordElement createEditPasswordElement(
782 ICdmFormElement parentElement, String labelString,
783 ConversationHolder conversation, User user, int style) {
784 EditPasswordElement element = new EditPasswordElement(this,
785 parentElement, labelString, user, conversation);
786 adapt(element);
787 parentElement.addElement(element);
788 return element;
789 }
790
791 /**
792 * <p>
793 * createIntegerTextWithLabelElement
794 * </p>
795 *
796 * @param parentElement
797 * a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement}
798 * object.
799 * @param labelString
800 * a {@link java.lang.String} object.
801 * @param initialInteger
802 * a {@link java.lang.Integer} object.
803 * @param style
804 * a int.
805 * @return a {@link eu.etaxonomy.taxeditor.ui.forms.NumberWithLabelElement}
806 * object.
807 */
808 public NumberWithLabelElement createIntegerTextWithLabelElement(
809 ICdmFormElement parentElement, String labelString,
810 Integer initialInteger, int style) {
811 NumberWithLabelElement element = new NumberWithLabelElement(this,
812 parentElement, labelString, initialInteger, style);
813 adapt(element);
814 parentElement.addElement(element);
815 return element;
816 }
817
818 /**
819 * <p>
820 * createFloatTextWithLabelElement
821 * </p>
822 *
823 * @param parentElement
824 * a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement}
825 * object.
826 * @param labelString
827 * a {@link java.lang.String} object.
828 * @param initialFloat
829 * a float.
830 * @param style
831 * a int.
832 * @return a {@link eu.etaxonomy.taxeditor.ui.forms.NumberWithLabelElement}
833 * object.
834 */
835 public NumberWithLabelElement createFloatTextWithLabelElement(
836 ICdmFormElement parentElement, String labelString,
837 float initialFloat, int style) {
838 NumberWithLabelElement element = new NumberWithLabelElement(this,
839 parentElement, labelString, initialFloat, style);
840 adapt(element);
841 parentElement.addElement(element);
842 return element;
843 }
844
845 /**
846 * <p>
847 * createLanguageStringWithLabelElement
848 * </p>
849 *
850 * @param parentElement
851 * a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement}
852 * object.
853 * @param labelString
854 * a {@link java.lang.String} object.
855 * @param languageString
856 * a {@link eu.etaxonomy.cdm.model.common.LanguageString} object.
857 * @param style
858 * a int.
859 * @return a
860 * {@link eu.etaxonomy.taxeditor.ui.forms.LanguageStringWithLabelElement}
861 * object.
862 */
863 public LanguageStringWithLabelElement createLanguageStringWithLabelElement(
864 ICdmFormElement parentElement, String labelString,
865 LanguageString languageString, int style) {
866 LanguageStringWithLabelElement element = new LanguageStringWithLabelElement(
867 this, parentElement, labelString, languageString, style);
868 adapt(element);
869 parentElement.addElement(element);
870 return element;
871 }
872
873 /**
874 * <p>
875 * createLanguageStringWithLabelElement
876 * </p>
877 *
878 * @param parentElement
879 * a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement}
880 * object.
881 * @param labelString
882 * a {@link java.lang.String} object.
883 * @param languageString
884 * a {@link eu.etaxonomy.cdm.model.common.LanguageString} object.
885 * @param height
886 * a int.
887 * @param style
888 * a int.
889 * @return a
890 * {@link eu.etaxonomy.taxeditor.ui.forms.LanguageStringWithLabelElement}
891 * object.
892 */
893 public LanguageStringWithLabelElement createLanguageStringWithLabelElement(
894 ICdmFormElement parentElement, String labelString,
895 LanguageString languageString, int height, int style) {
896 LanguageStringWithLabelElement element = new LanguageStringWithLabelElement(
897 this, parentElement, labelString, languageString, height, style);
898 adapt(element);
899 parentElement.addElement(element);
900 return element;
901 }
902
903 /**
904 * <p>
905 * createTextElement
906 * </p>
907 *
908 * @param parentElement
909 * a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement}
910 * object.
911 * @param initialText
912 * a {@link java.lang.String} object.
913 * @param style
914 * a int.
915 * @return a {@link eu.etaxonomy.taxeditor.ui.forms.TextWithLabelElement}
916 * object.
917 */
918 public TextWithLabelElement createTextElement(
919 ICdmFormElement parentElement, String initialText, int style) {
920 TextWithLabelElement element = new TextWithLabelElement(this,
921 parentElement, null, initialText, null, style);
922 adapt(element);
923 parentElement.addElement(element);
924 return element;
925 }
926
927 /**
928 * <p>
929 * createKeyValueViewerElement
930 * </p>
931 *
932 * @param parentElement
933 * a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement}
934 * object.
935 * @param keyHeading
936 * a {@link java.lang.String} object.
937 * @param valueHeading
938 * a {@link java.lang.String} object.
939 * @param map
940 * a {@link java.util.Map} object.
941 * @return a {@link eu.etaxonomy.taxeditor.ui.forms.KeyValueViewerElement}
942 * object.
943 */
944 public KeyValueViewerElement createKeyValueViewerElement(
945 ICdmFormElement parentElement, String keyHeading,
946 String valueHeading, Map<Object, Object> map) {
947 KeyValueViewerElement element = new KeyValueViewerElement(this,
948 parentElement, keyHeading, valueHeading, map);
949 adapt(element);
950 parentElement.addElement(element);
951 return element;
952 }
953
954 public static enum TermComboType {
955 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
956 }
957
958 /**
959 * <p>
960 * createTermComboElement
961 * </p>
962 *
963 * @param termComboType
964 * a
965 * {@link eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory.TermComboType}
966 * object.
967 * @param parentElement
968 * a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement}
969 * object.
970 * @param labelString
971 * a {@link java.lang.String} object.
972 * @param selection
973 * a {@link eu.etaxonomy.cdm.model.common.DefinedTermBase}
974 * object.
975 * @param style
976 * a int.
977 * @return a {@link eu.etaxonomy.taxeditor.ui.term.AbstractTermComboElement}
978 * object.
979 */
980 public AbstractTermComboElement createTermComboElement(
981 TermComboType termComboType, ICdmFormElement parentElement,
982 String labelString, DefinedTermBase selection, int style) {
983 AbstractTermComboElement element = null;
984
985 switch (termComboType) {
986 case EMPTY:
987 element = new EmptyComboElement<DefinedTermBase>(this,
988 parentElement, labelString, style);
989 break;
990 case EXTENSIONTYPE:
991 element = new ExtensionTypeComboElement(this, parentElement,
992 labelString, (ExtensionType) selection, style);
993 break;
994 case LANGUAGE:
995 element = new LanguageComboElement(this, parentElement,
996 labelString, (Language) selection, style);
997 break;
998 case MARKERTYPE:
999 element = new MarkerTypeComboElement(this, parentElement,
1000 labelString, (MarkerType) selection, style);
1001 break;
1002 case NOMENCLATURALSTATUSTYPE:
1003 element = new NomenclaturalStatusTypeComboElement(this,
1004 parentElement, labelString,
1005 (NomenclaturalStatusType) selection, style);
1006 break;
1007 case RANK:
1008 element = new RankComboElement(this, parentElement, labelString,
1009 (Rank) selection, style);
1010 break;
1011 case RIGHTSTYPE:
1012 element = new RightsTypeComboElement(this, parentElement,
1013 labelString, (RightsTerm) selection, style);
1014 break;
1015 case NAMERELATIONSHIP:
1016 element = new NameRelationshipTypeComboElement(this, parentElement,
1017 labelString, (NameRelationshipType) selection, style);
1018 break;
1019 case NAMEDAREATYPE:
1020 element = new NamedAreaTypeComboElement(this, parentElement,
1021 labelString, (NamedAreaType) selection, style);
1022 break;
1023 case ANNOTATIONTYPE:
1024 element = new AnnotationTypeComboElement(this, parentElement,
1025 labelString, (AnnotationType) selection, style);
1026 break;
1027 case PRESENCEABSENCESTATUS:
1028 element = new PresenceAbsenceTermComboElement(this, parentElement,
1029 labelString, (PresenceAbsenceTermBase) selection, style);
1030 break;
1031 case NAMETYPEDESIGNATIONSTATUS:
1032 element = new NameTypeDesignationStatusComboElement(this,
1033 parentElement, labelString,
1034 (NameTypeDesignationStatus) selection, style);
1035 break;
1036 case SPECIMENTYPEDESIGNATIONSTATUS:
1037 element = new SpecimenTypeDesignationStatusComboElement(this,
1038 parentElement, labelString,
1039 (SpecimenTypeDesignationStatus) selection, style);
1040 break;
1041 case SEX:
1042 element = new SexComboElement(this, parentElement, labelString,
1043 (Sex) selection, style);
1044 break;
1045 case STAGE:
1046 element = new StageComboElement(this, parentElement, labelString,
1047 (Stage) selection, style);
1048 break;
1049 case PRESERVATION_METHOD:
1050 element = new PreservationMethodComboElement(this, parentElement,
1051 labelString, (PreservationMethod) selection, style);
1052 break;
1053 case MEASUREMENT_UNIT:
1054 element = new MeasurementUnitComboElement(this, parentElement,
1055 labelString, (MeasurementUnit) selection, style);
1056 break;
1057 case STATE:
1058 element = new StateComboElement(this, parentElement, labelString,
1059 (State) selection, style);
1060 break;
1061 case SCOPE:
1062 element = new ScopeComboElement(this, parentElement, labelString,
1063 (Scope) selection, style);
1064 break;
1065 case MODIFIER:
1066 element = new ModifierComboElement(this, parentElement,
1067 labelString, (Modifier) selection, style);
1068 break;
1069 case STATISTICAL_MEASURE:
1070 element = new StatisticalMeasureComboElement(this, parentElement,
1071 labelString, (StatisticalMeasure) selection, style);
1072 break;
1073 case DETERMINATION_MODIFIER:
1074 element = new DeterminationModifierComboElement(this,
1075 parentElement, labelString,
1076 (DeterminationModifier) selection, style);
1077 break;
1078 case REFERENCE_SYSTEM:
1079 element = new ReferenceSystemComboElement(this, parentElement,
1080 labelString, (ReferenceSystem) selection, style);
1081 break;
1082 }
1083
1084 adapt(element);
1085 parentElement.addElement(element);
1086 return element;
1087 }
1088
1089 public static enum EnumComboType {
1090 REFERENCETYPE, NOMENCLATURALCODE
1091 }
1092
1093 /**
1094 * <p>
1095 * createEnumComboElement
1096 * </p>
1097 *
1098 * @param enumComboType
1099 * a
1100 * {@link eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory.EnumComboType}
1101 * object.
1102 * @param parentElement
1103 * a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement}
1104 * object.
1105 * @param style
1106 * a int.
1107 * @return a {@link eu.etaxonomy.taxeditor.ui.term.AbstractEnumComboElement}
1108 * object.
1109 */
1110 public AbstractEnumComboElement createEnumComboElement(
1111 EnumComboType enumComboType, ICdmFormElement parentElement,
1112 int style) {
1113 AbstractEnumComboElement element = null;
1114
1115 switch (enumComboType) {
1116 case REFERENCETYPE:
1117 element = new ReferenceTypeComboElement(this, parentElement,
1118 "Reference Type", null, style);
1119 break;
1120 case NOMENCLATURALCODE:
1121 element = new NomenclaturalCodeComboElement(this, parentElement,
1122 "Nomenclatural Code", null, style);
1123 break;
1124 }
1125 adapt(element);
1126 parentElement.addElement(element);
1127 return element;
1128 }
1129
1130 /**
1131 * <p>
1132 * createBrowserElement
1133 * </p>
1134 *
1135 * @param imageUri
1136 * a {@link java.net.URI} object.
1137 * @param style
1138 * a int.
1139 * @param parentElement
1140 * a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement}
1141 * object.
1142 * @return a {@link eu.etaxonomy.taxeditor.ui.forms.BrowserElement} object.
1143 */
1144 public BrowserElement createBrowserElement(ICdmFormElement parentElement,
1145 URI imageUri, int style) {
1146 BrowserElement element = new BrowserElement(this, parentElement,
1147 imageUri, style);
1148 adapt(element);
1149 parentElement.addElement(element);
1150 return element;
1151 }
1152
1153 /**
1154 * <p>
1155 * createImageElement
1156 * </p>
1157 *
1158 * @param parentElement
1159 * a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement}
1160 * object.
1161 * @param imageUri
1162 * a {@link java.net.URI} object.
1163 * @param style
1164 * a int.
1165 * @return a {@link eu.etaxonomy.taxeditor.ui.forms.ImageElement} object.
1166 */
1167 public ImageElement createImageElement(ICdmFormElement parentElement,
1168 URI imageUri, int style) {
1169 ImageElement element = new ImageElement(this, parentElement, imageUri,
1170 style);
1171 adapt(element);
1172 parentElement.addElement(element);
1173 return element;
1174 }
1175
1176 /**
1177 * <p>
1178 * createTextActionElement
1179 * </p>
1180 *
1181 * @param labelString
1182 * a {@link java.lang.String} object.
1183 * @param initialText
1184 * a {@link java.lang.String} object.
1185 * @param style
1186 * a int.
1187 * @param parentElement
1188 * a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement}
1189 * object.
1190 * @param buttonLabel
1191 * a {@link java.lang.String} object.
1192 * @return a {@link eu.etaxonomy.taxeditor.ui.forms.TextActionElement}
1193 * object.
1194 */
1195 public TextActionElement createTextActionElement(
1196 ICdmFormElement parentElement, String labelString,
1197 String buttonLabel, String initialText, int style) {
1198 TextActionElement element = new TextActionElement(this, parentElement,
1199 labelString, buttonLabel, initialText, style);
1200 adapt(element);
1201 parentElement.addElement(element);
1202 return element;
1203 }
1204
1205 /**
1206 *
1207 * @author n.hoffmann
1208 * @created Mar 5, 2010
1209 * @version 1.0
1210 */
1211 public static enum SelectionType {
1212 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
1213 }
1214
1215 /**
1216 * <p>
1217 * createCheckbox
1218 * </p>
1219 *
1220 * @param parentElement
1221 * a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement}
1222 * object.
1223 * @param label
1224 * a {@link java.lang.String} object.
1225 * @param initialState
1226 * a boolean.
1227 * @param style
1228 * a int.
1229 * @return a {@link eu.etaxonomy.taxeditor.ui.forms.CheckboxElement} object.
1230 */
1231 public CheckboxElement createCheckbox(ICdmFormElement parentElement,
1232 String label, boolean initialState, int style) {
1233 CheckboxElement element = new CheckboxElement(this, parentElement,
1234 label, initialState, style | orientation);
1235 adapt(element);
1236 parentElement.addElement(element);
1237 return element;
1238 }
1239
1240 /**
1241 * Creates a section as a part of the form.
1242 *
1243 * @return the section widget
1244 * @param section
1245 * a {@link eu.etaxonomy.taxeditor.ui.forms.AbstractFormSection}
1246 * object.
1247 */
1248 public Section adapt(AbstractFormSection section) {
1249 section.setMenu(section.getLayoutComposite().getMenu());
1250 adapt(section, true, true);
1251
1252 // handle focus and property change events for cdm use
1253 section.addFocusListener(selectionFocusHandler);
1254 section.setPropertyChangeListeners(propertyChangeListeners);
1255
1256 if (section.getToggle() != null) {
1257 section.getToggle().setHoverDecorationColor(
1258 getColors().getColor(IFormColors.TB_TOGGLE_HOVER));
1259 section.getToggle().setDecorationColor(
1260 getColors().getColor(IFormColors.TB_TOGGLE));
1261 }
1262
1263 section.setFont(boldFontHolder2.getBoldFont(section
1264 .getLayoutComposite().getFont()));
1265
1266 if ((section.getStyle() & Section.TITLE_BAR) != 0
1267 || (section.getStyle() & Section.SHORT_TITLE_BAR) != 0) {
1268 getColors().initializeSectionToolBarColors();
1269 section.setTitleBarBackground(getColors().getColor(
1270 IFormColors.TB_BG));
1271 section.setTitleBarBorderColor(getColors().getColor(
1272 IFormColors.TB_BORDER));
1273 }
1274 // call setTitleBarForeground regardless as it also sets the label color
1275 section.setTitleBarForeground(getColors().getColor(
1276 IFormColors.TB_TOGGLE));
1277 return section;
1278 }
1279
1280 private class BoldFontHolder2 {
1281 private Font normalFont;
1282
1283 private Font boldFont;
1284
1285 public BoldFontHolder2() {
1286 }
1287
1288 public Font getBoldFont(Font font) {
1289 createBoldFont(font);
1290 return boldFont;
1291 }
1292
1293 private void createBoldFont(Font font) {
1294 if (normalFont == null || !normalFont.equals(font)) {
1295 normalFont = font;
1296 dispose();
1297 }
1298 if (boldFont == null) {
1299 boldFont = FormFonts.getInstance().getBoldFont(
1300 getColors().getDisplay(), normalFont);
1301 }
1302 }
1303
1304 public void dispose() {
1305 if (boldFont != null) {
1306 FormFonts.getInstance().markFinished(boldFont,
1307 getColors().getDisplay());
1308 boldFont = null;
1309 }
1310 }
1311 }
1312
1313 /**
1314 * <p>
1315 * createToggleableTextField
1316 * </p>
1317 *
1318 * @param parentElement
1319 * a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement}
1320 * object.
1321 * @param labelString
1322 * a {@link java.lang.String} object.
1323 * @param initialText
1324 * a {@link java.lang.String} object.
1325 * @param initialState
1326 * a boolean.
1327 * @param style
1328 * a int.
1329 * @return a {@link eu.etaxonomy.taxeditor.ui.forms.ToggleableTextElement}
1330 * object.
1331 */
1332 public ToggleableTextElement createToggleableTextField(
1333 ICdmFormElement parentElement, String labelString,
1334 String initialText, boolean initialState, int style) {
1335 ToggleableTextElement element = new ToggleableTextElement(this,
1336 parentElement, labelString, initialText, initialState, style
1337 | orientation);
1338 adapt(element);
1339 parentElement.addElement(element);
1340 return element;
1341 }
1342
1343 /**
1344 * <p>
1345 * createTimePeriodElement
1346 * </p>
1347 *
1348 * @param parentElement
1349 * a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement}
1350 * object.
1351 * @param labelString
1352 * a {@link java.lang.String} object.
1353 * @param timePeriod
1354 * a {@link eu.etaxonomy.cdm.model.common.TimePeriod} object.
1355 * @param style
1356 * a int.
1357 * @return a {@link eu.etaxonomy.taxeditor.ui.forms.TimePeriodElement}
1358 * object.
1359 */
1360 public TimePeriodElement createTimePeriodElement(
1361 ICdmFormElement parentElement, String labelString,
1362 TimePeriod timePeriod, int style) {
1363 TimePeriodElement element = new TimePeriodElement(this, parentElement,
1364 labelString, timePeriod, style);
1365 adapt(element);
1366 parentElement.addElement(element);
1367 return element;
1368 }
1369
1370 /**
1371 * <p>
1372 * createPointElement
1373 * </p>
1374 *
1375 * @param style
1376 * a int.
1377 * @param parentElement
1378 * a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement}
1379 * object.
1380 * @param point
1381 * a {@link eu.etaxonomy.cdm.model.location.Point} object.
1382 * @return a {@link eu.etaxonomy.taxeditor.ui.forms.PointElement} object.
1383 */
1384 public PointElement createPointElement(ICdmFormElement parentElement,
1385 Point point, int style) {
1386 PointElement element = new PointElement(this, parentElement, point,
1387 style);
1388 adapt(element);
1389 parentElement.addElement(element);
1390 return element;
1391 }
1392
1393 /**
1394 * <p>
1395 * createDateDetailSection
1396 * </p>
1397 *
1398 * @param parentElement
1399 * a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement}
1400 * object.
1401 * @param style
1402 * a int.
1403 * @return a {@link eu.etaxonomy.taxeditor.ui.forms.DateDetailSection}
1404 * object.
1405 */
1406 public DateDetailSection createDateDetailSection(
1407 ICdmFormElement parentElement, int style) {
1408 DateDetailSection section = new DateDetailSection(this, parentElement,
1409 style);
1410 parentElement.addElement(section);
1411 adapt(section);
1412 return section;
1413 }
1414
1415 /**
1416 * <p>
1417 * createPartialElement
1418 * </p>
1419 *
1420 * @param parentElement
1421 * a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement}
1422 * object.
1423 * @param labelString
1424 * a {@link java.lang.String} object.
1425 * @param partial
1426 * a {@link org.joda.time.Partial} object.
1427 * @param style
1428 * a int.
1429 * @return a {@link eu.etaxonomy.taxeditor.ui.forms.PartialElement} object.
1430 */
1431 public PartialElement createPartialElement(ICdmFormElement parentElement,
1432 String labelString, Partial partial, int style) {
1433 PartialElement element = new PartialElement(this, parentElement,
1434 labelString, style);
1435 adapt(element);
1436 parentElement.addElement(element);
1437 return element;
1438 }
1439
1440 /**
1441 * <p>
1442 * addSelectionListener
1443 * </p>
1444 *
1445 * @param listener
1446 * a {@link org.eclipse.swt.events.SelectionListener} object.
1447 */
1448 public void addSelectionListener(SelectionListener listener) {
1449 selectionListenerList.add(listener);
1450 }
1451
1452 /**
1453 * <p>
1454 * removeSelectionListener
1455 * </p>
1456 *
1457 * @param listener
1458 * a {@link org.eclipse.swt.events.SelectionListener} object.
1459 */
1460 public void removeSelectionListener(SelectionListener listener) {
1461 if (listener == null) {
1462 StoreUtil
1463 .error(this.getClass(),
1464 "Tried to remove a selection listener from this factories listeners but was null",
1465 null);
1466 } else {
1467 selectionListenerList.remove(listener);
1468 }
1469 }
1470
1471 /**
1472 * <p>
1473 * addPropertyChangeListener
1474 * </p>
1475 *
1476 * @param listener
1477 * a {@link org.eclipse.jface.util.IPropertyChangeListener}
1478 * object.
1479 */
1480 public void addPropertyChangeListener(IPropertyChangeListener listener) {
1481 propertyChangeListeners.add(0, listener);
1482 }
1483
1484 /**
1485 * <p>
1486 * removePropertyChangeListener
1487 * </p>
1488 *
1489 * @param listener
1490 * a {@link org.eclipse.jface.util.IPropertyChangeListener}
1491 * object.
1492 */
1493 public void removePropertyChangeListener(IPropertyChangeListener listener) {
1494 propertyChangeListeners.remove(listener);
1495 }
1496
1497 /**
1498 * <p>
1499 * createHorizontalSeparator
1500 * </p>
1501 *
1502 * @param parentElement
1503 * a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement}
1504 * object.
1505 * @param style
1506 * a int.
1507 * @return a {@link org.eclipse.swt.widgets.Label} object.
1508 */
1509 public Label createHorizontalSeparator(ICdmFormElement parentElement,
1510 int style) {
1511 Label separator = this.createSeparator(
1512 parentElement.getLayoutComposite(), SWT.HORIZONTAL | style);
1513 separator.setLayoutData(FILL_HORIZONTALLY());
1514 return separator;
1515 }
1516
1517 /**
1518 * <p>
1519 * createVersionElement
1520 * </p>
1521 *
1522 * @param parentElement
1523 * a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement}
1524 * object.
1525 * @param entity
1526 * a {@link eu.etaxonomy.cdm.model.common.VersionableEntity}
1527 * object.
1528 * @param style
1529 * a int.
1530 * @return a
1531 * {@link eu.etaxonomy.taxeditor.ui.section.supplemental.VersionElement}
1532 * object.
1533 */
1534 public VersionElement createVersionElement(ICdmFormElement parentElement,
1535 VersionableEntity entity, int style) {
1536 VersionElement element = new VersionElement(this, parentElement,
1537 entity, style);
1538 adapt(element);
1539 parentElement.addElement(element);
1540 return element;
1541 }
1542
1543 /**
1544 * <p>
1545 * createVersionSection
1546 * </p>
1547 *
1548 * @param parentElement
1549 * a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement}
1550 * object.
1551 * @param style
1552 * a int.
1553 * @return a
1554 * {@link eu.etaxonomy.taxeditor.ui.section.supplemental.VersionSection}
1555 * object.
1556 */
1557 public VersionSection createVersionSection(ICdmFormElement parentElement,
1558 int style) {
1559 VersionSection section = new VersionSection(this, parentElement, style);
1560 parentElement.addElement(section);
1561 adapt(section);
1562 return section;
1563 }
1564
1565 /**
1566 * <p>
1567 * createEmptyElement
1568 * </p>
1569 *
1570 * @param parentElement
1571 * a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement}
1572 * object.
1573 * @return a {@link eu.etaxonomy.taxeditor.ui.section.EmptyElement} object.
1574 */
1575 public EmptyElement createEmptyElement(ICdmFormElement parentElement) {
1576 EmptyElement element = new EmptyElement(this, parentElement, null,
1577 SWT.NULL);
1578 adapt(element);
1579 parentElement.addElement(element);
1580 return element;
1581 }
1582
1583 /**
1584 * <p>
1585 * createHeadlineSection
1586 * </p>
1587 *
1588 * @param parentElement
1589 * a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement}
1590 * object.
1591 * @return a
1592 * {@link eu.etaxonomy.taxeditor.ui.section.supplemental.HeadlineSection}
1593 * object.
1594 */
1595 public HeadlineSection createHeadlineSection(ICdmFormElement parentElement) {
1596 HeadlineSection section = new HeadlineSection(this, parentElement,
1597 SWT.NULL);
1598 parentElement.addElement(section);
1599 adapt(section);
1600 return section;
1601 }
1602
1603 /**
1604 * <p>
1605 * createParsingMessageElement
1606 * </p>
1607 *
1608 * @param parentElement
1609 * a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement}
1610 * object.
1611 * @param parserProblem
1612 * a {@link eu.etaxonomy.cdm.strategy.parser.ParserProblem}
1613 * object.
1614 * @param style
1615 * a int.
1616 * @return a
1617 * {@link eu.etaxonomy.taxeditor.ui.section.taxon.ParsingMessageElement}
1618 * object.
1619 */
1620 public ParsingMessageElement createParsingMessageElement(
1621 ICdmFormElement parentElement, ParserProblem parserProblem,
1622 int style) {
1623 ParsingMessageElement element = new ParsingMessageElement(this,
1624 parentElement, parserProblem, style);
1625 adapt(element);
1626 parentElement.addElement(element);
1627 return element;
1628 }
1629
1630 // SIMPLIFY
1631
1632 /**
1633 *
1634 */
1635 public static enum DetailType {
1636 NONVIRALNAME, SCIENTIFICNAME, REFERENCEBASE, NOMENCLATURALREFERENCE, TAXONBASE, AUTHORSHIP, TEAM, PERSON, DESCRIPTION, DESCRIPTIONELEMENT, PARSINGMESSAGE, NAMERELATIONSHIP, TEAMORPERSONBASE, MEDIA, FIELD_OBSERVATION, DERIVED_UNIT_FACADE, GATHERING_EVENT, DERIVED_UNIT, NATURAL_LANGUAGE, FEATURE_DISTRIBUTION, CLASSIFICATION, TAXON_NODE, COLLECTION, POLYTOMOUS_KEY, POLYTOMOUS_KEY_NODE, INSTITUTION, DERIVED_UNIT_GENERAL, HYBRID, USER, GROUP
1637 }
1638
1639 /**
1640 * <p>
1641 * createCdmDetailSection
1642 * </p>
1643 *
1644 * @param detailType
1645 * a
1646 * {@link eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory.DetailType}
1647 * object.
1648 * @param parentElement
1649 * a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement}
1650 * object.
1651 * @param selectionProvider
1652 * a {@link org.eclipse.jface.viewers.ISelectionProvider} object.
1653 * @param style
1654 * a int.
1655 * @param conversation
1656 * a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder}
1657 * object.
1658 * @return a {@link eu.etaxonomy.taxeditor.ui.forms.AbstractFormSection}
1659 * object.
1660 */
1661 public AbstractFormSection createCdmDetailSection(DetailType detailType,
1662 ConversationHolder conversation, ICdmFormElement parentElement,
1663 ISelectionProvider selectionProvider, int style) {
1664 AbstractFormSection section = null;
1665
1666 switch (detailType) {
1667 case SCIENTIFICNAME:
1668 section = new NameDetailSection(this, conversation, parentElement,
1669 selectionProvider, style);
1670 break;
1671 case REFERENCEBASE:
1672 section = new ReferenceDetailSection(this, conversation,
1673 parentElement, selectionProvider, style);
1674 break;
1675 case NOMENCLATURALREFERENCE:
1676 section = new NomenclaturalReferenceDetailSection(this,
1677 conversation, parentElement, selectionProvider, style);
1678 break;
1679 case TAXONBASE:
1680 section = new TaxonBaseDetailSection(this, conversation,
1681 parentElement, selectionProvider, style);
1682 break;
1683 case AUTHORSHIP:
1684 section = new AuthorshipDetailSection(this, conversation,
1685 parentElement, selectionProvider, style);
1686 break;
1687 case TEAMORPERSONBASE:
1688 section = new TeamOrPersonBaseDetailSection(this, conversation,
1689 parentElement, selectionProvider, style);
1690 break;
1691 case TEAM:
1692 section = new TeamDetailSection(this, conversation, parentElement,
1693 null, style);
1694 break;
1695 case PERSON:
1696 section = new PersonDetailSection(this, conversation,
1697 parentElement, null, style);
1698 break;
1699 case DESCRIPTION:
1700 section = new DescriptionDetailSection(this, conversation,
1701 parentElement, selectionProvider, style);
1702 break;
1703 case DESCRIPTIONELEMENT:
1704 section = new DescriptionElementDetailSection(this, conversation,
1705 parentElement, selectionProvider, style);
1706 break;
1707 case PARSINGMESSAGE:
1708 section = new ParsingMessagesSection(this, conversation,
1709 parentElement, selectionProvider, style);
1710 break;
1711 case NONVIRALNAME:
1712 section = new NonViralNameDetailSection(this, conversation,
1713 parentElement, selectionProvider, style);
1714 break;
1715 case MEDIA:
1716 section = new eu.etaxonomy.taxeditor.ui.section.description.MediaDetailsSection(
1717 this, conversation, parentElement, selectionProvider, style);
1718 break;
1719 case DERIVED_UNIT_FACADE:
1720 section = new DerivedUnitFacadeDetailSection(this, conversation,
1721 parentElement, selectionProvider, style);
1722 break;
1723 case FIELD_OBSERVATION:
1724 section = new FieldObservationDetailSection(this, conversation,
1725 parentElement, selectionProvider, style);
1726 break;
1727 case GATHERING_EVENT:
1728 section = new GatheringEventDetailSection(this, conversation,
1729 parentElement, selectionProvider, style);
1730 break;
1731 case DERIVED_UNIT:
1732 section = new DerivedUnitBaseDetailSection(this, conversation,
1733 parentElement, selectionProvider, style);
1734 break;
1735 case NATURAL_LANGUAGE:
1736 section = new NaturalLanguageSection(this, conversation,
1737 parentElement, selectionProvider, style);
1738 break;
1739 case FEATURE_DISTRIBUTION:
1740 section = new FeatureDistributionDetailSection(this, conversation,
1741 parentElement, selectionProvider, style);
1742 break;
1743 case CLASSIFICATION:
1744 section = new ClassificationDetailSection(this, conversation,
1745 parentElement, selectionProvider, style);
1746 break;
1747 case TAXON_NODE:
1748 section = new TaxonNodeDetailSection(this, conversation,
1749 parentElement, selectionProvider, style);
1750 break;
1751 case POLYTOMOUS_KEY:
1752 section = new PolytomousKeyDetailSection(this, conversation,
1753 parentElement, selectionProvider, style);
1754 break;
1755 case POLYTOMOUS_KEY_NODE:
1756 section = new PolytomousKeyNodeDetailSection(this, conversation,
1757 parentElement, selectionProvider, style);
1758 break;
1759 case INSTITUTION:
1760 section = new InstitutionDetailSection(this, conversation,
1761 parentElement, selectionProvider, style);
1762 break;
1763 case DERIVED_UNIT_GENERAL:
1764 section = new GeneralDetailSection(this, conversation,
1765 parentElement, selectionProvider, style);
1766 break;
1767 case HYBRID:
1768 section = new HybridDetailSection(this, conversation,
1769 parentElement, selectionProvider, style);
1770 break;
1771 case USER:
1772 section = new UserDetailSection(this, conversation, parentElement,
1773 selectionProvider, style);
1774 break;
1775 case GROUP:
1776 section = new GroupDetailSection(this, conversation, parentElement,
1777 selectionProvider, style);
1778 break;
1779 }
1780
1781 if (section == null) {
1782 throw new RuntimeException(
1783 "You tried to create a cdm detail section that is not implemented yet.");
1784 }
1785
1786 parentElement.addElement(section);
1787 adapt(section);
1788 return section;
1789 }
1790
1791 /**
1792 * <p>
1793 * createCdmDetailElement
1794 * </p>
1795 *
1796 * @param detailType
1797 * a
1798 * {@link eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory.DetailType}
1799 * object.
1800 * @param style
1801 * a int.
1802 * @param parentElement
1803 * a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement}
1804 * object.
1805 * @return a
1806 * {@link eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement}
1807 * object.
1808 */
1809 public AbstractCdmDetailElement createCdmDetailElement(
1810 DetailType detailType, ICdmFormElement parentElement, int style) {
1811 AbstractCdmDetailElement element = null;
1812
1813 switch (detailType) {
1814 case SCIENTIFICNAME:
1815 element = new NameDetailElement(this, parentElement, style);
1816 break;
1817 case REFERENCEBASE:
1818 element = new ReferenceDetailElement(this, parentElement, style);
1819 break;
1820 case NOMENCLATURALREFERENCE:
1821 element = new NomenclaturalReferenceDetailElement(this,
1822 parentElement, style);
1823 break;
1824 case TAXONBASE:
1825 element = new TaxonBaseDetailElement(this, parentElement, style);
1826 break;
1827 case AUTHORSHIP:
1828 element = new AuthorshipDetailElement(this, parentElement, style);
1829 break;
1830 case TEAM:
1831 element = new TeamDetailElement(this, parentElement, style);
1832 break;
1833 case PERSON:
1834 element = new PersonDetailElement(this, parentElement, style);
1835 break;
1836 case DESCRIPTION:
1837 element = new DescriptionDetailElement(this, parentElement, style);
1838 break;
1839 case DESCRIPTIONELEMENT:
1840 element = new DescriptionElementDetailElement(this, parentElement,
1841 style);
1842 break;
1843 case NONVIRALNAME:
1844 element = new NonViralNameDetailElement(this, parentElement);
1845 break;
1846 case DERIVED_UNIT_FACADE:
1847 element = new DerivedUnitFacadeDetailElement(this, parentElement);
1848 break;
1849 case FIELD_OBSERVATION:
1850 element = new FieldObservationDetailElement(this, parentElement);
1851 break;
1852 case GATHERING_EVENT:
1853 element = new GatheringEventDetailElement(this, parentElement);
1854 break;
1855 case DERIVED_UNIT:
1856 element = new DerivedUnitBaseDetailElement(this, parentElement);
1857 break;
1858 case NATURAL_LANGUAGE:
1859 element = new NaturalLanguageDetailElement(this, parentElement);
1860 break;
1861 case FEATURE_DISTRIBUTION:
1862 element = new FeatureDistributionDetailElement(this, parentElement);
1863 break;
1864 case CLASSIFICATION:
1865 element = new ClassificationDetailElement(this, parentElement);
1866 break;
1867 case TAXON_NODE:
1868 element = new TaxonNodeDetailElement(this, parentElement);
1869 break;
1870 case COLLECTION:
1871 element = new CollectionDetailElement(this, parentElement);
1872 break;
1873 case POLYTOMOUS_KEY:
1874 element = new PolytomousKeyDetailElement(this, parentElement);
1875 break;
1876 case POLYTOMOUS_KEY_NODE:
1877 element = new PolytomousKeyNodeDetailElement(this, parentElement);
1878 break;
1879 case INSTITUTION:
1880 element = new InstitutionDetailElement(this, parentElement);
1881 break;
1882 case DERIVED_UNIT_GENERAL:
1883 element = new GeneralDetailElement(this, parentElement);
1884 break;
1885 case HYBRID:
1886 element = new HybridDetailElement(this, parentElement);
1887 break;
1888 case USER:
1889 element = new UserDetailElement(this, parentElement);
1890 break;
1891 case GROUP:
1892 element = new GroupDetailElement(this, parentElement);
1893 break;
1894 }
1895
1896 if (element == null) {
1897 StoreUtil
1898 .error(this.getClass(),
1899 "Detail element was not created. Seems like the case was not implemented for the requested detail type: "
1900 + detailType, null);
1901 }
1902
1903 adapt(element);
1904 parentElement.addElement(element);
1905 return element;
1906 }
1907
1908 /**
1909 *
1910 * @author n.hoffmann
1911 * @created Mar 5, 2010
1912 * @version 1.0
1913 */
1914 public static enum EntityDetailType {
1915 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
1916 }
1917
1918 /**
1919 * <p>
1920 * createEntityDetailSection
1921 * </p>
1922 *
1923 * @param entityDetailType
1924 * a
1925 * {@link eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory.EntityDetailType}
1926 * object.
1927 * @param style
1928 * a int.
1929 * @param conversation
1930 * a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder}
1931 * object.
1932 * @param parentElement
1933 * a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement}
1934 * object.
1935 * @return a {@link eu.etaxonomy.taxeditor.ui.forms.AbstractFormSection}
1936 * object.
1937 */
1938 public AbstractFormSection createEntityDetailSection(
1939 EntityDetailType entityDetailType, ConversationHolder conversation,
1940 ICdmFormElement parentElement, int style) {
1941 AbstractFormSection section = null;
1942
1943 switch (entityDetailType) {
1944 case TEAM:
1945 section = new TeamDetailSection(this, conversation, parentElement,
1946 null, style);
1947 break;
1948 case TEAMMEMBER:
1949 section = new TeamMemberSection(this, conversation, parentElement,
1950 style);
1951 break;
1952 case ANNOTATION:
1953 section = new AnnotationSection(this, conversation, parentElement,
1954 style);
1955 break;
1956 case CREDIT:
1957 section = new CreditSection(this, conversation, parentElement,
1958 style);
1959 break;
1960 case DESCRIPTIONELEMENTSOURCE:
1961 section = new DescriptionElementSourceSection(this, conversation,
1962 parentElement, style);
1963 break;
1964 case EXTENSION:
1965 section = new ExtensionSection(this, conversation, parentElement,
1966 style);
1967 break;
1968 case MARKER:
1969 section = new MarkerSection(this, conversation, parentElement,
1970 style);
1971 break;
1972 case MEDIA:
1973 section = new MediaSection(this, conversation, parentElement, style);
1974 break;
1975 case DESCRIPTIONELEMENTMEDIA:
1976 section = new DescriptionElementMediaSection(this, conversation,
1977 parentElement, style);
1978 break;
1979 case MEDIAREPRESENTATION:
1980 section = new MediaRepresentationSection(this, conversation,
1981 parentElement, style);
1982 break;
1983 case MEDIAREPRESENTATIONPART:
1984 section = new MediaRepresentationPartSection(this, conversation,
1985 parentElement, style);
1986 break;
1987 case MODIFIER:
1988 section = new ModifierSection(this, conversation, parentElement,
1989 style);
1990 break;
1991 case NOMENCLATURALSTATUS:
1992 section = new NomenclaturalStatusSection(this, conversation,
1993 parentElement, style);
1994 break;
1995 case NAME_RELATIONSHIP:
1996 section = new NameRelationshipDetailSection(this, conversation,
1997 parentElement, style);
1998 break;
1999 case PROTOLOG:
2000 section = new ProtologueSection(this, conversation, parentElement,
2001 style);
2002 break;
2003 case RIGHTS:
2004 section = new RightsSection(this, conversation, parentElement,
2005 style);
2006 break;
2007 case SOURCE:
2008 section = new SourceSection(this, conversation, parentElement,
2009 style);
2010 break;
2011 case SCOPE:
2012 section = new ScopeSection(this, conversation, parentElement, style);
2013 break;
2014 case DESCRIPTIONSOURCE:
2015 section = new DescriptionSourceSection(this, conversation,
2016 parentElement, style);
2017 break;
2018 case TYPEDESIGNATION:
2019 section = new TypeDesignationSection(this, conversation,
2020 parentElement, style);
2021 break;
2022 case STATE_DATA:
2023 section = new StateDataSection(this, conversation, parentElement,
2024 style);
2025 break;
2026 case STATISTICAL_MEASUREMENT_VALUE:
2027 section = new StatisticalMeasurementValueSection(this,
2028 conversation, parentElement, style);
2029 break;
2030 case DESCRIBED_SPECIMEN:
2031 section = new DescribedSpecimenSection(this, conversation,
2032 parentElement, style);
2033 break;
2034 case COLLECTING_AREA:
2035 section = new CollectingAreasDetailSection(this, conversation,
2036 parentElement, style);
2037 break;
2038 case DETERMINATION_EVENT:
2039 section = new DeterminationEventDetailSection(this, conversation,
2040 parentElement, style);
2041 break;
2042 case SPECIMEN_COLLECTION:
2043 section = new SpecimenCollectionDetailSection(this, conversation,
2044 parentElement, style);
2045 break;
2046 case IDENTIFIABLE_SOURCE_COLLECTION:
2047 section = new SourceCollectionDetailSection(this, conversation,
2048 parentElement, style);
2049 break;
2050 case GEOGRAPHICAL_SCOPE:
2051 section = new GeographicalScopeDetailSection(this, conversation,
2052 parentElement, style);
2053 break;
2054 case SCOPE_RESTRICTION:
2055 section = new ScopeRestrictionSection(this, conversation,
2056 parentElement, style);
2057 break;
2058 case MEMBER:
2059 section = new MemberDetailSection(this, conversation,
2060 parentElement, style);
2061 break;
2062 case GRANTED_AUTHORITY:
2063 section = new GrantedAuthorityDetailSection(this, conversation,
2064 parentElement, style);
2065 break;
2066 case GROUPS_BY_USER:
2067 section = new GroupsByUserDetailSection(this, conversation,
2068 parentElement, style);
2069 break;
2070 case TAXONOMIC_SCOPE:
2071 section = new TaxonomicScopeSection(this, conversation,
2072 parentElement, style);
2073 break;
2074 }
2075 parentElement.addElement(section);
2076 adapt(section);
2077 return section;
2078 }
2079
2080 /**
2081 * <p>
2082 * createEntityCollectionElement
2083 * </p>
2084 *
2085 * @param removeListener
2086 * a {@link org.eclipse.swt.events.SelectionListener} object.
2087 * @param style
2088 * a int.
2089 * @param parentElement
2090 * a {@link eu.etaxonomy.taxeditor.ui.forms.AbstractFormSection}
2091 * object.
2092 * @param versionableEntity
2093 * a {@link eu.etaxonomy.cdm.model.common.IVersionableEntity}
2094 * object.
2095 * @param backgroundColor
2096 * a {@link org.eclipse.swt.graphics.Color} object.
2097 * @return a
2098 * {@link eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionElement}
2099 * object.
2100 */
2101 public AbstractEntityCollectionElement createEntityCollectionElement(
2102 AbstractFormSection parentElement, Object versionableEntity,
2103 SelectionListener removeListener, Color backgroundColor, int style) {
2104 AbstractEntityCollectionElement element = null;
2105
2106 Object entity = HibernateProxyHelper.deproxy(versionableEntity);
2107
2108 if (entity instanceof Annotation) {
2109 element = new AnnotationElement(this, parentElement,
2110 (Annotation) entity, removeListener, style);
2111 } else if (entity instanceof Person) {
2112 element = new TeamMemberElement(this, parentElement,
2113 (Person) entity, removeListener, style);
2114 } else if (entity instanceof Credit) {
2115 element = new CreditElement(this, parentElement, (Credit) entity,
2116 removeListener, style);
2117 } else if (entity instanceof Extension) {
2118 element = new ExtensionElement(this, parentElement,
2119 (Extension) entity, removeListener, style);
2120 } else if (entity instanceof Marker) {
2121 element = new MarkerElement(this, parentElement, (Marker) entity,
2122 removeListener, style);
2123 } else if (entity instanceof Media) {
2124 element = new MediaElement(this, parentElement, (Media) entity,
2125 removeListener, style);
2126 } else if (entity instanceof MediaRepresentation) {
2127 element = new MediaRepresentationElement(this, parentElement,
2128 (MediaRepresentation) entity, removeListener, style);
2129 } else if (entity instanceof ImageFile) {
2130 element = new ImageFileElement(this, parentElement,
2131 (ImageFile) entity, removeListener, style);
2132 } else if (entity instanceof NomenclaturalStatus) {
2133 element = new NomenclaturalStatusElement(this, parentElement,
2134 (NomenclaturalStatus) entity, removeListener, style);
2135 } else if (entity instanceof Rights) {
2136 element = new RightsElement(this, parentElement, (Rights) entity,
2137 removeListener, style);
2138 } else if (entity instanceof DescriptionElementSource) {
2139 element = new DescriptionElementSourceElement(this, parentElement,
2140 (DescriptionElementSource) entity, removeListener, style);
2141 } else if (entity instanceof IdentifiableSource) {
2142 element = new IdentifiableSourceElement(this, parentElement,
2143 (IdentifiableSource) entity, removeListener, style);
2144 } else if (entity instanceof Scope) {
2145 element = new ScopeElement(this, parentElement, (Scope) entity,
2146 removeListener, style);
2147 } else if (entity instanceof Modifier) {
2148 element = new ModifierElement(this, parentElement,
2149 (Modifier) entity, removeListener, style);
2150 } else if (entity instanceof Reference) {
2151 element = new DescriptionSourceElement(this, parentElement,
2152 (Reference) entity, removeListener, style);
2153 } else if (entity instanceof NameTypeDesignation) {
2154 element = new NameTypeDesignationElement(this, parentElement,
2155 (NameTypeDesignation) entity, removeListener, style);
2156 } else if (entity instanceof NameRelationship) {
2157 element = new NameRelationshipDetailElement(this, parentElement,
2158 (NameRelationship) entity, removeListener, style);
2159 } else if (entity instanceof SpecimenTypeDesignation) {
2160 element = new SpecimenTypeDesignationElement(this, parentElement,
2161 (SpecimenTypeDesignation) entity, removeListener, style);
2162 } else if (entity instanceof StateData) {
2163 element = new StateDataElement(this, parentElement,
2164 (StateData) entity, removeListener, style);
2165 } else if (entity instanceof StatisticalMeasurementValue) {
2166 element = new StatisticalMeasurementValueElement(this,
2167 parentElement, (StatisticalMeasurementValue) entity,
2168 removeListener, style);
2169 } else if (entity instanceof DerivedUnit) {
2170 element = new DerivedUnitElement(this, parentElement,
2171 (DerivedUnit) entity, removeListener, style);
2172 } else if (entity instanceof NamedArea) {
2173 element = new NamedAreaDetailElement(this, parentElement,
2174 (NamedArea) entity, removeListener, style);
2175 } else if (entity instanceof DeterminationEvent) {
2176 element = new DeterminationEventDetailElement(this, parentElement,
2177 (DeterminationEvent) entity, removeListener, style);
2178 } else if (entity instanceof Specimen) {
2179 element = new SpecimenCollectionDetailElement(this, parentElement,
2180 (Specimen) entity, removeListener, style);
2181 } else if (entity instanceof User) {
2182 element = new MemberDetailElement(this, parentElement,
2183 (User) entity, removeListener, style);
2184 } else if (entity instanceof GrantedAuthority) {
2185 element = new GrantedAuthorityDetailElement(this, parentElement,
2186 (GrantedAuthority) entity, removeListener, style);
2187 } else if (entity instanceof Group) {
2188 element = new GroupsByUserDetailElement(this, parentElement,
2189 (Group) entity, removeListener, style);
2190 } else if (entity instanceof Taxon) {
2191 element = new TaxonDetailElement(this, parentElement,
2192 (Taxon) entity, removeListener, style);
2193 } else if (entity instanceof DescriptionElementBase) {
2194 // this is the special case for protologs, maybe we can do this
2195 // differently when API improves
2196 DescriptionElementBase descriptionElement = (DescriptionElementBase) entity;
2197 if (descriptionElement.getFeature().equals(Feature.PROTOLOGUE())) {
2198 element = new ProtologueElement(this, parentElement,
2199 descriptionElement, removeListener, style);
2200 }
2201 }
2202
2203 if (element == null) {
2204 StoreUtil
2205 .errorDialog(
2206 "No element for entity",
2207 this,
2208 "Could not generate element for entity. "
2209 + "Looks like the case is not handled already. Check implementation. Entity: "
2210 + entity, null);
2211 }
2212
2213 if (backgroundColor != null && !backgroundColor.isDisposed()) {
2214 element.setBackgroundColor(backgroundColor);
2215 }
2216
2217 adapt(element);
2218 parentElement.addElement(element);
2219 return element;
2220 }
2221
2222 /**
2223 * <p>
2224 * createSelectionElement
2225 * </p>
2226 *
2227 * @param selectionType
2228 * a
2229 * {@link eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory.SelectionType}
2230 * object.
2231 * @param parentElement
2232 * a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement}
2233 * object.
2234 * @param labelString
2235 * a {@link java.lang.String} object.
2236 * @param selectionType
2237 * @param selection
2238 * a {@link eu.etaxonomy.cdm.model.common.IAnnotatableEntity}
2239 * object.
2240 * @param style
2241 * a int.
2242 * @param conversation
2243 * a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder}
2244 * object.
2245 * @return a
2246 * {@link eu.etaxonomy.taxeditor.ui.selection.AbstractSelectionElement}
2247 * object.
2248 */
2249 public AbstractSelectionElement createSelectionElement(
2250 SelectionType selectionType, ConversationHolder conversation,
2251 ICdmFormElement parentElement, String labelString,
2252 ICdmBase selection, int style) {
2253 AbstractSelectionElement element = null;
2254
2255 IAnnotatableEntity entity = (IAnnotatableEntity) HibernateProxyHelper
2256 .deproxy(selection);
2257
2258 switch (selectionType) {
2259 case AGENT:
2260 element = new AgentSelectionElement(this, conversation,
2261 parentElement, labelString, (TeamOrPersonBase) entity,
2262 style);
2263 break;
2264 case PERSON:
2265 element = new PersonSelectionElement(this, conversation,
2266 parentElement, labelString, (Person) entity, style);
2267 break;
2268 case TEAM:
2269 element = new TeamSelectionElement(this, conversation,
2270 parentElement, labelString, (Team) entity, style);
2271 break;
2272 case AUTHOR_TEAM:
2273 element = new NomenclaturalAuthorTeamSelectionElement(this,
2274 conversation, parentElement, labelString, (Team) entity,
2275 style);
2276 break;
2277 case INSTITUTION:
2278 element = new InstitutionSelectionElement(this, conversation,
2279 parentElement, labelString, (Institution) entity, style);
2280 break;
2281 case NAME:
2282 element = new NameSelectionElement(this, conversation,
2283 parentElement, labelString, (TaxonNameBase) entity, style);
2284 break;
2285 case REFERENCE:
2286 element = new ReferenceSelectionElement(this, conversation,
2287 parentElement, labelString, (Reference) entity, style);
2288 break;
2289 case TAXON_BASE:
2290 element = new TaxonBaseSelectionElement(this, conversation,
2291 parentElement, labelString, (TaxonBase) entity, style);
2292 break;
2293 case TAXON:
2294 element = new TaxonSelectionElement(this, conversation,
2295 parentElement, labelString, (Taxon) entity, style);
2296 break;
2297 case SYNONYM:
2298 element = new SynonymSelectionElement(this, conversation,
2299 parentElement, labelString, (Synonym) entity, style);
2300 break;
2301 case DERIVED_UNIT:
2302 element = new DerivedUnitBaseSelectionElement(this, conversation,
2303 parentElement, labelString, (DerivedUnitBase) entity, style);
2304 break;
2305 case FIELD_OBSERVATION:
2306 element = new FieldObservationSelectionElement(this, conversation,
2307 parentElement, labelString, (FieldObservation) entity,
2308 style);
2309 break;
2310 case FEATURE_TREE:
2311 element = new FeatureTreeSelectionElement(this, conversation,
2312 parentElement, labelString, (FeatureTree) entity, style);
2313 break;
2314 case CLASSIFICATION:
2315 element = new ClassificationSelectionElement(this, conversation,
2316 parentElement, labelString, (Classification) entity, style);
2317 break;
2318 case TAXON_NODE:
2319 element = new TaxonNodeSelectionElement(this, conversation,
2320 parentElement, labelString, (TaxonNode) entity, style);
2321 break;
2322 case COLLECTION:
2323 element = new CollectionSelectionElement(this, conversation,
2324 parentElement, labelString, (Collection) entity, style);
2325 break;
2326 case FEATURE:
2327 element = new FeatureSelectionElement(this, conversation,
2328 parentElement, labelString, (Feature) entity, style);
2329 break;
2330 case POLYTOMOUS_KEY:
2331 element = new PolytomousKeySelectionElement(this, conversation,
2332 parentElement, labelString, (PolytomousKey) entity, style);
2333 break;
2334 case POLYTOMOUS_KEY_NODE:
2335 element = new PolytomousKeyNodeSelectionElement(this, conversation,
2336 parentElement, labelString, (PolytomousKeyNode) entity,
2337 style);
2338 break;
2339 case USER:
2340 element = new UserSelectionElement(this, conversation,
2341 parentElement, labelString, (User) entity, style);
2342 break;
2343 case GROUP:
2344 element = new GroupSelectionElement(this, conversation,
2345 parentElement, labelString, (Group) entity, style);
2346 break;
2347 default:
2348 new RuntimeException(
2349 "There is no selection composite for the desired selection type.");
2350 break;
2351 }
2352
2353 adapt(element);
2354 parentElement.addElement(element);
2355 return element;
2356 }
2357
2358 /**
2359 * <p>
2360 * createNamedAreaSelectionElement
2361 * </p>
2362 *
2363 * @param parentElement
2364 * a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement}
2365 * object.
2366 * @param conversation
2367 * a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder}
2368 * object.
2369 * @param labelString
2370 * a {@link java.lang.String} object.
2371 * @param selection
2372 * a {@link eu.etaxonomy.cdm.model.location.NamedArea} object.
2373 * @param style
2374 * a int.
2375 * @return a
2376 * {@link eu.etaxonomy.taxeditor.ui.selection.NamedAreaSelectionElement}
2377 * object.
2378 */
2379 public NamedAreaSelectionElement createNamedAreaSelectionElement(
2380 ICdmFormElement parentElement, ConversationHolder conversation,
2381 String labelString, NamedArea selection, int style) {
2382 NamedAreaSelectionElement element = new NamedAreaSelectionElement(this,
2383 conversation, parentElement, labelString, selection, style);
2384 adapt(element);
2385 parentElement.addElement(element);
2386 return element;
2387 }
2388
2389 /** {@inheritDoc} */
2390 public LabelElement createLabel(ICdmFormElement parentElement, String text) {
2391 LabelElement labelElement = new LabelElement(this, parentElement, text);
2392 adapt(labelElement);
2393 parentElement.addElement(labelElement);
2394 return labelElement;
2395 }
2396
2397 /**
2398 * <p>
2399 * Getter for the field <code>selectionProvider</code>.
2400 * </p>
2401 *
2402 * @return a {@link org.eclipse.jface.viewers.ISelectionProvider} object.
2403 */
2404 public ISelectionProvider getSelectionProvider() {
2405 return selectionProvider;
2406 }
2407
2408 /**
2409 * <p>
2410 * createDetailedDescriptionDetailElement
2411 * </p>
2412 *
2413 * @param parentElement
2414 * a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement}
2415 * object.
2416 * @param entity
2417 * a
2418 * {@link eu.etaxonomy.cdm.model.description.DescriptionElementBase}
2419 * object.
2420 * @param style
2421 * a int.
2422 * @return a
2423 * {@link eu.etaxonomy.taxeditor.ui.section.description.detail.AbstractDetailedDescriptionDetailElement}
2424 * object.
2425 */
2426 public AbstractDetailedDescriptionDetailElement createDetailedDescriptionDetailElement(
2427 ICdmFormElement parentElement, DescriptionElementBase entity,
2428 int style) {
2429 AbstractDetailedDescriptionDetailElement detailedDescriptionElement = null;
2430
2431 if (entity instanceof CategoricalData) {
2432 detailedDescriptionElement = new CategoricalDataDetailElement(this,
2433 parentElement, (CategoricalData) entity, style);
2434 } else if (entity instanceof CommonTaxonName) {
2435 detailedDescriptionElement = new CommonNameDetailElement(this,
2436 parentElement, (CommonTaxonName) entity, style);
2437 } else if (entity instanceof Distribution) {
2438 detailedDescriptionElement = new DistributionDetailElement(this,
2439 parentElement, (Distribution) entity, style);
2440 } else if (entity instanceof IndividualsAssociation) {
2441 detailedDescriptionElement = new IndividualsAssociationDetailElement(
2442 this, parentElement, (IndividualsAssociation) entity, style);
2443 } else if (entity instanceof QuantitativeData) {
2444 detailedDescriptionElement = new QuantitativeDataDetailElement(
2445 this, parentElement, (QuantitativeData) entity, style);
2446 } else if (entity instanceof TaxonInteraction) {
2447 detailedDescriptionElement = new TaxonInteractionDetailElement(
2448 this, parentElement, (TaxonInteraction) entity, style);
2449 } else if (entity instanceof TextData) {
2450 detailedDescriptionElement = new TextDataDetailElement(this,
2451 parentElement, (TextData) entity, style);
2452 } else {
2453 throw new IllegalStateException(
2454 "There is no interface for the given description element");
2455 }
2456 adapt(detailedDescriptionElement);
2457 parentElement.addElement(detailedDescriptionElement);
2458 return detailedDescriptionElement;
2459
2460 }
2461
2462 /**
2463 * Creates a styled text as a part of the form.
2464 *
2465 * @param parent
2466 * the text parent
2467 * @param value
2468 * the text initial value
2469 * @param style
2470 * the text style
2471 * @return the text widget
2472 */
2473 public StyledText createStyledText(Composite parent, String value, int style) {
2474 StyledText text = new StyledText(parent, getBorderStyle() | style
2475 | getOrientation());
2476 if (value != null)
2477 text.setText(value);
2478 text.setForeground(getColors().getForeground());
2479 text.setBackground(getColors().getBackground());
2480 // text.addFocusListener(visibilityHandler);
2481 return text;
2482 }
2483 }