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