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
.IStructuredSelection
;
15 import org
.eclipse
.jface
.viewers
.StructuredSelection
;
16 import org
.eclipse
.jface
.viewers
.TreeNode
;
17 import org
.eclipse
.jface
.viewers
.Viewer
;
18 import org
.eclipse
.swt
.widgets
.Composite
;
19 import org
.eclipse
.ui
.IWorkbenchPart
;
20 import org
.eclipse
.ui
.part
.EditorPart
;
22 import eu
.etaxonomy
.cdm
.api
.facade
.DerivedUnitFacade
;
23 import eu
.etaxonomy
.cdm
.ext
.occurrence
.gbif
.GbifResponse
;
24 import eu
.etaxonomy
.cdm
.model
.description
.PolytomousKeyNode
;
25 import eu
.etaxonomy
.taxeditor
.Messages
;
26 import eu
.etaxonomy
.taxeditor
.model
.AbstractUtility
;
27 import eu
.etaxonomy
.taxeditor
.model
.FeatureNodeContainer
;
28 import eu
.etaxonomy
.taxeditor
.model
.IPartContentHasSupplementalData
;
29 import eu
.etaxonomy
.taxeditor
.view
.AbstractCdmEditorViewPart
;
33 * <p>SupplementalDataViewPart class.</p>
36 * @created Jun 10, 2010
39 public class SupplementalDataViewPart
extends AbstractCdmEditorViewPart
{
41 /** Constant <code>ID="eu.etaxonomy.taxeditor.editor.view.supp"{trunked}</code> */
42 public static final String ID
= "eu.etaxonomy.taxeditor.view.supplementalData"; //$NON-NLS-1$
44 private SupplementalDataViewer viewer
;
47 * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
51 public void createViewer(Composite parent
) {
52 viewer
= new SupplementalDataViewer(parent
, this);
58 protected void selectionChanged_internal(IWorkbenchPart part
, ISelection selection
) {
59 if(AbstractUtility
.getActiveEditor() == null){
68 if(!(selection
instanceof IStructuredSelection
)){
72 IStructuredSelection structuredSelection
= (IStructuredSelection
) selection
;
74 if((part
instanceof EditorPart
|| part
instanceof IPartContentHasSupplementalData
)) {
75 if(structuredSelection
.size() != 1){
80 // do not show supplemental data for feature nodes
81 if(structuredSelection
.getFirstElement() instanceof FeatureNodeContainer
){
85 else if(structuredSelection
.getFirstElement() instanceof DerivedUnitFacade
){
88 else if(structuredSelection
.getFirstElement() instanceof PolytomousKeyNode
){
89 structuredSelection
= new StructuredSelection(((PolytomousKeyNode
)structuredSelection
.getFirstElement()).getKey());
91 else if(structuredSelection
.getFirstElement() instanceof TreeNode
){
92 structuredSelection
= new StructuredSelection(((TreeNode
)structuredSelection
.getFirstElement()).getValue());
94 else if(structuredSelection
.getFirstElement() instanceof GbifResponse
){
95 structuredSelection
= new StructuredSelection(((GbifResponse
)structuredSelection
.getFirstElement()).getDerivedUnitFacade().innerDerivedUnit());
97 showViewer(part
, structuredSelection
);
105 public void dispose() {
107 selectionService
.removePostSelectionListener(this);
113 public Viewer
getViewer() {
123 public boolean onComplete() {
124 // TODO Auto-generated method stub
130 protected String
getViewName() {
131 return Messages
.SupplementalDataViewPart_VIEWER_NAME
;