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 / ConnectFailedDialog.java < prev    next >
Encoding:
Java Source  |  1998-03-18  |  5.3 KB  |  205 lines

  1. /*
  2.  * @(#ConnectFailedDialog.java
  3.  *
  4.  * Copyright (c) 1997 Symantec Corporation. All Rights Reserved.
  5.  *
  6.  */
  7.  /**
  8.  * <P> This class is the default connect failed dialog.
  9.  */
  10.  
  11. package symantec.itools.db.beans.jdbc;
  12.  
  13. import java.util.*;
  14. import java.sql.*;
  15. import java.awt.*;
  16. import symantec.itools.db.awt.*;
  17.  
  18. /**
  19.  * This dialog gathers the user's name and password for a database.
  20.  */
  21.  
  22. import symantec.itools.awt.KeyPressManagerPanel;
  23. public class ConnectFailedDialog
  24.     extends symantec.itools.awt.util.dialog.ModalDialog
  25. {
  26.     //{{DECLARE_CONTROLS
  27.     symantec.itools.awt.KeyPressManagerPanel keyPressManagerPanel1;
  28.     java.awt.Button OK;
  29.     java.awt.Button Cancel;
  30.     java.awt.TextField UserNameEdit;
  31.     java.awt.TextField UserPasswordEdit;
  32.     java.awt.Label label3;
  33.     java.awt.Label label4;
  34.     java.awt.Label m_URLLabel;
  35.     java.awt.Label m_URLDisplay;
  36.     //}}
  37.  
  38.     boolean         m_ShouldRetry;
  39.  
  40.     /**
  41.      * Constructs a logon dialog. The given connection information
  42.      * is displayed then may be updated by the user.
  43.      * @param frame the parent frame
  44.      * @param title the title for this dialog
  45.      * @param conn the connection info to display/edit with this dialog
  46.      */
  47.     public ConnectFailedDialog()
  48.     {
  49.         super(new Frame(), "");
  50.         hide();
  51.     }
  52.  
  53.     /**
  54.      * Tells this component that it has been added to a container.
  55.      * <p>
  56.      * This is a standard Java AWT method which gets called by the AWT when
  57.      * this component is added to a container. Typically, it is used to
  58.      * create this component's peer.
  59.      * <p>
  60.      * Here, it is overridden to create and initialize this dialog's components.
  61.      *
  62.      * @see java.awt.Container#removeNotify
  63.      */
  64.     public void addNotify()
  65.     {
  66.         // Call parents addNotify method.
  67.         super.addNotify();
  68.  
  69.         //{{INIT_CONTROLS
  70.         setLayout(null);
  71.         setVisible(false);
  72.         setSize(insets().left + insets().right + 360,insets().top + insets().bottom + 152);
  73.         setBackground(new Color(12632256));
  74.         keyPressManagerPanel1 = new symantec.itools.awt.KeyPressManagerPanel();
  75.         keyPressManagerPanel1.setLayout(null);
  76.         keyPressManagerPanel1.setBounds(insets().left + 0,insets().top + 0,360,152);
  77.         add(keyPressManagerPanel1);
  78.         OK = new java.awt.Button();
  79.         OK.setLabel("OK");
  80.         OK.setBounds(68,108,85,25);
  81.         keyPressManagerPanel1.add(OK);
  82.         Cancel = new java.awt.Button();
  83.         Cancel.setLabel("Cancel");
  84.         Cancel.setBounds(164,108,85,25);
  85.         keyPressManagerPanel1.add(Cancel);
  86.         UserNameEdit = new java.awt.TextField(28);
  87.         UserNameEdit.setBounds(164,37,166,23);
  88.         keyPressManagerPanel1.add(UserNameEdit);
  89.         UserPasswordEdit = new java.awt.TextField(28);
  90.         UserPasswordEdit.setEchoChar('*');
  91.         UserPasswordEdit.setBounds(164,65,166,23);
  92.         keyPressManagerPanel1.add(UserPasswordEdit);
  93.         label3 = new java.awt.Label("User Name:");
  94.         label3.setBounds(56,40,90,15);
  95.         keyPressManagerPanel1.add(label3);
  96.         label4 = new java.awt.Label("Password:");
  97.         label4.setBounds(64,68,90,15);
  98.         keyPressManagerPanel1.add(label4);
  99.         m_URLLabel = new java.awt.Label("URL:");
  100.         m_URLLabel.setBounds(16,5,40,15);
  101.         keyPressManagerPanel1.add(m_URLLabel);
  102.         m_URLDisplay = new java.awt.Label("URL value");
  103.         m_URLDisplay.setBounds(55,5,270,15);
  104.         keyPressManagerPanel1.add(m_URLDisplay);
  105.         setTitle("Untitled");
  106.         //}}
  107.  
  108.         // Fill controls with properties sent in
  109.         UserNameEdit.setText(m_UserName);
  110.         UserPasswordEdit.setText(m_Password);
  111.         m_URLDisplay.setText(m_URL);
  112.  
  113.         //{{INIT_MENUS
  114.         //}}
  115.  
  116.  
  117.     Action lAction = new Action();
  118.     OK.addActionListener(lAction);
  119.     Cancel.addActionListener(lAction);
  120.  
  121.     }
  122.  
  123.     //{{DECLARE_MENUS
  124.     //}}
  125.  
  126.     /**
  127.      * Does the standard processing for when the OK button is clicked.
  128.      * It notes the contents of the user and password fields,
  129.      * sets the "ok clicked" flag to true, and hides the dialog.
  130.      */
  131.     public void clickedOK()
  132.     {
  133.         setUserName(UserNameEdit.getText());
  134.         setPassword(UserPasswordEdit.getText());
  135.         m_ShouldRetry = true;
  136.         hide();
  137.     }
  138.  
  139.     /**
  140.      * Does the standard processing for when the Cancel button is clicked.
  141.      * It sets the "ok clicked" flag to false and hides the dialog.
  142.      */
  143.     public void clickedCancel() {
  144.         m_ShouldRetry = false;
  145.         hide();
  146.     }
  147.  
  148.     String m_UserName;
  149.     public void setUserName(String value)
  150.     {
  151.         m_UserName = value;
  152.     }
  153.     public String getUserName()
  154.     {
  155.         return m_UserName;
  156.     }
  157.  
  158.     String m_Password;
  159.     public void setPassword(String value)
  160.     {
  161.         m_Password = value;
  162.     }
  163.     public String getPassword()
  164.     {
  165.         return m_Password;
  166.     }
  167.  
  168.     String m_URL;
  169.     public void setURL(String value)
  170.     {
  171.         m_URL = value;
  172.     }
  173.     public String getURL()
  174.     {
  175.         return m_URL;
  176.     }
  177.  
  178.     String m_Reason;
  179.     public void setReason(String value)
  180.     {
  181.         m_Reason = value;
  182.     }
  183.     public String getReason()
  184.     {
  185.         return m_Reason;
  186.     }
  187.  
  188.     public boolean getShouldRetry()
  189.     {
  190.         return m_ShouldRetry;
  191.     }
  192.  
  193.     class Action implements java.awt.event.ActionListener {
  194.         public void actionPerformed(java.awt.event.ActionEvent event) {
  195.             Object object = event.getSource();
  196.             if (object == OK)
  197.                 clickedOK();
  198.             else if (object == Cancel)
  199.                 clickedCancel();
  200.         }
  201.     }
  202.  
  203. }
  204.  
  205.