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