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/event ElementSelectionEvent.java
Date Sat, 11 Nov 2000 04:54:05 GMT
metasim     00/11/10 20:54:05

  Added:       src/antidote/org/apache/tools/ant/gui
                        ElementSelectionModel.java
               src/antidote/org/apache/tools/ant/gui/acs
                        ACSPropertyElement.java
                        ACSPropertyElementBeanInfo.java ACSTaskElement.java
                        ACSTaskElementBeanInfo.java
               src/antidote/org/apache/tools/ant/gui/customizer
                        StringArrayPropertyEditor.java
               src/antidote/org/apache/tools/ant/gui/event
                        ElementSelectionEvent.java
  Log:
  Geatly enhanced the property editor, adding new bean info for the
  element types and an additional property editor. The navigator now shows
  project, property, target and task nodes.
  
  Revision  Changes    Path
  1.1                  jakarta-ant/src/antidote/org/apache/tools/ant/gui/ElementSelectionModel.java
  
  Index: ElementSelectionModel.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 org.apache.tools.ant.gui.acs.ACSElement;
  import org.apache.tools.ant.gui.acs.ACSTargetElement;
  
  import javax.swing.tree.DefaultTreeSelectionModel;
  import javax.swing.tree.TreePath;
  import java.util.*;
  
  /**
   * Selection model for the currently selected targets.
   * 
   * @version $Revision: 1.1 $ 
   * @author Simeon Fitch 
   */
  class ElementSelectionModel extends DefaultTreeSelectionModel {
  	/** 
  	 * Default ctor.
  	 * 
  	 */
      public ElementSelectionModel() {
          setSelectionMode(DISCONTIGUOUS_TREE_SELECTION);
      }
  
  	/** 
  	 * Convenience method for providing the set of currently selected
       * elements.
  	 * 
       * @return the currently selected elements.
  	 */
      public ACSElement[] getSelectedElements() {
          TreePath[] path = getSelectionPaths();
          List values = new LinkedList();
          for(int i = 0; path != null && i < path.length; i++) {
              Object val = path[i].getLastPathComponent();
              if(val instanceof ACSElement) {
                  values.add(val);
              }
          }
  
          ACSElement[] retval = new ACSElement[values.size()];
          values.toArray(retval);
          return retval;
      }
  
  	/** 
  	 * Get the set of selected tagets. A target is included if one of its
       * child nodes is selected.
  	 * 
       * @return the currently selected targets, and indirectly selected targets.
  	 */
      public ACSTargetElement[] getSelectedTargets() {
          TreePath[] path = getSelectionPaths();
          List values = new LinkedList();
          for(int i = 0; path != null && i < path.length; i++) {
              TreePath curr = path[i];
              for(int j = 0; j < curr.getPathCount(); j++) {
                  Object item = curr.getPathComponent(j);
                  if(item instanceof ACSTargetElement) {
                      values.add(item);
                  }
              }
          }
  
          ACSTargetElement[] retval = new ACSTargetElement[values.size()];
          values.toArray(retval);
          return retval;
  
      }
  
  }
  
  
  
  1.1                  jakarta-ant/src/antidote/org/apache/tools/ant/gui/acs/ACSPropertyElement.java
  
  Index: ACSPropertyElement.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.acs;
  
  import com.sun.xml.tree.ElementNode;
  
  /**
   * Element containing a property definition.
   * 
   * @version $Revision: 1.1 $ 
   * @author Simeon Fitch 
   */
  public class ACSPropertyElement extends ACSTreeNodeElement {
      /** The 'name' property name. */
      public static final String NAME = "name";
      /** The 'value' property name. */
      public static final String VALUE = "value";
      /** The file to load properties from. */
      public static final String FILE = "file";
  
  	/** 
  	 * Default ctor.
  	 * 
  	 */
      public ACSPropertyElement() {
      }
  
  	/** 
  	 * Get the display name of this.
  	 * 
  	 * @return Display name.
  	 */
      public String getDisplayName() {
          String file = getFile();
  
          if(file == null || file.trim().length() == 0) {
              return "Property: " + getName();
          }
          else {
              return "Property File: " + file;
          }
      }
  
  	/** 
  	 * Get the property name.
  	 * 
  	 * @return Property name.
  	 */
      public String getName() {
          return getAttribute(NAME);
      }
  
  	/** 
  	 * Set the property name.
  	 * 
  	 * @param name Property name.
  	 */
      public void setName(String name) {
          String old = getName();
          setAttribute(NAME, name);
          firePropertyChange(NAME, old, name);
      }
  
  	/** 
  	 * Get the property value.
  	 * 
  	 * @return Property value.
  	 */
      public String getValue() {
          return getAttribute(VALUE);
      }
  
  	/** 
  	 * Set the property value.
  	 * 
  	 * @param name Property value.
  	 */
      public void setValue(String value) {
          String old = getValue();
          setAttribute(VALUE, value);
          firePropertyChange(VALUE, old, value);
      }
  
  	/** 
  	 * Get the external property file.
  	 * 
  	 * @return Property file.
  	 */
      public String getFile() {
          return getAttribute(FILE);
      }
  
  	/** 
  	 * Set the external property file.
  	 * 
  	 * @param name Property file.
  	 */
      public void setFile(String file) {
          String old = getFile();
          setAttribute(FILE, file);
          firePropertyChange(FILE, old, file);
      }
  }
  
  
  
  1.1                  jakarta-ant/src/antidote/org/apache/tools/ant/gui/acs/ACSPropertyElementBeanInfo.java
  
  Index: ACSPropertyElementBeanInfo.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.acs;
  
  import java.beans.*;
  
  /**
   * BeanInfo for the ACSPropertyElement class.
   * 
   * @version $Revision: 1.1 $ 
   * @author Simeon Fitch 
   */
  public class ACSPropertyElementBeanInfo extends BaseBeanInfo {
  	/** 
  	 * Default ctor.
  	 * 
  	 */
      public ACSPropertyElementBeanInfo() {
      }
  
  	/** 
  	 * Get the type that this BeanInfo represents.
  	 * 
  	 * @return Type.
  	 */
      public Class getType() {
          return ACSPropertyElement.class;
      }
  
  	/** 
  	 * Get the property descriptors.
  	 * 
       * @return Property descriptors.
  	 */
      public PropertyDescriptor[] getPropertyDescriptors() {
          PropertyDescriptor[] retval = null;
  
          try {
              retval = new PropertyDescriptor[] {
                  new PropertyDescriptor(ACSPropertyElement.FILE, 
                                         ACSPropertyElement.class),
                  new PropertyDescriptor(ACSPropertyElement.NAME, 
                                         ACSPropertyElement.class),
                  new PropertyDescriptor(ACSPropertyElement.VALUE, 
                                         ACSPropertyElement.class)
              };
  
              retval[0].setDisplayName(getResources().getString(
                  getClass(),ACSPropertyElement.FILE));
              retval[1].setDisplayName(getResources().getString(
                  getClass(),ACSPropertyElement.NAME));
              retval[2].setDisplayName(getResources().getString(
                  getClass(),ACSPropertyElement.VALUE));
  
              setSortingOrder(retval);
          }
          catch(IntrospectionException ex) {
              ex.printStackTrace();
              throw new Error(ex.toString());
          }
  
          return retval;
      }
  
  }
  
  
  
  1.1                  jakarta-ant/src/antidote/org/apache/tools/ant/gui/acs/ACSTaskElement.java
  
  Index: ACSTaskElement.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.acs;
  
  import com.sun.xml.tree.ElementNode;
  
  /**
   * Element containing a property definition.
   * 
   * @version $Revision: 1.1 $ 
   * @author Simeon Fitch 
   */
  public class ACSTaskElement extends ACSTreeNodeElement {
      /** Property name for the task type. */
      public static final String TASK_TYPE = "taskType";
  
  	/** 
  	 * Default ctor.
  	 * 
  	 */
      public ACSTaskElement() {
      }
  
  	/** 
  	 * Get the task type.
  	 * 
  	 * @return Task type.
  	 */
      public String getTaskType() {
          return getTagName();
      }
  
  }
  
  
  
  1.1                  jakarta-ant/src/antidote/org/apache/tools/ant/gui/acs/ACSTaskElementBeanInfo.java
  
  Index: ACSTaskElementBeanInfo.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.acs;
  
  import java.beans.*;
  
  /**
   * BeanInfo for the ACSTaskElement class.
   * 
   * @version $Revision: 1.1 $ 
   * @author Simeon Fitch 
   */
  public class ACSTaskElementBeanInfo extends BaseBeanInfo {
  	/** 
  	 * Default ctor.
  	 * 
  	 */
      public ACSTaskElementBeanInfo() {
      }
  
  	/** 
  	 * Get the type that this BeanInfo represents.
  	 * 
  	 * @return Type.
  	 */
      public Class getType() {
          return ACSTaskElement.class;
      }
  
  	/** 
  	 * Get the property descriptors.
  	 * 
       * @return Property descriptors.
  	 */
      public PropertyDescriptor[] getPropertyDescriptors() {
          PropertyDescriptor[] retval = null;
  
          try {
              retval = new PropertyDescriptor[] {
                  new PropertyDescriptor(ACSTaskElement.TASK_TYPE, 
                                         ACSTaskElement.class,
                                         "getTaskType", null),
                  new PropertyDescriptor(ACSTaskElement.XML_STRING, 
                                         ACSTaskElement.class,
                                         "getXMLString", null)
              };
  
              retval[0].setDisplayName(getResources().getString(
                  getClass(),ACSTaskElement.TASK_TYPE));
              retval[1].setDisplayName(getResources().getString(
                  getClass(),ACSTaskElement.XML_STRING));
  
              setSortingOrder(retval);
          }
          catch(IntrospectionException ex) {
              ex.printStackTrace();
              throw new Error(ex.toString());
          }
  
          return retval;
      }
  
  }
  
  
  
  1.1                  jakarta-ant/src/antidote/org/apache/tools/ant/gui/customizer/StringArrayPropertyEditor.java
  
  Index: StringArrayPropertyEditor.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.customizer;
  
  import javax.swing.*;
  import java.awt.Component;
  import java.util.StringTokenizer;
  
  /**
   * Custom property editor for String arrays.
   * 
   * @version $Revision: 1.1 $ 
   * @author Simeon Fitch 
   */
  public class StringArrayPropertyEditor extends AbstractPropertyEditor {
      private JTextField _widget = null;
  
      /** 
       * Default ctor.
       * 
       */
      public StringArrayPropertyEditor() {
          _widget = new JTextField();
          _widget.addFocusListener(new FocusHandler(this));
      }
  
      /** 
       * Get the child editing component. Uses JComponent so we can have tool
       * tips, etc.
       * 
       * @return Child editing component.
       */
      protected Component getChild() {
          return _widget;
      }
  
      /**
       * This method is intended for use when generating Java code to set
       * the value of the property.  It should return a fragment of Java code
       * that can be used to initialize a variable with the current property
       * value.
       * <p>
       * Example results are "2", "new Color(127,127,34)", "Color.orange", etc.
       *
       * @return A fragment of Java code representing an initializer for the
       *      current value.
       */
      public String getJavaInitializationString() {
          return getAsText();
      }
  
      /**
       * Set (or change) the object that is to be edited.  Builtin types such
       * as "int" must be wrapped as the corresponding object type such as
       * "java.lang.Integer".
       *
       * @param value The new target object to be edited.  Note that this
       *     object should not be modified by the PropertyEditor, rather 
       *     the PropertyEditor should create a new object to hold any
       *     modified value.
       */
      public void setValue(Object value) {
          if(!(value instanceof String[])) {
              throw new IllegalArgumentException(
                  "Value must be of type String[].");
          }
          String old = _widget.getText();
  
          String[] vals = (String[]) value;
          StringBuffer buf = new StringBuffer();
  
          for(int i = 0; i < vals.length; i++) {
              buf.append(vals[i]);
              if(i < vals.length - 1) {
                  buf.append(", ");
              }
          }
          _widget.setText(buf.toString());
          firePropertyChange(old, buf.toString());
      }
  
      /**
       * @return The value of the property.  Builtin types such as "int" will
       * be wrapped as the corresponding object type such as "java.lang.Integer".
       */
      public Object getValue() {
          String vals = _widget.getText();
          StringTokenizer tok = new StringTokenizer(vals,",");
          String[] retval = new String[tok.countTokens()];
          for(int i = 0; i < retval.length; i++) {
              retval[i] = tok.nextToken().trim();
          }
  
          return retval;
      }
  
      /**
       * Set the property value by parsing a given String.  May raise
       * java.lang.IllegalArgumentException if either the String is
       * badly formatted or if this kind of property can't be expressed
       * as text.
       * @param text  The string to be parsed.
       */
      public void setAsText(String text) throws IllegalArgumentException {
          Object old = _widget.getText();
          _widget.setText(text);
          firePropertyChange(old, text);
      }
  
      /**
       * @return The property value as a human editable string.
       * <p>   Returns null if the value can't be expressed 
       *       as an editable string.
       * <p>   If a non-null value is returned, then the PropertyEditor should
       *       be prepared to parse that string back in setAsText().
       */
      public String getAsText() {
          return _widget.getText();
      } 
  
  
  }
  
  
  
  
  
  1.1                  jakarta-ant/src/antidote/org/apache/tools/ant/gui/event/ElementSelectionEvent.java
  
  Index: ElementSelectionEvent.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.event;
  import org.apache.tools.ant.gui.acs.ACSElement;
  import org.apache.tools.ant.gui.command.Command;
  import org.apache.tools.ant.gui.command.NoOpCmd;
  import org.apache.tools.ant.gui.AppContext;
  
  /**
   * Event indicating that the current set of selected targets has changed.
   * 
   * @version $Revision: 1.1 $ 
   * @author Simeon Fitch 
   */
  public class ElementSelectionEvent extends AntEvent {
  
      /** New set of selected elements. */
      private ACSElement[] _selected = null;
  
  	/** 
  	 * Standard ctor.
  	 * 
  	 * @param context application context.
       * @param selected the selected Elements.
  	 */
      public ElementSelectionEvent(AppContext context, 
                                   ACSElement[] selected) {
          super(context);
          _selected = selected;
      }
  
  	/** 
  	 * Current set of selected elements.
  	 * 
       * @return selected element set.
  	 */
      public ACSElement[] getSelectedElements() {
          return _selected;
      }
  
  	/** 
  	 * Create the appropriate default response command to this event.
  	 * 
  	 * @return Command representing an appropriate response to this event.
  	 */
      public Command createDefaultCmd() {
          return new NoOpCmd();
      }
  }
  
  
  

Mime
View raw message