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