Some refactoring and started on implementing images for specimen.
[taxeditor.git] / taxeditor-editor / src / main / java / eu / etaxonomy / taxeditor / editor / 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.editor.view.supplementaldata;
12
13 import org.eclipse.jface.viewers.ISelection;
14 import org.eclipse.jface.viewers.IStructuredSelection;
15 import org.eclipse.jface.viewers.Viewer;
16 import org.eclipse.swt.widgets.Composite;
17 import org.eclipse.ui.IWorkbenchPart;
18 import org.eclipse.ui.part.EditorPart;
19
20 import eu.etaxonomy.cdm.api.facade.DerivedUnitFacade;
21 import eu.etaxonomy.taxeditor.editor.EditorUtil;
22 import eu.etaxonomy.taxeditor.editor.view.AbstractCdmEditorViewPart;
23 import eu.etaxonomy.taxeditor.model.AbstractCdmViewPart;
24 import eu.etaxonomy.taxeditor.model.FeatureNodeContainer;
25
26
27 /**
28 * <p>SupplementalDataViewPart class.</p>
29 *
30 * @author n.hoffmann
31 * @created Jun 10, 2010
32 * @version 1.0
33 */
34 public class SupplementalDataViewPart extends AbstractCdmEditorViewPart {
35
36 /** Constant <code>ID="eu.etaxonomy.taxeditor.editor.view.supp"{trunked}</code> */
37 public static final String ID = "eu.etaxonomy.taxeditor.editor.view.supplementalData";
38
39 private SupplementalDataViewer viewer;
40
41 /* (non-Javadoc)
42 * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
43 */
44 /** {@inheritDoc} */
45 @Override
46 public void createViewer(Composite parent) {
47 viewer = new SupplementalDataViewer(parent, this);
48 }
49
50
51 /** {@inheritDoc} */
52 public void selectionChanged(IWorkbenchPart part, ISelection selection) {
53 if(EditorUtil.getActiveEditor() == null){
54 showEmptyPage();
55 return;
56 }
57
58 if(((part instanceof EditorPart) || (part instanceof AbstractCdmViewPart)) && selection instanceof IStructuredSelection) {
59 IStructuredSelection structuredSelection = (IStructuredSelection) selection;
60 if(structuredSelection.size() != 1){
61 showEmptyPage();
62 return;
63 }
64
65 // do not show supplemental data for feature nodes
66 if(structuredSelection.getFirstElement() instanceof FeatureNodeContainer){
67 showEmptyPage();
68 return;
69 }
70 if(structuredSelection.getFirstElement() instanceof DerivedUnitFacade){
71 return;
72 }
73
74 showViewer(part, structuredSelection);
75 }else{
76 showEmptyPage();
77 }
78 }
79
80 /** {@inheritDoc} */
81 @Override
82 public void dispose() {
83 super.dispose();
84 selectionService.removePostSelectionListener(this);
85 }
86
87
88 /** {@inheritDoc} */
89 @Override
90 public Viewer getViewer() {
91 return viewer;
92 }
93
94 /**
95 * <p>onComplete</p>
96 *
97 * @return a boolean.
98 */
99 public boolean onComplete() {
100 // TODO Auto-generated method stub
101 return false;
102 }
103
104
105 }