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