KickJava   Java API By Example, From Geeks To Geeks.

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


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.ItemEvent JavaDoc;
30 import java.awt.event.ItemListener JavaDoc;
31
32 import javax.swing.BorderFactory JavaDoc;
33 import javax.swing.JCheckBox JavaDoc;
34 import javax.swing.JComboBox JavaDoc;
35 import javax.swing.JComponent JavaDoc;
36 import javax.swing.JLabel JavaDoc;
37 import javax.swing.JPanel JavaDoc;
38 import javax.swing.JSlider JavaDoc;
39 import javax.swing.JTextField JavaDoc;
40
41 import org.objectweb.cjdbc.common.i18n.WizardTranslate;
42 import org.objectweb.cjdbc.console.wizard.WizardConstants;
43 import org.objectweb.cjdbc.console.wizard.WizardTab;
44 import org.objectweb.cjdbc.console.wizard.WizardTabs;
45
46 /**
47  * This is the general panel for the configuration of the virtual database. It
48  * mainly contains pools information
49  *
50  * @author <a HREF="mailto:Nicolas.Modrzyk@inria.fr">Nicolas Modrzyk </a>
51  * @version 1.0
52  */

53 public class VirtualDatabaseTab extends WizardTab implements ItemListener JavaDoc
54 {
55   /** Virtual database minimum of threads */
56   public JSlider JavaDoc minNbOfThreads;
57   /** Virtual database maximum of threads */
58   public JSlider JavaDoc maxNbOfThreads;
59   /** Virtual database maximum thread idle time */
60   public JSlider JavaDoc maxThreadIdleTime;
61   /** Virtual database SQL dump length */
62   public JSlider JavaDoc sqlDumpLength;
63   /** Is Virtual database distributed? */
64   public JCheckBox JavaDoc distributed;
65   /** Virtual database BLOB filter */
66   public JComboBox JavaDoc blob;
67   /** Virtual database pooling? */
68   public JCheckBox JavaDoc pool;
69   /** Virtual database maximum number of connections */
70   public JSlider JavaDoc maxNbOfConnections;
71   /** Virtual database name */
72   public JTextField JavaDoc vdbName;
73
74   /**
75    * Creates a new <code>VirtualDatabaseTab</code> object
76    *
77    * @param tabs Wizard tabs
78    */

79   public VirtualDatabaseTab(WizardTabs tabs)
80   {
81     super(tabs, WizardConstants.TAB_VIRTUAL_DATABASE);
82
83     // panels
84
JPanel JavaDoc general = new JPanel JavaDoc();
85     general.setBorder(BorderFactory.createTitledBorder(WizardTranslate
86         .get("label.database.general")));
87     general.setLayout(new GridBagLayout JavaDoc());
88     this.add(general, constraints);
89     constraints.gridy = ++constraints.gridy;
90     JPanel JavaDoc poolPanel = new JPanel JavaDoc();
91     poolPanel.setBorder(BorderFactory.createTitledBorder(WizardTranslate
92         .get("label.database.pool")));
93     poolPanel.setLayout(new GridBagLayout JavaDoc());
94     this.add(poolPanel, constraints);
95     constraints.gridy = ++constraints.gridy;
96     JPanel JavaDoc miscellaneous = new JPanel JavaDoc();
97     miscellaneous.setBorder(BorderFactory.createTitledBorder(WizardTranslate
98         .get("label.database.miscellaneous")));
99     miscellaneous.setLayout(new GridBagLayout JavaDoc());
100     this.add(miscellaneous, constraints);
101
102     GridBagConstraints JavaDoc localconstraints = new GridBagConstraints JavaDoc();
103     localconstraints.fill = GridBagConstraints.HORIZONTAL;
104     localconstraints.weightx = 1.0;
105     localconstraints.gridy = 0;
106
107     // Name
108
localconstraints.gridy = ++localconstraints.gridy;
109     vdbName = new JTextField JavaDoc("");
110     localconstraints.gridx = 0;
111     general
112         .add(new JLabel JavaDoc(WizardTranslate.get("label.name")), localconstraints);
113     localconstraints.gridx = 1;
114     general.add(vdbName, localconstraints);
115
116     // Distributed
117
localconstraints.gridy = ++localconstraints.gridy;
118     localconstraints.gridx = 0;
119     general.add(new JLabel JavaDoc(WizardTranslate.get("label.distributed")),
120         localconstraints);
121     localconstraints.gridx = 1;
122     distributed = new JCheckBox JavaDoc();
123     distributed.setName("label.distributed");
124     distributed.addItemListener(this);
125     general.add(distributed, localconstraints);
126
127     // maxNbOfConnections
128
localconstraints.gridy = ++localconstraints.gridy;
129     maxNbOfConnections = new JSlider JavaDoc(JSlider.HORIZONTAL, 0, 2000, 0);
130     maxNbOfConnections.setPaintTicks(true);
131     maxNbOfConnections.setPaintLabels(true);
132     maxNbOfConnections.setMajorTickSpacing(500);
133     localconstraints.gridx = 0;
134     general.add(new JLabel JavaDoc(WizardTranslate.get("label.maxNbOfConnections")),
135         localconstraints);
136     localconstraints.gridx = 1;
137     general.add(maxNbOfConnections, localconstraints);
138
139     localconstraints.gridy = 0;
140
141     // pool
142
localconstraints.gridy = ++localconstraints.gridy;
143     pool = new JCheckBox JavaDoc("", true);
144     pool.addItemListener(this);
145     localconstraints.gridx = 0;
146     poolPanel.add(new JLabel JavaDoc(WizardTranslate.get("label.poolThreads")),
147         localconstraints);
148     localconstraints.gridx = 1;
149     poolPanel.add(pool, localconstraints);
150
151     // threads
152
localconstraints.gridy = ++localconstraints.gridy;
153     minNbOfThreads = new JSlider JavaDoc(JSlider.HORIZONTAL, 0, 2000, 0);
154     minNbOfThreads.setPaintTicks(true);
155     minNbOfThreads.setPaintLabels(true);
156     minNbOfThreads.setMajorTickSpacing(500);
157     localconstraints.gridx = 0;
158     poolPanel.add(new JLabel JavaDoc(WizardTranslate.get("label.minNbOfThreads")),
159         localconstraints);
160     localconstraints.gridx = 1;
161     poolPanel.add(minNbOfThreads, localconstraints);
162
163     localconstraints.gridy = ++localconstraints.gridy;
164     maxNbOfThreads = new JSlider JavaDoc(JSlider.HORIZONTAL, 0, 2000, 0);
165     maxNbOfThreads.setPaintTicks(true);
166     maxNbOfThreads.setPaintLabels(true);
167     maxNbOfThreads.setMajorTickSpacing(500);
168     localconstraints.gridx = 0;
169     poolPanel.add(new JLabel JavaDoc(WizardTranslate.get("label.maxNbOfThreads")),
170         localconstraints);
171     localconstraints.gridx = 1;
172     poolPanel.add(maxNbOfThreads, localconstraints);
173
174     localconstraints.gridy = ++localconstraints.gridy;
175     maxThreadIdleTime = new JSlider JavaDoc(JSlider.HORIZONTAL, 0, 2000, 0);
176     maxThreadIdleTime.setPaintTicks(true);
177     maxThreadIdleTime.setPaintLabels(true);
178     maxThreadIdleTime.setMajorTickSpacing(500);
179     localconstraints.gridx = 0;
180     poolPanel.add(new JLabel JavaDoc(WizardTranslate.get("label.maxThreadIdleTime")),
181         localconstraints);
182     localconstraints.gridx = 1;
183     poolPanel.add(maxThreadIdleTime, localconstraints);
184
185     localconstraints.gridy = 0;
186
187     // sqlDumpLength
188
localconstraints.gridy = ++localconstraints.gridy;
189     sqlDumpLength = new JSlider JavaDoc(JSlider.HORIZONTAL, 0, 512, 40);
190     sqlDumpLength.setPaintTicks(true);
191     sqlDumpLength.setPaintLabels(true);
192     sqlDumpLength.setMajorTickSpacing(100);
193     localconstraints.gridx = 0;
194     miscellaneous.add(new JLabel JavaDoc(WizardTranslate.get("label.sqlDumpLength")),
195         localconstraints);
196     localconstraints.gridx = 1;
197     miscellaneous.add(sqlDumpLength, localconstraints);
198
199     // blobEncodingMethod
200
localconstraints.gridy = ++localconstraints.gridy;
201     blob = new JComboBox JavaDoc(WizardConstants.BLOB);
202     blob.setSelectedIndex(0);
203     blob.addItemListener(this);
204     localconstraints.gridx = 0;
205     miscellaneous.add(new JLabel JavaDoc(WizardTranslate
206         .get("label.blobEncodingMethod")), localconstraints);
207     localconstraints.gridx = 1;
208     miscellaneous.add(blob, localconstraints);
209
210   }
211
212   /**
213    * @see java.awt.event.ItemListener#itemStateChanged(java.awt.event.ItemEvent)
214    */

215   public void itemStateChanged(ItemEvent JavaDoc e)
216   {
217     JComponent JavaDoc box = (JComponent JavaDoc) e.getSource();
218     if (box == pool)
219     {
220       if (pool.getSelectedObjects() != null)
221       {
222         minNbOfThreads.setEnabled(true);
223         maxNbOfThreads.setEnabled(true);
224         maxThreadIdleTime.setEnabled(true);
225       }
226       else
227       {
228         minNbOfThreads.setEnabled(false);
229         maxNbOfThreads.setEnabled(false);
230         maxThreadIdleTime.setEnabled(false);
231       }
232     }
233     else if (box == distributed)
234     {
235       tabs.distributionChanged();
236     }
237   }
238
239   /**
240    * Is it a distributed database
241    *
242    * @return true or false
243    */

244   public boolean isDistributedDB()
245   {
246     return distributed.getSelectedObjects() != null;
247   }
248
249 }
Popular Tags