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