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