KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > cjdbc > console > gui > model > OperationModel


1 /**
2  * C-JDBC: Clustered JDBC.
3  * Copyright (C) 2002-2004 French National Institute For Research In Computer
4  * Science And Control (INRIA).
5  * Contact: c-jdbc@objectweb.org
6  *
7  * This library is free software; you can redistribute it and/or modify it
8  * under the terms of the GNU Lesser General Public License as published by the
9  * Free Software Foundation; either version 2.1 of the License, or any later
10  * version.
11  *
12  * This library is distributed in the hope that it will be useful, but WITHOUT
13  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
15  * for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public License
18  * along with this library; if not, write to the Free Software Foundation,
19  * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
20  *
21  * Initial developer(s): Nicolas Modrzyk.
22  * Contributor(s): ______________________.
23  */

24
25 package org.objectweb.cjdbc.console.gui.model;
26
27 import javax.management.MBeanOperationInfo JavaDoc;
28 import javax.management.MBeanParameterInfo JavaDoc;
29 import javax.swing.table.AbstractTableModel JavaDoc;
30
31 import org.objectweb.cjdbc.console.gui.constants.GuiConstants;
32
33 /**
34  * This class defines a OperationModel
35  *
36  * @author <a HREF="mailto:Emmanuel.Cecchet@inria.fr">Emmanuel Cecchet </a>
37  * @version 1.0
38  */

39 public class OperationModel extends AbstractTableModel JavaDoc
40 {
41   private MBeanOperationInfo JavaDoc[] info;
42
43   /**
44    * Creates a new <code>OperationModel</code> object
45    *
46    * @param info MBean operation info
47    */

48   public OperationModel(MBeanOperationInfo JavaDoc[] info)
49   {
50     this.info = info;
51   }
52
53   /**
54    * @see javax.swing.table.TableModel#getColumnCount()
55    */

56   public int getColumnCount()
57   {
58     return 2;
59   }
60
61   /**
62    * Returns the info value.
63    *
64    * @return Returns the info.
65    */

66   public MBeanOperationInfo JavaDoc[] getInfo()
67   {
68     return info;
69   }
70
71   /**
72    * @see javax.swing.table.TableModel#getRowCount()
73    */

74   public int getRowCount()
75   {
76     return info.length;
77   }
78
79   /**
80    * @see javax.swing.table.TableModel#isCellEditable(int, int)
81    */

82   public boolean isCellEditable(int rowIndex, int columnIndex)
83   {
84     return false;
85   }
86
87   /**
88    * @see javax.swing.table.TableModel#getValueAt(int, int)
89    */

90   public Object JavaDoc getValueAt(int rowIndex, int columnIndex)
91   {
92     if ((rowIndex >= 0 && rowIndex < info.length) == false)
93       return null;
94     switch (columnIndex)
95     {
96       case 0 :
97         StringBuffer JavaDoc name = new StringBuffer JavaDoc(info[rowIndex].getName());
98         MBeanParameterInfo JavaDoc[] param = info[rowIndex].getSignature();
99         name.append("(");
100         for (int i = 0; i < param.length; i++)
101         {
102           if (i != 0)
103             name.append(",");
104           name.append(GuiConstants.getParameterType(param[i].getType()));
105         }
106         name.append(")");
107         return name.toString();
108       case 1 :
109         return GuiConstants.getParameterType(info[rowIndex].getReturnType());
110       default :
111         return null;
112     }
113   }
114
115   /**
116    * @see javax.swing.table.TableModel#getColumnName(int)
117    */

118   public String JavaDoc getColumnName(int column)
119   {
120     switch (column)
121     {
122       case 0 :
123         return "Name";
124       case 1 :
125         return "Return";
126       default :
127         return null;
128     }
129   }
130 }
Popular Tags