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