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

VirtualDatabaseTab.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.JComponent;
00036 import javax.swing.JLabel;
00037 import javax.swing.JPanel;
00038 import javax.swing.JSlider;
00039 import javax.swing.JTextField;
00040 
00041 import org.objectweb.cjdbc.common.i18n.WizardTranslate;
00042 import org.objectweb.cjdbc.console.wizard.WizardConstants;
00043 import org.objectweb.cjdbc.console.wizard.WizardTab;
00044 import org.objectweb.cjdbc.console.wizard.WizardTabs;
00045 
00046 /**
00047  * This is the general panel for the configuration of the virtual database. It
00048  * mainly contains pools information
00049  * 
00050  * @author <a href="mailto:Nicolas.Modrzyk@inria.fr">Nicolas Modrzyk </a>
00051  * @version 1.0
00052  */
00053 public class VirtualDatabaseTab extends WizardTab implements ItemListener
00054 {
00055   public JSlider    minNbOfThreads;
00056   public JSlider    maxNbOfThreads;
00057   public JSlider    maxThreadIdleTime;
00058   public JSlider    sqlDumpLength;
00059   public JCheckBox  distributed;
00060   public JComboBox  blob;
00061   public JCheckBox  pool;
00062   public JSlider    maxNbOfConnections;
00063   public JTextField vdbName;
00064 
00065   public VirtualDatabaseTab(WizardTabs tabs)
00066   {
00067     super(tabs, WizardConstants.TAB_VIRTUAL_DATABASE);
00068 
00069     // panels
00070     JPanel general = new JPanel();
00071     general.setBorder(BorderFactory.createTitledBorder(WizardTranslate
00072         .get("label.database.general")));
00073     general.setLayout(new GridBagLayout());
00074     this.add(general, constraints);
00075     constraints.gridy = ++constraints.gridy;
00076     JPanel poolPanel = new JPanel();
00077     poolPanel.setBorder(BorderFactory.createTitledBorder(WizardTranslate
00078         .get("label.database.pool")));
00079     poolPanel.setLayout(new GridBagLayout());
00080     this.add(poolPanel, constraints);
00081     constraints.gridy = ++constraints.gridy;
00082     JPanel miscellaneous = new JPanel();
00083     miscellaneous.setBorder(BorderFactory.createTitledBorder(WizardTranslate
00084         .get("label.database.miscellaneous")));
00085     miscellaneous.setLayout(new GridBagLayout());
00086     this.add(miscellaneous, constraints);
00087 
00088     GridBagConstraints localconstraints = new GridBagConstraints();
00089     localconstraints.fill = GridBagConstraints.HORIZONTAL;
00090     localconstraints.weightx = 1.0;
00091     localconstraints.gridy = 0;
00092 
00093     // Name
00094     localconstraints.gridy = ++localconstraints.gridy;
00095     vdbName = new JTextField("");
00096     localconstraints.gridx = 0;
00097     general
00098         .add(new JLabel(WizardTranslate.get("label.name")), localconstraints);
00099     localconstraints.gridx = 1;
00100     general.add(vdbName, localconstraints);
00101 
00102     // Distributed
00103     localconstraints.gridy = ++localconstraints.gridy;
00104     localconstraints.gridx = 0;
00105     general.add(new JLabel(WizardTranslate.get("label.distributed")),
00106         localconstraints);
00107     localconstraints.gridx = 1;
00108     distributed = new JCheckBox();
00109     distributed.setName("label.distributed");
00110     distributed.addItemListener(this);
00111     general.add(distributed, localconstraints);
00112 
00113     // maxNbOfConnections
00114     localconstraints.gridy = ++localconstraints.gridy;
00115     maxNbOfConnections = new JSlider(JSlider.HORIZONTAL, 0, 2000, 0);
00116     maxNbOfConnections.setPaintTicks(true);
00117     maxNbOfConnections.setPaintLabels(true);
00118     maxNbOfConnections.setMajorTickSpacing(500);
00119     localconstraints.gridx = 0;
00120     general.add(new JLabel(WizardTranslate.get("label.maxNbOfConnections")),
00121         localconstraints);
00122     localconstraints.gridx = 1;
00123     general.add(maxNbOfConnections, localconstraints);
00124 
00125     localconstraints.gridy = 0;
00126 
00127     // pool
00128     localconstraints.gridy = ++localconstraints.gridy;
00129     pool = new JCheckBox("", true);
00130     pool.addItemListener(this);
00131     localconstraints.gridx = 0;
00132     poolPanel.add(new JLabel(WizardTranslate.get("label.poolThreads")),
00133         localconstraints);
00134     localconstraints.gridx = 1;
00135     poolPanel.add(pool, localconstraints);
00136 
00137     // threads
00138     localconstraints.gridy = ++localconstraints.gridy;
00139     minNbOfThreads = new JSlider(JSlider.HORIZONTAL, 0, 2000, 0);
00140     minNbOfThreads.setPaintTicks(true);
00141     minNbOfThreads.setPaintLabels(true);
00142     minNbOfThreads.setMajorTickSpacing(500);
00143     localconstraints.gridx = 0;
00144     poolPanel.add(new JLabel(WizardTranslate.get("label.minNbOfThreads")),
00145         localconstraints);
00146     localconstraints.gridx = 1;
00147     poolPanel.add(minNbOfThreads, localconstraints);
00148 
00149     localconstraints.gridy = ++localconstraints.gridy;
00150     maxNbOfThreads = new JSlider(JSlider.HORIZONTAL, 0, 2000, 0);
00151     maxNbOfThreads.setPaintTicks(true);
00152     maxNbOfThreads.setPaintLabels(true);
00153     maxNbOfThreads.setMajorTickSpacing(500);
00154     localconstraints.gridx = 0;
00155     poolPanel.add(new JLabel(WizardTranslate.get("label.maxNbOfThreads")),
00156         localconstraints);
00157     localconstraints.gridx = 1;
00158     poolPanel.add(maxNbOfThreads, localconstraints);
00159 
00160     localconstraints.gridy = ++localconstraints.gridy;
00161     maxThreadIdleTime = new JSlider(JSlider.HORIZONTAL, 0, 2000, 0);
00162     maxThreadIdleTime.setPaintTicks(true);
00163     maxThreadIdleTime.setPaintLabels(true);
00164     maxThreadIdleTime.setMajorTickSpacing(500);
00165     localconstraints.gridx = 0;
00166     poolPanel.add(new JLabel(WizardTranslate.get("label.maxThreadIdleTime")),
00167         localconstraints);
00168     localconstraints.gridx = 1;
00169     poolPanel.add(maxThreadIdleTime, localconstraints);
00170 
00171     localconstraints.gridy = 0;
00172 
00173     // sqlDumpLength
00174     localconstraints.gridy = ++localconstraints.gridy;
00175     sqlDumpLength = new JSlider(JSlider.HORIZONTAL, 0, 512, 40);
00176     sqlDumpLength.setPaintTicks(true);
00177     sqlDumpLength.setPaintLabels(true);
00178     sqlDumpLength.setMajorTickSpacing(100);
00179     localconstraints.gridx = 0;
00180     miscellaneous.add(new JLabel(WizardTranslate.get("label.sqlDumpLength")),
00181         localconstraints);
00182     localconstraints.gridx = 1;
00183     miscellaneous.add(sqlDumpLength, localconstraints);
00184 
00185     // blobEncodingMethod
00186     localconstraints.gridy = ++localconstraints.gridy;
00187     blob = new JComboBox(WizardConstants.BLOB);
00188     blob.setSelectedIndex(0);
00189     blob.addItemListener(this);
00190     localconstraints.gridx = 0;
00191     miscellaneous.add(new JLabel(WizardTranslate
00192         .get("label.blobEncodingMethod")), localconstraints);
00193     localconstraints.gridx = 1;
00194     miscellaneous.add(blob, localconstraints);
00195 
00196   }
00197 
00198   /**
00199    * @see java.awt.event.ItemListener#itemStateChanged(java.awt.event.ItemEvent)
00200    */
00201   public void itemStateChanged(ItemEvent e)
00202   {
00203     JComponent box = (JComponent) e.getSource();
00204     if (box == pool)
00205     {
00206       if (pool.getSelectedObjects() != null)
00207       {
00208         minNbOfThreads.setEnabled(true);
00209         maxNbOfThreads.setEnabled(true);
00210         maxThreadIdleTime.setEnabled(true);
00211       }
00212       else
00213       {
00214         minNbOfThreads.setEnabled(false);
00215         maxNbOfThreads.setEnabled(false);
00216         maxThreadIdleTime.setEnabled(false);
00217       }
00218     }
00219     else if (box == distributed)
00220     {
00221       tabs.distributionChanged();
00222     }
00223   }
00224 
00225   /**
00226    * Is it a distributed database
00227    * 
00228    * @return true or false
00229    */
00230   public boolean isDistributedDB()
00231   {
00232     return distributed.getSelectedObjects() != null;
00233   }
00234 
00235 }

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