2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
6 * The contents of this file are subject to the Mozilla Public License Version 1.1
7 * See LICENSE.TXT at the top of this package for the full license terms.
10 package eu
.etaxonomy
.taxeditor
.view
.supplementaldata
;
12 import org
.eclipse
.jface
.viewers
.ISelection
;
13 import org
.eclipse
.jface
.viewers
.IStructuredSelection
;
14 import org
.eclipse
.jface
.viewers
.StructuredSelection
;
15 import org
.eclipse
.jface
.viewers
.TreeNode
;
16 import org
.eclipse
.jface
.viewers
.Viewer
;
17 import org
.eclipse
.swt
.widgets
.Composite
;
18 import org
.eclipse
.ui
.IWorkbenchPart
;
19 import org
.eclipse
.ui
.part
.EditorPart
;
21 import eu
.etaxonomy
.cdm
.api
.facade
.DerivedUnitFacade
;
22 import eu
.etaxonomy
.cdm
.ext
.occurrence
.gbif
.GbifResponse
;
23 import eu
.etaxonomy
.cdm
.model
.description
.PolytomousKeyNode
;
24 import eu
.etaxonomy
.taxeditor
.Messages
;
25 import eu
.etaxonomy
.taxeditor
.model
.AbstractUtility
;
26 import eu
.etaxonomy
.taxeditor
.model
.FeatureNodeContainer
;
27 import eu
.etaxonomy
.taxeditor
.model
.IPartContentHasSupplementalData
;
28 import eu
.etaxonomy
.taxeditor
.view
.AbstractCdmEditorViewPart
;
32 * <p>SupplementalDataViewPart class.</p>
35 * @created Jun 10, 2010
38 public class SupplementalDataViewPart
extends AbstractCdmEditorViewPart
{
40 /** Constant <code>ID="eu.etaxonomy.taxeditor.editor.view.supp"{trunked}</code> */
41 public static final String ID
= "eu.etaxonomy.taxeditor.view.supplementalData"; //$NON-NLS-1$
43 private SupplementalDataViewer viewer
;
46 * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
50 public void createViewer(Composite parent
) {
51 viewer
= new SupplementalDataViewer(parent
, this);
57 protected void selectionChanged_internal(IWorkbenchPart part
, ISelection selection
) {
58 if(AbstractUtility
.getActiveEditor() == null){
67 if(!(selection
instanceof IStructuredSelection
)){
71 IStructuredSelection structuredSelection
= (IStructuredSelection
) selection
;
73 if((part
instanceof EditorPart
|| part
instanceof IPartContentHasSupplementalData
)) {
74 if(structuredSelection
.size() != 1){
79 // do not show supplemental data for feature nodes
80 if(structuredSelection
.getFirstElement() instanceof FeatureNodeContainer
){
84 else if(structuredSelection
.getFirstElement() instanceof DerivedUnitFacade
){
87 else if(structuredSelection
.getFirstElement() instanceof PolytomousKeyNode
){
88 structuredSelection
= new StructuredSelection(((PolytomousKeyNode
)structuredSelection
.getFirstElement()).getKey());
90 else if(structuredSelection
.getFirstElement() instanceof TreeNode
){
91 structuredSelection
= new StructuredSelection(((TreeNode
)structuredSelection
.getFirstElement()).getValue());
93 else if(structuredSelection
.getFirstElement() instanceof GbifResponse
){
94 structuredSelection
= new StructuredSelection(((GbifResponse
)structuredSelection
.getFirstElement()).getDerivedUnitFacade().innerDerivedUnit());
96 showViewer(part
, structuredSelection
);
104 public void dispose() {
106 selectionService
.removePostSelectionListener(this);
112 public Viewer
getViewer() {
122 public boolean onComplete() {
123 // TODO Auto-generated method stub
129 protected String
getViewName() {
130 return Messages
.SupplementalDataViewPart_VIEWER_NAME
;