home *** CD-ROM | disk | FTP | other *** search
/ Chip 1998 November / Chip_1998-11_cd.bin / tema / Cafe / Source.bin / Wizard.java < prev    next >
Text File  |  1998-03-18  |  46KB  |  1,727 lines

  1. /*
  2.  * Wizard.java
  3.  */
  4.  
  5. package symantec.itools.awt;
  6.  
  7. import java.io.FileWriter;
  8. import java.io.IOException;
  9.  
  10. import java.awt.*;
  11. import java.awt.event.*;
  12. import java.beans.*;
  13. import java.util.Vector;
  14. import java.util.Enumeration;
  15.  
  16. /**
  17.  * The Wizard component provides services to create wizards.
  18.  * It maintains a list of pages and uses the services of a
  19.  * WizardController to define its behavior.
  20.  *
  21.  * @see WizardController
  22.  * @see SimpleWizardController
  23.  */
  24. public class Wizard extends Panel implements WizardInterface, java.io.Serializable
  25. {
  26.     /**
  27.      * Constructs a Wizard.
  28.      */
  29.     public Wizard()
  30.     {
  31.         //debug("Wizard");
  32.  
  33.         // Add a GridBagLayout to the Panel base class
  34.  
  35.         GridBagLayout gridBagLayout;
  36.         gridBagLayout = new GridBagLayout();
  37.         super.setLayout(gridBagLayout);
  38.  
  39.         // The first panel will contain the pages
  40.  
  41.         panel1 = new Panel();
  42.         panel1.setLayout(null);
  43.         GridBagConstraints gbc;
  44.         gbc = new GridBagConstraints();
  45.         gbc.gridx = 0;
  46.         gbc.gridy = 0;
  47.         gbc.weightx = 1.0;
  48.         gbc.weighty = 1.0;
  49.         gbc.fill = GridBagConstraints.BOTH;
  50.         gbc.insets = new Insets(0, 0, 0, 0);
  51.         ((GridBagLayout)super.getLayout()).setConstraints(panel1, gbc);
  52.         super.add(panel1);
  53.  
  54.         // Horizontal line
  55.  
  56.         horizontalLine1 = new symantec.itools.awt.shape.HorizontalLine();
  57.         try {
  58.             horizontalLine1.setBevelStyle(symantec.itools.awt.shape.HorizontalLine.BEVEL_LOWERED);
  59.         }
  60.         catch(java.beans.PropertyVetoException e) { }
  61.         gbc = new GridBagConstraints();
  62.         gbc.gridx = 0;
  63.         gbc.gridy = 1;
  64.         gbc.weightx = 1.0;
  65.         gbc.fill = GridBagConstraints.BOTH;
  66.         gbc.insets = new Insets(0, 0, 0, 0);
  67.         ((GridBagLayout)super.getLayout()).setConstraints(horizontalLine1, gbc);
  68.         super.add(horizontalLine1);
  69.  
  70.         // The second panel contains the navigation buttons and associated panels
  71.  
  72.         panel2 = new Panel();
  73.         panel2.setLayout(new FlowLayout(FlowLayout.RIGHT, 5, 5));
  74.         gbc = new GridBagConstraints();
  75.         gbc.gridx = 0;
  76.         gbc.gridy = 2;
  77.         gbc.weightx = 1.0;
  78.         gbc.fill = GridBagConstraints.BOTH;
  79.         gbc.insets = new Insets(0, 0, 0, 0);
  80.         ((GridBagLayout)super.getLayout()).setConstraints(panel2, gbc);
  81.         super.add(panel2);
  82.  
  83.         // Navigation buttons and associated panels
  84.  
  85.         panel3 = new Panel();
  86.         panel3.setLayout(new GridLayout());
  87.         panel2.add(panel3);
  88.         previousButton = new Button();
  89.         previousButton.setActionCommand("button");
  90.         previousButton.setLabel(PREVIOUS_LABEL);
  91.         previousButton.setEnabled(false);
  92.         panel3.add(previousButton);
  93.         nextButton = new Button();
  94.         nextButton.setActionCommand("button");
  95.         nextButton.setLabel(NEXT_LABEL);
  96.         nextButton.setEnabled(false);
  97.         panel3.add(nextButton);
  98.         finishButton = new Button();
  99.         finishButton.setActionCommand("button");
  100.         finishButton.setLabel(FINISH_LABEL);
  101.         finishButton.setEnabled(false);
  102.         panel3.add(finishButton);
  103.         panel4 = new Panel();
  104.         panel4.setLayout(new GridLayout(1, 2, 6, 0));
  105.         panel2.add(panel4);
  106.         cancelButton = new Button();
  107.         cancelButton.setActionCommand("button");
  108.         cancelButton.setLabel(CANCEL_LABEL);
  109.         if (java.beans.Beans.isDesignTime())
  110.             cancelButton.setEnabled(false);
  111.         panel4.add(cancelButton);
  112.         helpButton = new Button();
  113.         helpButton.setActionCommand("button");
  114.         helpButton.setLabel(HELP_LABEL);
  115.         if (java.beans.Beans.isDesignTime())
  116.             helpButton.setEnabled(false);
  117.         panel4.add(helpButton);
  118.  
  119.         // Other objects
  120.  
  121.         vPages = new Vector();
  122.         actionListeners = new Vector();
  123.  
  124.         controller = new SimpleWizardController(this);
  125.     }
  126.  
  127.     /**
  128.      * Sets a customized WizardController.
  129.      * This should be done once before actually using the Wizard
  130.      * and after all pages have been added. If no customized
  131.      * WizardController is set, a default SimpleWizardController
  132.      * is used.
  133.      *
  134.      * @see #getWizardController
  135.      */
  136.     public void setWizardController(WizardController controller)
  137.     {
  138.         WizardController oldController = this.controller;
  139.         this.controller = controller;
  140.  
  141.         if (controllerPrepared)
  142.         {
  143.             oldController.doCancel();
  144.             controllerPrepared = false;
  145.  
  146.             initiateController(userComponent);
  147.         }
  148.  
  149.         // Set the buttons status
  150.  
  151.         updateButtonsState();
  152.     }
  153.  
  154.     /**
  155.      * Initiates the WizardController.
  156.      * Begins the WizardController life cycle and shows the
  157.      * first page.
  158.      */
  159.     private void initiateController(Component comp)
  160.     {
  161.         if (!controllerPrepared)
  162.         {
  163.             // Prepare the controller
  164.  
  165.             controller.doPrepare();
  166.             controllerPrepared = true;
  167.  
  168.             // Prepare the new page
  169.  
  170.             controller.resetChainInfo();
  171.             controller.preparePage(comp, WizardController.NEXT);
  172.  
  173.             // Show the new page
  174.  
  175.             showPage(comp);
  176.             curIndex = 0;
  177.             controller.pageShown(comp);
  178.         }
  179.     }
  180.  
  181.     /**
  182.      * Restarts the wizard after usage.
  183.      * The WizardController life cycle will be reset and the
  184.      * first page will be shown again.
  185.      */
  186.     public void restart()
  187.     {
  188.         if (controllerPrepared)
  189.         {
  190.             controller.doCancel();
  191.             controllerPrepared = false;
  192.         }
  193.  
  194.         initiateController(getComponentAt(0));
  195.     }
  196.  
  197.     /**
  198.      * Get the current WizardController.
  199.      *
  200.      * @see #setWizardController
  201.      */
  202.     public WizardController getWizardController()
  203.     {
  204.         return controller;
  205.     }
  206.  
  207.     /**
  208.      * Selects the specified page and shows it.
  209.      * @param index the zero-relative index of the page to select
  210.      * @see #getSelectedIndex
  211.      * @exception PropertyVetoException
  212.      * if the specified property value is unacceptable
  213.      * @exception ArrayIndexOutOfBoundsException
  214.      * if the index is invalid
  215.      */
  216.     /*
  217.     public synchronized void setSelectedIndex(int index) throws PropertyVetoException
  218.     {
  219.         //debug("setSelectedIndex");
  220.  
  221.         // Property has been made read-only.
  222.  
  223.         // To FIX: Just ignore an invalid index. Should test isDesignTime.
  224.  
  225.         //if (!isIndexValid(index))
  226.         //    throw new ArrayIndexOutOfBoundsException();
  227.  
  228.         if ((isIndexValid(index)) && (index != curIndex))
  229.         {
  230.             Integer oldindex = new Integer(curIndex);
  231.             Integer newindex = new Integer(index);
  232.  
  233.             vetos.fireVetoableChange("SelectedIndex", oldindex, newindex);
  234.             showPageAt(index);
  235.             //resetChainInfo();
  236.             updateButtonsState();
  237.             changes.firePropertyChange("SelectedIndex", oldindex, newindex);
  238.         }
  239.     }
  240.     */
  241.  
  242.     /**
  243.      * Returns the zero-relative index of the currently selected page.
  244.      * @return the currently selected page or -1 if none are shown
  245.      */
  246.     public int getSelectedIndex()
  247.     {
  248.         //debug("getSelectedIndex");
  249.         return curIndex;
  250.     }
  251.  
  252.     /**
  253.      * Go to the page which has the given name.
  254.      *
  255.      * @see #getCurrentPageName
  256.      */
  257.     /*
  258.     public synchronized void setCurrentPageByName(String name)
  259.     {
  260.         int current = curIndex;
  261.         int count = getPageCount();
  262.         String s;
  263.  
  264.         for (int i = 0; i < count; i++)
  265.         {
  266.             if (getLabel(i).equals(name))
  267.             {
  268.                 showPageAt(i);
  269.                 resetChainInfo();
  270.                 updateButtonsState();
  271.                 return;
  272.             }
  273.         }
  274.     }
  275.     */
  276.  
  277.     /**
  278.      * Gets the name of the current page.
  279.      *
  280.      * @see #setCurrentPageByName
  281.      */
  282.     /*
  283.     public String getCurrentPageName()
  284.     {
  285.         return getLabel(curIndex);
  286.     }
  287.     */
  288.  
  289.     /**
  290.      * Sets the page labels associated with the page positions.
  291.      * Note that the pages do not need to have been added yet for
  292.      * this method to work.
  293.      * @param labels an array of page labels for the page positions
  294.      * @exception PropertyVetoException
  295.      * if the specified property value is unacceptable
  296.      * @see #getLabels
  297.      */
  298.     /*
  299.     public synchronized void setLabels(String[] labels) throws PropertyVetoException
  300.     {
  301.         //debug("setLabels");
  302.  
  303.         String[] oldValue = this.labels;
  304.  
  305.         vetos.fireVetoableChange("Labels", oldValue, labels);
  306.         this.labels = labels;
  307.         changes.firePropertyChange("Labels", oldValue, labels);
  308.     }
  309.     */
  310.  
  311.     /**
  312.      * Gets the current page labels associated with the page positions.
  313.      * @return an array of page labels for the page positions
  314.      * @see #setLabels
  315.      */
  316.     /*
  317.     public String[] getLabels()
  318.     {
  319.         return labels;
  320.     }
  321.     */
  322.  
  323.     /**
  324.      * Changes the label of the page at the specified index.
  325.      * @param index the zero-relative index of the page
  326.      * @param label the new label for the specified page
  327.      * @exception PropertyVetoException
  328.      * if the specified property value is unacceptable
  329.      * @exception ArrayIndexOutOfBoundsException
  330.      * if the index is invalid
  331.      * @see #getLabel
  332.      */
  333.     /*
  334.     public synchronized void setLabel(int index, String label) throws PropertyVetoException
  335.     {
  336.         //debug("setLabel");
  337.  
  338.         if (!isIndexValid(index))
  339.             throw new ArrayIndexOutOfBoundsException();
  340.  
  341.         String oldValue = getLabel(index);
  342.         vetos.fireVetoableChange("Label", oldValue, label);
  343.  
  344.         // Increase the size of the array if needed
  345.  
  346.         if ((labels == null) || (labels.length < (index + 1)))
  347.         {
  348.             String[] oldLabels = labels;
  349.             labels = new String[index + 1];
  350.  
  351.             if (oldLabels != null)
  352.                 for (int i = 0; i < oldLabels.length; i++)
  353.                     labels[i] = oldLabels[i];
  354.         }
  355.  
  356.         // Set the new value
  357.  
  358.         labels[index] = label;
  359.  
  360.         changes.firePropertyChange("Label", oldValue, label);
  361.     }
  362.     */
  363.  
  364.     /**
  365.      * Gets the label of the page at the specified index.
  366.      * @param index the zero-relative index of the page
  367.      * @return the page label
  368.      * @exception ArrayIndexOutOfBoundsException
  369.      * if the index is invalid
  370.      * @see #setLabel
  371.      */
  372.     /*
  373.     public synchronized String getLabel(int index)
  374.     {
  375.         if (!isIndexValid(index))
  376.             throw new ArrayIndexOutOfBoundsException();
  377.  
  378.         if ((labels != null) && (index < labels.length) && (labels[index] != null))
  379.             return labels[index];
  380.         else
  381.             return "";
  382.     }
  383.     */
  384.  
  385.     /**
  386.      * Replaces a page at the index specified.
  387.      * @param index the zero-relative index of the page to change
  388.      * @param comp the new component
  389.      * @see #getComponentAt
  390.      * @exception PropertyVetoException
  391.      * if the specified property value is unacceptable
  392.      * @exception ArrayIndexOutOfBoundsException
  393.      * if the index is invalid
  394.      * @exception IllegalArgumentException
  395.      * if the component is null
  396.      */
  397.     public synchronized void setComponentAt(int index, Component comp) throws PropertyVetoException
  398.     {
  399.         //debug("setComponentAt");
  400.  
  401.         if (!isIndexValid(index))
  402.             throw new ArrayIndexOutOfBoundsException();
  403.  
  404.         if (comp == null)
  405.             throw new IllegalArgumentException();
  406.  
  407.         Component oldPage = getComponentAt(index);
  408.         vetos.fireVetoableChange("ComponentAt", oldPage, comp);
  409.  
  410.         vPages.setElementAt(comp, index);
  411.         if (index == curIndex)
  412.         {
  413.             hidePage();
  414.             showPage(comp);
  415.         }
  416.  
  417.         changes.firePropertyChange("ComponentAt", oldPage, comp);
  418.     }
  419.  
  420.     /**
  421.      * Gets the component for the page at the given index.
  422.      * @param index zero-relative index of the page
  423.      * @return returns the component associated with the page
  424.      * @exception ArrayIndexOutOfBoundsException
  425.      * if the index is invalid
  426.      * @see #setComponentAt
  427.      */
  428.     public synchronized Component getComponentAt(int index)
  429.     {
  430.         //debug("getComponentAt");
  431.  
  432.         if (!isIndexValid(index))
  433.             throw new ArrayIndexOutOfBoundsException();
  434.  
  435.         return (Component)vPages.elementAt(index);
  436.     }
  437.  
  438.     /**
  439.      * Shows or hides the Help button depending on the value of the parameter.
  440.      *
  441.      * @exception PropertyVetoException
  442.      * if the specified property value is unacceptable
  443.      * @see #isHelpButtonVisible
  444.      */
  445.     public synchronized void setHelpButtonVisible(boolean visible) throws PropertyVetoException
  446.     {
  447.         if (visible == helpButtonVisible)
  448.             return;
  449.  
  450.         Boolean oldvalue = new Boolean(helpButtonVisible);
  451.         Boolean newvalue = new Boolean(visible);
  452.  
  453.         vetos.fireVetoableChange("HelpButtonVisible", oldvalue, newvalue);
  454.  
  455.         if (visible && !helpButtonVisible)
  456.         {
  457.             panel4.add(helpButton);
  458.             helpButtonVisible = true;
  459.         }
  460.         else if (!visible && helpButtonVisible)
  461.         {
  462.             panel4.remove(helpButton);
  463.             helpButtonVisible = false;
  464.         }
  465.  
  466.         changes.firePropertyChange("HelpButtonVisible", oldvalue, newvalue);
  467.     }
  468.  
  469.     /**
  470.      * Determines whether the Help button is visible.
  471.      *
  472.      * @see #setHelpButtonVisible
  473.      */
  474.     public boolean isHelpButtonVisible()
  475.     {
  476.         return helpButtonVisible;
  477.     }
  478.  
  479.     /**
  480.      * Sets a combined Next/Finish button or two buttons depending on the
  481.      * value of the parameter.
  482.      *
  483.      * @exception PropertyVetoException
  484.      * if the specified property value is unacceptable
  485.      * @see #isCombinedButton
  486.      */
  487.     public synchronized void setCombinedButton(boolean combined) throws PropertyVetoException
  488.     {
  489.         if (combined == combinedButton)
  490.             return;
  491.  
  492.         Boolean oldvalue = new Boolean(combinedButton);
  493.         Boolean newvalue = new Boolean(combined);
  494.  
  495.         vetos.fireVetoableChange("combinedButton", oldvalue, newvalue);
  496.  
  497.         if (combined && !combinedButton)
  498.         {
  499.             panel3.remove(finishButton);
  500.             combinedButton = true;
  501.         }
  502.         else if (!combined && combinedButton)
  503.         {
  504.             panel3.add(finishButton);
  505.             combinedButton = false;
  506.         }
  507.  
  508.         changes.firePropertyChange("combinedButton", oldvalue, newvalue);
  509.     }
  510.  
  511.     /**
  512.      * Determines whether there is a combined Next/Finish button.
  513.      *
  514.      * @see #setCombinedButton
  515.      */
  516.     public boolean isCombinedButton()
  517.     {
  518.         return combinedButton;
  519.     }
  520.  
  521.     /**
  522.      * Sets the buttons alignment of the navigation buttons.
  523.      *
  524.      * @param align
  525.      * Wizard.LEFT, Wizard.CENTER or Wizard.RIGHT
  526.      * @exception PropertyVetoException
  527.      * if the specified property value is unacceptable
  528.      * @exception IllegalArgumentException
  529.      * if the parameter is invalid
  530.      * @see #getButtonsAlignment
  531.      */
  532.     public synchronized void setButtonsAlignment(int align) throws PropertyVetoException
  533.     {
  534.         if ((align != LEFT) && (align != CENTER) && (align != RIGHT))
  535.             throw new IllegalArgumentException();
  536.  
  537.         Integer oldvalue = new Integer(getButtonsAlignment());
  538.         Integer newvalue = new Integer(align);
  539.  
  540.         vetos.fireVetoableChange("buttonsAlignment", oldvalue, newvalue);
  541.         ((FlowLayout)panel2.getLayout()).setAlignment(align);
  542.         panel2.invalidate();
  543.         //panel2.doLayout();
  544.         changes.firePropertyChange("buttonsAlignment", oldvalue, newvalue);
  545.     }
  546.  
  547.     /**
  548.      * Gets the buttons alignment of the navigation buttons.
  549.      *
  550.      * @see #setButtonsAlignment
  551.      */
  552.     public int getButtonsAlignment()
  553.     {
  554.         return ((FlowLayout)panel2.getLayout()).getAlignment();
  555.     }
  556.  
  557.     /**
  558.      * Gets the index for a specific page.
  559.      * @param comp the page to get the index of
  560.      * @return the zero-relative index of the page or -1 if it is not found
  561.      * @exception IllegalArgumentException
  562.      * if the component is null
  563.      */
  564.     public synchronized int getPageIndex(Component comp)
  565.     {
  566.            //debug("getPageIndex");
  567.         if (comp == null)
  568.             throw new IllegalArgumentException();
  569.         return vPages.indexOf(comp);
  570.     }
  571.  
  572.     /**
  573.      * Show and select the page at the given index.
  574.      * The page is activated, ready for user input.
  575.      * @param index zero-relative index of the page to select
  576.      */
  577.     private void showPageAt(int index)
  578.     {
  579.         //debug("showPageAt: " + index);
  580.  
  581.         // Check index
  582.  
  583.         if (!isIndexValid(index))
  584.             return;
  585.  
  586.         if (index != curIndex)
  587.         {
  588.             hidePage();
  589.             showPage(getComponentAt(index));
  590.             curIndex = index;
  591.         }
  592.     }
  593.  
  594.     /**
  595.      * Hides the current component component.
  596.      * This is a low-level method.
  597.      * @param comp the Component to add and show
  598.      */
  599.     private void hidePage()
  600.     {
  601.         //debug("hidePage");
  602.         if (userComponent != null)
  603.         {
  604.             userComponent.hide();
  605.             userComponent = null;
  606.         }
  607.     }
  608.  
  609.     /**
  610.      * Adds the component to the base panel and shows it.
  611.      * This is a low-level method used by showPageAt and
  612.      * setComponentAt only.
  613.      * @param comp the Component to add and show
  614.      */
  615.     private void showPage(Component comp)
  616.     {
  617.         //debug("showPage");
  618.  
  619.         // Register the new component
  620.  
  621.         userComponent = comp;
  622.  
  623.         if (userComponent != null)
  624.         {
  625.             // Add the component to the panel1 only if it has not already be done
  626.  
  627.             Component[] comps = panel1.getComponents();
  628.             int l = comps.length;
  629.             int x;
  630.             for (x = 0; x < l; x++)
  631.             {
  632.                 if (comps[x] == userComponent)
  633.                     break;
  634.             }
  635.             if (x == l)
  636.                 panel1.add(userComponent, -1);
  637.  
  638.             // Show and request focus...
  639.  
  640.             userComponent.show();
  641.             userComponent.requestFocus();
  642.             //userComponent.invalidate();
  643.             validate();
  644.         }
  645.     }
  646.  
  647.     /**
  648.      * Check if the specified index is in a valid range.
  649.      * @param index the index to test
  650.      */
  651.     private boolean isIndexValid(int index)
  652.     {
  653.         return ((index >=0) && (index < getPageCount())) ? true : false;
  654.     }
  655.  
  656.     /**
  657.      * Removes a page and its associated component at the given index.
  658.      * The currently active page cannot be removed.
  659.      * @param index zero-relative index of the page
  660.      * @exception ArrayIndexOutOfBoundsException
  661.      * if the index is invalid
  662.      */
  663.     public synchronized void removePageAt(int index)
  664.     {
  665.         //debug("removePageAt: " + index);
  666.  
  667.         if (!isIndexValid(index))
  668.             throw new ArrayIndexOutOfBoundsException();
  669.  
  670.         int oldSize = getPageCount();
  671.  
  672.         // Check if the current page will be removed
  673.  
  674.         if (index == curIndex)
  675.         {
  676.             if (getPageCount() == 1)
  677.             {
  678.                 // It is the last remaining page
  679.  
  680.                 if (userComponent != null)
  681.                     userComponent.hide();
  682.                 curIndex = -1;
  683.                 if (controllerPrepared)
  684.                 {
  685.                     controller.doCancel();
  686.                     controllerPrepared = false;
  687.                 }
  688.             }
  689.             else if (curIndex == (getPageCount() - 1))
  690.             {
  691.                 // It is the last page index
  692.  
  693.                 showPageAt(curIndex - 1);
  694.             }
  695.             else
  696.             {
  697.                 showPageAt(curIndex + 1);
  698.             }
  699.         }
  700.  
  701.         // Remove everything
  702.  
  703.         Component p = getComponentAt(index);
  704.         panel1.remove(p);
  705.         vPages.removeElementAt(index);
  706.         //vLabels.removeElementAt(index);
  707.  
  708.         // Update current index
  709.  
  710.         if ((curIndex != -1) && (index < curIndex))
  711.             curIndex--;
  712.  
  713.         updateButtonsState();
  714.  
  715.         int newSize = getPageCount();
  716.         changes.firePropertyChange("PageCount", new Integer(oldSize), new Integer(newSize));
  717.     }
  718.  
  719.     /**
  720.      * Removes all pages and their associated components, clearing
  721.      * the Wizard entirely.
  722.      */
  723.     public synchronized void removeAllPages()
  724.     {
  725.         //debug("removeAllPages");
  726.         if (userComponent != null)
  727.                userComponent.hide();
  728.            userComponent = null;
  729.         vPages = new Vector();
  730.         //vLabels = new Vector();
  731.         curIndex = -1;
  732.         if (controllerPrepared)
  733.         {
  734.             controller.doCancel();
  735.                controllerPrepared = false;
  736.            }
  737.         panel1.removeAll();
  738.         updateButtonsState();
  739.     }
  740.  
  741.     /**
  742.      * Gets the number of pages in the Wizard.
  743.      * @return the number of pages currently in the Wizard
  744.      */
  745.     public int getPageCount()
  746.     {
  747.         //debug("getPageCount: " + vPages.size());
  748.         return vPages.size();
  749.     }
  750.  
  751.     /**
  752.      * Adds a listener for all event changes.
  753.      * @param listener the listener to add.
  754.      * @see #removePropertyChangeListener
  755.      */
  756.     public void addPropertyChangeListener(PropertyChangeListener listener)
  757.     {
  758.         //debug("addPropertyChangeListener");
  759.         changes.addPropertyChangeListener(listener);
  760.     }
  761.  
  762.     /**
  763.      * Removes a listener for all event changes.
  764.      * @param listener the listener to remove.
  765.      * @see #addPropertyChangeListener
  766.      */
  767.     public void removePropertyChangeListener(PropertyChangeListener listener)
  768.     {
  769.         //debug("removePropertyChangeListener");
  770.         changes.removePropertyChangeListener(listener);
  771.     }
  772.  
  773.     /**
  774.      * Adds a vetoable listener for all event changes.
  775.      * @param listener the listener to add.
  776.      * @see #removeVetoableChangeListener
  777.      */
  778.     public void addVetoableChangeListener(VetoableChangeListener listener)
  779.     {
  780.         //debug("addVetoableChangeListener");
  781.         vetos.addVetoableChangeListener(listener);
  782.     }
  783.  
  784.     /**
  785.      * Removes a vetoable listener for all event changes.
  786.      * @param listener the listener to remove.
  787.      * @see #addVetoableChangeListener
  788.      */
  789.     public void removeVetoableChangeListener(VetoableChangeListener listener)
  790.     {
  791.         //debug("removeVetoableChangeListener");
  792.         vetos.removeVetoableChangeListener(listener);
  793.     }
  794.  
  795.     /**
  796.      * Adds the specified action listener to receive action events from
  797.      * the Finish button.
  798.      *
  799.      * @see #removeActionListener
  800.      */
  801.     public void addActionListener(ActionListener l)
  802.     {
  803.         actionListeners.addElement(l);
  804.     }
  805.  
  806.     /**
  807.      * Removes the specified action listener so that it no longer receives
  808.      * action events from the Finish button.
  809.      *
  810.      * @see #addActionListener
  811.      */
  812.     public void removeActionListener(ActionListener l)
  813.     {
  814.         actionListeners.removeElement(l);
  815.     }
  816.  
  817.     /**
  818.      * Fires an action event to all registered listeners.
  819.      *
  820.      * @see #addActionListener
  821.      * @see #removeActionListener
  822.      */
  823.     private void fireActionEvent(String command)
  824.     {
  825.         ActionEvent event = new ActionEvent(this, 0, command);
  826.  
  827.         for (Enumeration e = actionListeners.elements(); e.hasMoreElements();)
  828.         {
  829.             ActionListener l = (ActionListener)e.nextElement();
  830.             l.actionPerformed(event);
  831.         }
  832.     }
  833.  
  834.     // Methods overriding Container methods
  835.  
  836.     /**
  837.      * Adds a component to the end of this container.
  838.      * This is a standard Java AWT method which gets called to add a
  839.      * component to a container. The specified component is added to
  840.      * the end of this container.
  841.      *
  842.      * @param comp the component to add
  843.      * @return the added component
  844.      * @see #remove
  845.      */
  846.     public Component add(Component comp)
  847.     {
  848.         //debug("add");
  849.         return add(comp,-1);
  850.     }
  851.  
  852.     /**
  853.      * Adds a component to the end of this container.
  854.      * This is a standard Java AWT method which gets called to add a
  855.      * component to a container. Typically, the specified component is added to
  856.      * this container at the given zero-relative position index. A
  857.      * position index of -1 would append the component to the end.
  858.      * <p>
  859.      * It is overridden so that it only appends to the internal panel.
  860.      *
  861.      * @param comp the component to add
  862.      * @param pos the zero-relative index at which to add the component or -1
  863.      * for end
  864.      * @return the added component
  865.      * @exception IllegalArgumentException
  866.      * if the component is null
  867.      * @see #remove
  868.      */
  869.     public synchronized Component add(Component comp, int pos)
  870.     {
  871.         //debug("add: " + pos);
  872.  
  873.         if (comp == null)
  874.             throw new IllegalArgumentException();
  875.  
  876.         int oldSize = getPageCount();
  877.         int index;
  878.  
  879.         // Add page and label
  880.  
  881.         if (pos == -1)
  882.         {
  883.             index = getPageCount();
  884.             vPages.addElement(comp);
  885.             //vLabels.addElement("");
  886.         }
  887.         else
  888.         {
  889.             index = pos;
  890.             vPages.insertElementAt(comp, index);
  891.             //vLabels.insertElementAt("", index);
  892.         }
  893.  
  894.         // Update current index
  895.  
  896.         if ((curIndex != -1) && (index <= curIndex))
  897.             curIndex++;
  898.  
  899.         // Try to show the new page
  900.  
  901.         if (java.beans.Beans.isDesignTime())
  902.         {
  903.             // Show the pages as they are added
  904.  
  905.             showPageAt(index);
  906.         }
  907.         else if (!controllerPrepared)//curIndex == -1
  908.         {
  909.             // Show the first page only
  910.  
  911.             initiateController(comp);
  912.         }
  913.  
  914.         // Set the buttons status
  915.  
  916.         updateButtonsState();
  917.  
  918.         // Fire the page count change
  919.  
  920.         int newSize = getPageCount();
  921.         changes.firePropertyChange("PageCount", new Integer(oldSize), new Integer(newSize));
  922.  
  923.         return comp;
  924.     }
  925.  
  926.     /**
  927.      * Takes no action.
  928.      * This is a standard Java AWT method which gets called to add a
  929.      * component to a container.
  930.      * It is overridden here to do nothing, so the user cannot change the way
  931.      * this container works.
  932.      *
  933.      * @param name the positioning directive for the layout manager (IGNORED)
  934.      * @param comp the component to add (IGNORED)
  935.      * @return the component parameter
  936.      */
  937.     public Component add(String name, Component comp)
  938.     {
  939.         //debug("add");
  940.         return comp;
  941.     }
  942.  
  943.     /**
  944.      * Removes the specified component from this container.
  945.      * This is a standard Java AWT method which gets called to remove a
  946.      * component from a container. When this happens the component's
  947.      * removeNotify() will also get called to indicate component removal.
  948.      *
  949.      * @param comp the component to remove
  950.      * @see #add
  951.      */
  952.     public synchronized void remove(Component comp)
  953.     {
  954.         //debug("remove");
  955.         if (comp == null)
  956.             return;
  957.         removePageAt(getPageIndex(comp));
  958.     }
  959.  
  960.        /**
  961.      * Returns the recommended dimensions to properly display this component.
  962.      * This is a standard Java AWT method which gets called to determine
  963.      * the recommended size of this component.
  964.      * <p>
  965.      * The returned size is large enough to display the biggest page component
  966.      * at its preferred size.
  967.      *
  968.      * @see #getMinimumSize
  969.      */
  970.     public Dimension getPreferredSize()
  971.     {
  972.         //debug("getPreferredSize");
  973.         return super.getPreferredSize();
  974.         /*
  975.         Dimension p = size();
  976.         Dimension m = getMinimumSize();
  977.         return new Dimension(Math.max(p.width, m.width), Math.max(p.height, m.height));
  978.         */
  979.     }
  980.  
  981.     /**
  982.      * Returns the minimum dimensions to properly display this component.
  983.      * This is a standard Java AWT method which gets called to determine
  984.      * the minimum size of this component.
  985.      * <p>
  986.      *
  987.      * @see #getPreferredSize
  988.      */
  989.     public Dimension getMinimumSize()
  990.     {
  991.         //debug("getMinimumSize");
  992.         return super.getMinimumSize();
  993.         //return new Dimension(20, 40);
  994.     }
  995.  
  996.     /**
  997.      * Tells this component that it has been added to a container.
  998.      * This is a standard Java AWT method which gets called by the AWT when
  999.      * this component is added to a container. Typically, it is used to
  1000.      * create this component's peer.
  1001.      *
  1002.      * It has been overridden here to hook-up event listeners.
  1003.      *
  1004.      * @see #removeNotify
  1005.      */
  1006.     public synchronized void addNotify()
  1007.     {
  1008.         //debug("addNotify");
  1009.         super.addNotify();
  1010.  
  1011.         // Hook up listeners
  1012.  
  1013.         if ((mouse == null) && java.beans.Beans.isDesignTime())
  1014.         {
  1015.             mouse = new Mouse();
  1016.             addMouseListener(mouse);
  1017.         }
  1018.  
  1019.         if (action == null)
  1020.         {
  1021.             action = new Action();
  1022.  
  1023.             previousButton.addActionListener(action);
  1024.             nextButton.addActionListener(action);
  1025.             finishButton.addActionListener(action);
  1026.             cancelButton.addActionListener(action);
  1027.             helpButton.addActionListener(action);
  1028.         }
  1029.     }
  1030.  
  1031.     /**
  1032.      * Tells this component that it is being removed from a container.
  1033.      * This is a standard Java AWT method which gets called by the AWT when
  1034.      * this component is removed from a container. Typically, it is used to
  1035.      * destroy the peers of this component and all its subcomponents.
  1036.      *
  1037.      * It has been overridden here to unhook event listeners.
  1038.      *
  1039.      * @see #addNotify
  1040.      */
  1041.     public synchronized void removeNotify()
  1042.     {
  1043.         //debug("removeNotify");
  1044.  
  1045.         //Unhook listeners
  1046.  
  1047.         if (mouse != null)
  1048.         {
  1049.             removeMouseListener(mouse);
  1050.             mouse = null;
  1051.         }
  1052.  
  1053.         if (action != null)
  1054.         {
  1055.             previousButton.removeActionListener(action);
  1056.             nextButton.removeActionListener(action);
  1057.             finishButton.removeActionListener(action);
  1058.             cancelButton.removeActionListener(action);
  1059.             helpButton.removeActionListener(action);
  1060.  
  1061.             action = null;
  1062.         }
  1063.  
  1064.         super.removeNotify();
  1065.     }
  1066.  
  1067.     /**
  1068.      * Takes no action.
  1069.      * This is a standard Java AWT method which gets called to specify
  1070.      * which layout manager should be used to layout the components in
  1071.      * standard containers.
  1072.      *
  1073.      * Since layout managers CANNOT BE USED with this container the standard
  1074.      * setLayout has been OVERRIDDEN for this container and does nothing.
  1075.      *
  1076.      * @param mgr the layout manager to use to layout this container's components
  1077.      * (IGNORED)
  1078.      * @see java.awt.Container#getLayout
  1079.      **/
  1080.     public void setLayout(LayoutManager mgr)
  1081.     {
  1082.         //debug("setLayout");
  1083.     }
  1084.  
  1085.     public LayoutManager getLayout()
  1086.     {
  1087.         //debug("getLayout");
  1088.         return null;
  1089.     }
  1090.  
  1091.     /**
  1092.      * Handles the laying out of components within this component.
  1093.      * This is a standard Java AWT method which gets called by the AWT
  1094.      * when this component is validated with the validate() method.
  1095.      *
  1096.      * @see java.awt.Container#validate
  1097.      */
  1098.     public void layout()
  1099.     {
  1100.         //debug("layout");
  1101.  
  1102.         super.layout();
  1103.  
  1104.         Rectangle r = panel1.getBounds();
  1105.  
  1106.         if (userComponent != null)
  1107.         {
  1108.             userComponent.setBounds(0, 0, r.width, r.height);
  1109.             //userComponent.invalidate();
  1110.             //userComponent.validate();
  1111.         }
  1112.     }
  1113.  
  1114.     // Inner classes
  1115.  
  1116.     /**
  1117.      * This is the Mouse Event handling innerclass. It handles mouse events
  1118.      * at design time only.
  1119.      */
  1120.     class Mouse extends MouseAdapter implements java.io.Serializable
  1121.     {
  1122.         public void mousePressed(MouseEvent e)
  1123.         {
  1124.             //System.err.println("Before mouse click...");
  1125.             //System.err.println("Mouse click: " + e.getPoint().x + ", " + e.getPoint().y);
  1126.  
  1127.             Component c = getComponentAt(e.getPoint());
  1128.  
  1129.             //System.err.println("  class: " + c.getClass().getName());
  1130.  
  1131.             if (c == panel2)
  1132.             {
  1133.                 e.translatePoint(-panel2.getLocation().x, -panel2.getLocation().y);
  1134.                 c = panel2.getComponentAt(e.getPoint());
  1135.                 //System.err.println("  panel2: " + e.getPoint());
  1136.  
  1137.                 if (c == panel3)
  1138.                 {
  1139.                     e.translatePoint(-panel3.getLocation().x, -panel3.getLocation().y);
  1140.                     c = panel3.getComponentAt(e.getPoint());
  1141.                     //System.err.println("  panel3: " + e.getPoint());
  1142.  
  1143.                     if (c == previousButton)
  1144.                         goPrevious();
  1145.                     else if (c == nextButton)
  1146.                         goNext();
  1147.                     else
  1148.                         ;//System.err.println("none");
  1149.                 }
  1150.                 else if (c == panel4)
  1151.                 {
  1152.                     e.translatePoint(-panel4.getLocation().x, -panel4.getLocation().y);
  1153.                     c = panel4.getComponentAt(e.getPoint());
  1154.                     //System.err.println("  panel4: " + e.getPoint());
  1155.  
  1156.                     if (c == cancelButton)
  1157.                         ;//System.err.println("cancel");
  1158.                     else if (c == helpButton)
  1159.                         ;//System.err.println("help");
  1160.                     else
  1161.                         ;//System.err.println("none");
  1162.                 }
  1163.                 else
  1164.                 {
  1165.                     //System.err.println("none");
  1166.                 }
  1167.             }
  1168.         }
  1169.     }
  1170.  
  1171.     /**
  1172.      * This is the Action Event handling innerclass.
  1173.      */
  1174.     class Action implements ActionListener, java.io.Serializable
  1175.     {
  1176.         public void actionPerformed(ActionEvent e)
  1177.         {
  1178.             Object o = e.getSource();
  1179.  
  1180.             if (o == previousButton)
  1181.                 goPrevious();
  1182.             else if ((o == nextButton) && (!combinedButton || !controller.isFinishEnabled()))
  1183.                 goNext();
  1184.             else if ((o == finishButton) || ((o == nextButton) && combinedButton && controller.isFinishEnabled()))
  1185.                 doFinish();
  1186.             else if (o == cancelButton)
  1187.                 doCancel();
  1188.             else if (o == helpButton)
  1189.                 doHelp();
  1190.         }
  1191.     }
  1192.  
  1193.     /**
  1194.      * Performs the actions needed when the Finish button is pressed.
  1195.      *
  1196.      * @see #doCancel
  1197.      * @see #doHelp
  1198.      */
  1199.     public void doFinish()
  1200.     {
  1201.         //debug("doFinish");
  1202.  
  1203.         Component source = (curIndex != -1) ? getComponentAt(curIndex) : null;
  1204.  
  1205.         if (source == null)
  1206.             return;
  1207.  
  1208.         if (controller.validatePage(source, null, WizardController.FINISH))
  1209.         {
  1210.             controller.doFinish();
  1211.             controllerPrepared = false;
  1212.             fireActionEvent("Finish");
  1213.         }
  1214.     }
  1215.  
  1216.     /**
  1217.      * Performs the actions needed when the Cancel button is pressed.
  1218.      *
  1219.      * @see #doFinish
  1220.      * @see #doHelp
  1221.      */
  1222.     public void doCancel()
  1223.     {
  1224.         //debug("doCancel");
  1225.  
  1226.         Component source = (curIndex != -1) ? getComponentAt(curIndex) : null;
  1227.  
  1228.         if (source == null)
  1229.             return;
  1230.  
  1231.         if (controller.validatePage(source, null, WizardController.CANCEL))
  1232.         {
  1233.             controller.doCancel();
  1234.             controllerPrepared = false;
  1235.             fireActionEvent("Cancel");
  1236.         }
  1237.     }
  1238.  
  1239.     /**
  1240.      * Performs the actions needed when the Help button is pressed.
  1241.      *
  1242.      * @see #doFinish
  1243.      * @see #doCancel
  1244.      */
  1245.     public void doHelp()
  1246.     {
  1247.         //debug("doHelp");
  1248.  
  1249.         Component source = (curIndex != -1) ? getComponentAt(curIndex) : null;
  1250.  
  1251.         if (source == null)
  1252.             return;
  1253.  
  1254.         if (controller.validatePage(source, null, WizardController.HELP))
  1255.         {
  1256.             controller.doHelp();
  1257.             fireActionEvent("Help");
  1258.         }
  1259.     }
  1260.  
  1261.     // Implementation of the WizardInterface interface
  1262.  
  1263.     /**
  1264.      * Sets the index of the page to show when goPrevious is called.
  1265.      *
  1266.      * @see #setNextPageIndex
  1267.      * @see #goPrevious
  1268.      * @see WizardController
  1269.      * @see SimpleWizardController
  1270.      */
  1271.     public void setPreviousPageIndex(int index)
  1272.     {
  1273.         //debug("setPreviousPageIndex");
  1274.         controller.setPreviousPageIndex(index);
  1275.     }
  1276.  
  1277.     /**
  1278.      * Sets the index of the page to show when goNext is called.
  1279.      *
  1280.      * @see #setPreviousPageIndex
  1281.      * @see #goNext
  1282.      * @see WizardController
  1283.      * @see SimpleWizardController
  1284.      */
  1285.     public void setNextPageIndex(int index)
  1286.     {
  1287.         //debug("setNextPageIndex");
  1288.         controller.setNextPageIndex(index);
  1289.     }
  1290.  
  1291.     /**
  1292.      * Sets the page to show when goPrevious is called.
  1293.      *
  1294.      * @see #setNextPageIndex
  1295.      * @see #goPrevious
  1296.      * @see WizardController
  1297.      * @see SimpleWizardController
  1298.      */
  1299.     public void setPreviousPage(Component comp)
  1300.     {
  1301.         controller.setPreviousPage(comp);
  1302.     }
  1303.  
  1304.     /**
  1305.      * Sets the page to show when goNext is called.
  1306.      *
  1307.      * @see #setPreviousPageIndex
  1308.      * @see #goNext
  1309.      * @see WizardController
  1310.      * @see SimpleWizardController
  1311.      */
  1312.     public void setNextPage(Component comp)
  1313.     {
  1314.         controller.setNextPage(comp);
  1315.     }
  1316.  
  1317.     /**
  1318.      * Go to the previous page.
  1319.      * If a page has been selected with setPreviousPage it will be used.
  1320.      * If a page index has been selected with setPreviousPageIndex it will be
  1321.      * used unless a page has been specified. The chain information will be
  1322.      * reset.
  1323.      *
  1324.      * @see #goNext
  1325.      * @see #setPreviousPage
  1326.      * @see #setPreviousPageIndex
  1327.      */
  1328.     public synchronized void goPrevious()
  1329.     {
  1330.         //debug("goPrevious");
  1331.  
  1332.         // Determines the source and target
  1333.  
  1334.         Component source = (curIndex != -1) ? getComponentAt(curIndex) : null;
  1335.         Component target = controller.getPreviousPage();
  1336.  
  1337.         //if (target == null)
  1338.         //    return;
  1339.  
  1340.         int index = getPageIndex(target);
  1341.         // Validate the current page and continue if validation succeeded
  1342.  
  1343.         if (curIndex != -1)
  1344.         {
  1345.             if (!controller.validatePage(source, target, WizardController.PREVIOUS))
  1346.                 return;
  1347.         }
  1348.  
  1349.         // Determines the real target and continue if the new target is valid
  1350.  
  1351.         target = controller.getPreviousPage();
  1352.  
  1353.         if (target == null)
  1354.             return;
  1355.  
  1356.         index = getPageIndex(target);
  1357.  
  1358.         // Hide the current page
  1359.  
  1360.         if (curIndex != -1)
  1361.         {
  1362.             hidePage();
  1363.             controller.pageHidden(source);
  1364.         }
  1365.  
  1366.         // Prepare the controller if needed
  1367.  
  1368.         /*
  1369.         if (!controllerPrepared)
  1370.         {
  1371.             controller.doPrepare();
  1372.             controllerPrepared = true;
  1373.         }
  1374.         */
  1375.  
  1376.         // Prepare the new page
  1377.  
  1378.         controller.resetChainInfo();
  1379.         controller.preparePage(target, WizardController.PREVIOUS);
  1380.  
  1381.         // Show the new page
  1382.  
  1383.         showPage(target);
  1384.         curIndex = index;
  1385.         controller.pageShown(target);
  1386.  
  1387.         // Set state information
  1388.  
  1389.         updateButtonsState();
  1390.     }
  1391.  
  1392.     /**
  1393.      * Go to the next page.
  1394.      * If a page has been selected with setNextPage it will be used.
  1395.      * If a page index has been selected with setNextPageIndex it will be
  1396.      * used unless a page has been specified. The chain information will be
  1397.      * reset.
  1398.      *
  1399.      * @see #goPrevious
  1400.      * @see #setNextPage
  1401.      * @see #setNextPageIndex
  1402.      */
  1403.     public synchronized void goNext()
  1404.     {
  1405.         //debug("goNext");
  1406.  
  1407.         // Determines the source and target
  1408.  
  1409.         Component source = (curIndex != -1) ? getComponentAt(curIndex) : null;
  1410.         Component target = controller.getNextPage();
  1411.  
  1412.         //if (target == null)
  1413.         //    return;
  1414.  
  1415.         int index = getPageIndex(target);
  1416.  
  1417.         // Validate the current page and continue if validation succeeded
  1418.  
  1419.         if (curIndex != -1)
  1420.         {
  1421.             if (!controller.validatePage(source, target, WizardController.NEXT))
  1422.                 return;
  1423.         }
  1424.  
  1425.         // Determines the real target and continue if the new target is valid
  1426.  
  1427.         target = controller.getNextPage();
  1428.  
  1429.         if (target == null)
  1430.             return;
  1431.  
  1432.         index = getPageIndex(target);
  1433.  
  1434.         // Hide the current page
  1435.  
  1436.         if (curIndex != -1)
  1437.         {
  1438.             hidePage();
  1439.             controller.pageHidden(source);
  1440.         }
  1441.  
  1442.         // Prepare the controller if needed
  1443.  
  1444.         /*
  1445.         if (!controllerPrepared)
  1446.         {
  1447.             controller.doPrepare();
  1448.             controllerPrepared = true;
  1449.         }
  1450.         */
  1451.  
  1452.         // Prepare the new page
  1453.  
  1454.         controller.resetChainInfo();
  1455.         controller.preparePage(target, WizardController.NEXT);
  1456.  
  1457.         // Show the new page
  1458.  
  1459.         showPage(target);
  1460.         curIndex = index;
  1461.         controller.pageShown(target);
  1462.  
  1463.         // Set state information
  1464.  
  1465.         updateButtonsState();
  1466.     }
  1467.  
  1468.     /**
  1469.      * Sets a default status for the Previous, Next and Finish buttons.
  1470.      *
  1471.      * @see #setPreviousEnabled
  1472.      * @see #setNextEnabled
  1473.      * @see #setFinishEnabled
  1474.      * @see #setCancelEnabled
  1475.      * @see #setHelpEnabled
  1476.      */
  1477.     public synchronized void updateButtonsState()
  1478.     {
  1479.         //debug("updateButtonsState");
  1480.  
  1481.         /*
  1482.         setPreviousEnabled(controller.isPreviousEnabled());
  1483.         setNextEnabled(controller.isNextEnabled());
  1484.         setFinishEnabled(controller.isFinishEnabled());
  1485.         setCancelEnabled(controller.isCancelEnabled());
  1486.         setHelpEnabled(controller.isHelpEnabled());
  1487.         */
  1488.         previousButton.setEnabled(controller.isPreviousEnabled());
  1489.         if (combinedButton)
  1490.         {
  1491.             updateCombinedButton();
  1492.         }
  1493.         else
  1494.         {
  1495.             nextButton.setEnabled(controller.isNextEnabled());
  1496.             finishButton.setEnabled(controller.isFinishEnabled());
  1497.         }
  1498.         cancelButton.setEnabled(controller.isCancelEnabled());
  1499.         helpButton.setEnabled(controller.isHelpEnabled());
  1500.     }
  1501.  
  1502.     private void updateCombinedButton()
  1503.     {
  1504.         String ntext = NEXT_LABEL;
  1505.         boolean nstatus = true;
  1506.         boolean nextEnabled = controller.isNextEnabled();
  1507.         boolean finishEnabled = controller.isFinishEnabled();
  1508.  
  1509.         if (!nextEnabled && !finishEnabled)
  1510.             nstatus = false;
  1511.         else if (!nextEnabled && finishEnabled)
  1512.             ntext = FINISH_LABEL;
  1513.  
  1514.         nextButton.setLabel(ntext);
  1515.         nextButton.setEnabled(nstatus);
  1516.     }
  1517.  
  1518.     /**
  1519.      * Enables or disables the Previous button.
  1520.      * @param status <code>true</code> to enable the button
  1521.      *
  1522.      * @see #setNextEnabled
  1523.      * @see #setFinishEnabled
  1524.      * @see #setCancelEnabled
  1525.      * @see #setHelpEnabled
  1526.      */
  1527.     public void setPreviousEnabled(boolean status)
  1528.     {
  1529.         controller.setPreviousEnabled(status);
  1530.         //previousButton.setEnabled(status);
  1531.     }
  1532.  
  1533.     /**
  1534.      * Enables or disables the Next button.
  1535.      * @param status <code>true</code> to enable the button
  1536.      *
  1537.      * @see #setPreviousEnabled
  1538.      * @see #setFinishEnabled
  1539.      * @see #setCancelEnabled
  1540.      * @see #setHelpEnabled
  1541.      */
  1542.     public void setNextEnabled(boolean status)
  1543.     {
  1544.         controller.setNextEnabled(status);
  1545.         /*
  1546.         nextEnabled = status;
  1547.         if (combinedButton)
  1548.             updateCombinedButton();
  1549.         else
  1550.             nextButton.setEnabled(status);
  1551.         */
  1552.     }
  1553.  
  1554.     /**
  1555.      * Enables or disables the Finish button.
  1556.      * @param status <code>true</code> to enable the button
  1557.      *
  1558.      * @see #setPreviousEnabled
  1559.      * @see #setNextEnabled
  1560.      * @see #setCancelEnabled
  1561.      * @see #setHelpEnabled
  1562.      */
  1563.     public void setFinishEnabled(boolean status)
  1564.     {
  1565.         controller.setFinishEnabled(status);
  1566.         /*
  1567.         finishEnabled = status;
  1568.         if (combinedButton)
  1569.             updateCombinedButton();
  1570.         else
  1571.             finishButton.setEnabled(status);
  1572.         */
  1573.     }
  1574.  
  1575.     /**
  1576.      * Enables or disables the Cancel button.
  1577.      * @param status <code>true</code> to enable the button
  1578.      *
  1579.      * @see #setPreviousEnabled
  1580.      * @see #setNextEnabled
  1581.      * @see #setFinishEnabled
  1582.      * @see #setHelpEnabled
  1583.      */
  1584.     public void setCancelEnabled(boolean status)
  1585.     {
  1586.         controller.setCancelEnabled(status);
  1587.         //cancelButton.setEnabled(status);
  1588.     }
  1589.  
  1590.     /**
  1591.      * Enables or disables the Help button.
  1592.      * @param status <code>true</code> to enable the button
  1593.      *
  1594.      * @see #setPreviousEnabled
  1595.      * @see #setNextEnabled
  1596.      * @see #setFinishEnabled
  1597.      * @see #setCancelEnabled
  1598.      */
  1599.     public void setHelpEnabled(boolean status)
  1600.     {
  1601.         controller.setHelpEnabled(status);
  1602.         //helpButton.setEnabled(status);
  1603.     }
  1604.  
  1605.     // Member variables
  1606.  
  1607.     private WizardController controller;
  1608.  
  1609.     private boolean controllerPrepared = false;
  1610.  
  1611.     private VetoableChangeSupport vetos = new VetoableChangeSupport(this);
  1612.     private PropertyChangeSupport changes = new PropertyChangeSupport(this);
  1613.     private Vector vPages;
  1614.  
  1615.     private int curIndex = -1;
  1616.     private Component userComponent = null;
  1617.  
  1618.     private Action action;
  1619.     private Mouse mouse;
  1620.  
  1621.     /**
  1622.      * The panel that contains the pages.
  1623.      */
  1624.     protected Panel panel1;
  1625.     /**
  1626.      * The horizontal line separating the pages from the navigation buttons.
  1627.      */
  1628.     protected symantec.itools.awt.shape.HorizontalLine horizontalLine1;
  1629.     /**
  1630.      * The top-level panel below the horizontal line.
  1631.      */
  1632.     protected Panel panel2;
  1633.     /**
  1634.      * The panel that contains the navigation (Back,Next,Finish) buttons.
  1635.      */
  1636.     protected Panel panel3;
  1637.     /**
  1638.      * The panel that contains the Cancel and Help buttons.
  1639.      */
  1640.     protected Panel panel4;
  1641.     /**
  1642.      * The Back button.
  1643.      */
  1644.     protected Button previousButton;
  1645.     /**
  1646.      * The Next button.
  1647.      */
  1648.     protected Button nextButton;
  1649.     /**
  1650.      * The Finish button.
  1651.      */
  1652.     protected Button finishButton;
  1653.     /**
  1654.      * The Cancel button.
  1655.      */
  1656.     protected Button cancelButton;
  1657.     /**
  1658.      * The Help button.
  1659.      */
  1660.     protected Button helpButton;
  1661.  
  1662.     private boolean helpButtonVisible = true;
  1663.     private boolean combinedButton = false;
  1664.  
  1665.     //private boolean nextEnabled = false;
  1666.     //private boolean finishEnabled = false;
  1667.  
  1668.     private Vector actionListeners;
  1669.  
  1670.     /**
  1671.      * The text used for the Back button.
  1672.      */
  1673.     protected final static String PREVIOUS_LABEL = "< Back";
  1674.     /**
  1675.      * The text used for the Next button.
  1676.      */
  1677.     protected final static String NEXT_LABEL = "Next >";
  1678.     /**
  1679.      * The text used for the Finish button.
  1680.      */
  1681.     protected final static String FINISH_LABEL = "Finish";
  1682.     /**
  1683.      * The text used for the Cancel button.
  1684.      */
  1685.     protected final static String CANCEL_LABEL = "Cancel";
  1686.     /**
  1687.      * The text used for the Help button.
  1688.      */
  1689.     protected final static String HELP_LABEL = "Help";
  1690.  
  1691.     /**
  1692.      * Constant value indicating a layout aligned to the left.
  1693.      */
  1694.     public final static int LEFT = FlowLayout.LEFT;
  1695.     /**
  1696.      * Constant value indicating a layout centered.
  1697.      */
  1698.     public final static int CENTER = FlowLayout.CENTER;
  1699.     /**
  1700.      * Constant value indicating a layout aligned to the right.
  1701.      */
  1702.     public final static int RIGHT = FlowLayout.RIGHT;
  1703.  
  1704.     // Debug
  1705.  
  1706.     /*
  1707.     private void debug(String s) {
  1708.         fdebug("Wizard: " + s);
  1709.     }
  1710.  
  1711.     protected void fdebug(String s) {
  1712.         if (false)
  1713.         {
  1714.             try {
  1715.                 FileWriter fw = new FileWriter("d:\\temp\\w.log", true);
  1716.                 fw.write(s + "\n");
  1717.                 fw.close();
  1718.             } catch(IOException e) {
  1719.                 throw new RuntimeException("IOException caught in fdebug: " + e.getMessage());
  1720.             }
  1721.         }
  1722.         if (false)
  1723.             System.err.println(s);
  1724.     }
  1725.     */
  1726. }
  1727.