KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > cjdbc > console > gui > frames > NewBackendFrame


1 /**
2  * C-JDBC: Clustered JDBC.
3  * Copyright (C) 2002-2004 French National Institute For Research In Computer
4  * Science And Control (INRIA).
5  * Contact: c-jdbc@objectweb.org
6  *
7  * This library is free software; you can redistribute it and/or modify it
8  * under the terms of the GNU Lesser General Public License as published by the
9  * Free Software Foundation; either version 2.1 of the License, or any later
10  * version.
11  *
12  * This library is distributed in the hope that it will be useful, but WITHOUT
13  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
15  * for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public License
18  * along with this library; if not, write to the Free Software Foundation,
19  * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
20  *
21  * Initial developer(s): Emmanuel Cecchet.
22  * Contributor(s): Mathieu Peltier,Nicolas Modrzyk
23  */

24
25 package org.objectweb.cjdbc.console.gui.frames;
26
27 import java.awt.Dimension JavaDoc;
28 import java.awt.GridLayout JavaDoc;
29 import java.awt.Toolkit JavaDoc;
30 import java.awt.event.ActionListener JavaDoc;
31
32 import javax.swing.JButton JavaDoc;
33 import javax.swing.JFrame JavaDoc;
34 import javax.swing.JLabel JavaDoc;
35 import javax.swing.JTextField JavaDoc;
36
37 import org.objectweb.cjdbc.common.i18n.GuiTranslate;
38 import org.objectweb.cjdbc.console.gui.FrameConfirmKeyListener;
39 import org.objectweb.cjdbc.console.gui.constants.GuiCommands;
40 import org.objectweb.cjdbc.console.gui.objects.BackendObject;
41
42 /**
43  * This class defines a NewBackendFrame.
44  *
45  * @author <a HREF="mailto:Nicolas.Modrzyk@inrialpes.fr">Nicolas Modrzyk </a>
46  */

47 public class NewBackendFrame extends JFrame JavaDoc
48 {
49   private JTextField JavaDoc newName;
50   private JTextField JavaDoc newUrl;
51   private JTextField JavaDoc newDriver;
52   private JTextField JavaDoc newLoader;
53   private BackendObject bob;
54   private FrameConfirmKeyListener keyListener;
55
56   /**
57    * Returns the bob value.
58    *
59    * @return Returns the bob.
60    */

61   public BackendObject getBob()
62   {
63     return bob;
64   }
65   /**
66    * Sets the bob value.
67    *
68    * @param bob The bob to set.
69    */

70   public void setBob(BackendObject bob)
71   {
72     this.bob = bob;
73     newName.setText(bob.getName());
74     try
75     {
76       newUrl.setText(bob.getMbean().getURL());
77       newDriver.setText(bob.getMbean().getDriverClassName());
78       newLoader.setText(bob.getMbean().getDriverPath());
79     }
80     catch (Exception JavaDoc e)
81     {
82       e.printStackTrace();
83       newUrl.setText("");
84       newDriver.setText("");
85       newLoader.setText("");
86     }
87     
88   }
89   /**
90    * Creates a new <code>NewBackendFrame</code> object
91    *
92    * @param listener that listens to actions
93    * @param bob the backend object
94    */

95   public NewBackendFrame(BackendObject bob,ActionListener JavaDoc listener)
96   {
97     super(GuiTranslate.get("frame.backend.title"));
98     Toolkit JavaDoc toolkit = Toolkit.getDefaultToolkit();
99     Dimension JavaDoc dim = toolkit.getScreenSize();
100     int screenHeight = dim.height;
101     int screenWidth = dim.width;
102     int frameWidth = 450;
103     int frameHeight = 450;
104     this.setBounds((screenWidth - frameWidth) / 2,
105         (screenHeight - frameHeight) / 2, frameWidth, frameHeight);
106     this.validate();
107     this.setVisible(false);
108     this.getContentPane().setLayout(new GridLayout JavaDoc(5,2));
109
110     JButton JavaDoc optionConfirm = new JButton JavaDoc(GuiTranslate.get("frame.ok"));
111     optionConfirm.setActionCommand(GuiCommands.COMMAND_CREATE_BACKEND_APPROVE);
112     optionConfirm.addActionListener(listener);
113     
114     keyListener = new FrameConfirmKeyListener(optionConfirm);
115     this.addKeyListener(keyListener);
116     
117     // New Name
118
this.getContentPane().add(new JLabel JavaDoc(GuiTranslate.get("frame.backend.new.name")));
119     newName = new JTextField JavaDoc(0);
120     newName.setAlignmentX(CENTER_ALIGNMENT);
121     newName.setText("");
122     newName.addKeyListener(keyListener);
123     this.getContentPane().add(newName);
124     
125     // New URL
126
this.getContentPane().add(new JLabel JavaDoc(GuiTranslate.get("frame.backend.new.url")));
127     newUrl = new JTextField JavaDoc(0);
128     newUrl.setAlignmentX(CENTER_ALIGNMENT);
129     newUrl.setText("");
130     newUrl.addKeyListener(keyListener);
131     this.getContentPane().add(newUrl);
132     
133     // New Driver
134
this.getContentPane().add(new JLabel JavaDoc(GuiTranslate.get("frame.backend.new.driver")));
135     newDriver = new JTextField JavaDoc(0);
136     newDriver.setAlignmentX(CENTER_ALIGNMENT);
137     newDriver.setText("");
138     newDriver.addKeyListener(keyListener);
139     this.getContentPane().add(newDriver);
140     
141     // New Loader
142
this.getContentPane().add(new JLabel JavaDoc(GuiTranslate.get("frame.backend.new.loader")));
143     newLoader = new JTextField JavaDoc(0);
144     newLoader.setAlignmentX(CENTER_ALIGNMENT);
145     newLoader.setText("");
146     newLoader.addKeyListener(keyListener);
147     this.getContentPane().add(newLoader);
148
149     this.getContentPane().add(optionConfirm);
150
151     JButton JavaDoc optionCancel = new JButton JavaDoc(GuiTranslate.get("frame.cancel"));
152     optionCancel.setActionCommand(GuiCommands.COMMAND_CREATE_BACKEND_CANCEL);
153     optionCancel.addActionListener(listener);
154     this.getContentPane().add(optionCancel);
155
156     setBob(bob);
157     this.setVisible(false);
158     this.setDefaultCloseOperation(HIDE_ON_CLOSE);
159     this.validate();
160   }
161   /**
162    * @return Returns the newDriver.
163    */

164   public JTextField JavaDoc getNewDriver()
165   {
166     return newDriver;
167   }
168   /**
169    * @return Returns the newLoader.
170    */

171   public JTextField JavaDoc getNewLoader()
172   {
173     return newLoader;
174   }
175   /**
176    * @return Returns the newName.
177    */

178   public JTextField JavaDoc getNewName()
179   {
180     return newName;
181   }
182   /**
183    * @return Returns the newUrl.
184    */

185   public JTextField JavaDoc getNewUrl()
186   {
187     return newUrl;
188   }
189 }
190
191
192
Popular Tags