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