KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > debugger > 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.ui.models;
21
22 import java.util.Vector JavaDoc;
23
24 import org.netbeans.api.debugger.Watch;
25 import org.netbeans.spi.viewmodel.NodeModel;
26 import org.netbeans.spi.viewmodel.TreeModel;
27 import org.netbeans.spi.viewmodel.ModelListener;
28 import org.netbeans.spi.viewmodel.UnknownTypeException;
29 import org.openide.util.NbBundle;
30
31 /**
32  * @author Jan Jancura
33  */

34 public class WatchesNodeModel implements NodeModel {
35
36     public static final String JavaDoc WATCH =
37         "org/netbeans/modules/debugger/resources/watchesView/Watch";
38
39     private Vector JavaDoc listeners = new Vector JavaDoc ();
40     
41     
42     public String JavaDoc getDisplayName (Object JavaDoc o) throws UnknownTypeException {
43         if (o == TreeModel.ROOT)
44             return NbBundle.getBundle(WatchesNodeModel.class).getString("CTL_WatchesModel_Column_Name_Name");
45         if (o instanceof Watch)
46             return ((Watch) o).getExpression ();
47         throw new UnknownTypeException (o);
48     }
49     
50     public String JavaDoc getShortDescription (Object JavaDoc o) throws UnknownTypeException {
51         if (o == TreeModel.ROOT)
52             return TreeModel.ROOT;
53         if (o instanceof Watch) {
54             Watch w = (Watch) o;
55             return w.getExpression () + NbBundle.getBundle(WatchesNodeModel.class).getString("CTL_WatchesModel_Column_NameNoContext_Desc");
56         }
57         throw new UnknownTypeException (o);
58     }
59     
60     public String JavaDoc getIconBase (Object JavaDoc o) throws UnknownTypeException {
61         if (o == TreeModel.ROOT)
62             return WATCH;
63         if (o instanceof Watch)
64             return WATCH;
65         throw new UnknownTypeException (o);
66     }
67
68     /**
69      *
70      * @param l the listener to add
71      */

72     public void addModelListener (ModelListener l) {
73         listeners.add (l);
74     }
75
76     /**
77      *
78      * @param l the listener to remove
79      */

80     public void removeModelListener (ModelListener l) {
81         listeners.remove (l);
82     }
83     
84 }
85
Popular Tags