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
.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
.ui
.element
.CdmFormFactory
;
27 import eu
.etaxonomy
.taxeditor
.ui
.element
.RootElement
;
28 import eu
.etaxonomy
.taxeditor
.ui
.element
.CdmFormFactory
.EntityDetailType
;
29 import eu
.etaxonomy
.taxeditor
.ui
.section
.media
.MediaSection
;
30 import eu
.etaxonomy
.taxeditor
.ui
.section
.supplemental
.AnnotationSection
;
31 import eu
.etaxonomy
.taxeditor
.ui
.section
.supplemental
.CreditSection
;
32 import eu
.etaxonomy
.taxeditor
.ui
.section
.supplemental
.ExtensionSection
;
33 import eu
.etaxonomy
.taxeditor
.ui
.section
.supplemental
.HeadlineSection
;
34 import eu
.etaxonomy
.taxeditor
.ui
.section
.supplemental
.MarkerSection
;
35 import eu
.etaxonomy
.taxeditor
.ui
.section
.supplemental
.RightsSection
;
36 import eu
.etaxonomy
.taxeditor
.ui
.section
.supplemental
.SourceSection
;
37 import eu
.etaxonomy
.taxeditor
.ui
.section
.supplemental
.VersionSection
;
38 import eu
.etaxonomy
.taxeditor
.view
.AbstractCdmDataViewer
;
39 import eu
.etaxonomy
.taxeditor
.view
.AbstractCdmViewPart
;
40 import eu
.etaxonomy
.taxeditor
.view
.detail
.DetailsViewer
;
43 * <p>SupplementalDataViewer class.</p>
46 * @created Feb 12, 2010
49 public class SupplementalDataViewer
extends AbstractCdmDataViewer
implements ISelectionChangedListener
{
51 private enum VIEW_PART
{
55 IdentifiableMediaEntity
,
59 private VIEW_PART currentViewPart
;
63 * <p>Constructor for SupplementalDataViewer.</p>
65 * @param parent a {@link org.eclipse.swt.widgets.Composite} object.
66 * @param viewPart a {@link eu.etaxonomy.taxeditor.view.AbstractCdmViewPart} object.
68 public SupplementalDataViewer(Composite parent
, AbstractCdmViewPart viewPart
) {
69 super(parent
, viewPart
);
74 * @see org.eclipse.jface.viewers.Viewer#getSelection()
78 public ISelection
getSelection() {
83 * @see org.eclipse.jface.viewers.Viewer#setSelection(org.eclipse.jface.viewers.ISelection, boolean)
87 public void setSelection(ISelection selection
, boolean reveal
) {
92 * @see eu.etaxonomy.taxeditor.editor.view.AbstractDetailsViewer#showParts(eu.etaxonomy.cdm.model.common.AnnotatableEntity)
96 protected void showParts() {
100 if(getInput() instanceof IElementHasDetails
){
101 input
= ((IElementHasDetails
) getInput()).getData();
106 if(input
instanceof IdentifiableMediaEntity
){
107 if(currentViewPart
!= VIEW_PART
.IdentifiableMediaEntity
){
108 currentViewPart
= VIEW_PART
.IdentifiableMediaEntity
;
109 createIdentifiableMediaSections(rootElement
);
111 }else if(input
instanceof IdentifiableEntity
){
112 if(currentViewPart
!= VIEW_PART
.IdentifiableEntity
){
113 currentViewPart
= VIEW_PART
.IdentifiableEntity
;
114 createIdentifiableSections(rootElement
);
116 }else if(input
instanceof AnnotatableEntity
){
117 if(currentViewPart
!= VIEW_PART
.AnnotatableEntity
){
118 currentViewPart
= VIEW_PART
.AnnotatableEntity
;
119 createAnnotationSections(rootElement
);
121 }else if(input
instanceof VersionableEntity
){
122 if(currentViewPart
!= VIEW_PART
.VersionableEntity
){
123 currentViewPart
= VIEW_PART
.VersionableEntity
;
124 createHeadlineSection(rootElement
);
127 currentViewPart
= VIEW_PART
.EMPTY
;
133 private void createHeadlineSection(RootElement parent
){
135 HeadlineSection headlineSection
= formFactory
.createHeadlineSection(parent
);
136 addPart(headlineSection
);
138 if(currentViewPart
== VIEW_PART
.VersionableEntity
){
139 createVersionSection(parent
);
143 private void createAnnotationSections(RootElement parent
){
144 createHeadlineSection(parent
);
145 AnnotationSection annotationSection
= (AnnotationSection
)
146 formFactory
.createEntityDetailSection(EntityDetailType
.ANNOTATION
, getConversationHolder(), parent
, Section
.TWISTIE
);
148 formFactory
.createHorizontalSeparator(parent
, SWT
.BORDER
);
150 MarkerSection markerSection
= (MarkerSection
)
151 formFactory
.createEntityDetailSection(EntityDetailType
.MARKER
, getConversationHolder(), parent
, Section
.TWISTIE
);
153 formFactory
.createHorizontalSeparator(parent
, SWT
.BORDER
);
155 addPart(annotationSection
);
156 addPart(markerSection
);
158 if(currentViewPart
== VIEW_PART
.AnnotatableEntity
){
159 createVersionSection(parent
);
163 private void createIdentifiableSections(RootElement parent
){
164 createAnnotationSections(parent
);
165 CreditSection creditSection
= (CreditSection
)
166 formFactory
.createEntityDetailSection(EntityDetailType
.CREDIT
, getConversationHolder(), parent
, Section
.TWISTIE
);
168 formFactory
.createHorizontalSeparator(parent
, SWT
.BORDER
);
170 ExtensionSection extensionSection
= (ExtensionSection
)
171 formFactory
.createEntityDetailSection(EntityDetailType
.EXTENSION
, getConversationHolder(), parent
, Section
.TWISTIE
);
173 formFactory
.createHorizontalSeparator(parent
, SWT
.BORDER
);
175 RightsSection rightsSection
= (RightsSection
)
176 formFactory
.createEntityDetailSection(EntityDetailType
.RIGHTS
, getConversationHolder(), parent
, Section
.TWISTIE
);
178 formFactory
.createHorizontalSeparator(parent
, SWT
.BORDER
);
180 SourceSection sourceSection
= (SourceSection
)
181 formFactory
.createEntityDetailSection(EntityDetailType
.SOURCE
, getConversationHolder(), parent
, Section
.TWISTIE
);
183 formFactory
.createHorizontalSeparator(parent
, SWT
.BORDER
);
185 addPart(creditSection
);
186 addPart(extensionSection
);
187 addPart(rightsSection
);
188 addPart(sourceSection
);
190 if(currentViewPart
== VIEW_PART
.IdentifiableEntity
){
191 createVersionSection(parent
);
195 private void createIdentifiableMediaSections(RootElement parent
){
196 createIdentifiableSections(parent
);
197 MediaSection mediaSection
= (MediaSection
)
198 formFactory
.createEntityDetailSection(EntityDetailType
.MEDIA
, getConversationHolder(), parent
, Section
.TWISTIE
);
200 formFactory
.createHorizontalSeparator(parent
, SWT
.BORDER
);
202 addPart(mediaSection
);
204 if(currentViewPart
== VIEW_PART
.IdentifiableMediaEntity
){
205 createVersionSection(parent
);
209 private void createVersionSection(RootElement parent
){
210 VersionSection versionSection
= formFactory
.createVersionSection(parent
, Section
.NO_TITLE
| Section
.EXPANDED
);
211 addPart(versionSection
);
216 * @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent)
219 public void selectionChanged(SelectionChangedEvent event
) {
220 if(event
.getSource() instanceof DetailsViewer
){
221 if(event
.getSelection() == CdmFormFactory
.EMPTY_SELECTION
){
223 currentViewPart
= VIEW_PART
.EMPTY
;
227 IStructuredSelection selection
= (IStructuredSelection
) event
.getSelection();
228 setInput(selection
.getFirstElement());