Coverage Report - net.wotonomy.ui.swing.DisplayGroupActionAssociation
 
Classes in this File Line Coverage Branch Coverage Complexity
DisplayGroupActionAssociation
0% 
0% 
2.5
 
 1  
 /*
 2  
 Wotonomy: OpenStep design patterns for pure Java applications.
 3  
 Copyright (C) 2000 Intersect Software Corporation
 4  
 
 5  
 This library is free software; you can redistribute it and/or
 6  
 modify it under the terms of the GNU Lesser General Public
 7  
 License as published by the Free Software Foundation; either
 8  
 version 2.1 of the License, or (at your option) any later version.
 9  
 
 10  
 This library is distributed in the hope that it will be useful,
 11  
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 12  
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 13  
 Lesser General Public License for more details.
 14  
 
 15  
 You should have received a copy of the GNU Lesser General Public
 16  
 License along with this library; if not, see http://www.gnu.org
 17  
 */
 18  
 
 19  
 package net.wotonomy.ui.swing;
 20  
 
 21  
 import java.awt.event.ActionEvent;
 22  
 import java.awt.event.ActionListener;
 23  
 
 24  
 import net.wotonomy.foundation.NSArray;
 25  
 import net.wotonomy.foundation.NSSelector;
 26  
 import net.wotonomy.foundation.internal.WotonomyException;
 27  
 import net.wotonomy.ui.EODisplayGroup;
 28  
 
 29  
 /**
 30  
 * ActionAssociation binds any ActionEvent broadcaster 
 31  
 * (typically Buttons and the like) to a display group,
 32  
 * but invokes actions directly on the bound display
 33  
 * group rather than the selected objects.  
 34  
 * Bindings are: 
 35  
 * <ul>
 36  
 * <li>action: a method to be invoked on the bound display group.
 37  
 * If the argument aspect is bound, the method must take 
 38  
 * one argument.  Otherwise, the method must take no arguments.</li> 
 39  
 * <li>argument: the attribute of the selected object(s) (possibly 
 40  
 * from a different display group) that will be used as an argument 
 41  
 * to the action method</li> 
 42  
 * <li>enabled: a boolean property that determines whether
 43  
 * the controlled component is enabled</li> 
 44  
 * <li>visible: a boolean property that determines whether
 45  
 * the controlled component is visible</li> 
 46  
 * </ul>
 47  
 *
 48  
 * @author michael@mpowers.net
 49  
 * @author $Author: cgruber $
 50  
 * @version $Revision: 904 $
 51  
 */
 52  0
 public class DisplayGroupActionAssociation extends ActionAssociation
 53  
 {
 54  0
     static final NSArray aspects = 
 55  0
         new NSArray( new Object[] {
 56  0
             ActionAspect, ArgumentAspect, EnabledAspect, VisibleAspect
 57  
         } );
 58  0
     static final NSArray aspectSignatures = 
 59  0
         new NSArray( new Object[] {
 60  0
             AttributeToOneAspectSignature, 
 61  0
                         AttributeToOneAspectSignature, 
 62  0
                         AttributeToOneAspectSignature, 
 63  0
                         AttributeToOneAspectSignature 
 64  
         } );
 65  0
     static final NSArray objectKeysTaken = 
 66  0
         new NSArray( new Object[] {
 67  0
             "target" 
 68  
         } );
 69  
                 
 70  0
         static NSSelector addActionListener =
 71  0
                 new NSSelector( "addActionListener", 
 72  0
                 new Class[] { ActionListener.class } );
 73  0
         static NSSelector removeActionListener =
 74  0
                 new NSSelector( "removeActionListener", 
 75  0
                 new Class[] { ActionListener.class } );
 76  
 
 77  
     /**
 78  
     * Constructor specifying the object to be controlled by this
 79  
     * association.  Does not establish connection.
 80  
     */
 81  
     public DisplayGroupActionAssociation ( Object anObject )
 82  
     {
 83  0
         super( anObject );
 84  0
     }
 85  
     
 86  
     // interface ActionListener
 87  
     
 88  
     public void actionPerformed( ActionEvent evt )
 89  
     {
 90  0
                 EODisplayGroup actionDisplayGroup = null;
 91  0
                 String actionKey = null;
 92  
                 
 93  
                 // action aspect
 94  0
                 actionDisplayGroup = displayGroupForAspect( ActionAspect );
 95  0
                 if ( actionDisplayGroup != null )
 96  
                 {
 97  0
                         actionKey = displayGroupKeyForAspect( ActionAspect );
 98  
 
 99  
                         //TODO: argument aspect not implemented
 100  
 
 101  
                         try
 102  
                         {
 103  0
                                 NSSelector.invoke( actionKey, actionDisplayGroup );
 104  
                         }
 105  0
                         catch ( Exception exc )
 106  
                         {
 107  0
                                 throw new WotonomyException( "DisplayGroupActionAssociation: " 
 108  0
                                         + "error invoking action: " + actionKey, exc );
 109  0
                         }
 110  
                 }
 111  0
         }
 112  
         
 113  
 }
 114  
 
 115  
 /*
 116  
  * $Log$
 117  
  * Revision 1.2  2006/02/18 23:19:05  cgruber
 118  
  * Update imports and maven dependencies.
 119  
  *
 120  
  * Revision 1.1  2006/02/16 13:22:22  cgruber
 121  
  * Check in all sources in eclipse-friendly maven-enabled packages.
 122  
  *
 123  
  * Revision 1.2  2003/08/06 23:07:52  chochos
 124  
  * general code cleanup (mostly, removing unused imports)
 125  
  *
 126  
  * Revision 1.1.1.1  2000/12/21 15:48:46  mpowers
 127  
  * Contributing wotonomy.
 128  
  *
 129  
  * Revision 1.3  2000/12/20 16:25:40  michael
 130  
  * Added log to all files.
 131  
  *
 132  
  *
 133  
  */
 134