Coverage report

  %line %branch
com.nexes.wizard.WizardController
0% 
0% 

 1  
 package com.nexes.wizard;
 2  
 
 3  
 import java.awt.event.ActionListener;
 4  
 
 5  
 /**
 6  
  * This class is responsible for reacting to events generated by pushing any of the
 7  
  * three buttons, 'Next', 'Previous', and 'Cancel.' Based on what button is pressed,
 8  
  * the controller will update the model to show a new panel and reset the state of
 9  
  * the buttons as necessary.
 10  
  */
 11  
 public class WizardController implements ActionListener {
 12  
     
 13  
     private Wizard wizard;
 14  
     
 15  
     /**
 16  
      * This constructor accepts a reference to the Wizard component that created it,
 17  
      * which it uses to update the button components and access the WizardModel.
 18  
      * @param w A callback to the Wizard component that created this controller.
 19  
      */    
 20  0
     public WizardController(Wizard w) {
 21  0
         wizard = w;
 22  0
     }
 23  
 
 24  
     /**
 25  
      * Calling method for the action listener interface. This class listens for actions
 26  
      * performed by the buttons in the Wizard class, and calls methods below to determine
 27  
      * the correct course of action.
 28  
      * @param evt The ActionEvent that occurred.
 29  
      */    
 30  
     public void actionPerformed(java.awt.event.ActionEvent evt) {
 31  
         
 32  0
         if (evt.getActionCommand().equals(Wizard.CANCEL_BUTTON_ACTION_COMMAND))
 33  0
             cancelButtonPressed();
 34  0
         else if (evt.getActionCommand().equals(Wizard.BACK_BUTTON_ACTION_COMMAND))
 35  0
             backButtonPressed();
 36  0
         else if (evt.getActionCommand().equals(Wizard.NEXT_BUTTON_ACTION_COMMAND))
 37  0
             nextButtonPressed();
 38  
         
 39  0
     }
 40  
     
 41  
     
 42  
     
 43  
     private void cancelButtonPressed() {
 44  
         
 45  0
         wizard.close(Wizard.CANCEL_RETURN_CODE);
 46  0
     }
 47  
 
 48  
     private void nextButtonPressed() {
 49  
  
 50  0
         WizardModel model = wizard.getModel();
 51  0
         WizardPanelDescriptor descriptor = model.getCurrentPanelDescriptor();
 52  
         
 53  
         //  If it is a finishable panel, close down the dialog. Otherwise,
 54  
         //  get the ID that the current panel identifies as the next panel,
 55  
         //  and display it.
 56  
         
 57  0
         Object nextPanelDescriptor = descriptor.getNextPanelDescriptor();
 58  
         
 59  0
         if (nextPanelDescriptor instanceof WizardPanelDescriptor.FinishIdentclass="keyword">ifier) {
 60  0
             wizard.close(Wizard.FINISH_RETURN_CODE);
 61  0
         } else {        
 62  0
             wizard.setCurrentPanel(nextPanelDescriptor);
 63  
         }
 64  
         
 65  0
     }
 66  
 
 67  
     private void backButtonPressed() {
 68  
  
 69  0
         WizardModel model = wizard.getModel();
 70  0
         WizardPanelDescriptor descriptor = model.getCurrentPanelDescriptor();
 71  
  
 72  
         //  Get the descriptor that the current panel identifies as the previous
 73  
         //  panel, and display it.
 74  
         
 75  0
         Object backPanelDescriptor = descriptor.getBackPanelDescriptor();        
 76  0
         wizard.setCurrentPanel(backPanelDescriptor);
 77  
         
 78  0
     }
 79  
 
 80  
     
 81  
     void resetButtonsToPanelRules() {
 82  
     
 83  
         //  Reset the buttons to support the original panel rules,
 84  
         //  including whether the next or back buttons are enabled or
 85  
         //  disabled, or if the panel is finishable.
 86  
         
 87  0
         WizardModel model = wizard.getModel();
 88  0
         WizardPanelDescriptor descriptor = model.getCurrentPanelDescriptor();
 89  
         
 90  0
         model.setCancelButtonText(Wizard.CANCEL_TEXT);
 91  0
         model.setCancelButtonIcon(Wizard.CANCEL_ICON);
 92  
         
 93  
         //  If the panel in question has another panel behind it, enable
 94  
         //  the back button. Otherwise, disable it.
 95  
         
 96  0
         model.setBackButtonText(Wizard.BACK_TEXT);
 97  0
         model.setBackButtonIcon(Wizard.BACK_ICON);
 98  
         
 99  0
         if (descriptor.getBackPanelDescriptor() != null)
 100  0
             model.setBackButtonEnabled(Boolean.TRUE);
 101  
         else
 102  0
             model.setBackButtonEnabled(Boolean.FALSE);
 103  
 
 104  
         //  If the panel in question has one or more panels in front of it,
 105  
         //  enable the next button. Otherwise, disable it.
 106  
  
 107  0
         if (descriptor.getNextPanelDescriptor() != null)
 108  0
             model.setNextFinishButtonEnabled(Boolean.TRUE);
 109  
         else
 110  0
             model.setNextFinishButtonEnabled(Boolean.FALSE);
 111  
  
 112  
         //  If the panel in question is the last panel in the series, change
 113  
         //  the Next button to Finish. Otherwise, set the text back to Next.
 114  
         
 115  0
         if (descriptor.getNextPanelDescriptor() instanceof WizardPanelDescriptor.FinishIdentclass="keyword">ifier) {
 116  0
             model.setNextFinishButtonText(Wizard.FINISH_TEXT);
 117  0
             model.setNextFinishButtonIcon(Wizard.FINISH_ICON);
 118  0
         } else {
 119  0
             model.setNextFinishButtonText(Wizard.NEXT_TEXT);
 120  0
             model.setNextFinishButtonIcon(Wizard.NEXT_ICON);
 121  
         }
 122  
         
 123  0
     }
 124  
     
 125  
     
 126  
 }

This report is generated by jcoverage, Maven and Maven JCoverage Plugin.