KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > cjdbc > console > wizard > tab > RecoveryTab


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.wizard.tab;
26
27 import java.awt.GridBagConstraints JavaDoc;
28 import java.awt.GridBagLayout JavaDoc;
29 import java.awt.event.ActionEvent JavaDoc;
30 import java.awt.event.ActionListener JavaDoc;
31
32 import javax.swing.BorderFactory JavaDoc;
33 import javax.swing.JButton JavaDoc;
34 import javax.swing.JComponent JavaDoc;
35 import javax.swing.JLabel JavaDoc;
36 import javax.swing.JPanel JavaDoc;
37 import javax.swing.JSlider JavaDoc;
38 import javax.swing.JTextField JavaDoc;
39
40 import org.objectweb.cjdbc.common.i18n.WizardTranslate;
41 import org.objectweb.cjdbc.console.wizard.WizardConstants;
42 import org.objectweb.cjdbc.console.wizard.WizardTab;
43 import org.objectweb.cjdbc.console.wizard.WizardTabs;
44
45 /**
46  * The recovery tab has the fields needed to define a
47  * <code>RecoveryLog</code> This tab can be extended later to use for
48  * other recovery log types.
49  *
50  * @see <code>WizardTab</code>
51  * @author <a HREF="mailto:Nicolas.Modrzyk@inria.fr">Nicolas Modrzyk </a>
52  * @version 1.0
53  */

54 public class RecoveryTab extends WizardTab implements ActionListener JavaDoc
55 {
56   /** Recovery log driver */
57   public JTextField JavaDoc driver;
58   /** Recovery log driver path */
59   public JTextField JavaDoc driverPath;
60   /** Recovery log login */
61   public JTextField JavaDoc login;
62   /** Recovery log url */
63   public JTextField JavaDoc url;
64   /** Recovery log password */
65   public JTextField JavaDoc password;
66   /** Recovery log request timeout */
67   public JSlider JavaDoc requestTimeout;
68   /** Recovery log backend select */
69   public JButton JavaDoc selectBackend;
70
71   /**
72    * Creates a new <code>RecoveryTab</code> object
73    *
74    * @param tabs the wizard tabs
75    */

76   public RecoveryTab(WizardTabs tabs)
77   {
78     super(tabs, WizardConstants.TAB_RECOVERY);
79
80     ///////////////////////////////////////////////////////////////////////////
81
// jdbc recovery panel
82
///////////////////////////////////////////////////////////////////////////
83

84     JPanel JavaDoc general = new JPanel JavaDoc();
85     general.setBorder(BorderFactory.createTitledBorder(WizardTranslate
86         .get("label.jdbcrecovery")));
87     general.setLayout(new GridBagLayout JavaDoc());
88     GridBagConstraints JavaDoc generalconstraints = new GridBagConstraints JavaDoc();
89     generalconstraints.fill = GridBagConstraints.HORIZONTAL;
90     generalconstraints.weightx = 1.0;
91
92     // Driver
93
generalconstraints.gridy = ++generalconstraints.gridy;
94     driver = new JTextField JavaDoc("");
95     generalconstraints.gridx = 0;
96     general.add(new JLabel JavaDoc(WizardTranslate.get("label.backendDriver")),
97         generalconstraints);
98     generalconstraints.gridx = 1;
99     general.add(driver, generalconstraints);
100
101     // Driver path
102
generalconstraints.gridy = ++generalconstraints.gridy;
103     driverPath = new JTextField JavaDoc("");
104     generalconstraints.gridx = 0;
105     general.add(new JLabel JavaDoc(WizardTranslate.get("label.backendDriverPath")),
106         generalconstraints);
107     generalconstraints.gridx = 1;
108     general.add(driverPath, generalconstraints);
109
110     // url
111
generalconstraints.gridy = ++generalconstraints.gridy;
112     url = new JTextField JavaDoc("");
113     generalconstraints.gridx = 0;
114     general.add(new JLabel JavaDoc(WizardTranslate.get("label.backendUrl")),
115         generalconstraints);
116     generalconstraints.gridx = 1;
117     general.add(url, generalconstraints);
118
119     // login
120
generalconstraints.gridy = ++generalconstraints.gridy;
121     login = new JTextField JavaDoc("");
122     generalconstraints.gridx = 0;
123     general.add(new JLabel JavaDoc(WizardTranslate.get("label.username")),
124         generalconstraints);
125     generalconstraints.gridx = 1;
126     general.add(login, generalconstraints);
127
128     // password
129
generalconstraints.gridy = ++generalconstraints.gridy;
130     password = new JTextField JavaDoc("");
131     generalconstraints.gridx = 0;
132     general.add(new JLabel JavaDoc(WizardTranslate.get("label.password")),
133         generalconstraints);
134     generalconstraints.gridx = 1;
135     general.add(password, generalconstraints);
136
137     // request timeout
138
generalconstraints.gridy = ++generalconstraints.gridy;
139     requestTimeout = new JSlider JavaDoc(JSlider.HORIZONTAL, 0, 2000, 60);
140     requestTimeout.setPaintTicks(true);
141     requestTimeout.setPaintLabels(true);
142     requestTimeout.setMajorTickSpacing(500);
143     generalconstraints.gridx = 0;
144     general.add(new JLabel JavaDoc(WizardTranslate.get("label.requestTimeout")),
145         generalconstraints);
146     generalconstraints.gridx = 1;
147     general.add(requestTimeout, generalconstraints);
148
149     // select backend type button
150
generalconstraints.gridy = ++generalconstraints.gridy;
151     generalconstraints.gridy = ++generalconstraints.gridy;
152     selectBackend = new JButton JavaDoc(WizardTranslate.get("label.selectbackend"));
153     selectBackend.addActionListener(this);
154     generalconstraints.gridx = 1;
155     general.add(selectBackend, generalconstraints);
156
157     this.add(general, constraints);
158     constraints.gridy = ++constraints.gridy;
159   }
160
161   /**
162    * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
163    */

164   public void actionPerformed(ActionEvent JavaDoc e)
165   {
166     JComponent JavaDoc source = (JComponent JavaDoc) e.getSource();
167     if (source == selectBackend)
168     {
169       String JavaDoc select = WizardTab.showBackendSelectDialog();
170       if (select != null)
171       {
172         url.setText(types.getString(select + ".url"));
173         driver.setText(types.getString(select + ".driver"));
174       }
175     }
176
177   }
178
179 }
Popular Tags