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

NewBackendFrame.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): Emmanuel Cecchet. 
00022  * Contributor(s): Mathieu Peltier,Nicolas Modrzyk
00023  */
00024 
00025 package org.objectweb.cjdbc.console.gui.frames;
00026 
00027 import java.awt.Dimension;
00028 import java.awt.GridLayout;
00029 import java.awt.Toolkit;
00030 import java.awt.event.ActionListener;
00031 
00032 import javax.swing.JButton;
00033 import javax.swing.JFrame;
00034 import javax.swing.JLabel;
00035 import javax.swing.JTextField;
00036 
00037 import org.objectweb.cjdbc.common.i18n.GuiTranslate;
00038 import org.objectweb.cjdbc.console.gui.FrameConfirmKeyListener;
00039 import org.objectweb.cjdbc.console.gui.constants.GuiCommands;
00040 import org.objectweb.cjdbc.console.gui.objects.BackendObject;
00041 
00042 /**
00043  * This class defines a NewBackendFrame.
00044  * 
00045  * @author <a href="mailto:Nicolas.Modrzyk@inrialpes.fr">Nicolas Modrzyk </a>
00046  */
00047 public class NewBackendFrame extends JFrame
00048 {
00049   private JTextField newName;
00050   private JTextField newUrl;
00051   private JTextField newDriver;
00052   private JTextField newLoader;
00053   private BackendObject bob;
00054   private FrameConfirmKeyListener keyListener;
00055 
00056   /**
00057    * Returns the bob value.
00058    * 
00059    * @return Returns the bob.
00060    */
00061   public BackendObject getBob()
00062   {
00063     return bob;
00064   }
00065   /**
00066    * Sets the bob value.
00067    * 
00068    * @param bob The bob to set.
00069    */
00070   public void setBob(BackendObject bob)
00071   {
00072     this.bob = bob;
00073     newName.setText(bob.getName());
00074     try
00075     {
00076       newUrl.setText(bob.getMbean().getURL());
00077       newDriver.setText(bob.getMbean().getDriverClassName());
00078       newLoader.setText(bob.getMbean().getDriverPath());
00079     }
00080     catch (Exception e)
00081     {
00082       e.printStackTrace();
00083       newUrl.setText("");
00084       newDriver.setText("");
00085       newLoader.setText("");
00086     }
00087     
00088   }
00089   /**
00090    * Creates a new <code>NewBackendFrame</code> object
00091    * 
00092    * @param listener that listens to actions
00093    * @param bob the backend object
00094    */
00095   public NewBackendFrame(BackendObject bob,ActionListener listener)
00096   {
00097     super(GuiTranslate.get("frame.backend.title"));
00098     Toolkit toolkit = Toolkit.getDefaultToolkit();
00099     Dimension dim = toolkit.getScreenSize();
00100     int screenHeight = dim.height;
00101     int screenWidth = dim.width;
00102     int frameWidth = 450;
00103     int frameHeight = 450;
00104     this.setBounds((screenWidth - frameWidth) / 2,
00105         (screenHeight - frameHeight) / 2, frameWidth, frameHeight);
00106     this.validate();
00107     this.setVisible(false);
00108     this.getContentPane().setLayout(new GridLayout(5,2));
00109 
00110     JButton optionConfirm = new JButton(GuiTranslate.get("frame.ok"));
00111     optionConfirm.setActionCommand(GuiCommands.COMMAND_CREATE_BACKEND_APPROVE);
00112     optionConfirm.addActionListener(listener);
00113     
00114     keyListener = new FrameConfirmKeyListener(optionConfirm);
00115     this.addKeyListener(keyListener);
00116     
00117     // New Name
00118     this.getContentPane().add(new JLabel(GuiTranslate.get("frame.backend.new.name")));
00119     newName = new JTextField(0);
00120     newName.setAlignmentX(CENTER_ALIGNMENT);
00121     newName.setText("");
00122     newName.addKeyListener(keyListener);
00123     this.getContentPane().add(newName);
00124     
00125     // New URL
00126     this.getContentPane().add(new JLabel(GuiTranslate.get("frame.backend.new.url")));
00127     newUrl = new JTextField(0);
00128     newUrl.setAlignmentX(CENTER_ALIGNMENT);
00129     newUrl.setText("");
00130     newUrl.addKeyListener(keyListener);
00131     this.getContentPane().add(newUrl);
00132     
00133     // New Driver
00134     this.getContentPane().add(new JLabel(GuiTranslate.get("frame.backend.new.driver")));
00135     newDriver = new JTextField(0);
00136     newDriver.setAlignmentX(CENTER_ALIGNMENT);
00137     newDriver.setText("");
00138     newDriver.addKeyListener(keyListener);
00139     this.getContentPane().add(newDriver);
00140     
00141     // New Loader
00142     this.getContentPane().add(new JLabel(GuiTranslate.get("frame.backend.new.loader")));
00143     newLoader = new JTextField(0);
00144     newLoader.setAlignmentX(CENTER_ALIGNMENT);
00145     newLoader.setText("");
00146     newLoader.addKeyListener(keyListener);
00147     this.getContentPane().add(newLoader);
00148 
00149     this.getContentPane().add(optionConfirm);
00150 
00151     JButton optionCancel = new JButton(GuiTranslate.get("frame.cancel"));
00152     optionCancel.setActionCommand(GuiCommands.COMMAND_CREATE_BACKEND_CANCEL);
00153     optionCancel.addActionListener(listener);
00154     this.getContentPane().add(optionCancel);
00155 
00156     setBob(bob);
00157     this.setVisible(false);
00158     this.setDefaultCloseOperation(HIDE_ON_CLOSE);
00159     this.validate();
00160   }
00161   /**
00162    * @return Returns the newDriver.
00163    */
00164   public JTextField getNewDriver()
00165   {
00166     return newDriver;
00167   }
00168   /**
00169    * @return Returns the newLoader.
00170    */
00171   public JTextField getNewLoader()
00172   {
00173     return newLoader;
00174   }
00175   /**
00176    * @return Returns the newName.
00177    */
00178   public JTextField getNewName()
00179   {
00180     return newName;
00181   }
00182   /**
00183    * @return Returns the newUrl.
00184    */
00185   public JTextField getNewUrl()
00186   {
00187     return newUrl;
00188   }
00189 }
00190 
00191 

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