home *** CD-ROM | disk | FTP | other *** search
/ Symantec Visual Cafe for Java 2.5 / symantec-visual-cafe-2.5-database-dev-edition.iso / VCafe / prosrc.bin / LogonDialog.java < prev    next >
Encoding:
Java Source  |  1998-03-18  |  4.9 KB  |  161 lines

  1. /*
  2.  * @(#LogonDialog.java
  3.  *
  4.  * Copyright (c) 1997 Symantec Corporation. All Rights Reserved.
  5.  *
  6.  */
  7.  
  8. package symantec.itools.db.awt;
  9.  
  10. import java.awt.Button;
  11. import java.awt.Label;
  12. import java.awt.Font;
  13. import java.awt.Event;
  14. import java.util.*;
  15. import java.sql.*;
  16. import java.lang.*;
  17. import java.awt.*;
  18. import java.util.ResourceBundle;
  19. import symantec.itools.db.net.*;
  20. import symantec.itools.db.pro.*;
  21.  
  22. /**
  23.  * This dialog gathers the user's name and password for a database.
  24.  */
  25. public class LogonDialog extends symantec.itools.awt.util.dialog.ModalDialog
  26. {
  27.     //{{DECLARE_CONTROLS
  28.     symantec.itools.awt.KeyPressManagerPanel keyPressManagerPanel1;
  29.     java.awt.Button OK;
  30.     java.awt.Button Cancel;
  31.     java.awt.TextField UserNameEdit;
  32.     java.awt.TextField UserPasswordEdit;
  33.     java.awt.Label label3;
  34.     java.awt.Label label4;
  35.     java.awt.Label datasource;
  36.     java.awt.Label datasource1;
  37.     //}}
  38.  
  39.     ConnectionInfo  m_ConnectionInfo;
  40.     boolean         m_Action;
  41.  
  42.     /**
  43.      * Constructs a logon dialog. The given connection information
  44.      * is displayed then may be updated by the user.
  45.      * @param frame the parent frame
  46.      * @param title the title for this dialog
  47.      * @param conn the connection info to display/edit with this dialog
  48.      */
  49.     public LogonDialog(java.awt.Frame frame, String title,
  50.         ConnectionInfo conn) {
  51.  
  52.         super(frame, title);
  53.         m_ConnectionInfo = conn;
  54.  
  55.     }
  56.  
  57.     /**
  58.      * Tells this component that it has been added to a container.
  59.      * <p>
  60.      * This is a standard Java AWT method which gets called by the AWT when
  61.      * this component is added to a container. Typically, it is used to
  62.      * create this component's peer.
  63.      * <p>
  64.      * Here, it is overridden to create and initialize this dialog's components.
  65.      *
  66.      * @see java.awt.Container#removeNotify
  67.      */
  68.     public void addNotify() {
  69.         ResourceBundle res = ResourceBundle.getBundle("symantec.itools.db.resources.ResBundle");
  70.  
  71.         // Call parents addNotify method.
  72.         super.addNotify();
  73.  
  74.         //{{INIT_CONTROLS
  75.         setLayout(null);
  76.         resize(insets().left + insets().right + 360,insets().top + insets().bottom + 152);
  77.         setBackground(new Color(12632256));
  78.         keyPressManagerPanel1 = new symantec.itools.awt.KeyPressManagerPanel();
  79.         keyPressManagerPanel1.setLayout(null);
  80.         keyPressManagerPanel1.reshape(insets().left + 0,insets().top + 0,360,152);
  81.         add(keyPressManagerPanel1);
  82.         OK = new java.awt.Button("OK");
  83.         OK.reshape(68,108,85,25);
  84.         keyPressManagerPanel1.add(OK);
  85.         Cancel = new java.awt.Button(res.getString("Cancel"));
  86.         Cancel.reshape(164,108,85,25);
  87.         keyPressManagerPanel1.add(Cancel);
  88.         UserNameEdit = new java.awt.TextField(28);
  89.         UserNameEdit.reshape(164,37,166,23);
  90.         keyPressManagerPanel1.add(UserNameEdit);
  91.         UserPasswordEdit = new java.awt.TextField(28);
  92.         UserPasswordEdit.setEchoCharacter('*');
  93.         UserPasswordEdit.reshape(164,65,166,23);
  94.         keyPressManagerPanel1.add(UserPasswordEdit);
  95.         label3 = new java.awt.Label(res.getString("UserName"));
  96.         label3.reshape(56,40,90,15);
  97.         keyPressManagerPanel1.add(label3);
  98.         label4 = new java.awt.Label(res.getString("Password"));
  99.         label4.reshape(64,68,90,15);
  100.         keyPressManagerPanel1.add(label4);
  101.         datasource = new java.awt.Label(res.getString("DataSourceName"));
  102.         datasource.reshape(16,5,133,15);
  103.         keyPressManagerPanel1.add(datasource);
  104.         datasource1 = new java.awt.Label(res.getString("DataSourceName"));
  105.         datasource1.reshape(164,5,200,15);
  106.         keyPressManagerPanel1.add(datasource1);
  107.         setTitle(res.getString("Title"));
  108.         //}}
  109.  
  110.         // Fill controls with properties sent in
  111.         UserNameEdit.setText(m_ConnectionInfo.getUser());
  112.         UserPasswordEdit.setText(m_ConnectionInfo.getPassword());
  113.         datasource1.setText(m_ConnectionInfo.getDBString());
  114.  
  115.         //{{INIT_MENUS
  116.         //}}
  117.  
  118.  
  119.     Action lAction = new Action();
  120.     OK.addActionListener(lAction);
  121.     Cancel.addActionListener(lAction);
  122.  
  123.     }
  124.  
  125.     //{{DECLARE_MENUS
  126.     //}}
  127.  
  128.     /**
  129.      * Does the standard processing for when the OK button is clicked.
  130.      * It notes the contents of the user and password fields,
  131.      * sets the "ok clicked" flag to true, and hides the dialog.
  132.      */
  133.     public void clickedOK() {
  134.         m_ConnectionInfo.setUser(UserNameEdit.getText());
  135.         m_ConnectionInfo.setPassword(UserPasswordEdit.getText());
  136.         m_Action = true;
  137.         hide();
  138.     }
  139.  
  140.     /**
  141.      * Does the standard processing for when the Cancel button is clicked.
  142.      * It sets the "ok clicked" flag to false and hides the dialog.
  143.      */
  144.     public void clickedCancel() {
  145.         m_Action = false;
  146.         hide();
  147.     }
  148.  
  149.     class Action implements java.awt.event.ActionListener {
  150.         public void actionPerformed(java.awt.event.ActionEvent event) {
  151.             Object object = event.getSource();
  152.             if (object == OK)
  153.                 clickedOK();
  154.             else if (object == Cancel)
  155.                 clickedCancel();
  156.         }
  157.     }
  158.  
  159. }
  160.  
  161.