1 11 package org.eclipse.debug.internal.ui.views.memory.renderings; 12 13 import java.util.ArrayList ; 14 15 import org.eclipse.debug.internal.ui.viewers.AsynchronousTableModel; 16 import org.eclipse.debug.internal.ui.viewers.AsynchronousViewer; 17 import org.eclipse.debug.internal.ui.viewers.ModelNode; 18 19 abstract public class AbstractVirtualContentTableModel extends AsynchronousTableModel{ 20 21 public AbstractVirtualContentTableModel(AsynchronousViewer viewer) { 22 super(viewer); 23 } 24 25 public Object [] getElements() 26 { 27 ModelNode[] nodes = getNodes(getRootNode().getElement()); 28 ArrayList result = new ArrayList (); 29 if (nodes != null) 30 { 31 for (int i=0; i<nodes.length; i++) 32 { 33 ModelNode[] children = nodes[i].getChildrenNodes(); 34 if (children != null) 35 { 36 for (int j=0; j<children.length; j++) 37 { 38 result.add(children[j].getElement()); 39 } 40 } 41 } 42 43 return result.toArray(); 44 } 45 return new Object [0]; 46 } 47 48 public Object getElement(int idx) 49 { 50 Object [] elements = getElements(); 51 if (idx >=0 && idx < elements.length) 52 return elements[idx]; 53 54 return null; 55 } 56 57 58 public int indexOfElement(Object element) 59 { 60 Object [] elements = getElements(); 61 62 for (int i=0; i<elements.length; i++) 63 { 64 if (elements[i] == element) 65 return i; 66 } 67 return -1; 68 } 69 70 abstract public int indexOfKey(Object key); 71 72 abstract public int columnOf(Object element, Object key); 73 74 abstract public Object getKey(int idx); 75 76 abstract public Object getKey(Object element); 77 78 abstract public Object getKey(int idx, int col); 79 80 public void handleViewerChanged() 81 { 82 83 } 84 85 } 86 | Popular Tags |