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