Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: javatools/swing/ConnectionMethodChoosePanel.java


1   /*
2    * ConnectionMethodChoosePanel.java
3    *
4    * Created on 23 febbraio 2003, 17.54
5       Javatools (modified version) - Some useful general classes.
6       Copyright (C) 2002-2003  Chris Bitmead (original) Antonio Petrelli (modified)
7   
8       This program is free software; you can redistribute it and/or modify
9       it under the terms of the GNU General Public License as published by
10      the Free Software Foundation; either version 2 of the License, or
11      (at your option) any later version.
12  
13      This program is distributed in the hope that it will be useful,
14      but WITHOUT ANY WARRANTY; without even the implied warranty of
15      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16      GNU General Public License for more details.
17  
18      You should have received a copy of the GNU General Public License
19      along with this program; if not, write to the Free Software
20      Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
21  
22      Contact me at: brenmcguire@users.sourceforge.net
23   */
24  
25  package javatools.swing;
26  
27  /**
28   *
29   * @author  Antonio Petrelli
30   */
31  public class ConnectionMethodChoosePanel extends javatools.swing.InputPanel {
32      
33      /** Creates new form ConnectionMethodChoosePanel */
34      public ConnectionMethodChoosePanel() {
35          javatoolsBundle = java.util.ResourceBundle.getBundle("res/JavatoolsBundle");
36          initComponents();
37      }
38      
39      /** This method is called from within the constructor to
40       * initialize the form.
41       * WARNING: Do NOT modify this code. The content of this method is
42       * always regenerated by the Form Editor.
43       */
44      private void initComponents() {//GEN-BEGIN:initComponents
45          java.awt.GridBagConstraints gridBagConstraints;
46  
47          bgChooseMethod = new javax.swing.ButtonGroup();
48          lblConnectionMethod = new javax.swing.JLabel();
49          radConnect = new javax.swing.JRadioButton();
50          radCreate = new javax.swing.JRadioButton();
51  
52          setLayout(new java.awt.GridBagLayout());
53  
54          lblConnectionMethod.setText(javatoolsBundle.getString("SelectConnectionMethod"));
55          gridBagConstraints = new java.awt.GridBagConstraints();
56          gridBagConstraints.gridx = 0;
57          gridBagConstraints.gridy = 0;
58          gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
59          add(lblConnectionMethod, gridBagConstraints);
60  
61          radConnect.setSelected(true);
62          radConnect.setText(javatoolsBundle.getString("ConnectExistingDatabase"));
63          bgChooseMethod.add(radConnect);
64          gridBagConstraints = new java.awt.GridBagConstraints();
65          gridBagConstraints.gridx = 0;
66          gridBagConstraints.gridy = 1;
67          gridBagConstraints.gridwidth = 3;
68          gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
69          gridBagConstraints.insets = new java.awt.Insets(10, 20, 0, 0);
70          add(radConnect, gridBagConstraints);
71  
72          radCreate.setText(javatoolsBundle.getString("CreateDatabaseInstance"));
73          bgChooseMethod.add(radCreate);
74          gridBagConstraints = new java.awt.GridBagConstraints();
75          gridBagConstraints.gridx = 0;
76          gridBagConstraints.gridy = 2;
77          gridBagConstraints.gridwidth = 2;
78          gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
79          gridBagConstraints.insets = new java.awt.Insets(10, 20, 0, 0);
80          add(radCreate, gridBagConstraints);
81  
82      }//GEN-END:initComponents
83  
84      /** Returns the number of managed values.
85       * @return The number of managed values.
86       */
87      public int getNumValues() {
88          return 1;
89      }    
90      
91      /** Returns the value whose position is specified.
92       * @param numValue The position of the value.
93       * @throws WizardException If <CODE>numValue</CODE> is not valid.
94       * @return The needed value.
95       */
96      public String getValue(int numValue) throws WizardException {
97          String tempString;
98          
99          tempString = "connect";
100         if (numValue == 0) {
101             if (radCreate.isSelected())
102                 tempString = "create";
103         }
104         else
105             throw new WizardException("[ConnectionMethodChoosePanel] Value number not valid");
106         return tempString;
107     }    
108     
109     /** Returns the value whose name is specified.
110      * @param name The name of the value.
111      * @return The value.
112      */
113     public String getValue(String name) {
114         String tempString;
115         
116         tempString = null;
117         try {
118             if (name.equals("ConnectionMethod"))
119                 tempString =  getValue(0);
120         }
121         catch (WizardException e) {
122             System.out.println(e.getMessage());
123         }
124         return tempString;
125     }
126     
127     /** Returns the name of a value whose position is specified.
128      * @param numValue The position of the value.
129      * @throws WizardException If <CODE>numValue</CODE> is not valid.
130      * @return The name of the value.
131      */
132     public String getValueName(int numValue) throws WizardException {
133         String tempString;
134         
135         tempString = "ConnectioMethod";
136         if (numValue != 0)
137             throw new WizardException("[ConnectionMethodChoosePanel] Value number not valid");
138         return tempString;
139     }
140     
141     /** Returns the position of a value whose name is specified.
142      * @param name The name of the value.
143      * @return The position of the value.
144      */
145     public int getValuePos(String name) {
146         int tempValue;
147         
148         tempValue = 0;
149         if (!name.equals("ConnectionMethod"))
150             tempValue = -1;
151         return tempValue;
152     }
153     
154     /** Sets a value whose name is specified.
155      * @param name The name of the value.
156      * @param value The value.
157      */
158     public void setValue(String name, String value) {
159         try {
160             if (name.equals("ConnectionMethod"))
161                 setValue(0, value);
162         }
163         catch (WizardException e) {
164             System.out.println(e.getMessage());
165         }
166     }
167     
168     /** Sets a value whose position is specified.
169      * @param numValue The position of the value.
170      * @param value The value.
171      * @throws WizardException If <CODE>numValue</CODE> is not valid.
172      */
173     public void setValue(int numValue, String value) throws WizardException {
174         if (numValue == 0) {
175             if (value.equals("connect"))
176                 radConnect.setSelected(true);
177             else if (value.equals("create"))
178                 radCreate.setSelected(true);
179             else
180                 throw new WizardException("[ConnectionMethodChoosePanel] value not valid");
181         }
182         else
183             throw new WizardException("[ConnectionMethodChoosePanel] Value number not valid");
184     }
185     
186     // Variables declaration - do not modify//GEN-BEGIN:variables
187     private javax.swing.ButtonGroup bgChooseMethod;
188     private javax.swing.JRadioButton radConnect;
189     private javax.swing.JLabel lblConnectionMethod;
190     private javax.swing.JRadioButton radCreate;
191     // End of variables declaration//GEN-END:variables
192     
193     private java.util.ResourceBundle javatoolsBundle;
194 }