Revision 3be6ef3e
Added by Niels Hoffmann over 13 years ago
taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/TaxonNodeContentProvider.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.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 |
* @author p.ciardelli |
|
22 |
* @created 02.06.2009 |
|
23 |
* @version 1.0 |
|
24 |
*/ |
|
25 |
public class TaxonNodeContentProvider implements ITreeContentProvider { |
|
26 |
private static final Logger logger = Logger |
|
27 |
.getLogger(TaxonNodeContentProvider.class); |
|
28 |
|
|
29 |
private static final Object[] NO_CHILDREN = new Object[0]; |
|
30 |
|
|
31 |
public Object[] getChildren(Object parentElement) { |
|
32 |
Object[] children = null; |
|
33 |
|
|
34 |
if(parentElement instanceof ITreeNode){ |
|
35 |
children = ((ITreeNode) parentElement).getChildNodes().toArray(); |
|
36 |
} |
|
37 |
|
|
38 |
return children != null ? children : NO_CHILDREN; |
|
39 |
} |
|
40 |
|
|
41 |
public Object getParent(Object element) { |
|
42 |
if(element instanceof TaxonNode){ |
|
43 |
return ((TaxonNode) element).getParent(); |
|
44 |
} |
|
45 |
return null; |
|
46 |
} |
|
47 |
|
|
48 |
public boolean hasChildren(Object element) { |
|
49 |
if(element instanceof TaxonNode){ |
|
50 |
return ((TaxonNode) element).getCountChildren() > 0; |
|
51 |
} |
|
52 |
return getChildren(element).length > 0; |
|
53 |
} |
|
54 |
|
|
55 |
public Object[] getElements(Object inputElement) { |
|
56 |
return this.getChildren(inputElement); |
|
57 |
} |
|
58 |
|
|
59 |
public void dispose() { |
|
60 |
} |
|
61 |
|
|
62 |
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { |
|
63 |
} |
|
64 |
} |
|
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 |
} |
Also available in: Unified diff
performed javacscript:fix and worked on documentation