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