2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
10 package eu
.etaxonomy
.taxeditor
.view
.e4
.supplementaldata
;
12 import javax
.inject
.Inject
;
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
;
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
;
50 public class SupplementalDataViewerE4
extends AbstractCdmDataViewerE4
{
52 private boolean showDebug
;
56 public ISelection
getSelection() {
62 public void setSelection(ISelection selection
, boolean reveal
) {
68 protected void showParts() {
70 showDebug
= PreferencesUtil
.getBooleanValue(IPreferenceKeys
.SHOW_DEBUG_INFORMATION
);
74 if(getInput() instanceof IElementHasDetails
){
75 input
= ((IElementHasDetails
) getInput()).getData();
82 createHeadlineSection(rootElement
);
83 //2. Annotatable entitiy
84 if(input
instanceof AnnotatableEntity
){
85 createAnnotationSections(rootElement
);
87 //3. Identifiable entity
88 if(input
instanceof IdentifiableEntity
){
89 createIdentifiableSections(rootElement
);
91 if(input
instanceof ISourceable
&& !(input
instanceof IdentifiableEntity
)){
92 createSourceSection(rootElement
);
94 //4. Identifiable media entity
95 if(input
instanceof IdentifiableMediaEntity
){
96 createIdentifiableMediaSections(rootElement
);
99 if(input
instanceof VersionableEntity
){
100 createVersionSection(rootElement
);
104 createCdmBaseSection(rootElement
);
110 private void createHeadlineSection(RootElement parent
){
111 HeadlineSection headlineSection
= formFactory
.createHeadlineSection(parent
);
112 addPart(headlineSection
);
115 private void createSourceSection(RootElement parent
){
116 int expandStyle
= getSectionStyle(SourceSection
.class, false);
117 SourceSection sourceSection
= formFactory
.createSourceSection(getConversationHolder(), parent
, expandStyle
);
118 formFactory
.createHorizontalSeparator(parent
, SWT
.BORDER
);
119 addPart(sourceSection
);
122 private void createAnnotationSections(RootElement parent
) {
123 int expandStyle
= getSectionStyle(AnnotationSection
.class, false);
124 AnnotationSection annotationSection
= formFactory
.createAnnotationSection(getConversationHolder(), parent
, expandStyle
);
126 formFactory
.createHorizontalSeparator(parent
, SWT
.BORDER
);
127 expandStyle
= getSectionStyle(MarkerSection
.class, false);
128 MarkerSection markerSection
= formFactory
.createMarkerSection(getConversationHolder(), parent
, ExpandableComposite
.TWISTIE
);
130 formFactory
.createHorizontalSeparator(parent
, SWT
.BORDER
);
132 addPart(annotationSection
);
133 addPart(markerSection
);
136 private void createIdentifiableSections(RootElement parent
) {
137 int expandStyle
= getSectionStyle(SourceSection
.class, false);
138 SourceSection sourceSection
= formFactory
.createSourceSection(getConversationHolder(), parent
, expandStyle
);
140 formFactory
.createHorizontalSeparator(parent
, SWT
.BORDER
);
141 expandStyle
= getSectionStyle(IdentifierSection
.class, false);
142 IdentifierSection identifierSection
= formFactory
.createIdentifierDetailSection(getConversationHolder(), parent
, expandStyle
);
144 formFactory
.createHorizontalSeparator(parent
, SWT
.BORDER
);
145 expandStyle
= getSectionStyle(ExtensionSection
.class, false);
146 ExtensionSection extensionSection
= formFactory
.createExtensionSection(getConversationHolder(), parent
, expandStyle
);
148 formFactory
.createHorizontalSeparator(parent
, SWT
.BORDER
);
149 expandStyle
= getSectionStyle(CreditSection
.class, false);
150 CreditSection creditSection
= formFactory
.createCreditSection(getConversationHolder(), parent
, expandStyle
);
152 formFactory
.createHorizontalSeparator(parent
, SWT
.BORDER
);
153 expandStyle
= getSectionStyle(RightsSection
.class, false);
154 RightsSection rightsSection
= formFactory
.createRightsSection(getConversationHolder(), parent
, expandStyle
);
156 formFactory
.createHorizontalSeparator(parent
, SWT
.BORDER
);
158 addPart(sourceSection
);
159 addPart(identifierSection
);
160 addPart(extensionSection
);
161 addPart(creditSection
);
162 addPart(rightsSection
);
166 private void createIdentifiableMediaSections(RootElement parent
) {
167 int expandStyle
= getSectionStyle(MediaSection
.class, false);
168 MediaSection mediaSection
= formFactory
.createMediaSection(getConversationHolder(), parent
, expandStyle
);
170 formFactory
.createHorizontalSeparator(parent
, SWT
.BORDER
);
172 addPart(mediaSection
);
175 private void createVersionSection(RootElement parent
){
176 VersionSection versionSection
= formFactory
.createVersionSection(parent
, ExpandableComposite
.NO_TITLE
| ExpandableComposite
.EXPANDED
);
177 addPart(versionSection
);
180 private void createCdmBaseSection(RootElement parent
) {
182 CdmBaseSection cdmBaseSection
= formFactory
.createCdmBaseSection(parent
, ExpandableComposite
.NO_TITLE
| ExpandableComposite
.EXPANDED
);
183 addPart(cdmBaseSection
);
187 public void update(CdmDataChangeMap arg0
) {
192 private void updateView(@UIEventTopic(WorkbenchEventConstants
.REFRESH_SUPPLEMENTAL
)boolean refresh
){