Project

General

Profile

Download (1.79 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.model.taxon.ITreeNode;
18
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
19

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

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

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

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

    
60
	/** {@inheritDoc} */
61
	public Object[] getElements(Object inputElement) {
62
		return this.getChildren(inputElement);
63
	}
64

    
65
	/**
66
	 * <p>dispose</p>
67
	 */
68
	public void dispose() {
69
	}
70

    
71
	/** {@inheritDoc} */
72
	public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
73
	}
74
}
(10-10/13)