3 * Copyright (C) 2007 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
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.
11 package eu
.etaxonomy
.taxeditor
.editor
.key
.polytomous
;
13 import java
.util
.ArrayList
;
14 import java
.util
.List
;
16 import org
.eclipse
.jface
.viewers
.IStructuredContentProvider
;
17 import org
.eclipse
.jface
.viewers
.Viewer
;
19 import eu
.etaxonomy
.cdm
.model
.description
.PolytomousKey
;
20 import eu
.etaxonomy
.cdm
.model
.description
.PolytomousKeyNode
;
24 * @created Apr 4, 2011
27 public class PolytomousKeyListContentProvider
implements
28 IStructuredContentProvider
{
33 * @see org.eclipse.jface.viewers.IContentProvider#dispose()
36 public void dispose() {
43 * org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface
44 * .viewers.Viewer, java.lang.Object, java.lang.Object)
47 public void inputChanged(Viewer viewer
, Object oldInput
, Object newInput
) {
54 * org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java
58 public Object
[] getElements(Object inputElement
) {
59 if (inputElement
instanceof PolytomousKey
) {
60 List result
= new ArrayList();
62 PolytomousKeyNode root
= ((PolytomousKey
) inputElement
).getRoot();
65 // result.addAll(root.getChildren());
66 getChildren(result
, root
);
67 return result
.toArray();
69 // else if (inputElement instanceof PolytomousKeyNode) {
70 // return ((PolytomousKeyNode) inputElement).getChildren().toArray();
76 private void getChildren(List result
, PolytomousKeyNode node
) {
79 for (PolytomousKeyNode internalNode
: node
.getChildren()) {
80 getChildren(result
, internalNode
);