001    package com.sptci.system;
002    
003    import nextapp.echo2.app.event.ActionEvent;
004    
005    import com.sptci.echo2.Listener;
006    import com.sptci.util.PasswordGenerator;
007    
008    /**
009     * The action listener that is used to update {@link PasswordPane#suggest}
010     * with a recommended randomly generated password.
011     *
012     * <p>Copyright 2007 Sans Pareil Technologies, Inc.</p>
013     * @author Rakesh Vidyadharan 2007-04-23
014     * @version $Id: SuggestPasswordListener.java 3135 2007-04-24 01:16:30Z rakesh $
015     */
016    class SuggestPasswordListener extends Listener<PasswordController>
017    {
018      /**
019       * The length of the password that is to be generated.
020       *
021       * {@value}
022       */
023      public static final int PASSWORD_LENGTH = 8;
024    
025      /**
026       * Create a new instance of the listener backed by the specified
027       * controller.
028       *
029       * @param controller The controller to use to access the view that is
030       *   to be updated.
031       */
032      SuggestPasswordListener( PasswordController controller )
033      {
034        super( controller );
035      }
036    
037      /**
038       * The action listener implementation.  Updates {@link 
039       * PasswordPane#suggest} with a recommended value.
040       *
041       * @see PasswordController#setSuggest
042       * @see com.sptci.util.PasswordGenerator#generate( int )
043       */
044      public void actionPerformed( ActionEvent event )
045      {
046        controller.setSuggest(
047            new String( new PasswordGenerator().generate( PASSWORD_LENGTH ) ) );
048      }
049    }