KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > openccm > packaging > widgets > SoftpkgVersion


1 /*====================================================================
2
3 OpenCCM: The Open CORBA Component Model Platform
4 Copyright (C) 2000-2004 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): Christophe Contreras
23 Contributor(s): ___________________________________________________.
24
25 ====================================================================*/

26
27 package org.objectweb.openccm.packaging.widgets;
28
29 /**
30  * This is a widget allowing to set a component package version
31  *
32  *
33  * @author <a HREF="mailto:Christophe.Contreras@lifl.fr">Christophe Contreras</a>
34  *
35  */

36 public class SoftpkgVersion
37      extends org.objectweb.apollon.gui.bricks.AbstractBrick
38 {
39     // ==================================================================
40
//
41
// Internal state.
42
//
43
// ==================================================================
44

45     /**
46      * JDK 1.3 does not support JSpinner
47      * so this is commented out to avoid compilation problems
48      */

49     /** the spinners for setting version */
50 /*
51     private javax.swing.JSpinner[] version_numbers
52      = {
53         new javax.swing.JSpinner(),
54         new javax.swing.JSpinner(),
55         new javax.swing.JSpinner(),
56         new javax.swing.JSpinner(),
57         };
58 */

59
60     private javax.swing.JTextField JavaDoc[] version_numbers
61      = {
62         new javax.swing.JTextField JavaDoc(),
63         new javax.swing.JTextField JavaDoc(),
64         new javax.swing.JTextField JavaDoc(),
65         new javax.swing.JTextField JavaDoc(),
66         };
67
68     // ==================================================================
69
//
70
// Constructors.
71
//
72
// ==================================================================
73

74     /**
75      * The default constructor.
76      */

77     public
78     SoftpkgVersion ()
79     {
80         this ("Version");
81     }
82
83     /**
84      * The constructor with a label.
85      */

86     public
87     SoftpkgVersion (String JavaDoc label)
88     {
89         super (label);
90 /* // inits the spinners
91         version_numbers[0] = new javax.swing.JSpinner();
92         version_numbers[1] = new javax.swing.JSpinner();
93         version_numbers[2] = new javax.swing.JSpinner();
94         version_numbers[3] = new javax.swing.JSpinner();
95 */

96         javax.swing.JPanel JavaDoc content = new javax.swing.JPanel JavaDoc();
97
98         // building of the content panel with commas
99
content.add(this.version_numbers[0]);
100         content.add(new javax.swing.JLabel JavaDoc(","));
101         content.add(this.version_numbers[1]);
102         content.add(new javax.swing.JLabel JavaDoc(","));
103         content.add(this.version_numbers[2]);
104         content.add(new javax.swing.JLabel JavaDoc(","));
105         content.add(this.version_numbers[3]);
106
107         // adding the content to the panel
108
this.add(content);
109     }
110
111     // ==================================================================
112
//
113
// Public methods.
114
//
115
// ==================================================================
116

117     /**
118      * The getter method
119      */

120     public String JavaDoc
121     get()
122     {
123
124         // buidling of the version string
125
String JavaDoc version
126          = version_numbers[0].getText()
127             +","
128             + version_numbers[1].getText()
129             +","
130             + version_numbers[2].getText()
131             +","
132             + version_numbers[3].getText()
133             ;
134         /**
135          * JDK 1.3 does not support JSpinner
136          * so this is commented out to avoid compilation problems
137          */

138 /*
139          = version_numbers[0].getValue().toString()
140             +","
141             + version_numbers[1].getValue().toString()
142             +","
143             + version_numbers[2].getValue().toString()
144             +","
145             + version_numbers[3].getValue().toString()
146             ;
147 */

148
149         return version;
150     }
151
152     /**
153      * The setter method
154      */

155     public void
156     set(String JavaDoc formated_version)
157     {
158
159         /**
160          * JDK 1.3 does not support split method
161          * so this is commented out to avoid compilation problems
162          */

163         // parse the version string to extract major/minor version numbers
164
/* String [] version_array
165          = formated_version
166             .split(",");
167
168         // sets the spinners with found values
169         for (int i = 0 ; i < version_array.length ; i++)
170         {
171 // version_numbers[i].setValue(Integer.decode(version_array[i]));
172             version_numbers[i].setText(version_array[i]);
173         }
174 */

175         java.util.StringTokenizer JavaDoc version_array;
176         if (formated_version != null)
177         {
178             version_array
179              = new java.util.StringTokenizer JavaDoc (formated_version,",");
180         }
181         else
182         {
183             version_array
184              = new java.util.StringTokenizer JavaDoc("",",");
185         }
186         for (int i = 0 ; i < 4 ; i++)
187         {
188             if (version_array.hasMoreTokens())
189             {
190                 version_numbers[i].setText(version_array.nextToken());
191             }
192             else
193             {
194                 version_numbers[i].setText("0");
195             }
196         }
197     }
198
199 }
200
Popular Tags