ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From meta...@locus.apache.org
Subject cvs commit: jakarta-ant/src/antidote/org/apache/tools/ant/gui AntAction.java EventToActionMapper.java ActionManager.java BuildEventForwarder.java Console.java
Date Tue, 14 Nov 2000 21:47:51 GMT
metasim     00/11/14 13:47:51

  Modified:    src/antidote/org/apache/tools/ant/gui ActionManager.java
                        BuildEventForwarder.java Console.java
  Added:       src/antidote/org/apache/tools/ant/gui AntAction.java
                        EventToActionMapper.java
  Log:
  Added ability to define state transition condtions for the enabled state of GUI
  actions. As specific events are fired in the GUI the enabled state is updated
  for specific actions.
  
  Revision  Changes    Path
  1.3       +39 -120   jakarta-ant/src/antidote/org/apache/tools/ant/gui/ActionManager.java
  
  Index: ActionManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/antidote/org/apache/tools/ant/gui/ActionManager.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ActionManager.java	2000/11/06 12:52:42	1.2
  +++ ActionManager.java	2000/11/14 21:47:51	1.3
  @@ -55,16 +55,13 @@
   
   import org.apache.tools.ant.gui.event.*;
   import javax.swing.*;
  -import java.awt.event.ActionEvent;
  -import java.awt.event.ActionListener;
   import java.util.*;
  -import java.net.URL;
   
   /**
    * Manager of antidote actions. Receives its configuration from the action
    * ResourceBundle.
    * 
  - * @version $Revision: 1.2 $ 
  + * @version $Revision: 1.3 $ 
    * @author Simeon Fitch 
    */
   public class ActionManager {
  @@ -80,7 +77,11 @@
   
       /** Event bus. */
       private EventBus _bus = null;
  +    /** Class for storing the event type to action type
  +     *  mapping for setting enabled state. */
  +    private EventToActionMapper _mapper = null;
   
  +
   	/** 
   	 * Standard ctor.
   	 * 
  @@ -88,6 +89,9 @@
   	 */
       public ActionManager(EventBus bus) {
           _bus = bus;
  +        bus.addMember(EventBus.RESPONDING, new Enabler());
  +
  +        _mapper = new EventToActionMapper();
   
           // Configure the set of actions.
           String toTok = _resources.getString("actions");
  @@ -95,8 +99,16 @@
           _actionIDs = new String[tok.countTokens()];
           for(int i = 0; i < _actionIDs.length; i++) {
               _actionIDs[i] = tok.nextToken();
  -            _actions.put(_actionIDs[i], new AntAction(_actionIDs[i]));
  +            AntAction action = new AntAction(_resources, _bus, _actionIDs[i]);
  +            _actions.put(_actionIDs[i], action);
  +                         
  +
  +            // For each action we need to add the reverse event trigger
  +            // lookup.
  +            _mapper.addAction(action);
  +
           }
  +
       }
   
   	/** 
  @@ -204,137 +216,44 @@
           }
       }
   
  -	/** 
  -	 * Convenience method for looking put a resource with the name
  -     * "id.key". Will return null if the resource doesn't exist.
  -	 * 
  -	 * @param id Action id.
  -	 * @param key Key name for the action.
  -	 * @return String resource for composite key, or null if not found.
  -	 */
  -    private String getString(String id, String key) {
  -        String retval = null;
  -        try {
  -            retval = _resources.getString(id + "." + key);
  -        }
  -        catch(MissingResourceException ex) {
  -            // Its ok to be missing a resource name...
  -            // Too bad the API throws an exception in this case. 
  -        }
  -        return retval;
  -    }
  -
  -    /** Class representing an action in the Antidote application. */
  -    private class AntAction extends AbstractAction {
  -        /** Property name for the parent menu item. */
  -        public static final String PARENT_MENU_NAME = "parentMenuName";
  -        public static final String SEPARATOR = "separator";
  -        public static final String ACCELERATOR = "accelerator";
   
  -        /** Unique id. */
  -        private String _id = null;
  -
  -        /** 
  -         * Standard ctor.
  -         * 
  -         * @param id Unique id for the action
  -         */
  -        public AntAction(String id) {
  -            _id = id;
  -            putValue(NAME, getString(id, "name"));
  -            putValue(SHORT_DESCRIPTION, getString(id, "shortDescription"));
  -            putValue(PARENT_MENU_NAME, getString(id, PARENT_MENU_NAME));
  -            putValue(SEPARATOR, getString(id, SEPARATOR));
  -
  -            String accelerator = getString(id, ACCELERATOR);
  -
  -            if(accelerator != null) {
  -                putValue(ACCELERATOR, KeyStroke.getKeyStroke(accelerator));
  -            }
  -
  -            String iconName = getString(id, "icon");
  -            if(iconName != null) {
  -                try {
  -                    URL imageLoc = 
  -                        AntAction.class.getResource("resources/" + iconName);
  -                    if(imageLoc != null) {
  -                        putValue(SMALL_ICON, new ImageIcon(imageLoc));
  -                    }
  -                }
  -                catch(Exception ex) {
  -                    // XXX log me.
  -                    ex.printStackTrace();
  -                }
  -            }
  -        }
  -        
  -        /** 
  -         * Unique id for the action.
  -         * 
  -         * @return Action id.
  -         */
  -        public String getID() {
  -            return _id;
  -        }
  +    /** Class for updating the enabled status of icons based
  +     *  on the events seen. */
  +    private class Enabler implements BusMember {
  +        private final Filter _filter = new Filter();
   
  -        /** 
  -         * Get the name of the menu in the menu bar that this action shoul
  -         * appear under.
  -         * 
  -         * @return Menu to appear under, or null if not a menu action.
  -         */
  -        public String getParentMenuName() {
  -            return (String) getValue(PARENT_MENU_NAME);
  -        }
  -        
  -        /** 
  -         * Get the localized name for the action.
  -         * 
  -         * @return Name
  -         */
  -        public String getName() {
  -            return (String) getValue(NAME);
  -        }
  -        
           /** 
  -         * Get the short description. Used in tool tips.
  +         * Get the filter to that is used to determine if an event should
  +         * to to the member.
            * 
  -         * @return Short description.
  +         * @return Filter to use.
            */
  -        public String getShortDescription() {
  -            return (String) getValue(SHORT_DESCRIPTION);
  +        public BusFilter getBusFilter() {
  +            return _filter;
           }
           
           /** 
  -         * Determine if a separator should appear before the action.
  +         * Receives all events.
            * 
  -         * @return True if add separator, false otherwise.
  +         * @param event Event to post.
            */
  -        public boolean isPreceededBySeparator() {
  -            return Boolean.valueOf(
  -                String.valueOf(getValue(SEPARATOR))).booleanValue();
  +        public void eventPosted(EventObject event) {
  +            _mapper.applyEvent(event);
           }
  +    }
   
  +    /** Class providing filtering for project events. */
  +    private static class Filter implements BusFilter {
           /** 
  -         * Get the icon.
  +         * Determines if the given event should be accepted.
            * 
  -         * @return Icon for action, or null if none.
  +         * @param event Event to test.
  +         * @return True if event should be given to BusMember, false otherwise.
            */
  -        public Icon getIcon() {
  -            return (Icon) getValue(SMALL_ICON);
  +        public boolean accept(EventObject event) {
  +            return true;
           }
  +    }
   
  -        public KeyStroke getAccelerator() {
  -            return (KeyStroke) getValue(ACCELERATOR);
  -        }
   
  -        /** 
  -         * Pass the action on to the EventBus.
  -         * 
  -         * @param e Event to forward.
  -         */
  -        public void actionPerformed(ActionEvent e) {
  -            _bus.postEvent(e);
  -        }
  -    }
   }
  
  
  
  1.2       +6 -0      jakarta-ant/src/antidote/org/apache/tools/ant/gui/BuildEventForwarder.java
  
  Index: BuildEventForwarder.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/antidote/org/apache/tools/ant/gui/BuildEventForwarder.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- BuildEventForwarder.java	2000/11/06 12:52:42	1.1
  +++ BuildEventForwarder.java	2000/11/14 21:47:51	1.2
  @@ -59,7 +59,7 @@
   /**
    * BuildListener for forwarding events to the EventBus.
    * 
  - * @version $Revision: 1.1 $ 
  + * @version $Revision: 1.2 $ 
    * @author Simeon Fitch 
    */
   public class BuildEventForwarder implements BuildListener {
  @@ -76,6 +76,9 @@
        */
       public void buildStarted(BuildEvent event){
           postEvent(event, BuildEventType.BUILD_STARTED);
  +        // We doubly post this event.
  +        _context.getEventBus().postEvent(
  +            new BuildStartedEvent(_context, event));
       }
   
       /**
  @@ -86,6 +89,9 @@
        */
       public void buildFinished(BuildEvent event) {
           postEvent(event, BuildEventType.BUILD_FINISHED);
  +        // We doubly post this event.
  +        _context.getEventBus().postEvent(
  +            new BuildFinishedEvent(_context, event));
       }
   
       /**
  
  
  
  1.6       +10 -5     jakarta-ant/src/antidote/org/apache/tools/ant/gui/Console.java
  
  Index: Console.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/antidote/org/apache/tools/ant/gui/Console.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- Console.java	2000/11/14 19:48:02	1.5
  +++ Console.java	2000/11/14 21:47:51	1.6
  @@ -64,7 +64,7 @@
   /**
    * Logging console display.
    * 
  - * @version $Revision: 1.5 $ 
  + * @version $Revision: 1.6 $ 
    * @author Simeon Fitch 
    */
   public class Console extends AntEditor {
  @@ -148,6 +148,8 @@
               switch(buildEvent.getType().getValue()) {
                 case BuildEventType.BUILD_STARTED_VAL:
                     clearDisplay();
  +              case BuildEventType.BUILD_FINISHED_VAL:
  +                  text = buildEvent.getType().toString();
                     break;
                 case BuildEventType.TARGET_STARTED_VAL:
                     text = buildEvent.getEvent().getTarget().getName() + ":";
  @@ -157,13 +159,16 @@
                 case BuildEventType.TASK_FINISHED_VAL:
                     break;
                 case BuildEventType.MESSAGE_LOGGED_VAL:
  -                  text = buildEvent.toString();
  +                  // Filter out events that are below our
  +                  // selected filterint level.
  +                  LogLevelEnum level = 
  +                      (LogLevelEnum) _logLevel.getSelectedItem();
  +                  if(buildEvent.getEvent().getPriority() <= level.getValue()) {
  +                      text = buildEvent.toString();
  +                  }
                     break;
               }
   
  -            // Filter out events that are below our selected filterint level.
  -            LogLevelEnum level = (LogLevelEnum) _logLevel.getSelectedItem();
  -            if(buildEvent.getEvent().getPriority() > level.getValue()) return;
   
               if(text != null) {
                   try {
  
  
  
  1.1                  jakarta-ant/src/antidote/org/apache/tools/ant/gui/AntAction.java
  
  Index: AntAction.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999, 2000 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  package org.apache.tools.ant.gui;
  
  import javax.swing.*;
  import java.net.URL;
  import java.awt.event.ActionEvent;
  import java.awt.event.ActionListener;
  import java.util.*;
  
  import org.apache.tools.ant.gui.event.EventBus;
  
  /**
   * Class representing an action in the Antidote application. 
   * 
   * @version $Revision: 1.1 $ 
   * @author Simeon Fitch 
   */
  public class AntAction extends AbstractAction {
      /** Property name for the parent menu item. */
      public static final String PARENT_MENU_NAME = "parentMenuName";
      public static final String SEPARATOR = "separator";
      public static final String ACCELERATOR = "accelerator";
      public static final String ENABLED = "enabled";
      public static final String ENABLE_ON = "enableOn";
      public static final String DISABLE_ON = "disableOn";
  
      /** Property resources. */
      private  ResourceBundle _resources =  null;
      /** Event bus. */
      private EventBus _bus = null;
      /** Unique id. */
      private String _id = null;
  
      /** Events that the action should cause transition to the 
       *  enabled(true) state. */
      private Class[] _enableOn = null;
      /** Events that the action should cause transition to the 
       *  enabled(false) state. */
      private Class[] _disableOn = null;
  
  
      /** 
       * Standard ctor.
       * 
       * @param id Unique id for the action
       */
      public AntAction(ResourceBundle resources, EventBus bus, String id) {
          _resources = resources;
          _bus = bus;
          _id = id;
          putValue(NAME, getString("name"));
          putValue(SHORT_DESCRIPTION, getString("shortDescription"));
          putValue(PARENT_MENU_NAME, getString(PARENT_MENU_NAME));
          putValue(SEPARATOR, getString(SEPARATOR));
  
  
          // Set the default enabled state.
          String enabled = getString(ENABLED);
          if(enabled != null) {
              setEnabled(Boolean.valueOf(enabled).booleanValue());
          }
  
          // Set an accellerator if any.
          String accelerator = getString(ACCELERATOR);
          if(accelerator != null) {
              putValue(ACCELERATOR, KeyStroke.getKeyStroke(accelerator));
          }
  
          // Add an icon if any (which means it'll show up on the tool bar).
          String iconName = getString("icon");
          if(iconName != null) {
              try {
                  URL imageLoc = 
                      AntAction.class.getResource("resources/" + iconName);
                  if(imageLoc != null) {
                      putValue(SMALL_ICON, new ImageIcon(imageLoc));
                  }
              }
              catch(Exception ex) {
                  // XXX log me.
                  ex.printStackTrace();
              }
          }
  
          _enableOn = resolveClasses(getString(ENABLE_ON));
          _disableOn = resolveClasses(getString(DISABLE_ON));
  
      }
          
  	/** 
  	 * Convenience method for looking put a resource with the name
       * "id.key". Will return null if the resource doesn't exist.
  	 * 
  	 * @param key Key name for the action.
  	 * @return String resource for composite key, or null if not found.
  	 */
      private String getString(String key) {
          String retval = null;
          try {
              retval = _resources.getString(_id + "." + key);
          }
          catch(MissingResourceException ex) {
              // Its ok to be missing a resource name...
              // Too bad the API throws an exception in this case. 
          }
          return retval;
      }
  
  
  	/** 
  	 * Parse out the list of classes from the given string and
       * resolve them into classes.
  	 * 
  	 * @param classNames Comma delimited list of class names.
  	 */
      private Class[] resolveClasses(String classNames) {
          if(classNames == null) return null;
  
          StringTokenizer tok = new StringTokenizer(classNames, ", ");
          Vector vals = new Vector();
          while(tok.hasMoreTokens()) {
              String name = tok.nextToken();
              try {
                  vals.addElement(Class.forName(name));
              }
              catch(ClassNotFoundException ex) {
                  //XXX log me.
                  System.err.println(
                      "Warning: the event class " + name + 
                      " was not found. Please check config file.");
              }
          }
  
          Class[] retval = new Class[vals.size()];
          vals.copyInto(retval);
          return retval;
      }
  
      /** 
       * Unique id for the action.
       * 
       * @return Action id.
       */
      public String getID() {
          return _id;
      }
  
      /** 
       * Get the name of the menu in the menu bar that this action shoul
       * appear under.
       * 
       * @return Menu to appear under, or null if not a menu action.
       */
      public String getParentMenuName() {
          return (String) getValue(PARENT_MENU_NAME);
      }
          
      /** 
       * Get the localized name for the action.
       * 
       * @return Name
       */
      public String getName() {
          return (String) getValue(NAME);
      }
          
      /** 
       * Get the short description. Used in tool tips.
       * 
       * @return Short description.
       */
      public String getShortDescription() {
          return (String) getValue(SHORT_DESCRIPTION);
      }
          
      /** 
       * Determine if a separator should appear before the action.
       * 
       * @return True if add separator, false otherwise.
       */
      public boolean isPreceededBySeparator() {
          return Boolean.valueOf(
              String.valueOf(getValue(SEPARATOR))).booleanValue();
      }
  
      /** 
       * Get the icon.
       * 
       * @return Icon for action, or null if none.
       */
      public Icon getIcon() {
          return (Icon) getValue(SMALL_ICON);
      }
  
  	/** 
  	 * Get the accelerator keystroke.
  	 * 
  	 * @return Accelerator
  	 */
      public KeyStroke getAccelerator() {
          return (KeyStroke) getValue(ACCELERATOR);
      }
  
  
  	/** 
  	 * Get the event types which should cause this to go to the
       * enabled state.
  	 * 
  	 */
      public Class[] getEnableOnEvents() {
          return _enableOn;
      }
  
  	/** 
  	 * Get the event types which should cause this to go to 
       * this disabled state.
  	 * 
  	 */
      public Class[] getDisableOnEvents() {
          return _disableOn;
      }
  
      /** 
       * Pass the action on to the EventBus.
       * 
       * @param e Event to forward.
       */
      public void actionPerformed(ActionEvent e) {
          _bus.postEvent(e);
      }
  }
  
  
  
  
  1.1                  jakarta-ant/src/antidote/org/apache/tools/ant/gui/EventToActionMapper.java
  
  Index: EventToActionMapper.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999, 2000 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  package org.apache.tools.ant.gui;
  import java.util.*;
  
  /**
   * The purpose of this class is to manage the 
   * mappings between event type and action enabled state.
   * 
   * @version $Revision: 1.1 $ 
   * @author Simeon Fitch 
   */
  class EventToActionMapper {
  
      /** Lookup for enable(true) events. Key is event type, value is
       *  a list of actions that are changed by the event. */
      private Map _enableOn = new HashMap();
      /** Lookup for enable(false) events. Key is event type, value is
       *  a list of actions that are changed by the event. */
      private Map _disableOn = new HashMap();
  
  
      public EventToActionMapper() {
  
      }
  
  	/** 
  	 * Add an action.
  	 * 
  	 * @param action Action to add.
  	 */
      public void addAction(AntAction action) {
          putAction(action, action.getEnableOnEvents(), _enableOn);
          putAction(action, action.getDisableOnEvents(), _disableOn);
      }
  
  
  	/** 
  	 * For the given action store it in the event type mapping
       * for each of the given types.
  	 * 
  	 * @param action Action to store.
  	 * @param clazzes Array of types to store it under.
  	 * @param storage The place to store the association.
  	 */
      private void putAction(AntAction action, Class[] clazzes, Map storage) {
          if(clazzes == null) return;
  
          for(int i = 0; i < clazzes.length; i++) {
              List values = (List) storage.get(clazzes[i]);
              if(values == null) {
                  values = new ArrayList(1);
                  storage.put(clazzes[i], values);
              }
  
              values.add(action);
          }
      }
  
  
  	/** 
  	 * For the given event change the state of any actions that 
       * have been registered as needing a transition as a result of
       * the event.
  	 * 
  	 * @param event The event to apply.
  	 */
      public void applyEvent(EventObject event) {
          if(event == null) return;
  
          List vals = null;
  
          vals = (List) _enableOn.get(event.getClass());
          changeState(vals, true);
  
          vals = (List) _disableOn.get(event.getClass());
          changeState(vals, false);
      }
  
  	/** 
  	 * Set the enabled state of the given actions.
  	 * 
  	 * @param actions List of AntActions to set state for.
  	 * @param state The state to set them to.
  	 */
      private void changeState(List actions, boolean state) {
          if(actions == null) return;
  
          for(int i = 0, len = actions.size(); i < len; i++) {
              AntAction action = (AntAction) actions.get(i);
              action.setEnabled(state);
          }
      }
  
  
  }
  
  
  

Mime
View raw message