1 11 package org.eclipse.ant.internal.ui.model; 12 13 import java.util.List ; 14 15 import org.eclipse.jface.viewers.ITreeContentProvider; 16 import org.eclipse.jface.viewers.Viewer; 17 18 19 public class AntModelContentProvider implements ITreeContentProvider { 20 21 protected static final Object [] EMPTY_ARRAY= new Object [0]; 22 23 26 public void dispose() { 27 } 28 29 33 public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { 34 } 35 36 39 public Object [] getChildren(Object parentNode) { 40 if (parentNode instanceof AntElementNode) { 41 AntElementNode parentElement = (AntElementNode)parentNode; 42 if (parentElement.hasChildren()) { 43 List children= parentElement.getChildNodes(); 44 return children.toArray(); 45 } 46 } else if (parentNode instanceof IAntModel) { 47 return new Object [] {((IAntModel)parentNode).getProjectNode()}; 48 } 49 return EMPTY_ARRAY; 50 } 51 52 55 public Object getParent(Object aNode) { 56 AntElementNode tempElement = (AntElementNode)aNode; 57 return tempElement.getParentNode(); 58 } 59 60 63 public boolean hasChildren(Object aNode) { 64 return ((AntElementNode)aNode).hasChildren(); 65 } 66 67 70 public Object [] getElements(Object inputElement) { 71 if (inputElement instanceof IAntModel ) { 72 AntProjectNode projectNode= ((IAntModel) inputElement).getProjectNode(); 73 if (projectNode == null) { 74 return new AntElementNode[0]; 75 } 76 77 return new Object [] {projectNode}; 78 } 79 80 if (inputElement instanceof Object []) { 81 return (Object [])inputElement; 82 } 83 return EMPTY_ARRAY; 84 } 85 } 86 | Popular Tags |