home *** CD-ROM | disk | FTP | other *** search
Java Source | 1998-03-18 | 4.9 KB | 161 lines |
- /*
- * @(#LogonDialog.java
- *
- * Copyright (c) 1997 Symantec Corporation. All Rights Reserved.
- *
- */
-
- package symantec.itools.db.awt;
-
- import java.awt.Button;
- import java.awt.Label;
- import java.awt.Font;
- import java.awt.Event;
- import java.util.*;
- import java.sql.*;
- import java.lang.*;
- import java.awt.*;
- import java.util.ResourceBundle;
- import symantec.itools.db.net.*;
- import symantec.itools.db.pro.*;
-
- /**
- * This dialog gathers the user's name and password for a database.
- */
- public class LogonDialog extends symantec.itools.awt.util.dialog.ModalDialog
- {
- //{{DECLARE_CONTROLS
- symantec.itools.awt.KeyPressManagerPanel keyPressManagerPanel1;
- java.awt.Button OK;
- java.awt.Button Cancel;
- java.awt.TextField UserNameEdit;
- java.awt.TextField UserPasswordEdit;
- java.awt.Label label3;
- java.awt.Label label4;
- java.awt.Label datasource;
- java.awt.Label datasource1;
- //}}
-
- ConnectionInfo m_ConnectionInfo;
- boolean m_Action;
-
- /**
- * Constructs a logon dialog. The given connection information
- * is displayed then may be updated by the user.
- * @param frame the parent frame
- * @param title the title for this dialog
- * @param conn the connection info to display/edit with this dialog
- */
- public LogonDialog(java.awt.Frame frame, String title,
- ConnectionInfo conn) {
-
- super(frame, title);
- m_ConnectionInfo = conn;
-
- }
-
- /**
- * Tells this component that it has been added to a container.
- * <p>
- * This is a standard Java AWT method which gets called by the AWT when
- * this component is added to a container. Typically, it is used to
- * create this component's peer.
- * <p>
- * Here, it is overridden to create and initialize this dialog's components.
- *
- * @see java.awt.Container#removeNotify
- */
- public void addNotify() {
- ResourceBundle res = ResourceBundle.getBundle("symantec.itools.db.resources.ResBundle");
-
- // Call parents addNotify method.
- super.addNotify();
-
- //{{INIT_CONTROLS
- setLayout(null);
- resize(insets().left + insets().right + 360,insets().top + insets().bottom + 152);
- setBackground(new Color(12632256));
- keyPressManagerPanel1 = new symantec.itools.awt.KeyPressManagerPanel();
- keyPressManagerPanel1.setLayout(null);
- keyPressManagerPanel1.reshape(insets().left + 0,insets().top + 0,360,152);
- add(keyPressManagerPanel1);
- OK = new java.awt.Button("OK");
- OK.reshape(68,108,85,25);
- keyPressManagerPanel1.add(OK);
- Cancel = new java.awt.Button(res.getString("Cancel"));
- Cancel.reshape(164,108,85,25);
- keyPressManagerPanel1.add(Cancel);
- UserNameEdit = new java.awt.TextField(28);
- UserNameEdit.reshape(164,37,166,23);
- keyPressManagerPanel1.add(UserNameEdit);
- UserPasswordEdit = new java.awt.TextField(28);
- UserPasswordEdit.setEchoCharacter('*');
- UserPasswordEdit.reshape(164,65,166,23);
- keyPressManagerPanel1.add(UserPasswordEdit);
- label3 = new java.awt.Label(res.getString("UserName"));
- label3.reshape(56,40,90,15);
- keyPressManagerPanel1.add(label3);
- label4 = new java.awt.Label(res.getString("Password"));
- label4.reshape(64,68,90,15);
- keyPressManagerPanel1.add(label4);
- datasource = new java.awt.Label(res.getString("DataSourceName"));
- datasource.reshape(16,5,133,15);
- keyPressManagerPanel1.add(datasource);
- datasource1 = new java.awt.Label(res.getString("DataSourceName"));
- datasource1.reshape(164,5,200,15);
- keyPressManagerPanel1.add(datasource1);
- setTitle(res.getString("Title"));
- //}}
-
- // Fill controls with properties sent in
- UserNameEdit.setText(m_ConnectionInfo.getUser());
- UserPasswordEdit.setText(m_ConnectionInfo.getPassword());
- datasource1.setText(m_ConnectionInfo.getDBString());
-
- //{{INIT_MENUS
- //}}
-
-
- Action lAction = new Action();
- OK.addActionListener(lAction);
- Cancel.addActionListener(lAction);
-
- }
-
- //{{DECLARE_MENUS
- //}}
-
- /**
- * Does the standard processing for when the OK button is clicked.
- * It notes the contents of the user and password fields,
- * sets the "ok clicked" flag to true, and hides the dialog.
- */
- public void clickedOK() {
- m_ConnectionInfo.setUser(UserNameEdit.getText());
- m_ConnectionInfo.setPassword(UserPasswordEdit.getText());
- m_Action = true;
- hide();
- }
-
- /**
- * Does the standard processing for when the Cancel button is clicked.
- * It sets the "ok clicked" flag to false and hides the dialog.
- */
- public void clickedCancel() {
- m_Action = false;
- hide();
- }
-
- class Action implements java.awt.event.ActionListener {
- public void actionPerformed(java.awt.event.ActionEvent event) {
- Object object = event.getSource();
- if (object == OK)
- clickedOK();
- else if (object == Cancel)
- clickedCancel();
- }
- }
-
- }
-
-