Fixing issues with display of images in the supplemental data view
[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 if(((IStructuredSelection) selection).size() != 1){
60 showEmptyPage();
61 return;
62 }
63
64 // do not show supplemental data for feature nodes
65 if(((IStructuredSelection) selection).getFirstElement() instanceof FeatureNodeContainer){
66 showEmptyPage();
67 return;
68 }
69 if(((IStructuredSelection) selection).getFirstElement() instanceof DerivedUnitFacade){
70 return;
71 }
72
73 showViewer(part, selection);
74 }else{
75 showEmptyPage();
76 }
77 }
78
79 /** {@inheritDoc} */
80 @Override
81 public void dispose() {
82 super.dispose();
83 selectionService.removePostSelectionListener(this);
84 }
85
86
87 /** {@inheritDoc} */
88 @Override
89 public Viewer getViewer() {
90 return viewer;
91 }
92
93 /**
94 * <p>onComplete</p>
95 *
96 * @return a boolean.
97 */
98 public boolean onComplete() {
99 // TODO Auto-generated method stub
100 return false;
101 }
102
103
104 }