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