Project

General

Profile

Download (3.02 KB) Statistics
| Branch: | Tag: | Revision:
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.FeatureNodeContainer;
24
import eu.etaxonomy.taxeditor.store.StoreUtil;
25
import eu.etaxonomy.taxeditor.view.AbstractCdmEditorViewPart;
26
import eu.etaxonomy.taxeditor.view.AbstractCdmViewPart;
27
import eu.etaxonomy.taxeditor.view.detail.CdmSectionPart;
28

    
29

    
30
/**
31
 * <p>SupplementalDataViewPart class.</p>
32
 *
33
 * @author n.hoffmann
34
 * @created Jun 10, 2010
35
 * @version 1.0
36
 */
37
public class SupplementalDataViewPart extends AbstractCdmEditorViewPart {
38

    
39
	/** Constant <code>ID="eu.etaxonomy.taxeditor.editor.view.supp"{trunked}</code> */
40
	public static final String ID = "eu.etaxonomy.taxeditor.view.supplementalData";
41

    
42
	private SupplementalDataViewer viewer;
43
	
44
	/* (non-Javadoc)
45
	 * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
46
	 */
47
	/** {@inheritDoc} */
48
	@Override
49
	public void createViewer(Composite parent) {
50
		viewer = new SupplementalDataViewer(parent, this);
51
	}
52

    
53

    
54
	/** {@inheritDoc} */
55
	public void selectionChanged(IWorkbenchPart part, ISelection selection) {
56
		if(StoreUtil.getActiveEditor() == null){
57
			showEmptyPage();
58
			return;
59
		}
60
		
61
		if(((part instanceof EditorPart) || (part instanceof AbstractCdmViewPart)) && selection instanceof IStructuredSelection) {
62
			IStructuredSelection structuredSelection = (IStructuredSelection) selection;
63
			if(structuredSelection.size() != 1){
64
				showEmptyPage();
65
				return;
66
			}
67
			
68
			// do not show supplemental data for feature nodes
69
			if(structuredSelection.getFirstElement() instanceof FeatureNodeContainer){
70
				showEmptyPage();
71
				return;
72
			}
73
			if(structuredSelection.getFirstElement() instanceof DerivedUnitFacade){
74
				return;
75
			}
76
			if(structuredSelection.getFirstElement() instanceof PolytomousKeyNode){
77
			    structuredSelection = new StructuredSelection(((PolytomousKeyNode)structuredSelection.getFirstElement()).getKey());
78
            }
79
			showViewer(part, structuredSelection);
80
		}else{
81
			showEmptyPage();		
82
		}
83
	}
84
	
85
	/** {@inheritDoc} */
86
	@Override
87
	public void dispose() {
88
		super.dispose();
89
		selectionService.removePostSelectionListener(this);
90
	}
91

    
92

    
93
	/** {@inheritDoc} */
94
	@Override
95
	public Viewer getViewer() {
96
		return viewer;
97
	}
98

    
99
	/**
100
	 * <p>onComplete</p>
101
	 *
102
	 * @return a boolean.
103
	 */
104
	public boolean onComplete() {
105
		// TODO Auto-generated method stub
106
		return false;
107
	}
108
	
109
	
110
}
(1-1/2)