3 * Copyright (C) 2007 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
7 * The contents of this file are subject to the Mozilla Public License Version 1.1
8 * See LICENSE.TXT at the top of this package for the full license terms.
11 package eu
.etaxonomy
.taxeditor
.view
.supplementaldata
;
13 import org
.eclipse
.jface
.viewers
.ISelection
;
14 import org
.eclipse
.jface
.viewers
.ISelectionChangedListener
;
15 import org
.eclipse
.jface
.viewers
.IStructuredSelection
;
16 import org
.eclipse
.jface
.viewers
.SelectionChangedEvent
;
17 import org
.eclipse
.swt
.SWT
;
18 import org
.eclipse
.swt
.widgets
.Composite
;
19 import org
.eclipse
.ui
.forms
.widgets
.Section
;
21 import eu
.etaxonomy
.cdm
.model
.common
.AnnotatableEntity
;
22 import eu
.etaxonomy
.cdm
.model
.common
.CdmBase
;
23 import eu
.etaxonomy
.cdm
.model
.common
.IdentifiableEntity
;
24 import eu
.etaxonomy
.cdm
.model
.common
.VersionableEntity
;
25 import eu
.etaxonomy
.cdm
.model
.media
.IdentifiableMediaEntity
;
26 import eu
.etaxonomy
.taxeditor
.model
.IElementHasDetails
;
27 import eu
.etaxonomy
.taxeditor
.preference
.PreferencesUtil
;
28 import eu
.etaxonomy
.taxeditor
.ui
.element
.CdmFormFactory
;
29 import eu
.etaxonomy
.taxeditor
.ui
.element
.RootElement
;
30 import eu
.etaxonomy
.taxeditor
.ui
.element
.CdmFormFactory
.EntityDetailType
;
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
.view
.AbstractCdmDataViewer
;
42 import eu
.etaxonomy
.taxeditor
.view
.AbstractCdmViewPart
;
43 import eu
.etaxonomy
.taxeditor
.view
.detail
.DetailsViewer
;
46 * <p>SupplementalDataViewer class.</p>
49 * @created Feb 12, 2010
52 public class SupplementalDataViewer
extends AbstractCdmDataViewer
implements ISelectionChangedListener
{
54 private boolean showDebug
;
58 * <p>Constructor for SupplementalDataViewer.</p>
60 * @param parent a {@link org.eclipse.swt.widgets.Composite} object.
61 * @param viewPart a {@link eu.etaxonomy.taxeditor.view.AbstractCdmViewPart} object.
63 public SupplementalDataViewer(Composite parent
, AbstractCdmViewPart viewPart
) {
64 super(parent
, viewPart
);
69 * @see org.eclipse.jface.viewers.Viewer#getSelection()
73 public ISelection
getSelection() {
78 * @see org.eclipse.jface.viewers.Viewer#setSelection(org.eclipse.jface.viewers.ISelection, boolean)
82 public void setSelection(ISelection selection
, boolean reveal
) {
87 * @see eu.etaxonomy.taxeditor.editor.view.AbstractDetailsViewer#showParts(eu.etaxonomy.cdm.model.common.AnnotatableEntity)
91 protected void showParts() {
93 showDebug
= PreferencesUtil
.getPreferenceStore().getBoolean(PreferencesUtil
.SHOW_DEBUG_INFORMATION
);
97 if(getInput() instanceof IElementHasDetails
){
98 input
= ((IElementHasDetails
) getInput()).getData();
105 createHeadlineSection(rootElement
);
106 //2. Annotatable entitiy
107 if(input
instanceof AnnotatableEntity
){
108 createAnnotationSections(rootElement
);
110 //3. Identifiable entity
111 if(input
instanceof IdentifiableEntity
){
112 createIdentifiableSections(rootElement
);
114 //4. Identifiable media entity
115 if(input
instanceof IdentifiableMediaEntity
){
116 createIdentifiableMediaSections(rootElement
);
119 if(input
instanceof VersionableEntity
){
120 createVersionSection(rootElement
);
124 createCdmBaseSection(rootElement
);
132 private void createHeadlineSection(RootElement parent
){
133 HeadlineSection headlineSection
= formFactory
.createHeadlineSection(parent
);
134 addPart(headlineSection
);
137 private void createAnnotationSections(RootElement parent
){
138 AnnotationSection annotationSection
= (AnnotationSection
)
139 formFactory
.createEntityDetailSection(EntityDetailType
.ANNOTATION
, getConversationHolder(), parent
, Section
.TWISTIE
);
141 formFactory
.createHorizontalSeparator(parent
, SWT
.BORDER
);
143 MarkerSection markerSection
= (MarkerSection
)
144 formFactory
.createEntityDetailSection(EntityDetailType
.MARKER
, getConversationHolder(), parent
, Section
.TWISTIE
);
146 formFactory
.createHorizontalSeparator(parent
, SWT
.BORDER
);
148 addPart(annotationSection
);
149 addPart(markerSection
);
152 private void createIdentifiableSections(RootElement parent
){
153 CreditSection creditSection
= (CreditSection
)
154 formFactory
.createEntityDetailSection(EntityDetailType
.CREDIT
, getConversationHolder(), parent
, Section
.TWISTIE
);
156 formFactory
.createHorizontalSeparator(parent
, SWT
.BORDER
);
158 ExtensionSection extensionSection
= (ExtensionSection
)
159 formFactory
.createEntityDetailSection(EntityDetailType
.EXTENSION
, getConversationHolder(), parent
, Section
.TWISTIE
);
161 formFactory
.createHorizontalSeparator(parent
, SWT
.BORDER
);
163 RightsSection rightsSection
= (RightsSection
)
164 formFactory
.createEntityDetailSection(EntityDetailType
.RIGHTS
, getConversationHolder(), parent
, Section
.TWISTIE
);
166 formFactory
.createHorizontalSeparator(parent
, SWT
.BORDER
);
168 SourceSection sourceSection
= (SourceSection
)
169 formFactory
.createEntityDetailSection(EntityDetailType
.SOURCE
, getConversationHolder(), parent
, Section
.TWISTIE
);
171 formFactory
.createHorizontalSeparator(parent
, SWT
.BORDER
);
173 addPart(creditSection
);
174 addPart(extensionSection
);
175 addPart(rightsSection
);
176 addPart(sourceSection
);
180 private void createIdentifiableMediaSections(RootElement parent
){
181 MediaSection mediaSection
= (MediaSection
)
182 formFactory
.createEntityDetailSection(EntityDetailType
.MEDIA
, getConversationHolder(), parent
, Section
.TWISTIE
);
184 formFactory
.createHorizontalSeparator(parent
, SWT
.BORDER
);
186 addPart(mediaSection
);
189 private void createVersionSection(RootElement parent
){
190 VersionSection versionSection
= formFactory
.createVersionSection(parent
, Section
.NO_TITLE
| Section
.EXPANDED
);
191 addPart(versionSection
);
197 private void createCdmBaseSection(RootElement parent
) {
199 CdmBaseSection cdmBaseSection
= formFactory
.createCdmBaseSection(parent
, Section
.NO_TITLE
| Section
.EXPANDED
);
200 addPart(cdmBaseSection
);
205 * @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent)
208 public void selectionChanged(SelectionChangedEvent event
) {
209 if(event
.getSource() instanceof DetailsViewer
){
210 if(event
.getSelection() == CdmFormFactory
.EMPTY_SELECTION
){
215 IStructuredSelection selection
= (IStructuredSelection
) event
.getSelection();
216 setInput(selection
.getFirstElement());