KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > debugger > jpda > ui > models > WatchesNodeModel


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.debugger.jpda.ui.models;
21
22 import org.netbeans.spi.debugger.ContextProvider;
23 import org.netbeans.api.debugger.jpda.InvalidExpressionException;
24 import org.netbeans.api.debugger.jpda.JPDAWatch;
25 import org.netbeans.spi.viewmodel.TreeModel;
26 import org.netbeans.spi.viewmodel.ModelListener;
27 import org.netbeans.spi.viewmodel.UnknownTypeException;
28 import org.openide.util.NbBundle;
29
30
31 /**
32  * @author Jan Jancura
33  */

34 public class WatchesNodeModel extends VariablesNodeModel {
35
36     public static final String JavaDoc WATCH =
37         "org/netbeans/modules/debugger/resources/watchesView/Watch";
38
39
40     public WatchesNodeModel (ContextProvider lookupProvider) {
41         super (lookupProvider);
42     }
43     
44     public String JavaDoc getDisplayName (Object JavaDoc o) throws UnknownTypeException {
45         if (o == TreeModel.ROOT)
46             return NbBundle.getBundle (WatchesNodeModel.class).
47                 getString ("CTL_WatchesModel_Column_Name_Name");
48         if (o instanceof JPDAWatch)
49             return ((JPDAWatch) o).getExpression ();
50         return super.getDisplayName (o);
51     }
52     
53     public String JavaDoc getShortDescription (Object JavaDoc o) throws UnknownTypeException {
54         if (o == TreeModel.ROOT)
55             return TreeModel.ROOT;
56         if (o instanceof JPDAWatch) {
57             JPDAWatch w = (JPDAWatch) o;
58             boolean evaluated;
59             evaluated = VariablesTreeModelFilter.isEvaluated(o);
60             if (!evaluated) {
61                 return w.getExpression ();
62             }
63             String JavaDoc e = w.getExceptionDescription ();
64             if (e != null)
65                 return w.getExpression () + " = >" + e + "<";
66             String JavaDoc t = w.getType ();
67             if (t == null)
68                 return w.getExpression () + " = " + w.getValue ();
69             else
70                 try {
71                     return w.getExpression () + " = (" + w.getType () + ") " +
72                         w.getToStringValue ();
73                 } catch (InvalidExpressionException ex) {
74                     return ex.getLocalizedMessage ();
75                 }
76         }
77         return super.getShortDescription (o);
78     }
79     
80     public String JavaDoc getIconBase (Object JavaDoc o) throws UnknownTypeException {
81         if (o == TreeModel.ROOT)
82             return WATCH;
83         if (o instanceof JPDAWatch)
84             return WATCH;
85         return super.getIconBase (o);
86     }
87
88 }
89
Popular Tags