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.widgets.ExpandableComposite;
|
19
|
|
20
|
import eu.etaxonomy.cdm.model.common.AnnotatableEntity;
|
21
|
import eu.etaxonomy.cdm.model.reference.ISourceable;
|
22
|
import eu.etaxonomy.cdm.model.common.IdentifiableEntity;
|
23
|
import eu.etaxonomy.cdm.model.common.VersionableEntity;
|
24
|
import eu.etaxonomy.cdm.model.media.IdentifiableMediaEntity;
|
25
|
import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;
|
26
|
import eu.etaxonomy.taxeditor.event.WorkbenchEventConstants;
|
27
|
import eu.etaxonomy.taxeditor.model.IElementHasDetails;
|
28
|
import eu.etaxonomy.taxeditor.preference.IPreferenceKeys;
|
29
|
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
|
30
|
import eu.etaxonomy.taxeditor.ui.element.RootElement;
|
31
|
import eu.etaxonomy.taxeditor.ui.section.media.MediaSection;
|
32
|
import eu.etaxonomy.taxeditor.ui.section.supplemental.AnnotationSection;
|
33
|
import eu.etaxonomy.taxeditor.ui.section.supplemental.CdmBaseSection;
|
34
|
import eu.etaxonomy.taxeditor.ui.section.supplemental.CreditSection;
|
35
|
import eu.etaxonomy.taxeditor.ui.section.supplemental.ExtensionSection;
|
36
|
import eu.etaxonomy.taxeditor.ui.section.supplemental.HeadlineSection;
|
37
|
import eu.etaxonomy.taxeditor.ui.section.supplemental.MarkerSection;
|
38
|
import eu.etaxonomy.taxeditor.ui.section.supplemental.RightsSection;
|
39
|
import eu.etaxonomy.taxeditor.ui.section.supplemental.SourceSection;
|
40
|
import eu.etaxonomy.taxeditor.ui.section.supplemental.VersionSection;
|
41
|
import eu.etaxonomy.taxeditor.ui.section.supplemental.identifier.IdentifierSection;
|
42
|
import eu.etaxonomy.taxeditor.view.e4.AbstractCdmDataViewerE4;
|
43
|
|
44
|
/**
|
45
|
*
|
46
|
* @author pplitzner
|
47
|
* @since Aug 10, 2017
|
48
|
*
|
49
|
*/
|
50
|
public class SupplementalDataViewerE4 extends AbstractCdmDataViewerE4 {
|
51
|
|
52
|
private boolean showDebug;
|
53
|
|
54
|
/** {@inheritDoc} */
|
55
|
@Override
|
56
|
public ISelection getSelection() {
|
57
|
return null;
|
58
|
}
|
59
|
|
60
|
/** {@inheritDoc} */
|
61
|
@Override
|
62
|
public void setSelection(ISelection selection, boolean reveal) {
|
63
|
|
64
|
}
|
65
|
|
66
|
/** {@inheritDoc} */
|
67
|
@Override
|
68
|
protected void showParts() {
|
69
|
|
70
|
showDebug = PreferencesUtil.getBooleanValue(IPreferenceKeys.SHOW_DEBUG_INFORMATION);
|
71
|
|
72
|
Object input;
|
73
|
|
74
|
if(getInput() instanceof IElementHasDetails){
|
75
|
input = ((IElementHasDetails) getInput()).getData();
|
76
|
}else{
|
77
|
input = getInput();
|
78
|
}
|
79
|
|
80
|
destroySections();
|
81
|
//1. Headline
|
82
|
createHeadlineSection(rootElement);
|
83
|
//2. Annotatable entitiy
|
84
|
if(input instanceof AnnotatableEntity){
|
85
|
createAnnotationSections(rootElement);
|
86
|
}
|
87
|
//3. Identifiable entity
|
88
|
if(input instanceof IdentifiableEntity){
|
89
|
createIdentifiableSections(rootElement);
|
90
|
}
|
91
|
if(input instanceof ISourceable && !(input instanceof IdentifiableEntity)){
|
92
|
createSourceSection(rootElement);
|
93
|
}
|
94
|
//4. Identifiable media entity
|
95
|
if(input instanceof IdentifiableMediaEntity){
|
96
|
createIdentifiableMediaSections(rootElement);
|
97
|
}
|
98
|
//5. Versionable
|
99
|
if(input instanceof VersionableEntity){
|
100
|
createVersionSection(rootElement);
|
101
|
}
|
102
|
//6. CdmBase
|
103
|
if(showDebug){
|
104
|
createCdmBaseSection(rootElement);
|
105
|
}
|
106
|
|
107
|
layout();
|
108
|
}
|
109
|
|
110
|
private void createHeadlineSection(RootElement parent){
|
111
|
HeadlineSection headlineSection = formFactory.createHeadlineSection(parent);
|
112
|
addPart(headlineSection);
|
113
|
}
|
114
|
|
115
|
private void createSourceSection(RootElement parent){
|
116
|
SourceSection sourceSection = formFactory.createSourceSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE);
|
117
|
formFactory.createHorizontalSeparator(parent, SWT.BORDER);
|
118
|
addPart(sourceSection);
|
119
|
}
|
120
|
|
121
|
private void createAnnotationSections(RootElement parent) {
|
122
|
AnnotationSection annotationSection = formFactory.createAnnotationSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE);
|
123
|
|
124
|
formFactory.createHorizontalSeparator(parent, SWT.BORDER);
|
125
|
|
126
|
MarkerSection markerSection = formFactory.createMarkerSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE);
|
127
|
|
128
|
formFactory.createHorizontalSeparator(parent, SWT.BORDER);
|
129
|
|
130
|
addPart(annotationSection);
|
131
|
addPart(markerSection);
|
132
|
}
|
133
|
|
134
|
private void createIdentifiableSections(RootElement parent) {
|
135
|
|
136
|
SourceSection sourceSection = formFactory.createSourceSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE);
|
137
|
|
138
|
formFactory.createHorizontalSeparator(parent, SWT.BORDER);
|
139
|
|
140
|
IdentifierSection identifierSection = formFactory.createIdentifierDetailSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE);
|
141
|
|
142
|
formFactory.createHorizontalSeparator(parent, SWT.BORDER);
|
143
|
|
144
|
ExtensionSection extensionSection = formFactory.createExtensionSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE);
|
145
|
|
146
|
formFactory.createHorizontalSeparator(parent, SWT.BORDER);
|
147
|
|
148
|
CreditSection creditSection = formFactory.createCreditSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE);
|
149
|
|
150
|
formFactory.createHorizontalSeparator(parent, SWT.BORDER);
|
151
|
|
152
|
RightsSection rightsSection = formFactory.createRightsSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE);
|
153
|
|
154
|
formFactory.createHorizontalSeparator(parent, SWT.BORDER);
|
155
|
|
156
|
addPart(sourceSection);
|
157
|
addPart(identifierSection);
|
158
|
addPart(extensionSection);
|
159
|
addPart(creditSection);
|
160
|
addPart(rightsSection);
|
161
|
|
162
|
}
|
163
|
|
164
|
private void createIdentifiableMediaSections(RootElement parent) {
|
165
|
MediaSection mediaSection = formFactory.createMediaSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE);
|
166
|
|
167
|
formFactory.createHorizontalSeparator(parent, SWT.BORDER);
|
168
|
|
169
|
addPart(mediaSection);
|
170
|
}
|
171
|
|
172
|
private void createVersionSection(RootElement parent){
|
173
|
VersionSection versionSection = formFactory.createVersionSection(parent, ExpandableComposite.NO_TITLE | ExpandableComposite.EXPANDED);
|
174
|
addPart(versionSection);
|
175
|
}
|
176
|
|
177
|
private void createCdmBaseSection(RootElement parent) {
|
178
|
|
179
|
CdmBaseSection cdmBaseSection = formFactory.createCdmBaseSection(parent, ExpandableComposite.NO_TITLE | ExpandableComposite.EXPANDED);
|
180
|
addPart(cdmBaseSection);
|
181
|
}
|
182
|
|
183
|
@Override
|
184
|
public void update(CdmDataChangeMap arg0) {
|
185
|
}
|
186
|
|
187
|
@Inject
|
188
|
@Optional
|
189
|
private void updateView(@UIEventTopic(WorkbenchEventConstants.REFRESH_SUPPLEMENTAL)boolean refresh){
|
190
|
if(refresh){
|
191
|
this.refresh();
|
192
|
}
|
193
|
}
|
194
|
}
|