| %line | %branch | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| com.aimedia.ui.CancelAction | 
  | 
    
  | 
  
| 1 |  /* | 
    |
| 2 |   ******************************************************************************* | 
    |
| 3 |   * Copyright (c) 2005 Chris Rose and AIMedia | 
    |
| 4 |   * All rights reserved. CancelAction and the accompanying materials | 
    |
| 5 |   * are made available under the terms of the Common Public License v1.0 | 
    |
| 6 |   * which accompanies this distribution, and is available at | 
    |
| 7 |   * http://www.eclipse.org/legal/cpl-v10.html | 
    |
| 8 |   *  | 
    |
| 9 |   * Contributors: | 
    |
| 10 |   *     Chris Rose | 
    |
| 11 |   *******************************************************************************/ | 
    |
| 12 |  package com.aimedia.ui; | 
    |
| 13 | ||
| 14 |  import java.awt.event.*; | 
    |
| 15 | ||
| 16 |  import javax.swing.*; | 
    |
| 17 | ||
| 18 |  import org.apache.log4j.Logger; | 
    |
| 19 | ||
| 20 |  /** | 
    |
| 21 |   * Generic Action implementation for cancelling a UI action.  | 
    |
| 22 |   * @author Chris Rose | 
    |
| 23 |   */ | 
    |
| 24 | public class CancelAction extends AbstractAction {  | 
    |
| 25 |      /** | 
    |
| 26 |       * Logger for this class | 
    |
| 27 |       */ | 
    |
| 28 | 0 |      private static final Logger logger = Logger.getLogger(CancelAction.class); | 
    
| 29 | ||
| 30 |      private ICancellable target; | 
    |
| 31 | ||
| 32 |      /** | 
    |
| 33 |       * Create a new cancel action handling the supplied target. | 
    |
| 34 |       * @param target the <code>ICancellable</code> that will receive the cancel | 
    |
| 35 |       * action | 
    |
| 36 |       */ | 
    |
| 37 |      public CancelAction(ICancellable target) { | 
    |
| 38 | 0 |          super("Cancel"); | 
    
| 39 | 0 |  		putValue(MNEMONIC_KEY, new Integer(KeyEvent.VK_C)); | 
    
| 40 | 0 |          if (null == target) { | 
    
| 41 | 0 |              throw new IllegalArgumentException("Must have a non-null target"); | 
    
| 42 | }  | 
    |
| 43 | 0 |          this.target = target; | 
    
| 44 | 0 |  		putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_C, InputEvent.CTRL_DOWN_MASK)); | 
    
| 45 | 0 |      } | 
    
| 46 | ||
| 47 |      /* (non-Javadoc) | 
    |
| 48 |       * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent) | 
    |
| 49 |       */ | 
    |
| 50 | public void actionPerformed(ActionEvent e) {  | 
    |
| 51 | 0 |          if (logger.isDebugEnabled()) { | 
    
| 52 | 0 |              logger.debug("actionPerformed() - doCancel invoked on " + target.getClass().getName()); | 
    
| 53 | }  | 
    |
| 54 | ||
| 55 | 0 |          target.doCancel(); | 
    
| 56 | 0 |      } | 
    
| 57 | ||
| 58 | }  | 
    
| This report is generated by jcoverage, Maven and Maven JCoverage Plugin. |