KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > web > debug > variablesfilterring > JSPVariablesTableModelFilter


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.web.debug.variablesfilterring;
21
22 import org.netbeans.modules.web.debug.variablesfilterring.JSPVariablesFilter.AttributeMap;
23 import org.netbeans.spi.viewmodel.TableModel;
24
25 import org.netbeans.spi.viewmodel.TableModelFilter;
26 import org.netbeans.spi.viewmodel.UnknownTypeException;
27
28 /**
29  *
30  * @author Libor Kotouc
31  */

32 public class JSPVariablesTableModelFilter implements TableModelFilter {
33
34     public JSPVariablesTableModelFilter() {
35     }
36
37     /**
38      * Returns filterred value to be displayed in column <code>columnID</code>
39      * and row <code>node</code>. Column ID is defined in by
40      * {@link ColumnModel#getID}, and rows are defined by values returned from
41      * {@TreeModel#getChildren}. You should not throw UnknownTypeException
42      * directly from this method!
43      *
44      * @param original the original table model
45      * @param node a object returned from {@TreeModel#getChildren} for this row
46      * @param columnID a id of column defined by {@link ColumnModel#getID}
47      * @throws ComputingException if the value is not known yet and will
48      * be computed later
49      * @throws UnknownTypeException this exception can be thrown from
50      * <code>original.getValueAt (...)</code> method call only!
51      *
52      * @return value of variable representing given position in tree table.
53      */

54     public Object JavaDoc getValueAt(TableModel original, Object JavaDoc node, String JavaDoc columnID)
55     throws UnknownTypeException
56     {
57         
58         Object JavaDoc colValue = "";
59         if (node instanceof JSPVariablesFilter.AttributeMap.Attribute)
60             colValue = original.getValueAt(((AttributeMap.Attribute)node).getValue(), columnID);
61         else if (node instanceof JSPVariablesFilter.AttributeMap ||
62                  node instanceof JSPVariablesFilter.ImplicitLocals)
63             colValue = "";
64         else
65             colValue = original.getValueAt(node, columnID);
66         
67         return colValue;
68     }
69     
70     /**
71      * Changes a value displayed in column <code>columnID</code>
72      * and row <code>node</code>. Column ID is defined in by
73      * {@link ColumnModel#getID}, and rows are defined by values returned from
74      * {@TreeModel#getChildren}. You should not throw UnknownTypeException
75      * directly from this method!
76      *
77      * @param original the original table model
78      * @param node a object returned from {@TreeModel#getChildren} for this row
79      * @param columnID a id of column defined by {@link ColumnModel#getID}
80      * @param value a new value of variable on given position
81      * @throws UnknownTypeException this exception can be thrown from
82      * <code>original.setValueAt (...)</code> method call only!
83      */

84     public void setValueAt(TableModel original, Object JavaDoc node, String JavaDoc columnID, Object JavaDoc value)
85     throws UnknownTypeException
86     {
87             original.setValueAt(node, columnID, value);
88     }
89
90     /**
91      * Filters original isReadOnly value from given table model. You should
92      * not throw UnknownTypeException
93      * directly from this method!
94      *
95      * @param original the original table model
96      * @param node a object returned from {@TreeModel#getChildren} for this row
97      * @param columnID a id of column defined by {@link ColumnModel#getID}
98      * @throws UnknownTypeException this exception can be thrown from
99      * <code>original.isReadOnly (...)</code> method call only!
100      *
101      * @return true if variable on given position is read only
102      */

103     public boolean isReadOnly(TableModel original, Object JavaDoc node, String JavaDoc columnID)
104     throws UnknownTypeException
105     {
106         boolean ro = true;
107         if (node instanceof JSPVariablesFilter.AttributeMap ||
108                  node instanceof JSPVariablesFilter.ImplicitLocals ||
109                  node instanceof JSPVariablesFilter.AttributeMap.Attribute)
110             ro = true;
111         else
112             ro = original.isReadOnly(node, columnID);
113         
114         return ro;
115     }
116
117     public void removeModelListener(org.netbeans.spi.viewmodel.ModelListener l) {
118     }
119
120     public void addModelListener(org.netbeans.spi.viewmodel.ModelListener l) {
121     }
122
123 }
124
Popular Tags