1
|
/**
|
2
|
* Copyright (C) 2007 EDIT
|
3
|
* European Distributed Institute of Taxonomy
|
4
|
* http://www.e-taxonomy.eu
|
5
|
*
|
6
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
7
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
8
|
*/
|
9
|
|
10
|
package eu.etaxonomy.taxeditor.view.e4.supplementaldata;
|
11
|
|
12
|
import javax.inject.Inject;
|
13
|
|
14
|
import org.eclipse.e4.core.di.annotations.Optional;
|
15
|
import org.eclipse.e4.ui.di.UIEventTopic;
|
16
|
import org.eclipse.jface.viewers.ISelection;
|
17
|
import org.eclipse.swt.SWT;
|
18
|
import org.eclipse.ui.forms.IFormPart;
|
19
|
import org.eclipse.ui.forms.widgets.ExpandableComposite;
|
20
|
|
21
|
import eu.etaxonomy.cdm.model.common.AnnotatableEntity;
|
22
|
import eu.etaxonomy.cdm.model.common.IdentifiableEntity;
|
23
|
import eu.etaxonomy.cdm.model.common.VersionableEntity;
|
24
|
import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
|
25
|
import eu.etaxonomy.cdm.model.media.IdentifiableMediaEntity;
|
26
|
import eu.etaxonomy.cdm.model.name.TypeDesignationBase;
|
27
|
import eu.etaxonomy.cdm.model.reference.ISourceable;
|
28
|
import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;
|
29
|
import eu.etaxonomy.taxeditor.event.WorkbenchEventConstants;
|
30
|
import eu.etaxonomy.taxeditor.model.IElementHasDetails;
|
31
|
import eu.etaxonomy.taxeditor.preference.IPreferenceKeys;
|
32
|
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
|
33
|
import eu.etaxonomy.taxeditor.store.StoreUtil;
|
34
|
import eu.etaxonomy.taxeditor.ui.element.RootElement;
|
35
|
import eu.etaxonomy.taxeditor.ui.section.media.MediaSection;
|
36
|
import eu.etaxonomy.taxeditor.ui.section.supplemental.AnnotationSection;
|
37
|
import eu.etaxonomy.taxeditor.ui.section.supplemental.CdmBaseSection;
|
38
|
import eu.etaxonomy.taxeditor.ui.section.supplemental.CreditSection;
|
39
|
import eu.etaxonomy.taxeditor.ui.section.supplemental.ExtensionSection;
|
40
|
import eu.etaxonomy.taxeditor.ui.section.supplemental.HeadlineSection;
|
41
|
import eu.etaxonomy.taxeditor.ui.section.supplemental.MarkerSection;
|
42
|
import eu.etaxonomy.taxeditor.ui.section.supplemental.RightsSection;
|
43
|
import eu.etaxonomy.taxeditor.ui.section.supplemental.SourceSection;
|
44
|
import eu.etaxonomy.taxeditor.ui.section.supplemental.VersionSection;
|
45
|
import eu.etaxonomy.taxeditor.ui.section.supplemental.identifier.IdentifierSection;
|
46
|
import eu.etaxonomy.taxeditor.view.detail.CdmSectionPart;
|
47
|
import eu.etaxonomy.taxeditor.view.e4.AbstractCdmDataViewerE4;
|
48
|
|
49
|
/**
|
50
|
*
|
51
|
* @author pplitzner
|
52
|
* @since Aug 10, 2017
|
53
|
*
|
54
|
*/
|
55
|
public class SupplementalDataViewerE4 extends AbstractCdmDataViewerE4 {
|
56
|
|
57
|
private boolean showDebug;
|
58
|
|
59
|
/** {@inheritDoc} */
|
60
|
@Override
|
61
|
public ISelection getSelection() {
|
62
|
return null;
|
63
|
}
|
64
|
|
65
|
/** {@inheritDoc} */
|
66
|
@Override
|
67
|
public void setSelection(ISelection selection, boolean reveal) {
|
68
|
|
69
|
}
|
70
|
|
71
|
/** {@inheritDoc} */
|
72
|
@Override
|
73
|
protected void showParts() {
|
74
|
|
75
|
showDebug = PreferencesUtil.getBooleanValue(IPreferenceKeys.SHOW_DEBUG_INFORMATION);
|
76
|
|
77
|
Object input;
|
78
|
|
79
|
if(getInput() instanceof IElementHasDetails){
|
80
|
input = ((IElementHasDetails) getInput()).getData();
|
81
|
}else{
|
82
|
input = getInput();
|
83
|
}
|
84
|
|
85
|
destroySections();
|
86
|
//1. Headline
|
87
|
createHeadlineSection(rootElement);
|
88
|
//2. Annotatable entitiy
|
89
|
if(input instanceof AnnotatableEntity){
|
90
|
createAnnotationSections(rootElement);
|
91
|
}
|
92
|
//3. Identifiable entity
|
93
|
if(input instanceof IdentifiableEntity){
|
94
|
createIdentifiableSections(rootElement);
|
95
|
}
|
96
|
if(input instanceof ISourceable
|
97
|
&& !(input instanceof IdentifiableEntity)
|
98
|
&& !(input instanceof DescriptionElementBase)
|
99
|
&& !(input instanceof TypeDesignationBase)
|
100
|
){
|
101
|
createSourceSection(rootElement);
|
102
|
}
|
103
|
//4. Identifiable media entity
|
104
|
if(input instanceof IdentifiableMediaEntity){
|
105
|
createIdentifiableMediaSections(rootElement);
|
106
|
}
|
107
|
//5. Versionable
|
108
|
if(input instanceof VersionableEntity){
|
109
|
createVersionSection(rootElement);
|
110
|
}
|
111
|
//6. CdmBase
|
112
|
if(showDebug){
|
113
|
createCdmBaseSection(rootElement);
|
114
|
}
|
115
|
|
116
|
layout();
|
117
|
}
|
118
|
|
119
|
private void createHeadlineSection(RootElement parent){
|
120
|
HeadlineSection headlineSection = formFactory.createHeadlineSection(parent);
|
121
|
addPart(headlineSection);
|
122
|
}
|
123
|
|
124
|
private void createSourceSection(RootElement parent){
|
125
|
int expandStyle = StoreUtil.getSectionStyle(SourceSection.class, getInput().getClass().getCanonicalName(), false);
|
126
|
SourceSection sourceSection = formFactory.createSourceSection(getConversationHolder(), parent, expandStyle);
|
127
|
formFactory.createHorizontalSeparator(parent, SWT.BORDER);
|
128
|
addPart(sourceSection);
|
129
|
}
|
130
|
|
131
|
private void createAnnotationSections(RootElement parent) {
|
132
|
int expandStyle = StoreUtil.getSectionStyle(AnnotationSection.class, getInput().getClass().getCanonicalName(), false);
|
133
|
AnnotationSection annotationSection = formFactory.createAnnotationSection(getConversationHolder(), parent, expandStyle);
|
134
|
|
135
|
formFactory.createHorizontalSeparator(parent, SWT.BORDER);
|
136
|
expandStyle = StoreUtil.getSectionStyle(MarkerSection.class, getInput().getClass().getCanonicalName(), false);
|
137
|
MarkerSection markerSection = formFactory.createMarkerSection(getConversationHolder(), parent, expandStyle);
|
138
|
|
139
|
formFactory.createHorizontalSeparator(parent, SWT.BORDER);
|
140
|
|
141
|
addPart(annotationSection);
|
142
|
addPart(markerSection);
|
143
|
}
|
144
|
|
145
|
private void createIdentifiableSections(RootElement parent) {
|
146
|
int expandStyle = StoreUtil.getSectionStyle(SourceSection.class, getInput().getClass().getCanonicalName(), false);
|
147
|
SourceSection sourceSection = formFactory.createSourceSection(getConversationHolder(), parent, expandStyle);
|
148
|
|
149
|
formFactory.createHorizontalSeparator(parent, SWT.BORDER);
|
150
|
expandStyle = StoreUtil.getSectionStyle(IdentifierSection.class, getInput().getClass().getCanonicalName(), false);
|
151
|
IdentifierSection identifierSection = formFactory.createIdentifierDetailSection(getConversationHolder(), parent, expandStyle);
|
152
|
|
153
|
formFactory.createHorizontalSeparator(parent, SWT.BORDER);
|
154
|
expandStyle = StoreUtil.getSectionStyle(ExtensionSection.class, getInput().getClass().getCanonicalName(), false);
|
155
|
ExtensionSection extensionSection = formFactory.createExtensionSection(getConversationHolder(), parent, expandStyle);
|
156
|
|
157
|
formFactory.createHorizontalSeparator(parent, SWT.BORDER);
|
158
|
expandStyle = StoreUtil.getSectionStyle(CreditSection.class, getInput().getClass().getCanonicalName(), false);
|
159
|
CreditSection creditSection = formFactory.createCreditSection(getConversationHolder(), parent, expandStyle);
|
160
|
|
161
|
formFactory.createHorizontalSeparator(parent, SWT.BORDER);
|
162
|
expandStyle = StoreUtil.getSectionStyle(RightsSection.class, getInput().getClass().getCanonicalName(), false);
|
163
|
RightsSection rightsSection = formFactory.createRightsSection(getConversationHolder(), parent, expandStyle);
|
164
|
|
165
|
formFactory.createHorizontalSeparator(parent, SWT.BORDER);
|
166
|
|
167
|
addPart(sourceSection);
|
168
|
addPart(identifierSection);
|
169
|
addPart(extensionSection);
|
170
|
addPart(creditSection);
|
171
|
addPart(rightsSection);
|
172
|
|
173
|
}
|
174
|
|
175
|
private void createIdentifiableMediaSections(RootElement parent) {
|
176
|
int expandStyle = StoreUtil.getSectionStyle(MediaSection.class, getInput().getClass().getCanonicalName(), false);
|
177
|
MediaSection mediaSection = formFactory.createMediaSection(getConversationHolder(), parent, expandStyle);
|
178
|
|
179
|
formFactory.createHorizontalSeparator(parent, SWT.BORDER);
|
180
|
|
181
|
addPart(mediaSection);
|
182
|
}
|
183
|
|
184
|
private void createVersionSection(RootElement parent){
|
185
|
VersionSection versionSection = formFactory.createVersionSection(parent, ExpandableComposite.NO_TITLE);
|
186
|
addPart(versionSection);
|
187
|
}
|
188
|
|
189
|
private void createCdmBaseSection(RootElement parent) {
|
190
|
CdmBaseSection cdmBaseSection = formFactory.createCdmBaseSection(parent, ExpandableComposite.NO_TITLE);
|
191
|
addPart(cdmBaseSection);
|
192
|
}
|
193
|
|
194
|
@Override
|
195
|
public void update(CdmDataChangeMap arg0) {
|
196
|
}
|
197
|
|
198
|
@Inject
|
199
|
@Optional
|
200
|
private void updateView(@UIEventTopic(WorkbenchEventConstants.REFRESH_SUPPLEMENTAL)boolean refresh){
|
201
|
if(refresh){
|
202
|
this.refresh();
|
203
|
}
|
204
|
}
|
205
|
|
206
|
public void setEnabled(boolean doEnable){
|
207
|
for (IFormPart section: this.managedForm.getParts()){
|
208
|
if (section instanceof CdmSectionPart){
|
209
|
((CdmSectionPart)section).getSection().setEnabled(doEnable);
|
210
|
}
|
211
|
}
|
212
|
|
213
|
}
|
214
|
|
215
|
}
|