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

RequestManagerTab.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 
00040 import org.objectweb.cjdbc.common.i18n.WizardTranslate;
00041 import org.objectweb.cjdbc.common.xml.DatabasesXmlTags;
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  * RequestManager is the main panel for the information regarding the request
00048  * manager. This tab will open tabs like <code>CachingTab</code> and
00049  * <code>RecoveryTab</code>
00050  * 
00051  * @see <code>WizardTab</code>
00052  * @author <a href="mailto:Nicolas.Modrzyk@inria.fr">Nicolas Modrzyk </a>
00053  * @version 1.0
00054  */
00055 public class RequestManagerTab extends WizardTab implements ItemListener
00056 {
00057 
00058   public JCheckBox          caseSensitiveParsing;
00059   public JSlider            beginTimeout;
00060   public JSlider            commitTimeout;
00061   public JSlider            rollbackTimeout;
00062   public JComboBox          scheduler;
00063   public JPanel             shedulerPanel;
00064   public GridBagConstraints shedulerPanelconstraints;
00065   public JComboBox          schedulerLevel;
00066   public JComboBox          loadbalancer;
00067   public GridBagConstraints loadbalancerPanelconstraints;
00068   public JPanel             loadbalancerPanel;
00069   public JCheckBox          usecaching;
00070   public JCheckBox          userecoverylog;
00071   public JComboBox          wait4completion;
00072 
00073   /**
00074    * Creates a new <code>RequestManagerTab</code> object
00075    * 
00076    * @param tabs
00077    */
00078   public RequestManagerTab(WizardTabs tabs)
00079   {
00080     super(tabs, WizardConstants.TAB_REQUEST_MANAGER);
00081 
00082     ///////////////////////////////////////////////////////////////////////////
00083     // general panel
00084     ///////////////////////////////////////////////////////////////////////////
00085 
00086     JPanel general = new JPanel();
00087     general.setBorder(BorderFactory.createTitledBorder(WizardTranslate
00088         .get("label.scheduler")));
00089     general.setLayout(new GridBagLayout());
00090     GridBagConstraints generalconstraints = new GridBagConstraints();
00091     generalconstraints.fill = GridBagConstraints.HORIZONTAL;
00092     generalconstraints.weightx = 1.0;
00093 
00094     // caseSensitiveParsing
00095     generalconstraints.gridy = ++generalconstraints.gridy;
00096     generalconstraints.gridx = 0;
00097     general.add(new JLabel(WizardTranslate.get("label.caseSensitiveParsing")),
00098         generalconstraints);
00099     generalconstraints.gridx = 1;
00100     caseSensitiveParsing = new JCheckBox();
00101     caseSensitiveParsing.setName("label.caseSensitiveParsing");
00102     general.add(caseSensitiveParsing, generalconstraints);
00103 
00104     // beginTimeout
00105     generalconstraints.gridy = ++generalconstraints.gridy;
00106     beginTimeout = new JSlider(JSlider.HORIZONTAL, 0, 2000, 60);
00107     beginTimeout.setPaintTicks(true);
00108     beginTimeout.setPaintLabels(true);
00109     beginTimeout.setMajorTickSpacing(500);
00110     generalconstraints.gridx = 0;
00111     general.add(new JLabel(WizardTranslate.get("label.beginTimeout")),
00112         generalconstraints);
00113     generalconstraints.gridx = 1;
00114     general.add(beginTimeout, generalconstraints);
00115 
00116     // commitTimeout
00117     generalconstraints.gridy = ++generalconstraints.gridy;
00118     commitTimeout = new JSlider(JSlider.HORIZONTAL, 0, 2000, 60);
00119     commitTimeout.setPaintTicks(true);
00120     commitTimeout.setPaintLabels(true);
00121     commitTimeout.setMajorTickSpacing(500);
00122     generalconstraints.gridx = 0;
00123     general.add(new JLabel(WizardTranslate.get("label.commitTimeout")),
00124         generalconstraints);
00125     generalconstraints.gridx = 1;
00126     general.add(commitTimeout, generalconstraints);
00127 
00128     // beginTimeout
00129     generalconstraints.gridy = ++generalconstraints.gridy;
00130     rollbackTimeout = new JSlider(JSlider.HORIZONTAL, 0, 2000, 60);
00131     rollbackTimeout.setPaintTicks(true);
00132     rollbackTimeout.setPaintLabels(true);
00133     rollbackTimeout.setMajorTickSpacing(500);
00134     generalconstraints.gridx = 0;
00135     general.add(new JLabel(WizardTranslate.get("label.rollbackTimeout")),
00136         generalconstraints);
00137     generalconstraints.gridx = 1;
00138     general.add(rollbackTimeout, generalconstraints);
00139 
00140     // use caching
00141     generalconstraints.gridy = ++generalconstraints.gridy;
00142     generalconstraints.gridx = 0;
00143     general.add(new JLabel(WizardTranslate.get("label.usecaching")),
00144         generalconstraints);
00145     generalconstraints.gridx = 1;
00146     usecaching = new JCheckBox();
00147     usecaching.setName("label.usecaching");
00148     usecaching.addItemListener(this);
00149     general.add(usecaching, generalconstraints);
00150 
00151     // use recovery log
00152     generalconstraints.gridy = ++generalconstraints.gridy;
00153     generalconstraints.gridx = 0;
00154     general.add(new JLabel(WizardTranslate.get("label.userecoverylog")),
00155         generalconstraints);
00156     generalconstraints.gridx = 1;
00157     userecoverylog = new JCheckBox();
00158     userecoverylog.addItemListener(this);
00159     userecoverylog.setName("label.userecoverylog");
00160     general.add(userecoverylog, generalconstraints);
00161 
00162     this.add(general, constraints);
00163     constraints.gridy = ++constraints.gridy;
00164 
00165     ///////////////////////////////////////////////////////////////////////////
00166     // scheduler panel
00167     ///////////////////////////////////////////////////////////////////////////
00168 
00169     shedulerPanel = new JPanel();
00170     shedulerPanel.setBorder(BorderFactory.createTitledBorder(WizardTranslate
00171         .get("label.scheduler")));
00172     shedulerPanel.setLayout(new GridBagLayout());
00173     shedulerPanelconstraints = new GridBagConstraints();
00174     shedulerPanelconstraints.fill = GridBagConstraints.HORIZONTAL;
00175     shedulerPanelconstraints.weightx = 1.0;
00176 
00177     // scheduler list
00178     scheduler = new JComboBox(WizardConstants.SCHEDULERS_STANDARD);
00179     scheduler.setSelectedIndex(0);
00180     scheduler.addItemListener(this);
00181     shedulerPanelconstraints.gridx = 0;
00182     shedulerPanel.add(new JLabel(WizardTranslate.get("label.scheduler.type")),
00183         shedulerPanelconstraints);
00184     shedulerPanelconstraints.gridx = 1;
00185     shedulerPanel.add(scheduler, shedulerPanelconstraints);
00186 
00187     shedulerPanelconstraints.gridy = 1;
00188     schedulerLevel = new JComboBox(WizardConstants.SCHEDULER_SINGLEDB_LEVELS);
00189     schedulerLevel.setSelectedIndex(0);
00190     schedulerLevel.addItemListener(this);
00191     shedulerPanelconstraints.gridx = 0;
00192     shedulerPanel.add(new JLabel(WizardTranslate.get("label.scheduler.level")),
00193         shedulerPanelconstraints);
00194     shedulerPanelconstraints.gridx = 1;
00195     shedulerPanel.add(schedulerLevel, shedulerPanelconstraints);
00196 
00197     this.add(shedulerPanel, constraints);
00198     constraints.gridy = ++constraints.gridy;
00199 
00200     ///////////////////////////////////////////////////////////////////////////
00201     // loadbalancer panel
00202     ///////////////////////////////////////////////////////////////////////////
00203 
00204     loadbalancerPanel = new JPanel();
00205     loadbalancerPanel.setBorder(BorderFactory
00206         .createTitledBorder(WizardTranslate.get("label.loadbalancer")));
00207     loadbalancerPanel.setLayout(new GridBagLayout());
00208     loadbalancerPanelconstraints = new GridBagConstraints();
00209     loadbalancerPanelconstraints.fill = GridBagConstraints.HORIZONTAL;
00210     loadbalancerPanelconstraints.weightx = 1.0;
00211 
00212     loadbalancer = new JComboBox(WizardConstants.LOAD_BALANCER_SINGLEDB);
00213     loadbalancer.setSelectedIndex(0);
00214     loadbalancer.addItemListener(this);
00215     loadbalancerPanelconstraints.gridx = 0;
00216     loadbalancerPanel.add(new JLabel(WizardTranslate
00217         .get("label.loadbalancer.type")), loadbalancerPanelconstraints);
00218     loadbalancerPanelconstraints.gridx = 1;
00219     loadbalancerPanel.add(loadbalancer, loadbalancerPanelconstraints);
00220 
00221     loadbalancerPanelconstraints.gridy = 1;
00222     wait4completion = new JComboBox(WizardConstants.WAIT_POLICIES);
00223     wait4completion.setEnabled(false);
00224     loadbalancerPanelconstraints.gridx = 0;
00225     loadbalancerPanel.add(new JLabel(WizardTranslate
00226         .get("label.loadbalancer.wait")), loadbalancerPanelconstraints);
00227     loadbalancerPanelconstraints.gridx = 1;
00228     loadbalancerPanel.add(wait4completion, loadbalancerPanelconstraints);
00229 
00230     this.add(loadbalancerPanel, constraints);
00231   }
00232 
00233   /**
00234    * @see org.objectweb.cjdbc.console.wizard.listeners.WizardListener#distributionChanged()
00235    */
00236   public void distributionChanged()
00237   {
00238     shedulerPanel.remove(scheduler);
00239     if (tabs.isDistributedDatabase())
00240     {
00241       scheduler = new JComboBox(WizardConstants.SCHEDULERS_DISTRIBUTED);
00242     }
00243     else
00244     {
00245       scheduler = new JComboBox(WizardConstants.SCHEDULERS_STANDARD);
00246     }
00247     scheduler.setSelectedIndex(0);
00248     scheduler.addItemListener(this);
00249     shedulerPanelconstraints.gridx = 1;
00250     shedulerPanelconstraints.gridy = 0;
00251     shedulerPanel.add(scheduler, shedulerPanelconstraints);
00252     shedulerPanel.validate();
00253     shedulerPanel.repaint();
00254   }
00255 
00256   /**
00257    * @see java.awt.event.ItemListener#itemStateChanged(java.awt.event.ItemEvent)
00258    */
00259   public void itemStateChanged(ItemEvent e)
00260   {
00261     JComponent source = (JComponent) e.getSource();
00262     if (source.equals(scheduler))
00263     {
00264       // change scheduler level
00265       shedulerPanel.remove(schedulerLevel);
00266       if (scheduler.getSelectedIndex() == 0)
00267         schedulerLevel = new JComboBox(
00268             WizardConstants.SCHEDULER_SINGLEDB_LEVELS);
00269       else if (scheduler.getSelectedIndex() == 1)
00270         schedulerLevel = new JComboBox(WizardConstants.SCHEDULER_RAIDB0_LEVELS);
00271       else if (scheduler.getSelectedIndex() == 2)
00272         schedulerLevel = new JComboBox(WizardConstants.SCHEDULER_RAIDB1_LEVELS);
00273       else if (scheduler.getSelectedIndex() == 3)
00274         schedulerLevel = new JComboBox(WizardConstants.SCHEDULER_RAIDB2_LEVELS);
00275 
00276       shedulerPanelconstraints.gridx = 1;
00277       shedulerPanelconstraints.gridy = 1;
00278       schedulerLevel.setSelectedIndex(0);
00279       schedulerLevel.addItemListener(this);
00280       shedulerPanel.add(schedulerLevel, shedulerPanelconstraints);
00281       shedulerPanel.validate();
00282       shedulerPanel.repaint();
00283 
00284       // change loadbalancer list
00285       loadbalancerPanel.remove(loadbalancer);
00286       if (scheduler.getSelectedIndex() == 0)
00287         loadbalancer = new JComboBox(WizardConstants.LOAD_BALANCER_SINGLEDB);
00288       else if (scheduler.getSelectedIndex() == 1)
00289         loadbalancer = new JComboBox(WizardConstants.LOAD_BALANCER_RAIDB0);
00290       else if (scheduler.getSelectedIndex() == 2)
00291         loadbalancer = new JComboBox(WizardConstants.LOAD_BALANCER_RAIDB1);
00292       else if (scheduler.getSelectedIndex() == 3)
00293         loadbalancer = new JComboBox(WizardConstants.LOAD_BALANCER_RAIDB2);
00294 
00295       loadbalancerPanelconstraints.gridx = 1;
00296       loadbalancerPanelconstraints.gridy = 0;
00297       loadbalancer.setSelectedIndex(0);
00298       loadbalancer.addItemListener(this);
00299       loadbalancerPanel.add(loadbalancer, loadbalancerPanelconstraints);
00300       loadbalancerPanel.validate();
00301       loadbalancerPanel.repaint();
00302 
00303     }
00304     else if (source.equals(usecaching))
00305     {
00306       if (usecaching.getSelectedObjects() != null)
00307         tabs.setTabEnabled(WizardConstants.TAB_CACHING, true);
00308       else
00309         tabs.setTabEnabled(WizardConstants.TAB_CACHING, false);
00310     }
00311     else if (source.equals(userecoverylog))
00312     {
00313       if (userecoverylog.getSelectedObjects() != null)
00314         tabs.setTabEnabled(WizardConstants.TAB_RECOVERY, true);
00315       else
00316         tabs.setTabEnabled(WizardConstants.TAB_RECOVERY, false);
00317     }
00318 
00319     // enable wait4completion combo ?
00320     if (source.equals(loadbalancer) || source.equals(scheduler))
00321     {
00322       String selected = (String) loadbalancer.getSelectedItem();
00323       if (selected.startsWith(DatabasesXmlTags.ELT_RAIDb_1)
00324           || selected.startsWith(DatabasesXmlTags.ELT_RAIDb_2))
00325         wait4completion.setEnabled(true);
00326       else
00327         wait4completion.setEnabled(false);
00328     }
00329   }
00330 }

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