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