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

ConnectionParameterDialog.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.objects;
00026 
00027 import java.awt.Color;
00028 import java.awt.GridBagConstraints;
00029 import java.awt.GridBagLayout;
00030 import java.awt.HeadlessException;
00031 import java.awt.event.ActionEvent;
00032 import java.awt.event.ActionListener;
00033 import java.util.ArrayList;
00034 
00035 import javax.swing.BorderFactory;
00036 import javax.swing.JButton;
00037 import javax.swing.JDialog;
00038 import javax.swing.JLabel;
00039 import javax.swing.JPanel;
00040 import javax.swing.JSlider;
00041 
00042 import org.objectweb.cjdbc.common.i18n.WizardTranslate;
00043 import org.objectweb.cjdbc.console.gui.constants.GuiConstants;
00044 import org.objectweb.cjdbc.console.wizard.WizardConstants;
00045 
00046 /**
00047  * This class defines a ConnectionParameterDialog, all the forms and fields
00048  * needed to define a connection manager on a backend
00049  * 
00050  * @author <a href="mailto:Nicolas.Modrzyk@inria.fr">Nicolas Modrzyk </a>
00051  * @version 1.0
00052  */
00053 public class ConnectionParameterDialog extends JDialog
00054     implements
00055       ActionListener
00056 {
00057 
00058   private ArrayList values;
00059 
00060   /**
00061    * Creates a new <code>ConnectionParameterDialog</code> object
00062    * 
00063    * @throws java.awt.HeadlessException
00064    */
00065   public ConnectionParameterDialog(ConnectionTypeInfo type)
00066       throws HeadlessException
00067   {
00068     super();
00069     this.setModal(true);
00070     this.setTitle(type.getType());
00071     this.setResizable(false);
00072     this.setBackground(Color.white);
00073 
00074     values = new ArrayList();
00075 
00076     this.setSize(WizardConstants.CONNECTION_FRAME_WIDTH,
00077         WizardConstants.CONNECTION_FRAME_HEIGHT);
00078     GuiConstants.centerComponent(this, WizardConstants.CONNECTION_FRAME_WIDTH,
00079         WizardConstants.CONNECTION_FRAME_HEIGHT);
00080 
00081     JPanel pane = new JPanel();
00082     pane.setBorder(BorderFactory.createTitledBorder(type.getType()));
00083     this.add(pane);
00084 
00085     pane.setLayout(new GridBagLayout());
00086     GridBagConstraints constraints = new GridBagConstraints();
00087     constraints.fill = GridBagConstraints.HORIZONTAL;
00088     constraints.anchor = GridBagConstraints.CENTER;
00089 
00090     constraints.weightx = 1.0;
00091 
00092     String[] atts = type.getAttributes();
00093     for (int i = 0; i < atts.length; i++)
00094     {
00095       constraints.gridy = ++constraints.gridy;
00096       constraints.gridx = 0;
00097       pane.add(new JLabel(atts[i]), constraints);
00098       constraints.gridx = 1;
00099       JSlider slider = new JSlider(0, 600, type.getValue(i));
00100       slider.setPaintLabels(true);
00101       slider.setPaintTicks(true);
00102       slider.setPaintTrack(true);
00103       slider.setMajorTickSpacing(100);
00104       pane.add(slider, constraints);
00105       values.add(slider);
00106     }
00107 
00108     constraints.gridy = ++constraints.gridy;
00109     constraints.gridx = 0;
00110     JButton button = new JButton(WizardTranslate.get("label.finish.edit"));
00111     button.addActionListener(this);
00112     pane.add(button, constraints);
00113 
00114     this.validate();
00115     this.setVisible(true);
00116 
00117   }
00118 
00119   /**
00120    * Returns the values value.
00121    * 
00122    * @return Returns the values.
00123    */
00124   public ArrayList getValues()
00125   {
00126     int size = values.size();
00127     ArrayList results = new ArrayList(size);
00128     for (int i = 0; i < size; i++)
00129       results.add(new Integer((((JSlider) values.get(i)).getValue())));
00130     return results;
00131   }
00132 
00133   /**
00134    * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
00135    */
00136   public void actionPerformed(ActionEvent e)
00137   {
00138     this.setVisible(false);
00139   }
00140 }

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