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