1 11 12 package org.eclipse.ant.internal.ui.views; 13 14 import java.util.ArrayList ; 15 import java.util.Arrays ; 16 import java.util.List ; 17 18 import org.eclipse.ant.internal.ui.model.AntModelContentProvider; 19 import org.eclipse.jface.viewers.StructuredSelection; 20 import org.eclipse.jface.viewers.TreeViewer; 21 import org.eclipse.jface.viewers.Viewer; 22 23 24 public class AntViewContentProvider extends AntModelContentProvider { 25 26 private TreeViewer fTreeViewer; 27 private List fElements= new ArrayList (); 28 29 32 public Object [] getElements(Object anInputElement) { 33 if (anInputElement instanceof Object []) { 34 return fElements.toArray(); 35 } 36 return EMPTY_ARRAY; 37 } 38 39 public void add(Object o) { 40 if (fElements.contains(o)) { 41 return; 42 } 43 fElements.add(o); 44 fTreeViewer.add(fTreeViewer.getInput(), o); 45 fTreeViewer.setSelection(new StructuredSelection(o), true); 46 } 47 48 public void addAll(Object [] o) { 49 fElements.addAll(Arrays.asList(o)); 50 fTreeViewer.add(fTreeViewer.getInput(), o); 51 } 52 53 57 public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { 58 fTreeViewer= (TreeViewer)viewer; 59 } 60 61 public void remove(Object o) { 62 fElements.remove(o); 63 fTreeViewer.remove(o); 64 } 65 66 public void removeAll() { 67 fTreeViewer.remove(fElements.toArray()); 68 fElements.clear(); 69 } 70 71 74 public void dispose() { 75 } 76 } 77 | Popular Tags |