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
.model
.description
.PolytomousKeyNode
;
24 import eu
.etaxonomy
.taxeditor
.model
.AbstractUtility
;
25 import eu
.etaxonomy
.taxeditor
.model
.FeatureNodeContainer
;
26 import eu
.etaxonomy
.taxeditor
.model
.IPartContentHasSupplementalData
;
27 import eu
.etaxonomy
.taxeditor
.view
.AbstractCdmEditorViewPart
;
31 * <p>SupplementalDataViewPart class.</p>
34 * @created Jun 10, 2010
37 public class SupplementalDataViewPart
extends AbstractCdmEditorViewPart
{
39 /** Constant <code>ID="eu.etaxonomy.taxeditor.editor.view.supp"{trunked}</code> */
40 public static final String ID
= "eu.etaxonomy.taxeditor.view.supplementalData";
42 private SupplementalDataViewer viewer
;
45 * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
49 public void createViewer(Composite parent
) {
50 viewer
= new SupplementalDataViewer(parent
, this);
56 public void selectionChanged(IWorkbenchPart part
, ISelection selection
) {
57 if(AbstractUtility
.getActiveEditor() == null){
66 if(!(selection
instanceof IStructuredSelection
)){
70 IStructuredSelection structuredSelection
= (IStructuredSelection
) selection
;
72 if((part
instanceof EditorPart
|| part
instanceof IPartContentHasSupplementalData
)) {
73 if(structuredSelection
.size() != 1){
78 // do not show supplemental data for feature nodes
79 if(structuredSelection
.getFirstElement() instanceof FeatureNodeContainer
){
83 else if(structuredSelection
.getFirstElement() instanceof DerivedUnitFacade
){
86 else if(structuredSelection
.getFirstElement() instanceof PolytomousKeyNode
){
87 structuredSelection
= new StructuredSelection(((PolytomousKeyNode
)structuredSelection
.getFirstElement()).getKey());
89 else if(structuredSelection
.getFirstElement() instanceof TreeNode
){
90 structuredSelection
= new StructuredSelection(((TreeNode
)structuredSelection
.getFirstElement()).getValue());
92 showViewer(part
, structuredSelection
);
100 public void dispose() {
102 selectionService
.removePostSelectionListener(this);
108 public Viewer
getViewer() {
118 public boolean onComplete() {
119 // TODO Auto-generated method stub