1 11 package org.eclipse.ant.internal.ui.views; 12 13 14 import java.util.ArrayList ; 15 import java.util.List ; 16 17 import org.eclipse.jface.viewers.IStructuredContentProvider; 18 import org.eclipse.jface.viewers.Viewer; 19 import org.eclipse.ant.internal.ui.views.elements.TargetNode; 20 21 24 public class AntTargetContentProvider implements IStructuredContentProvider { 25 26 29 private List targets = new ArrayList (); 30 31 34 public Object [] getElements(Object inputElement) { 35 return targets.toArray(); 36 } 37 38 41 public void dispose() { 42 } 43 44 47 public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { 48 } 49 50 56 public List getTargets() { 57 return targets; 58 } 59 60 66 public void addTarget(TargetNode target) { 67 targets.add(target); 68 } 69 70 76 public void removeTarget(int index) { 77 if (targets.size() > index && index >= 0) { 78 targets.remove(index); 79 } 80 } 81 82 89 public void moveUpTarget(int index) { 90 Object target= targets.get(index); 91 if (index == 0 || target == null) { 92 return; 93 } 94 targets.set(index, targets.get(index - 1)); 95 targets.set(index - 1, target); 96 } 97 98 105 public void moveDownTarget(int index) { 106 Object target= targets.get(index); 107 if (index == targets.size() - 1 || target == null) { 108 return; 109 } 110 targets.set(index, targets.get(index + 1)); 111 targets.set(index + 1, target); 112 } 113 114 } 115 | Popular Tags |