Main Page | Packages | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | Related Pages

CachingTab.java

00001 /**
00002  * C-JDBC: Clustered JDBC.
00003  * Copyright (C) 2002-2004 French National Institute For Research In Computer
00004  * Science And Control (INRIA).
00005  * Contact: c-jdbc@objectweb.org
00006  * 
00007  * This library is free software; you can redistribute it and/or modify it
00008  * under the terms of the GNU Lesser General Public License as published by the
00009  * Free Software Foundation; either version 2.1 of the License, or any later
00010  * version.
00011  * 
00012  * This library is distributed in the hope that it will be useful, but WITHOUT
00013  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00014  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
00015  * for more details.
00016  * 
00017  * You should have received a copy of the GNU Lesser General Public License
00018  * along with this library; if not, write to the Free Software Foundation,
00019  * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
00020  *
00021  * Initial developer(s): Nicolas Modrzyk.
00022  * Contributor(s): ______________________.
00023  */
00024 
00025 package org.objectweb.cjdbc.console.wizard.tab;
00026 
00027 import java.awt.GridBagConstraints;
00028 import java.awt.GridBagLayout;
00029 import java.awt.event.ItemEvent;
00030 import java.awt.event.ItemListener;
00031 
00032 import javax.swing.BorderFactory;
00033 import javax.swing.JCheckBox;
00034 import javax.swing.JComboBox;
00035 import javax.swing.JLabel;
00036 import javax.swing.JPanel;
00037 import javax.swing.JSlider;
00038 
00039 import org.objectweb.cjdbc.common.i18n.WizardTranslate;
00040 import org.objectweb.cjdbc.console.wizard.WizardConstants;
00041 import org.objectweb.cjdbc.console.wizard.WizardTab;
00042 import org.objectweb.cjdbc.console.wizard.WizardTabs;
00043 
00044 /**
00045  * This tab defines the fields to fill for caching.
00046  * 
00047  * @see <code>WizardTab</code>
00048  * @author <a href="mailto:Nicolas.Modrzyk@inria.fr">Nicolas Modrzyk </a>
00049  * @version 1.0
00050  */
00051 public class CachingTab extends WizardTab implements ItemListener
00052 {
00053   public JCheckBox metadataenable;
00054   public JCheckBox parsingenable;
00055   public JCheckBox resultenable;
00056   public JSlider   maxNbOfMetadata;
00057   public JSlider   maxNbOfField;
00058   public JCheckBox backgroundParsing;
00059   public JSlider   maxNbOfEntries;
00060   public JSlider   resultMaxNbOfEntries;
00061   public JSlider   pendingTimeout;
00062   public JComboBox granularity;
00063 
00064   /**
00065    * Creates a new <code>CachingTab</code> object
00066    * 
00067    * @param tabs
00068    */
00069   public CachingTab(WizardTabs tabs)
00070   {
00071     super(tabs, WizardConstants.TAB_CACHING);
00072 
00073     ///////////////////////////////////////////////////////////////////////////
00074     // metadatacache panel
00075     ///////////////////////////////////////////////////////////////////////////
00076 
00077     JPanel metadatacache = new JPanel();
00078     metadatacache.setBorder(BorderFactory.createTitledBorder(WizardTranslate
00079         .get("label.metadatacache")));
00080     metadatacache.setLayout(new GridBagLayout());
00081     GridBagConstraints metadatacacheconstraints = new GridBagConstraints();
00082     metadatacacheconstraints.fill = GridBagConstraints.HORIZONTAL;
00083     metadatacacheconstraints.weightx = 1.0;
00084 
00085     // enable
00086     metadatacacheconstraints.gridy = ++metadatacacheconstraints.gridy;
00087     metadatacacheconstraints.gridx = 0;
00088     metadatacache.add(new JLabel(WizardTranslate.get("label.enable")),
00089         metadatacacheconstraints);
00090     metadatacacheconstraints.gridx = 1;
00091     metadataenable = new JCheckBox();
00092     metadataenable.addItemListener(this);
00093     metadatacache.add(metadataenable, metadatacacheconstraints);
00094 
00095     // maxNbOfMetadata
00096     metadatacacheconstraints.gridy = ++metadatacacheconstraints.gridy;
00097     maxNbOfMetadata = new JSlider(JSlider.HORIZONTAL, 0, 200000, 10000);
00098     maxNbOfMetadata.setPaintTicks(true);
00099     maxNbOfMetadata.setPaintLabels(true);
00100     maxNbOfMetadata.setMajorTickSpacing(50000);
00101     maxNbOfMetadata.setEnabled(false);
00102     metadatacacheconstraints.gridx = 0;
00103     metadatacache.add(new JLabel(WizardTranslate.get("label.maxNbOfMetadata")),
00104         metadatacacheconstraints);
00105     metadatacacheconstraints.gridx = 1;
00106     metadatacache.add(maxNbOfMetadata, metadatacacheconstraints);
00107 
00108     // maxNbOfField
00109     metadatacacheconstraints.gridy = ++metadatacacheconstraints.gridy;
00110     maxNbOfField = new JSlider(JSlider.HORIZONTAL, 0, 1000, 0);
00111     maxNbOfField.setPaintTicks(true);
00112     maxNbOfField.setPaintLabels(true);
00113     maxNbOfField.setMajorTickSpacing(100);
00114     maxNbOfField.setEnabled(false);
00115     metadatacacheconstraints.gridx = 0;
00116     metadatacache.add(new JLabel(WizardTranslate.get("label.maxNbOfFields")),
00117         metadatacacheconstraints);
00118     metadatacacheconstraints.gridx = 1;
00119     metadatacache.add(maxNbOfField, metadatacacheconstraints);
00120 
00121     this.add(metadatacache, constraints);
00122     constraints.gridy = ++constraints.gridy;
00123 
00124     ///////////////////////////////////////////////////////////////////////////
00125     // parsingcache panel
00126     ///////////////////////////////////////////////////////////////////////////
00127 
00128     JPanel parsingcache = new JPanel();
00129     parsingcache.setBorder(BorderFactory.createTitledBorder(WizardTranslate
00130         .get("label.parsingcache")));
00131     parsingcache.setLayout(new GridBagLayout());
00132     GridBagConstraints parsingcacheconstraints = new GridBagConstraints();
00133     parsingcacheconstraints.fill = GridBagConstraints.HORIZONTAL;
00134     parsingcacheconstraints.weightx = 1.0;
00135 
00136     // enable
00137     parsingcacheconstraints.gridy = ++parsingcacheconstraints.gridy;
00138     parsingcacheconstraints.gridx = 0;
00139     parsingcache.add(new JLabel(WizardTranslate.get("label.enable")),
00140         parsingcacheconstraints);
00141     parsingcacheconstraints.gridx = 1;
00142     parsingenable = new JCheckBox();
00143     parsingenable.addItemListener(this);
00144     parsingcache.add(parsingenable, parsingcacheconstraints);
00145 
00146     // backgroundParsing
00147     parsingcacheconstraints.gridy = ++parsingcacheconstraints.gridy;
00148     parsingcacheconstraints.gridx = 0;
00149     parsingcache.add(
00150         new JLabel(WizardTranslate.get("label.backgroundParsing")),
00151         parsingcacheconstraints);
00152     parsingcacheconstraints.gridx = 1;
00153     backgroundParsing = new JCheckBox();
00154     backgroundParsing.addItemListener(this);
00155     backgroundParsing.setEnabled(false);
00156     parsingcache.add(backgroundParsing, parsingcacheconstraints);
00157 
00158     // maxNbOfEntries
00159     parsingcacheconstraints.gridy = ++parsingcacheconstraints.gridy;
00160     maxNbOfEntries = new JSlider(JSlider.HORIZONTAL, 0, 10000, 5000);
00161     maxNbOfEntries.setPaintTicks(true);
00162     maxNbOfEntries.setPaintLabels(true);
00163     maxNbOfEntries.setMajorTickSpacing(2500);
00164     maxNbOfEntries.setEnabled(false);
00165     parsingcacheconstraints.gridx = 0;
00166     parsingcache.add(new JLabel(WizardTranslate.get("label.maxNbOfEntries")),
00167         parsingcacheconstraints);
00168     parsingcacheconstraints.gridx = 1;
00169     parsingcache.add(maxNbOfEntries, parsingcacheconstraints);
00170 
00171     this.add(parsingcache, constraints);
00172     constraints.gridy = ++constraints.gridy;
00173 
00174     ///////////////////////////////////////////////////////////////////////////
00175     // resultcache panel
00176     ///////////////////////////////////////////////////////////////////////////
00177 
00178     JPanel resultcache = new JPanel();
00179     resultcache.setBorder(BorderFactory.createTitledBorder(WizardTranslate
00180         .get("label.resultcache")));
00181     resultcache.setLayout(new GridBagLayout());
00182     GridBagConstraints resultcacheconstraints = new GridBagConstraints();
00183     resultcacheconstraints.fill = GridBagConstraints.HORIZONTAL;
00184     resultcacheconstraints.weightx = 1.0;
00185 
00186     // enable
00187     resultcacheconstraints.gridy = ++resultcacheconstraints.gridy;
00188     resultcacheconstraints.gridx = 0;
00189     resultcache.add(new JLabel(WizardTranslate.get("label.enable")),
00190         resultcacheconstraints);
00191     resultcacheconstraints.gridx = 1;
00192     resultenable = new JCheckBox();
00193     resultenable.addItemListener(this);
00194     resultcache.add(resultenable, resultcacheconstraints);
00195 
00196     // granularity
00197     resultcacheconstraints.gridy = ++resultcacheconstraints.gridy;
00198     granularity = new JComboBox(WizardConstants.RESULT_CACHE_GRANULARITY);
00199     granularity.setSelectedIndex(0);
00200     granularity.addItemListener(this);
00201     granularity.setEnabled(false);
00202     resultcacheconstraints.gridx = 0;
00203     resultcache.add(new JLabel(WizardTranslate.get("label.granularity")),
00204         resultcacheconstraints);
00205     resultcacheconstraints.gridx = 1;
00206     resultcache.add(granularity, resultcacheconstraints);
00207 
00208     // maxNbOfEntries
00209     resultcacheconstraints.gridy = ++resultcacheconstraints.gridy;
00210     resultMaxNbOfEntries = new JSlider(JSlider.HORIZONTAL, 0, 1000000, 100000);
00211     resultMaxNbOfEntries.setPaintTicks(true);
00212     resultMaxNbOfEntries.setMajorTickSpacing(100000);
00213     resultMaxNbOfEntries.setEnabled(false);
00214     resultcacheconstraints.gridx = 0;
00215     resultcache.add(new JLabel(WizardTranslate.get("label.maxNbOfEntries")),
00216         resultcacheconstraints);
00217     resultcacheconstraints.gridx = 1;
00218     resultcache.add(resultMaxNbOfEntries, resultcacheconstraints);
00219 
00220     // pendingTimeout
00221     resultcacheconstraints.gridy = ++resultcacheconstraints.gridy;
00222     pendingTimeout = new JSlider(JSlider.HORIZONTAL, 0, 3600, 0);
00223     pendingTimeout.setPaintTicks(true);
00224     pendingTimeout.setPaintLabels(true);
00225     pendingTimeout.setMajorTickSpacing(600);
00226     pendingTimeout.setEnabled(false);
00227     resultcacheconstraints.gridx = 0;
00228     resultcache.add(new JLabel(WizardTranslate.get("label.pendingTimeout")),
00229         resultcacheconstraints);
00230     resultcacheconstraints.gridx = 1;
00231     resultcache.add(pendingTimeout, resultcacheconstraints);
00232 
00233     this.add(resultcache, constraints);
00234     constraints.gridy = ++constraints.gridy;
00235 
00236   }
00237 
00238   /**
00239    * @see java.awt.event.ItemListener#itemStateChanged(java.awt.event.ItemEvent)
00240    */
00241   public void itemStateChanged(ItemEvent e)
00242   {
00243     Object source = e.getSource();
00244     if (source == resultenable)
00245     {
00246       boolean enable = resultenable.getSelectedObjects() != null;
00247       granularity.setEnabled(enable);
00248       pendingTimeout.setEnabled(enable);
00249       resultMaxNbOfEntries.setEnabled(enable);
00250     }
00251     else if (source == parsingenable)
00252     {
00253       boolean enable = parsingenable.getSelectedObjects() != null;
00254       backgroundParsing.setEnabled(enable);
00255       maxNbOfEntries.setEnabled(enable);
00256     }
00257     else if (source == metadataenable)
00258     {
00259       boolean enable = metadataenable.getSelectedObjects() != null;
00260       maxNbOfMetadata.setEnabled(enable);
00261       maxNbOfField.setEnabled(enable);
00262     }
00263   }
00264 }

Generated on Mon Apr 11 22:01:29 2005 for C-JDBC by  doxygen 1.3.9.1