home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgLangD.iso / VCAFE.3.0A / Sample.bin / OptionsDialog.java < prev    next >
Text File  |  1998-11-05  |  9KB  |  280 lines

  1. // Copyright (c) 1997, 1998 Symantec, Inc. All Rights Reserved.
  2.  
  3. import java.awt.*;
  4.  
  5. import symantec.itools.awt.ImagePanel;
  6. import symantec.itools.awt.Label3D;
  7. import symantec.itools.awt.Wizard;
  8. import symantec.itools.awt.TabPanel;
  9. import symantec.itools.awt.util.spinner.NumericSpinner;
  10.  
  11. /**
  12.  * This dialog was added to this project by dragging a Dialog form component 
  13.  * into the project.
  14.  * It was then customized with Cafe's visual tools, including the Interaction
  15.  * Wizard.
  16.  * Then it was manually customized to 
  17.  * 1) initialize component values from report data
  18.  * 2) save the results.
  19.  */
  20. public class OptionsDialog extends Dialog
  21. {
  22.     /*
  23.     Sets the initial component values from the program data.
  24.     */
  25.     void initializeComponentsFromData() {
  26.         WebLogAnalyzer wla = (WebLogAnalyzer)getParent();
  27.         try {
  28.             sessionLimitSpinner.setCurrent(wla.data.userSessionIdleLimit);
  29.             ignoreLogFileErrors.setState(wla.data.ignoreUnexpectedLogFileErrors);
  30.         } catch(java.beans.PropertyVetoException x) {
  31.         }
  32.     }
  33.  
  34.  
  35. //  --  AUTOMATICALLY GENERATED/MAINTAINED CODE FRAMEWORK BELOW THIS LINE  --
  36.  
  37.     /**
  38.      * Constructs this dialog.
  39.      * Initializes components the components.
  40.      * Registers component listeners.
  41.      * All of the code in this routine except the last line are 
  42.      * automatically generated/maintained by Visual Cafe.
  43.      */
  44.     public OptionsDialog(Frame parent, boolean modal)
  45.     {
  46.         super(parent, modal);
  47.  
  48.         // This code is automatically generated by Visual Cafe when you add
  49.         // components to the visual environment. It instantiates and initializes
  50.         // the components. To modify the code, only use code syntax that matches
  51.         // what Visual Cafe can generate, or Visual Cafe may be unable to back
  52.         // parse your Java file into its visual environment.
  53.         //{{INIT_CONTROLS
  54.         setLayout(null);
  55.         setBackground(java.awt.Color.lightGray);
  56.         setSize(441,348);
  57.         setVisible(false);
  58.         try {
  59.             imagePanel1.setImageURL(symantec.itools.net.RelativeURL.getURL("images/wl-wizardb.jpg"));
  60.         }
  61.         catch (java.net.MalformedURLException error) { }
  62.         catch(java.beans.PropertyVetoException e) { }
  63.         imagePanel1.setLayout(null);
  64.         add(imagePanel1);
  65.         imagePanel1.setBackground(new java.awt.Color(64,128,128));
  66.         imagePanel1.setBounds(8,7,418,40);
  67.         try {
  68.             label3D1.setBevelStyle(symantec.itools.awt.Label3D.BEVEL_LOWERED);
  69.         }
  70.         catch(java.beans.PropertyVetoException e) { }
  71.         try {
  72.             label3D1.setText("Program Options");
  73.         }
  74.         catch(java.beans.PropertyVetoException e) { }
  75.         imagePanel1.add(label3D1);
  76.         label3D1.setBackground(java.awt.Color.lightGray);
  77.         label3D1.setBounds(11,8,111,24);
  78.         try {
  79.             {
  80.                 String[] tempString = new String[2];
  81.                 tempString[0] = "General";
  82.                 tempString[1] = "";
  83.                 tabPanel1.setPanelLabels(tempString);
  84.             }
  85.         }
  86.         catch(java.beans.PropertyVetoException e) { }
  87.         add(tabPanel1);
  88.         tabPanel1.setBounds(1,54,435,247);
  89.         panel1.setLayout(null);
  90.         tabPanel1.add(panel1);
  91.         panel1.setBounds(12,33,411,203);
  92.         sessionLimitLabel.setText("User Session Idle Limit (minutes)");
  93.         panel1.add(sessionLimitLabel);
  94.         sessionLimitLabel.setBounds(13,13,214,36);
  95.         try {
  96.             sessionLimitSpinner.setMin(1);
  97.         }
  98.         catch(java.beans.PropertyVetoException e) { }
  99.         try {
  100.             sessionLimitSpinner.setCurrent(30);
  101.         }
  102.         catch(java.beans.PropertyVetoException e) { }
  103.         try {
  104.             sessionLimitSpinner.setMax(100);
  105.         }
  106.         catch(java.beans.PropertyVetoException e) { }
  107.         try {
  108.             sessionLimitSpinner.setEditable(true);
  109.         }
  110.         catch(java.beans.PropertyVetoException e) { }
  111.         panel1.add(sessionLimitSpinner);
  112.         sessionLimitSpinner.setBounds(234,20,69,25);
  113.         ignoreLogFileErrors.setLabel("Ignore unexpected log file errors");
  114.         panel1.add(ignoreLogFileErrors);
  115.         ignoreLogFileErrors.setBounds(13,56,280,24);
  116.         try {
  117.             tabPanel1.setCurrentPanelNdx(0);
  118.         }
  119.         catch(java.beans.PropertyVetoException e) { }
  120.         panel6.setLayout(new GridLayout(1,1,8,0));
  121.         add(panel6);
  122.         panel6.setBounds(303,305,121,25);
  123.         okButton.setLabel("OK");
  124.         panel6.add(okButton);
  125.         okButton.setFont(new Font("Dialog", Font.BOLD, 12));
  126.         okButton.setBounds(0,0,56,25);
  127.         cancelButton.setLabel("Cancel");
  128.         panel6.add(cancelButton);
  129.         cancelButton.setBounds(64,0,56,25);
  130.         setTitle("Program Options");
  131.         //}}
  132.  
  133.         //{{REGISTER_LISTENERS
  134.         SymWindow aSymWindow = new SymWindow();
  135.         this.addWindowListener(aSymWindow);
  136.         SymAction lSymAction = new SymAction();
  137.         cancelButton.addActionListener(lSymAction);
  138.         okButton.addActionListener(lSymAction);
  139.         //}}
  140.         
  141.         // Initialize the component values
  142.         initializeComponentsFromData();
  143.         
  144.         // Center this dialog within its parent's bounds
  145.         WLAUtil.centerInParent(this);
  146.     }
  147.     
  148.     /**
  149.      * Tells this component that it has been added to a container. 
  150.      * This is a standard Java AWT method which gets called by the AWT when 
  151.      * this component is added to a container. 
  152.      * Typically, it is used to create this component's peer. <br>
  153.      * It has been OVERRIDDEN here to adjust the position of components as needed
  154.      * for the container's insets. <br>
  155.      * This method is automatically generated by Visual Cafe.
  156.      */
  157.     public void addNotify()
  158.     {
  159.           // Record the size of the window prior to calling parents addNotify.
  160.         Dimension d = getSize();
  161.  
  162.         super.addNotify();
  163.  
  164.         if (fComponentsAdjusted)
  165.             return;
  166.  
  167.         // Adjust components according to the insets
  168.         Insets insets = getInsets();
  169.         setSize(insets.left + insets.right + d.width, insets.top + insets.bottom + d.height);
  170.         Component components[] = getComponents();
  171.         for (int i = 0; i < components.length; i++)
  172.         {
  173.             Point p = components[i].getLocation();
  174.             p.translate(insets.left, insets.top);
  175.             components[i].setLocation(p);
  176.         }
  177.         fComponentsAdjusted = true;
  178.     }
  179.  
  180.     // Used for addNotify check.
  181.     boolean fComponentsAdjusted = false;
  182.  
  183.     /**
  184.      * Constructs this Dialog with the given title.
  185.      * This routine was automatically generated by Visual Cafe, and is not
  186.      * actually used.
  187.      */
  188.     public OptionsDialog(Frame parent, String title, boolean modal)
  189.     {
  190.         this(parent, modal);
  191.         setTitle(title);
  192.     }
  193.  
  194.     //{{DECLARE_CONTROLS
  195.     symantec.itools.awt.ImagePanel imagePanel1 = new symantec.itools.awt.ImagePanel();
  196.     symantec.itools.awt.Label3D label3D1 = new symantec.itools.awt.Label3D();
  197.     symantec.itools.awt.TabPanel tabPanel1 = new symantec.itools.awt.TabPanel();
  198.     java.awt.Panel panel1 = new java.awt.Panel();
  199.     java.awt.Label sessionLimitLabel = new java.awt.Label();
  200.     symantec.itools.awt.util.spinner.NumericSpinner sessionLimitSpinner = new symantec.itools.awt.util.spinner.NumericSpinner();
  201.     java.awt.Checkbox ignoreLogFileErrors = new java.awt.Checkbox();
  202.     java.awt.Panel panel6 = new java.awt.Panel();
  203.     java.awt.Button okButton = new java.awt.Button();
  204.     java.awt.Button cancelButton = new java.awt.Button();
  205.     //}}
  206.  
  207.     /** 
  208.      * This is an event listener created by Visual Cafe to handle WindowEvents.
  209.      */
  210.     class SymWindow extends java.awt.event.WindowAdapter
  211.     {
  212.         public void windowClosing(java.awt.event.WindowEvent event)
  213.         {
  214.             Object object = event.getSource();
  215.             if (object == OptionsDialog.this)
  216.                 OptionsDialog_WindowClosing(event);
  217.         }
  218.     }
  219.     
  220.     /**
  221.      * Handles the WINDOW_CLOSING WindowEvent.
  222.      * This method is automatically added when the Dialog form was added to
  223.      * this project.
  224.      */
  225.     void OptionsDialog_WindowClosing(java.awt.event.WindowEvent event)
  226.     {
  227.         dispose();
  228.     }
  229.  
  230.     /** 
  231.      * This is an event listener created by Visual Cafe to handle ActionEvents.
  232.      * It was created by the Interaction Wizard.
  233.      */
  234.     class SymAction implements java.awt.event.ActionListener
  235.     {
  236.         public void actionPerformed(java.awt.event.ActionEvent event)
  237.         {
  238.             Object object = event.getSource();
  239.             if (object == cancelButton)
  240.                 cancelButton_Action(event);
  241.             else if (object == okButton)
  242.                 okButton_Action(event);
  243.         }
  244.     }
  245.  
  246.     /**
  247.      * This handles the ActionEvents generated by the Cancel button.
  248.      * Created using the Interaction Wizard.
  249.      */
  250.     void cancelButton_Action(java.awt.event.ActionEvent event)
  251.     {
  252.         // to do: code goes here.
  253.              
  254.         //{{CONNECTION
  255.         // Hide the Dialog
  256.         setVisible(false);
  257.         //}}
  258.     }
  259.  
  260.     /**
  261.      * This handles the ActionEvents generated by the OK button.
  262.      * Created using the Interaction Wizard, then the modified to
  263.      * save changes to the program options.
  264.      */
  265.     void okButton_Action(java.awt.event.ActionEvent event)
  266.     {
  267.         // to do: code goes here.
  268.         // Save The Options
  269.         WebLogAnalyzer wla = (WebLogAnalyzer)getParent();
  270.         wla.data.userSessionIdleLimit = sessionLimitSpinner.getCurrent();
  271.         wla.data.ignoreUnexpectedLogFileErrors = ignoreLogFileErrors.getState();
  272.         
  273.         //{{CONNECTION
  274.         // Hide the Dialog
  275.         setVisible(false);
  276.         //}}
  277.     }
  278.     
  279. }
  280.