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