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