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