KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > debugger > ui > models > SessionsTableModel


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 import org.netbeans.api.debugger.Session;
24 import org.netbeans.spi.debugger.ui.Constants;
25 import org.netbeans.spi.viewmodel.TableModel;
26 import org.netbeans.spi.viewmodel.ModelListener;
27 import org.netbeans.spi.viewmodel.UnknownTypeException;
28
29
30 /**
31  *
32  * @author Jan Jancura
33  */

34 public class SessionsTableModel implements TableModel, Constants {
35
36     private Vector JavaDoc listeners = new Vector JavaDoc ();
37
38
39     public Object JavaDoc getValueAt (Object JavaDoc row, String JavaDoc columnID) throws
40     UnknownTypeException {
41         if (row instanceof Session) {
42             if (columnID.equals (SESSION_STATE_COLUMN_ID))
43                 return "";
44             else
45             if (columnID.equals (SESSION_LANGUAGE_COLUMN_ID))
46                 return row;
47             else
48             if (columnID.equals (SESSION_HOST_NAME_COLUMN_ID))
49                 return ((Session) row).getLocationName ();
50         }
51         throw new UnknownTypeException (row);
52     }
53     
54     public boolean isReadOnly (Object JavaDoc row, String JavaDoc columnID) throws
55     UnknownTypeException {
56         if (row instanceof Session) {
57             if (columnID.equals (SESSION_STATE_COLUMN_ID))
58                 return true;
59             else
60             if (columnID.equals (SESSION_LANGUAGE_COLUMN_ID))
61                 return false;
62             else
63             if (columnID.equals (SESSION_HOST_NAME_COLUMN_ID))
64                 return true;
65         }
66         throw new UnknownTypeException (row);
67     }
68     
69     public void setValueAt (Object JavaDoc row, String JavaDoc columnID, Object JavaDoc value)
70     throws UnknownTypeException {
71         throw new UnknownTypeException (row);
72     }
73     
74     /**
75      * Registers given listener.
76      *
77      * @param l the listener to add
78      */

79     public void addModelListener (ModelListener l) {
80         listeners.add (l);
81     }
82
83     /**
84      * Unregisters given listener.
85      *
86      * @param l the listener to remove
87      */

88     public void removeModelListener (ModelListener l) {
89         listeners.remove (l);
90     }
91
92 }
93
Popular Tags