ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From meta...@apache.org
Subject cvs commit: jakarta-ant/src/antidote/org/apache/tools/ant/gui/event ProjectSelectedEvent.java ElementSelectionEvent.java EventBus.java PropertySelectionEvent.java TargetSelectionEvent.java TaskSelectionEvent.java NewProjectEvent.java ProjectSelectionEvent.java
Date Mon, 08 Jan 2001 19:43:41 GMT
metasim     01/01/08 11:43:41

  Modified:    src/antidote/org/apache/tools/ant/gui/event
                        ElementSelectionEvent.java EventBus.java
                        PropertySelectionEvent.java
                        TargetSelectionEvent.java TaskSelectionEvent.java
  Added:       src/antidote/org/apache/tools/ant/gui/event
                        ProjectSelectedEvent.java
  Removed:     src/antidote/org/apache/tools/ant/gui/event
                        NewProjectEvent.java ProjectSelectionEvent.java
  Log:
  Added *internal* support multiple projects, and generalized the selection
  state mechanism.
  
  Revision  Changes    Path
  1.6       +29 -2     jakarta-ant/src/antidote/org/apache/tools/ant/gui/event/ElementSelectionEvent.java
  
  Index: ElementSelectionEvent.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/antidote/org/apache/tools/ant/gui/event/ElementSelectionEvent.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- ElementSelectionEvent.java	2001/01/03 14:18:22	1.5
  +++ ElementSelectionEvent.java	2001/01/08 19:43:38	1.6
  @@ -57,10 +57,13 @@
   import org.apache.tools.ant.gui.command.DisplayErrorCmd;
   import org.apache.tools.ant.gui.core.AppContext;
   
  +import java.lang.reflect.Array;
  +import java.util.*;
  +
   /**
    * Event indicating that the current set of selected targets has changed.
    * 
  - * @version $Revision: 1.5 $ 
  + * @version $Revision: 1.6 $ 
    * @author Simeon Fitch 
    */
   public class ElementSelectionEvent extends AntEvent {
  @@ -90,6 +93,29 @@
       }
   
   
  +    /** 
  +     * Get only those events of a specific type.
  +     * 
  +     * @param type Specific type to get values for, or null if none.
  +     */
  +    protected ACSElement[] getFiltered(Class type) {
  +        ACSElement[] retval = null;
  +        List vals = new ArrayList(1);
  +        if(_selected != null) {
  +            for(int i = 0; i < _selected.length; i++) {
  +                if(type.isInstance(_selected[i])) {
  +                    vals.add(_selected[i]);
  +                }
  +            }
  +        }
  +
  +        if(vals.size() > 0) {
  +            retval = (ACSElement[]) Array.newInstance(type, vals.size());
  +            vals.toArray(retval);
  +        }
  +        return retval;
  +    }
  +
   	/** 
   	 * Factory method for creating the appropriate specialization of this
        * for communicating an element selection.
  @@ -116,7 +142,8 @@
                   retval = new PropertySelectionEvent(context, selected);
               }
               else if(type.isAssignableFrom(ACSProjectElement.class)) {
  -                retval = new ProjectSelectionEvent(context, selected);
  +                retval = new ProjectSelectedEvent(
  +                    context, (ACSProjectElement) selected[0]);
               }
               else {
                   // For elements without a specific event
  
  
  
  1.5       +5 -5      jakarta-ant/src/antidote/org/apache/tools/ant/gui/event/EventBus.java
  
  Index: EventBus.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/antidote/org/apache/tools/ant/gui/event/EventBus.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- EventBus.java	2001/01/03 14:18:22	1.4
  +++ EventBus.java	2001/01/08 19:43:38	1.5
  @@ -71,17 +71,17 @@
    * NB: This class is overly simple right now, but will eventually
    * be expanded to do better event filtering, interrupt levels, etc. 
    * 
  - * @version $Revision: 1.4 $ 
  + * @version $Revision: 1.5 $ 
    * @author Simeon Fitch 
   */
   public class EventBus {
  -	/** The default "monitoring" interrupt level, used by members who
  -	 * are only listeners/monitors of events. */
  -	public static final int MONITORING = 1;
   	/** The default "vetoing" interrupt level, used by bus members
   	 *  whose role is to veto request events or otherwise handle an
   	 *  event before it is processed by the default handler. */
  -	public static final int VETOING = 5;
  +	public static final int VETOING = 1;
  +	/** The default "monitoring" interrupt level, used by members who
  +	 * are only listeners/monitors of events. */
  +	public static final int MONITORING = 5;
   	/** The default "responding" interrupt level, for members who service
   	 *  events in a default manner. */
   	public static final int RESPONDING = 10;
  
  
  
  1.4       +11 -1     jakarta-ant/src/antidote/org/apache/tools/ant/gui/event/PropertySelectionEvent.java
  
  Index: PropertySelectionEvent.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/antidote/org/apache/tools/ant/gui/event/PropertySelectionEvent.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- PropertySelectionEvent.java	2001/01/03 14:18:23	1.3
  +++ PropertySelectionEvent.java	2001/01/08 19:43:39	1.4
  @@ -53,12 +53,13 @@
    */
   package org.apache.tools.ant.gui.event;
   import org.apache.tools.ant.gui.acs.ACSElement;
  +import org.apache.tools.ant.gui.acs.ACSPropertyElement;
   import org.apache.tools.ant.gui.core.AppContext;
   
   /**
    * Event fired when one or more tasks are selected.
    * 
  - * @version $Revision: 1.3 $ 
  + * @version $Revision: 1.4 $ 
    * @author Simeon Fitch 
    */
   public class PropertySelectionEvent extends ElementSelectionEvent {
  @@ -72,4 +73,13 @@
                                 ACSElement[] selected) {
           super(context, selected);
       }
  +
  +    /** 
  +     * Get the selected properties.
  +     * 
  +     */
  +    public ACSPropertyElement[] getSelectedProperties() {
  +        return (ACSPropertyElement[]) getFiltered(ACSPropertyElement.class);
  +    }
  +
   }
  
  
  
  1.7       +12 -2     jakarta-ant/src/antidote/org/apache/tools/ant/gui/event/TargetSelectionEvent.java
  
  Index: TargetSelectionEvent.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/antidote/org/apache/tools/ant/gui/event/TargetSelectionEvent.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- TargetSelectionEvent.java	2001/01/03 14:18:23	1.6
  +++ TargetSelectionEvent.java	2001/01/08 19:43:39	1.7
  @@ -53,12 +53,13 @@
    */
   package org.apache.tools.ant.gui.event;
   import org.apache.tools.ant.gui.acs.ACSElement;
  +import org.apache.tools.ant.gui.acs.ACSTargetElement;
   import org.apache.tools.ant.gui.core.AppContext;
   
   /**
    * Event fired when one or more targets are selected.
    * 
  - * @version $Revision: 1.6 $ 
  + * @version $Revision: 1.7 $ 
    * @author Simeon Fitch 
    */
   public class TargetSelectionEvent extends ElementSelectionEvent {
  @@ -69,7 +70,16 @@
        * @param selected the selected Elements.
   	 */
       public TargetSelectionEvent(AppContext context, 
  -                               ACSElement[] selected) {
  +                                ACSElement[] selected) {
           super(context, selected);
       }
  +
  +    /** 
  +     * Get the selected targets.
  +     * 
  +     */
  +    public ACSTargetElement[] getSelectedTargets() {
  +        return (ACSTargetElement[]) getFiltered(ACSTargetElement.class);
  +    }
  +
   }
  
  
  
  1.4       +11 -1     jakarta-ant/src/antidote/org/apache/tools/ant/gui/event/TaskSelectionEvent.java
  
  Index: TaskSelectionEvent.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/antidote/org/apache/tools/ant/gui/event/TaskSelectionEvent.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- TaskSelectionEvent.java	2001/01/03 14:18:23	1.3
  +++ TaskSelectionEvent.java	2001/01/08 19:43:40	1.4
  @@ -53,12 +53,13 @@
    */
   package org.apache.tools.ant.gui.event;
   import org.apache.tools.ant.gui.acs.ACSElement;
  +import org.apache.tools.ant.gui.acs.ACSTaskElement;
   import org.apache.tools.ant.gui.core.AppContext;
   
   /**
    * Event fired when one or more tasks are selected.
    * 
  - * @version $Revision: 1.3 $ 
  + * @version $Revision: 1.4 $ 
    * @author Simeon Fitch 
    */
   public class TaskSelectionEvent extends ElementSelectionEvent {
  @@ -72,4 +73,13 @@
                                 ACSElement[] selected) {
           super(context, selected);
       }
  +
  +    /** 
  +     * Get the selected tasks.
  +     * 
  +     */
  +    public ACSTaskElement[] getSelectedTasks() {
  +        return (ACSTaskElement[]) getFiltered(ACSTaskElement.class);
  +    }
  +
   }
  
  
  
  1.1                  jakarta-ant/src/antidote/org/apache/tools/ant/gui/event/ProjectSelectedEvent.java
  
  Index: ProjectSelectedEvent.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", "Ant", 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.event;
  import org.apache.tools.ant.gui.core.AppContext;
  import org.apache.tools.ant.gui.acs.ACSProjectElement;
  import org.apache.tools.ant.gui.acs.ACSElement;
  
  /**
   * Event providing notification of a change in the currently selected project.
   * 
   * @version $Revision: 1.1 $ 
   * @author Simeon Fitch 
   */
  public class ProjectSelectedEvent extends ElementSelectionEvent {
      /** The selected project. */
      private ACSProjectElement _project = null;
  
  	/** 
  	 * Standard ctor.
  	 * 
  	 * @param context application context.
  	 */
      public ProjectSelectedEvent(
          AppContext context, ACSProjectElement project) {
          super(context, new ACSElement[] { project });
          _project = project;
      }
  
      /** 
       * Get the selected project, or null if there are no
       * open projects.
       * 
       * @return Selected project, or null if no projects selected.
       */
      public ACSProjectElement getSelectedProject() {
          return _project;
      }
  }
  
  
  

Mime
View raw message