Project

General

Profile

Download (1.95 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.navigation.navigator;
12

    
13
import org.apache.log4j.Logger;
14
import org.eclipse.jface.viewers.ITreeContentProvider;
15
import org.eclipse.jface.viewers.Viewer;
16

    
17
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
18
import eu.etaxonomy.cdm.model.taxon.ITreeNode;
19
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
20
import eu.etaxonomy.taxeditor.navigation.NavigationUtil;
21

    
22
/**
23
 * <p>TaxonNodeContentProvider class.</p>
24
 *
25
 * @author p.ciardelli
26
 * @created 02.06.2009
27
 * @version 1.0
28
 */
29
public class TaxonNodeContentProvider implements ITreeContentProvider {
30
	private static final Logger logger = Logger
31
			.getLogger(TaxonNodeContentProvider.class);
32

    
33
	private static final Object[] NO_CHILDREN = new Object[0];
34
	
35
	/** {@inheritDoc} */
36
	public Object[] getChildren(Object parentElement) {
37
		Object[] children = null;		
38
		
39
		if(parentElement instanceof ITreeNode){
40
			TaxonNode taxonNode = NavigationUtil.getTaxonNode(parentElement);
41
			children = taxonNode.getChildNodes().toArray();
42
		}
43
		
44
		return children != null ? children : NO_CHILDREN;
45
	}
46

    
47
	/** {@inheritDoc} */
48
	public Object getParent(Object element) {
49
		if(element instanceof TaxonNode){
50
			return ((TaxonNode) element).getParent();
51
		}		
52
		return null;
53
	}
54

    
55
	/** {@inheritDoc} */
56
	public boolean hasChildren(Object element) {
57
		if(element instanceof TaxonNode){
58
			return ((TaxonNode) element).getCountChildren() > 0;
59
		}
60
		return getChildren(element).length > 0;
61
	}
62

    
63
	/** {@inheritDoc} */
64
	public Object[] getElements(Object inputElement) {
65
		return this.getChildren(inputElement);
66
	}
67

    
68
	/**
69
	 * <p>dispose</p>
70
	 */
71
	public void dispose() {
72
	}
73

    
74
	/** {@inheritDoc} */
75
	public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
76
	}
77
}
(11-11/14)