00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 package org.objectweb.cjdbc.console.gui.frames;
00026
00027 import java.awt.Dimension;
00028 import java.awt.FlowLayout;
00029 import java.awt.Toolkit;
00030 import java.awt.event.ActionListener;
00031
00032 import javax.swing.JButton;
00033 import javax.swing.JDialog;
00034 import javax.swing.JFrame;
00035 import javax.swing.JLabel;
00036 import javax.swing.JPasswordField;
00037 import javax.swing.JTextField;
00038 import javax.swing.WindowConstants;
00039
00040 import org.objectweb.cjdbc.common.i18n.GuiTranslate;
00041 import org.objectweb.cjdbc.console.gui.FrameConfirmKeyListener;
00042 import org.objectweb.cjdbc.console.gui.constants.GuiCommands;
00043 import org.objectweb.cjdbc.console.gui.session.GuiSession;
00044
00045
00046
00047
00048
00049
00050
00051 public class GuiVirtualDatabaseLoginFrame extends JDialog
00052 {
00053 private JPasswordField passwordBox;
00054 private JTextField loginBox;
00055 private ActionListener actionListener;
00056 private String databaseName;
00057 private String controllerHost;
00058 private String controllerPort;
00059 private JButton optionConfirm;
00060 private FrameConfirmKeyListener keyListener;
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072 public GuiVirtualDatabaseLoginFrame(JFrame parent, ActionListener listener,
00073 String databaseName, String controllerHost, String controllerPort,
00074 GuiSession session)
00075
00076 {
00077 super(parent, GuiTranslate.get("frame.database.title", databaseName), true);
00078
00079 this.actionListener = listener;
00080 this.controllerHost = controllerHost;
00081 this.controllerPort = controllerPort;
00082 Toolkit toolkit = Toolkit.getDefaultToolkit();
00083 Dimension dim = toolkit.getScreenSize();
00084 int screenHeight = dim.height;
00085 int screenWidth = dim.width;
00086 int frameWidth = 450;
00087 int frameHeight = 80;
00088 this.setBounds((screenWidth - frameWidth) / 2,
00089 (screenHeight - frameHeight) / 2, frameWidth, frameHeight);
00090 this.validate();
00091 this.setVisible(false);
00092 this.setResizable(false);
00093 this.getContentPane().setLayout(new FlowLayout());
00094 this.databaseName = databaseName;
00095
00096
00097 optionConfirm = new JButton(GuiTranslate.get("frame.database.approve"));
00098 optionConfirm.setActionCommand(GuiCommands.COMMAND_DATABASE_AUTHENTICATE);
00099 optionConfirm.addActionListener(actionListener);
00100
00101 keyListener = new FrameConfirmKeyListener(optionConfirm);
00102 this.addKeyListener(keyListener);
00103
00104 Dimension buttonDim = new Dimension(80, 20);
00105
00106 this.getContentPane().add(
00107 new JLabel(GuiTranslate.get("frame.database.login")));
00108 loginBox = new JTextField(0);
00109 loginBox.setAlignmentX(CENTER_ALIGNMENT);
00110 String login = session.getAuthenticatedDatabaseLogin(databaseName);
00111 if (login != null)
00112 loginBox.setText(login);
00113 loginBox.setPreferredSize(buttonDim);
00114 loginBox.addActionListener(actionListener);
00115 loginBox.addKeyListener(keyListener);
00116 this.getContentPane().add(loginBox);
00117
00118 this.getContentPane().add(
00119 new JLabel(GuiTranslate.get("frame.database.password")));
00120 passwordBox = new JPasswordField(0);
00121 passwordBox.setPreferredSize(buttonDim);
00122 String pass = session.getAuthenticatedDatabasePassword(databaseName);
00123 if (pass != null)
00124 passwordBox.setText(pass);
00125 passwordBox.setAlignmentX(CENTER_ALIGNMENT);
00126 passwordBox.addKeyListener(keyListener);
00127 passwordBox.addActionListener(actionListener);
00128 this.getContentPane().add(passwordBox);
00129
00130 this.getContentPane().add(optionConfirm);
00131 this.validate();
00132 setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);
00133 }
00134
00135
00136
00137
00138
00139
00140 public JTextField getLoginBox()
00141 {
00142 return loginBox;
00143 }
00144
00145
00146
00147
00148
00149
00150 public JTextField getPasswordBox()
00151 {
00152 return passwordBox;
00153 }
00154
00155
00156
00157
00158
00159
00160 public String getDatabaseName()
00161 {
00162 return databaseName;
00163 }
00164
00165
00166
00167
00168
00169
00170 public String getControllerHost()
00171 {
00172 return controllerHost;
00173 }
00174
00175
00176
00177
00178
00179
00180 public String getControllerPort()
00181 {
00182 return controllerPort;
00183 }
00184 }