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
.editor
.view
.supplementaldata
;
13 import org
.apache
.log4j
.Logger
;
14 import org
.eclipse
.jface
.viewers
.ISelection
;
15 import org
.eclipse
.jface
.viewers
.ISelectionChangedListener
;
16 import org
.eclipse
.jface
.viewers
.IStructuredSelection
;
17 import org
.eclipse
.jface
.viewers
.SelectionChangedEvent
;
18 import org
.eclipse
.swt
.SWT
;
19 import org
.eclipse
.swt
.widgets
.Composite
;
20 import org
.eclipse
.ui
.forms
.widgets
.Section
;
22 import eu
.etaxonomy
.cdm
.model
.common
.AnnotatableEntity
;
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
.editor
.name
.AbstractGroupedContainer
;
27 import eu
.etaxonomy
.taxeditor
.editor
.view
.AbstractCdmDataViewer
;
28 import eu
.etaxonomy
.taxeditor
.editor
.view
.detail
.DetailsViewer
;
29 import eu
.etaxonomy
.taxeditor
.forms
.AbstractFormSection
;
30 import eu
.etaxonomy
.taxeditor
.forms
.CdmFormFactory
;
31 import eu
.etaxonomy
.taxeditor
.forms
.RootElement
;
32 import eu
.etaxonomy
.taxeditor
.forms
.CdmFormFactory
.EntityDetailType
;
33 import eu
.etaxonomy
.taxeditor
.model
.AbstractCdmViewPart
;
34 import eu
.etaxonomy
.taxeditor
.section
.supplemental
.HeadlineSection
;
35 import eu
.etaxonomy
.taxeditor
.section
.supplemental
.VersionSection
;
38 * <p>SupplementalDataViewer class.</p>
41 * @created Feb 12, 2010
44 public class SupplementalDataViewer
extends AbstractCdmDataViewer
implements ISelectionChangedListener
{
45 private static final Logger logger
= Logger
46 .getLogger(SupplementalDataViewer
.class);
48 private enum VIEW_PART
{
52 IdentifiableMediaEntity
,
56 private VIEW_PART currentViewPart
;
58 private DetailsViewer detailsViewer
;
62 * <p>Constructor for SupplementalDataViewer.</p>
64 * @param parent a {@link org.eclipse.swt.widgets.Composite} object.
65 * @param viewPart a {@link eu.etaxonomy.taxeditor.model.AbstractCdmViewPart} object.
67 public SupplementalDataViewer(Composite parent
, AbstractCdmViewPart viewPart
) {
68 super(parent
, viewPart
);
73 * @see org.eclipse.jface.viewers.Viewer#getSelection()
77 public ISelection
getSelection() {
82 * @see org.eclipse.jface.viewers.Viewer#setSelection(org.eclipse.jface.viewers.ISelection, boolean)
86 public void setSelection(ISelection selection
, boolean reveal
) {
87 // TODO Auto-generated method stub
92 * @see eu.etaxonomy.taxeditor.editor.view.AbstractDetailsViewer#showParts(eu.etaxonomy.cdm.model.common.AnnotatableEntity)
96 protected void showParts() {
100 if(getInput() instanceof AbstractGroupedContainer
){
101 input
= ((AbstractGroupedContainer
) 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 AbstractFormSection annotationSection
=
146 formFactory
.createEntityDetailSection(EntityDetailType
.ANNOTATION
, getConversationHolder(), parent
, Section
.TWISTIE
);
148 formFactory
.createHorizontalSeparator(parent
, SWT
.BORDER
);
150 AbstractFormSection 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 AbstractFormSection creditSection
= formFactory
.createEntityDetailSection(EntityDetailType
.CREDIT
, getConversationHolder(), parent
, Section
.TWISTIE
);
167 formFactory
.createHorizontalSeparator(parent
, SWT
.BORDER
);
169 AbstractFormSection extensionSection
= formFactory
.createEntityDetailSection(EntityDetailType
.EXTENSION
, getConversationHolder(), parent
, Section
.TWISTIE
);
171 formFactory
.createHorizontalSeparator(parent
, SWT
.BORDER
);
173 AbstractFormSection rightsSection
= formFactory
.createEntityDetailSection(EntityDetailType
.RIGHTS
, getConversationHolder(), parent
, Section
.TWISTIE
);
175 formFactory
.createHorizontalSeparator(parent
, SWT
.BORDER
);
177 AbstractFormSection sourceSection
= formFactory
.createEntityDetailSection(EntityDetailType
.SOURCE
, getConversationHolder(), parent
, Section
.TWISTIE
);
179 formFactory
.createHorizontalSeparator(parent
, SWT
.BORDER
);
181 addPart(creditSection
);
182 addPart(extensionSection
);
183 addPart(rightsSection
);
184 addPart(sourceSection
);
186 if(currentViewPart
== VIEW_PART
.IdentifiableEntity
){
187 createVersionSection(parent
);
191 private void createIdentifiableMediaSections(RootElement parent
){
192 createIdentifiableSections(parent
);
193 AbstractFormSection mediaSection
= formFactory
.createEntityDetailSection(EntityDetailType
.MEDIA
, getConversationHolder(), parent
, Section
.TWISTIE
);
195 formFactory
.createHorizontalSeparator(parent
, SWT
.BORDER
);
197 addPart(mediaSection
);
199 if(currentViewPart
== VIEW_PART
.IdentifiableMediaEntity
){
200 createVersionSection(parent
);
204 private void createVersionSection(RootElement parent
){
205 VersionSection versionSection
= formFactory
.createVersionSection(parent
, Section
.NO_TITLE
| Section
.EXPANDED
);
206 addPart(versionSection
);
211 * @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent)
214 public void selectionChanged(SelectionChangedEvent event
) {
215 if(event
.getSource() instanceof DetailsViewer
){
216 detailsViewer
= (DetailsViewer
) event
.getSource();
218 if(event
.getSelection() == CdmFormFactory
.EMPTY_SELECTION
){
220 currentViewPart
= VIEW_PART
.EMPTY
;
224 IStructuredSelection selection
= (IStructuredSelection
) event
.getSelection();
225 setInput(selection
.getFirstElement());