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
.ExpandableComposite
;
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
.media
.IdentifiableMediaEntity
;
25 import eu
.etaxonomy
.taxeditor
.model
.IElementHasDetails
;
26 import eu
.etaxonomy
.taxeditor
.preference
.IPreferenceKeys
;
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
.section
.media
.MediaSection
;
31 import eu
.etaxonomy
.taxeditor
.ui
.section
.supplemental
.AnnotationSection
;
32 import eu
.etaxonomy
.taxeditor
.ui
.section
.supplemental
.CdmBaseSection
;
33 import eu
.etaxonomy
.taxeditor
.ui
.section
.supplemental
.CreditSection
;
34 import eu
.etaxonomy
.taxeditor
.ui
.section
.supplemental
.ExtensionSection
;
35 import eu
.etaxonomy
.taxeditor
.ui
.section
.supplemental
.HeadlineSection
;
36 import eu
.etaxonomy
.taxeditor
.ui
.section
.supplemental
.MarkerSection
;
37 import eu
.etaxonomy
.taxeditor
.ui
.section
.supplemental
.RightsSection
;
38 import eu
.etaxonomy
.taxeditor
.ui
.section
.supplemental
.SourceSection
;
39 import eu
.etaxonomy
.taxeditor
.ui
.section
.supplemental
.VersionSection
;
40 import eu
.etaxonomy
.taxeditor
.view
.AbstractCdmDataViewer
;
41 import eu
.etaxonomy
.taxeditor
.view
.AbstractCdmViewPart
;
42 import eu
.etaxonomy
.taxeditor
.view
.detail
.DetailsViewer
;
45 * <p>SupplementalDataViewer class.</p>
48 * @created Feb 12, 2010
51 public class SupplementalDataViewer
extends AbstractCdmDataViewer
implements ISelectionChangedListener
{
53 private boolean showDebug
;
57 * <p>Constructor for SupplementalDataViewer.</p>
59 * @param parent a {@link org.eclipse.swt.widgets.Composite} object.
60 * @param viewPart a {@link eu.etaxonomy.taxeditor.view.AbstractCdmViewPart} object.
62 public SupplementalDataViewer(Composite parent
, AbstractCdmViewPart viewPart
) {
63 super(parent
, viewPart
);
68 * @see org.eclipse.jface.viewers.Viewer#getSelection()
72 public ISelection
getSelection() {
77 * @see org.eclipse.jface.viewers.Viewer#setSelection(org.eclipse.jface.viewers.ISelection, boolean)
81 public void setSelection(ISelection selection
, boolean reveal
) {
86 * @see eu.etaxonomy.taxeditor.editor.view.AbstractDetailsViewer#showParts(eu.etaxonomy.cdm.model.common.AnnotatableEntity)
90 protected void showParts() {
92 showDebug
= PreferencesUtil
.getPreferenceStore().getBoolean(IPreferenceKeys
.SHOW_DEBUG_INFORMATION
);
96 if(getInput() instanceof IElementHasDetails
){
97 input
= ((IElementHasDetails
) getInput()).getData();
104 createHeadlineSection(rootElement
);
105 //2. Annotatable entitiy
106 if(input
instanceof AnnotatableEntity
){
107 createAnnotationSections(rootElement
);
109 //3. Identifiable entity
110 if(input
instanceof IdentifiableEntity
){
111 createIdentifiableSections(rootElement
);
113 //4. Identifiable media entity
114 if(input
instanceof IdentifiableMediaEntity
){
115 createIdentifiableMediaSections(rootElement
);
118 if(input
instanceof VersionableEntity
){
119 createVersionSection(rootElement
);
123 createCdmBaseSection(rootElement
);
131 private void createHeadlineSection(RootElement parent
){
132 HeadlineSection headlineSection
= formFactory
.createHeadlineSection(parent
);
133 addPart(headlineSection
);
136 private void createAnnotationSections(RootElement parent
) {
137 AnnotationSection annotationSection
= formFactory
.createAnnotationSection(getConversationHolder(), parent
, ExpandableComposite
.TWISTIE
);
139 formFactory
.createHorizontalSeparator(parent
, SWT
.BORDER
);
141 MarkerSection markerSection
= formFactory
.createMarkerSection(getConversationHolder(), parent
, ExpandableComposite
.TWISTIE
);
143 formFactory
.createHorizontalSeparator(parent
, SWT
.BORDER
);
145 addPart(annotationSection
);
146 addPart(markerSection
);
149 private void createIdentifiableSections(RootElement parent
) {
150 CreditSection creditSection
= formFactory
.createCreditSection(getConversationHolder(), parent
, ExpandableComposite
.TWISTIE
);
152 formFactory
.createHorizontalSeparator(parent
, SWT
.BORDER
);
154 ExtensionSection extensionSection
= formFactory
.createExtensionSection(getConversationHolder(), parent
, ExpandableComposite
.TWISTIE
);
156 formFactory
.createHorizontalSeparator(parent
, SWT
.BORDER
);
158 RightsSection rightsSection
= formFactory
.createRightsSection(getConversationHolder(), parent
, ExpandableComposite
.TWISTIE
);
160 formFactory
.createHorizontalSeparator(parent
, SWT
.BORDER
);
162 SourceSection sourceSection
= formFactory
.createSourceSection(getConversationHolder(), parent
, ExpandableComposite
.TWISTIE
);
164 formFactory
.createHorizontalSeparator(parent
, SWT
.BORDER
);
166 addPart(creditSection
);
167 addPart(extensionSection
);
168 addPart(rightsSection
);
169 addPart(sourceSection
);
173 private void createIdentifiableMediaSections(RootElement parent
) {
174 MediaSection mediaSection
= formFactory
.createMediaSection(getConversationHolder(), parent
, ExpandableComposite
.TWISTIE
);
176 formFactory
.createHorizontalSeparator(parent
, SWT
.BORDER
);
178 addPart(mediaSection
);
181 private void createVersionSection(RootElement parent
){
182 VersionSection versionSection
= formFactory
.createVersionSection(parent
, ExpandableComposite
.NO_TITLE
| ExpandableComposite
.EXPANDED
);
183 addPart(versionSection
);
189 private void createCdmBaseSection(RootElement parent
) {
191 CdmBaseSection cdmBaseSection
= formFactory
.createCdmBaseSection(parent
, ExpandableComposite
.NO_TITLE
| ExpandableComposite
.EXPANDED
);
192 addPart(cdmBaseSection
);
197 * @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent)
201 public void selectionChanged(SelectionChangedEvent event
) {
202 if(event
.getSource() instanceof DetailsViewer
){
203 if(event
.getSelection() == CdmFormFactory
.EMPTY_SELECTION
){
208 IStructuredSelection selection
= (IStructuredSelection
) event
.getSelection();
209 setInput(selection
.getFirstElement());