KickJava   Java API By Example, From Geeks To Geeks.

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


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.JLabel JavaDoc;
36 import javax.swing.JPanel JavaDoc;
37 import javax.swing.JSlider JavaDoc;
38
39 import org.objectweb.cjdbc.common.i18n.WizardTranslate;
40 import org.objectweb.cjdbc.console.wizard.WizardConstants;
41 import org.objectweb.cjdbc.console.wizard.WizardTab;
42 import org.objectweb.cjdbc.console.wizard.WizardTabs;
43
44 /**
45  * This tab defines the fields to fill for caching.
46  *
47  * @see <code>WizardTab</code>
48  * @author <a HREF="mailto:Nicolas.Modrzyk@inria.fr">Nicolas Modrzyk </a>
49  * @version 1.0
50  */

51 public class CachingTab extends WizardTab implements ItemListener JavaDoc
52 {
53   /** Is metadata enabled? */
54   public JCheckBox JavaDoc metadataenable;
55   /** Is parsing enabled? */
56   public JCheckBox JavaDoc parsingenable;
57   /** Is result enabled? */
58   public JCheckBox JavaDoc resultenable;
59   /** Max nb of metadata */
60   public JSlider JavaDoc maxNbOfMetadata;
61   /** Max nb of fields */
62   public JSlider JavaDoc maxNbOfField;
63   /** Is background parsing enabled? */
64   public JCheckBox JavaDoc backgroundParsing;
65   /** Max nb of entries */
66   public JSlider JavaDoc maxNbOfEntries;
67   /** Max nb of result entries */
68   public JSlider JavaDoc resultMaxNbOfEntries;
69   /** Pending timeout */
70   public JSlider JavaDoc pendingTimeout;
71   /** Cache granularity */
72   public JComboBox JavaDoc granularity;
73
74   /**
75    * Creates a new <code>CachingTab</code> object
76    *
77    * @param tabs the wizard tas
78    */

79   public CachingTab(WizardTabs tabs)
80   {
81     super(tabs, WizardConstants.TAB_CACHING);
82
83     ///////////////////////////////////////////////////////////////////////////
84
// metadatacache panel
85
///////////////////////////////////////////////////////////////////////////
86

87     JPanel JavaDoc metadatacache = new JPanel JavaDoc();
88     metadatacache.setBorder(BorderFactory.createTitledBorder(WizardTranslate
89         .get("label.metadatacache")));
90     metadatacache.setLayout(new GridBagLayout JavaDoc());
91     GridBagConstraints JavaDoc metadatacacheconstraints = new GridBagConstraints JavaDoc();
92     metadatacacheconstraints.fill = GridBagConstraints.HORIZONTAL;
93     metadatacacheconstraints.weightx = 1.0;
94
95     // enable
96
metadatacacheconstraints.gridy = ++metadatacacheconstraints.gridy;
97     metadatacacheconstraints.gridx = 0;
98     metadatacache.add(new JLabel JavaDoc(WizardTranslate.get("label.enable")),
99         metadatacacheconstraints);
100     metadatacacheconstraints.gridx = 1;
101     metadataenable = new JCheckBox JavaDoc();
102     metadataenable.addItemListener(this);
103     metadatacache.add(metadataenable, metadatacacheconstraints);
104
105     // maxNbOfMetadata
106
metadatacacheconstraints.gridy = ++metadatacacheconstraints.gridy;
107     maxNbOfMetadata = new JSlider JavaDoc(JSlider.HORIZONTAL, 0, 200000, 10000);
108     maxNbOfMetadata.setPaintTicks(true);
109     maxNbOfMetadata.setPaintLabels(true);
110     maxNbOfMetadata.setMajorTickSpacing(50000);
111     maxNbOfMetadata.setEnabled(false);
112     metadatacacheconstraints.gridx = 0;
113     metadatacache.add(new JLabel JavaDoc(WizardTranslate.get("label.maxNbOfMetadata")),
114         metadatacacheconstraints);
115     metadatacacheconstraints.gridx = 1;
116     metadatacache.add(maxNbOfMetadata, metadatacacheconstraints);
117
118     // maxNbOfField
119
metadatacacheconstraints.gridy = ++metadatacacheconstraints.gridy;
120     maxNbOfField = new JSlider JavaDoc(JSlider.HORIZONTAL, 0, 1000, 0);
121     maxNbOfField.setPaintTicks(true);
122     maxNbOfField.setPaintLabels(true);
123     maxNbOfField.setMajorTickSpacing(100);
124     maxNbOfField.setEnabled(false);
125     metadatacacheconstraints.gridx = 0;
126     metadatacache.add(new JLabel JavaDoc(WizardTranslate.get("label.maxNbOfFields")),
127         metadatacacheconstraints);
128     metadatacacheconstraints.gridx = 1;
129     metadatacache.add(maxNbOfField, metadatacacheconstraints);
130
131     this.add(metadatacache, constraints);
132     constraints.gridy = ++constraints.gridy;
133
134     ///////////////////////////////////////////////////////////////////////////
135
// parsingcache panel
136
///////////////////////////////////////////////////////////////////////////
137

138     JPanel JavaDoc parsingcache = new JPanel JavaDoc();
139     parsingcache.setBorder(BorderFactory.createTitledBorder(WizardTranslate
140         .get("label.parsingcache")));
141     parsingcache.setLayout(new GridBagLayout JavaDoc());
142     GridBagConstraints JavaDoc parsingcacheconstraints = new GridBagConstraints JavaDoc();
143     parsingcacheconstraints.fill = GridBagConstraints.HORIZONTAL;
144     parsingcacheconstraints.weightx = 1.0;
145
146     // enable
147
parsingcacheconstraints.gridy = ++parsingcacheconstraints.gridy;
148     parsingcacheconstraints.gridx = 0;
149     parsingcache.add(new JLabel JavaDoc(WizardTranslate.get("label.enable")),
150         parsingcacheconstraints);
151     parsingcacheconstraints.gridx = 1;
152     parsingenable = new JCheckBox JavaDoc();
153     parsingenable.addItemListener(this);
154     parsingcache.add(parsingenable, parsingcacheconstraints);
155
156     // backgroundParsing
157
parsingcacheconstraints.gridy = ++parsingcacheconstraints.gridy;
158     parsingcacheconstraints.gridx = 0;
159     parsingcache.add(
160         new JLabel JavaDoc(WizardTranslate.get("label.backgroundParsing")),
161         parsingcacheconstraints);
162     parsingcacheconstraints.gridx = 1;
163     backgroundParsing = new JCheckBox JavaDoc();
164     backgroundParsing.addItemListener(this);
165     backgroundParsing.setEnabled(false);
166     parsingcache.add(backgroundParsing, parsingcacheconstraints);
167
168     // maxNbOfEntries
169
parsingcacheconstraints.gridy = ++parsingcacheconstraints.gridy;
170     maxNbOfEntries = new JSlider JavaDoc(JSlider.HORIZONTAL, 0, 10000, 5000);
171     maxNbOfEntries.setPaintTicks(true);
172     maxNbOfEntries.setPaintLabels(true);
173     maxNbOfEntries.setMajorTickSpacing(2500);
174     maxNbOfEntries.setEnabled(false);
175     parsingcacheconstraints.gridx = 0;
176     parsingcache.add(new JLabel JavaDoc(WizardTranslate.get("label.maxNbOfEntries")),
177         parsingcacheconstraints);
178     parsingcacheconstraints.gridx = 1;
179     parsingcache.add(maxNbOfEntries, parsingcacheconstraints);
180
181     this.add(parsingcache, constraints);
182     constraints.gridy = ++constraints.gridy;
183
184     ///////////////////////////////////////////////////////////////////////////
185
// resultcache panel
186
///////////////////////////////////////////////////////////////////////////
187

188     JPanel JavaDoc resultcache = new JPanel JavaDoc();
189     resultcache.setBorder(BorderFactory.createTitledBorder(WizardTranslate
190         .get("label.resultcache")));
191     resultcache.setLayout(new GridBagLayout JavaDoc());
192     GridBagConstraints JavaDoc resultcacheconstraints = new GridBagConstraints JavaDoc();
193     resultcacheconstraints.fill = GridBagConstraints.HORIZONTAL;
194     resultcacheconstraints.weightx = 1.0;
195
196     // enable
197
resultcacheconstraints.gridy = ++resultcacheconstraints.gridy;
198     resultcacheconstraints.gridx = 0;
199     resultcache.add(new JLabel JavaDoc(WizardTranslate.get("label.enable")),
200         resultcacheconstraints);
201     resultcacheconstraints.gridx = 1;
202     resultenable = new JCheckBox JavaDoc();
203     resultenable.addItemListener(this);
204     resultcache.add(resultenable, resultcacheconstraints);
205
206     // granularity
207
resultcacheconstraints.gridy = ++resultcacheconstraints.gridy;
208     granularity = new JComboBox JavaDoc(WizardConstants.RESULT_CACHE_GRANULARITY);
209     granularity.setSelectedIndex(0);
210     granularity.addItemListener(this);
211     granularity.setEnabled(false);
212     resultcacheconstraints.gridx = 0;
213     resultcache.add(new JLabel JavaDoc(WizardTranslate.get("label.granularity")),
214         resultcacheconstraints);
215     resultcacheconstraints.gridx = 1;
216     resultcache.add(granularity, resultcacheconstraints);
217
218     // maxNbOfEntries
219
resultcacheconstraints.gridy = ++resultcacheconstraints.gridy;
220     resultMaxNbOfEntries = new JSlider JavaDoc(JSlider.HORIZONTAL, 0, 1000000, 100000);
221     resultMaxNbOfEntries.setPaintTicks(true);
222     resultMaxNbOfEntries.setMajorTickSpacing(100000);
223     resultMaxNbOfEntries.setEnabled(false);
224     resultcacheconstraints.gridx = 0;
225     resultcache.add(new JLabel JavaDoc(WizardTranslate.get("label.maxNbOfEntries")),
226         resultcacheconstraints);
227     resultcacheconstraints.gridx = 1;
228     resultcache.add(resultMaxNbOfEntries, resultcacheconstraints);
229
230     // pendingTimeout
231
resultcacheconstraints.gridy = ++resultcacheconstraints.gridy;
232     pendingTimeout = new JSlider JavaDoc(JSlider.HORIZONTAL, 0, 3600, 0);
233     pendingTimeout.setPaintTicks(true);
234     pendingTimeout.setPaintLabels(true);
235     pendingTimeout.setMajorTickSpacing(600);
236     pendingTimeout.setEnabled(false);
237     resultcacheconstraints.gridx = 0;
238     resultcache.add(new JLabel JavaDoc(WizardTranslate.get("label.pendingTimeout")),
239         resultcacheconstraints);
240     resultcacheconstraints.gridx = 1;
241     resultcache.add(pendingTimeout, resultcacheconstraints);
242
243     this.add(resultcache, constraints);
244     constraints.gridy = ++constraints.gridy;
245
246   }
247
248   /**
249    * @see java.awt.event.ItemListener#itemStateChanged(java.awt.event.ItemEvent)
250    */

251   public void itemStateChanged(ItemEvent JavaDoc e)
252   {
253     Object JavaDoc source = e.getSource();
254     if (source == resultenable)
255     {
256       boolean enable = resultenable.getSelectedObjects() != null;
257       granularity.setEnabled(enable);
258       pendingTimeout.setEnabled(enable);
259       resultMaxNbOfEntries.setEnabled(enable);
260     }
261     else if (source == parsingenable)
262     {
263       boolean enable = parsingenable.getSelectedObjects() != null;
264       backgroundParsing.setEnabled(enable);
265       maxNbOfEntries.setEnabled(enable);
266     }
267     else if (source == metadataenable)
268     {
269       boolean enable = metadataenable.getSelectedObjects() != null;
270       maxNbOfMetadata.setEnabled(enable);
271       maxNbOfField.setEnabled(enable);
272     }
273   }
274 }
Popular Tags