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