KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > debug > internal > ui > views > memory > renderings > AbstractVirtualContentTableModel


1 /*******************************************************************************
2  * Copyright (c) 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.debug.internal.ui.views.memory.renderings;
12
13 import java.util.ArrayList JavaDoc;
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 JavaDoc[] getElements()
26     {
27         ModelNode[] nodes = getNodes(getRootNode().getElement());
28         ArrayList JavaDoc result = new ArrayList JavaDoc();
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 JavaDoc[0];
46     }
47     
48     public Object JavaDoc getElement(int idx)
49     {
50         Object JavaDoc[] 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 JavaDoc element)
59     {
60         Object JavaDoc[] 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 JavaDoc key);
71     
72     abstract public int columnOf(Object JavaDoc element, Object JavaDoc key);
73     
74     abstract public Object JavaDoc getKey(int idx);
75     
76     abstract public Object JavaDoc getKey(Object JavaDoc element);
77     
78     abstract public Object JavaDoc getKey(int idx, int col);
79     
80     public void handleViewerChanged()
81     {
82         
83     }
84
85 }
86
Popular Tags