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