KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > openccm > explorer > CosTrading > gui > ServiceTypePropsTableModel


1 /*===========================================================================
2
3 OpenCCM: The Open CORBA Component Model Platform
4 Copyright (C) 2000-2003 INRIA - USTL - LIFL - GOAL
5 Contact: openccm@objectweb.org
6
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or any later version.
11
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public
18 License along with this library; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20 USA
21
22 Initial developer(s):Sylvain Leblanc.
23 Contributor(s): ______________________________________.
24
25 ===========================================================================*/

26
27 package org.objectweb.openccm.explorer.CosTrading.gui;
28
29 import javax.swing.table.AbstractTableModel JavaDoc;
30
31 import org.objectweb.openccm.corba.TypeCodeUtils;
32 import org.omg.CosTradingRepos.ServiceTypeRepositoryPackage.PropStruct;
33 import org.omg.CosTradingRepos.ServiceTypeRepositoryPackage.PropertyMode;
34
35 /**
36  * A Table model for service type properties.
37  *
38  * @author <a HREF="mailto:Sylvain.Leblanc@lifl.fr">Sylvain Leblanc</a>
39  * @version 0.1
40  */

41 public class ServiceTypePropsTableModel extends AbstractTableModel JavaDoc {
42
43     // ==================================================================
44
//
45
// Internal state.
46
//
47
// ==================================================================
48

49     /** Names of the cols: "name", "value type", "mode". */
50     protected final String JavaDoc[] names = new String JavaDoc[] {"name", "value type", "mode"};
51
52     /** Rows values in a list. */
53     protected java.util.List JavaDoc[] rows;
54
55     // ==================================================================
56
//
57
// Constructors.
58
//
59
// ==================================================================
60

61     /**
62      * Default constructor.
63      *
64      * @param props The properties to display in the table.
65      */

66     public ServiceTypePropsTableModel(PropStruct[] props) {
67         rows = new java.util.List JavaDoc[props.length];
68             
69         for (int i=0 ; i<props.length ; i++) {
70             rows[i] = new java.util.LinkedList JavaDoc();
71             rows[i].add(props[i].name);
72             rows[i].add(TypeCodeUtils.toStringValue(props[i].value_type));
73             rows[i].add(modeImage(props[i].mode));
74         }
75     }
76
77     // ==================================================================
78
//
79
// Internal methods.
80
//
81
// ==================================================================
82

83     /**
84      * Return the string image to display for a property mode.
85      *
86      * @param mode The property mode to display.
87      *
88      * @return The string to display for the given property mode.
89      */

90     protected String JavaDoc modeImage(PropertyMode mode) {
91         if (mode.equals(PropertyMode.PROP_NORMAL)) return "default";
92         if (mode.equals(PropertyMode.PROP_MANDATORY)) return "mandatory";
93         if (mode.equals(PropertyMode.PROP_READONLY)) return "readonly";
94         if (mode.equals(PropertyMode.PROP_MANDATORY_READONLY)) return "mandatory readonly";
95         return "";
96     }
97
98     // ==================================================================
99
//
100
// Public methods.
101
//
102
// ==================================================================
103

104     // some overrides
105
public int getColumnCount() { return names.length; }
106     public String JavaDoc getColumnName(int col) { return names[col]; }
107     public int getRowCount() { return rows.length;}
108     public Object JavaDoc getValueAt(int row, int col) { return rows[row].get(col); }
109 };
110
Popular Tags