- enabled DescriptiveView (Factual Data) to show descriptions of SpecimenOrObservati...
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / view / supplementaldata / SupplementalDataViewPart.java
1 // $Id$
2 /**
3 * Copyright (C) 2007 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
6 *
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.
9 */
10
11 package eu.etaxonomy.taxeditor.view.supplementaldata;
12
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.Viewer;
17 import org.eclipse.swt.widgets.Composite;
18 import org.eclipse.ui.IWorkbenchPart;
19 import org.eclipse.ui.part.EditorPart;
20
21 import eu.etaxonomy.cdm.api.facade.DerivedUnitFacade;
22 import eu.etaxonomy.cdm.model.description.PolytomousKeyNode;
23 import eu.etaxonomy.taxeditor.model.AbstractUtility;
24 import eu.etaxonomy.taxeditor.model.FeatureNodeContainer;
25 import eu.etaxonomy.taxeditor.model.IPartContentHasSupplementalData;
26 import eu.etaxonomy.taxeditor.view.AbstractCdmEditorViewPart;
27
28
29 /**
30 * <p>SupplementalDataViewPart class.</p>
31 *
32 * @author n.hoffmann
33 * @created Jun 10, 2010
34 * @version 1.0
35 */
36 public class SupplementalDataViewPart extends AbstractCdmEditorViewPart {
37
38 /** Constant <code>ID="eu.etaxonomy.taxeditor.editor.view.supp"{trunked}</code> */
39 public static final String ID = "eu.etaxonomy.taxeditor.view.supplementalData";
40
41 private SupplementalDataViewer viewer;
42
43 /* (non-Javadoc)
44 * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
45 */
46 /** {@inheritDoc} */
47 @Override
48 public void createViewer(Composite parent) {
49 viewer = new SupplementalDataViewer(parent, this);
50 }
51
52
53 /** {@inheritDoc} */
54 @Override
55 public void selectionChanged(IWorkbenchPart part, ISelection selection) {
56 if(AbstractUtility.getActiveEditor() == null){
57 showEmptyPage();
58 return;
59 }
60
61 if(part == this){
62 return;
63 }
64
65 if(!(selection instanceof IStructuredSelection)){
66 return;
67 }
68
69 IStructuredSelection structuredSelection = (IStructuredSelection) selection;
70
71 if((part instanceof EditorPart || part instanceof IPartContentHasSupplementalData)) {
72 if(structuredSelection.size() != 1){
73 showEmptyPage();
74 return;
75 }
76
77 // do not show supplemental data for feature nodes
78 if(structuredSelection.getFirstElement() instanceof FeatureNodeContainer){
79 showEmptyPage();
80 return;
81 }
82 else if(structuredSelection.getFirstElement() instanceof DerivedUnitFacade){
83 return;
84 }
85 else if(structuredSelection.getFirstElement() instanceof PolytomousKeyNode){
86 structuredSelection = new StructuredSelection(((PolytomousKeyNode)structuredSelection.getFirstElement()).getKey());
87 }
88 showViewer(part, structuredSelection);
89 }else{
90 showEmptyPage();
91 }
92 }
93
94 /** {@inheritDoc} */
95 @Override
96 public void dispose() {
97 super.dispose();
98 selectionService.removePostSelectionListener(this);
99 }
100
101
102 /** {@inheritDoc} */
103 @Override
104 public Viewer getViewer() {
105 return viewer;
106 }
107
108 /**
109 * <p>onComplete</p>
110 *
111 * @return a boolean.
112 */
113 @Override
114 public boolean onComplete() {
115 // TODO Auto-generated method stub
116 return false;
117 }
118
119
120 }