You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by me...@locus.apache.org on 2000/11/10 21:41:10 UTC

cvs commit: jakarta-ant/src/antidote/org/apache/tools/ant/gui LabelFieldGBC.java Console.java PropertyEditor.java ResourceManager.java version.txt

metasim     00/11/10 12:41:09

  Modified:    src/antidote/org/apache/tools/ant/gui Console.java
                        PropertyEditor.java ResourceManager.java
                        version.txt
  Added:       src/antidote/org/apache/tools/ant/gui LabelFieldGBC.java
  Log:
  Started addition of a generic Bean editor/property sheet and supporting
  infrastructure for Ant Elements.
  
  Revision  Changes    Path
  1.4       +2 -1      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.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- Console.java	2000/11/07 14:22:27	1.3
  +++ Console.java	2000/11/10 20:41:09	1.4
  @@ -64,7 +64,7 @@
   /**
    * Logging console display.
    * 
  - * @version $Revision: 1.3 $ 
  + * @version $Revision: 1.4 $ 
    * @author Simeon Fitch 
    */
   public class Console extends AntEditor {
  @@ -95,6 +95,7 @@
               context.getResources().getString(getClass(), "logLevel"));
           controls.add(label);
           _logLevel = new JComboBox(LogLevelEnum.getValues());
  +        _logLevel.setSelectedItem(LogLevelEnum.INFO);
           controls.add(_logLevel);
           
           add(BorderLayout.NORTH, controls);
  
  
  
  1.4       +18 -104   jakarta-ant/src/antidote/org/apache/tools/ant/gui/PropertyEditor.java
  
  Index: PropertyEditor.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/antidote/org/apache/tools/ant/gui/PropertyEditor.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- PropertyEditor.java	2000/11/09 23:14:10	1.3
  +++ PropertyEditor.java	2000/11/10 20:41:09	1.4
  @@ -52,7 +52,9 @@
    * <http://www.apache.org/>.
    */
   package org.apache.tools.ant.gui;
  -import org.apache.tools.ant.gui.acs.ACSTargetElement;
  +
  +import org.apache.tools.ant.gui.customizer.DynamicCustomizer;
  +import org.apache.tools.ant.gui.acs.*;
   import org.apache.tools.ant.gui.event.*;
   import javax.swing.*;
   import java.util.*;
  @@ -63,13 +65,13 @@
   /**
    * Stub for a property editor.
    *
  - * @version $Revision: 1.3 $ 
  + * @version $Revision: 1.4 $ 
    * @author Simeon H.K. Fitch 
    */
   class PropertyEditor extends AntEditor {
   
  -    /** Text pane. */
  -    private JEditorPane _text = null;
  +    /** The property sheet. */
  +    private DynamicCustomizer _customizer = null;
   
   	/** 
   	 * Standard ctor.
  @@ -80,115 +82,27 @@
           super(context);
           context.getEventBus().addMember(EventBus.MONITORING, new Handler());
           setLayout(new BorderLayout());
  -
  -        _text = new JEditorPane("text/html", getAppContext().getResources().
  -                                getString(getClass(), "noTargets"));
  -        _text.setEditable(false);
  -        _text.setOpaque(false);
  -
  -        JScrollPane scroller = new JScrollPane(_text);
  -
  -        add(BorderLayout.CENTER, scroller);
   	}
   
   	/** 
  -	 * Populate the display with the given target info.
  +	 * Update the display for the current item. 
   	 * 
  -	 * @param targets Targets to display info for.
  +	 * @param item Current item.
   	 */
  -    private void displayTargetInfo(ACSTargetElement[] targets) {
  -
  -        // The text to display.
  -        String text = null;
  -
  -        int num = targets == null ? 0 : targets.length;
  -        Object[] args = null;
  -        switch(num) {
  -          case 0:
  -              text = getAppContext().getResources().
  -                  getString(getClass(), "noTargets");
  -              break;
  -          case 1:
  -              args = getTargetParams(targets[0]);
  -              text = getAppContext().getResources().
  -                  getMessage(getClass(), "oneTarget", args);
  -              break;
  -          default:
  -              args = getTargetParams(targets);
  -              text = getAppContext().getResources().
  -                  getMessage(getClass(), "manyTargets", args);
  -              break;
  +    private void updateDisplay(ACSElement item) {
  +        if(_customizer != null) {
  +            remove(_customizer);
  +            _customizer = null;
           }
   
  -        if(text != null) {
  -            _text.setText(text);
  -        }
  -    }
  -
  -	/** 
  -	 * Get the parameters for the formatted message presented for a single
  -     * target.
  -	 * 
  -	 * @param target Target to generate params for.
  -     * @return Argument list for the formatted message.
  -	 */
  -    private Object[] getTargetParams(ACSTargetElement target) {
  -        List args = new LinkedList();
  -        args.add(target.getName());
  -        args.add(target.getDescription() == null ? 
  -                 "" : target.getDescription());
  -        StringBuffer buf = new StringBuffer();
  -        String[] depends = target.getDependencyNames();
  -        for(int i = 0; i < depends.length; i++) {
  -            buf.append(depends[i]);
  -            if(i < depends.length - 1) {
  -                buf.append(", ");
  -            }
  +        if(item != null) {
  +            _customizer = new DynamicCustomizer(item.getClass(), true);
  +            _customizer.setObject(item);
  +            add(BorderLayout.CENTER, _customizer);
           }
  -        args.add(buf.toString());
  -
  -        return args.toArray();
  +        validate();
       }
   
  -	/** 
  -	 * Get the parameters for the formatted message presented for multiple
  -     * targets.
  -	 * 
  -	 * @param target Targets to generate params for.
  -     * @return Argument list for the formatted message.
  -	 */
  -    private Object[] getTargetParams(ACSTargetElement[] targets) {
  -        List args = new LinkedList();
  -
  -        StringBuffer buf = new StringBuffer();
  -        Set depends = new HashSet();
  -        for(int i = 0; i < targets.length; i++) {
  -            buf.append(targets[i].getName());
  -            if(i < targets.length - 1) {
  -                buf.append(", ");
  -            }
  -
  -            String[] dependNames = targets[i].getDependencyNames();
  -            for(int j = 0; j < dependNames.length; j++) {
  -                depends.add(dependNames[j]);
  -            }
  -        }
  -
  -        args.add(buf.toString());
  -
  -        Iterator it = depends.iterator();
  -        buf = new StringBuffer();
  -        while(it.hasNext()) {
  -            buf.append(it.next());
  -            if(it.hasNext()) {
  -                buf.append(", ");
  -            }
  -        }
  -
  -        args.add(buf.toString());
  -
  -        return args.toArray();
  -    }
   
       /** Class for handling project events. */
       private class Handler implements BusMember {
  @@ -212,7 +126,7 @@
           public void eventPosted(EventObject event) {
               TargetSelectionEvent e = (TargetSelectionEvent) event;
               ACSTargetElement[] targets = e.getSelectedTargets();
  -            displayTargetInfo(targets);
  +            updateDisplay(targets.length == 0 ? null : targets[0]);
           }
   
       }
  
  
  
  1.3       +20 -4     jakarta-ant/src/antidote/org/apache/tools/ant/gui/ResourceManager.java
  
  Index: ResourceManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/antidote/org/apache/tools/ant/gui/ResourceManager.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ResourceManager.java	2000/11/06 12:52:43	1.2
  +++ ResourceManager.java	2000/11/10 20:41:09	1.3
  @@ -63,13 +63,29 @@
    * Singleton class for accessing various resources by the application.
    * Relies on the resource bundles for resource values.
    *
  - * @version $Revision: 1.2 $ 
  + * @version $Revision: 1.3 $ 
    * @author Simeon H.K. Fitch 
    */
   public class ResourceManager {
  -    private ResourceBundle _resources = 
  -        ResourceBundle.getBundle(
  -            "org.apache.tools.ant.gui.resources.antidote");
  +    /** Resources to reference. */
  +    private ResourceBundle _resources = null;
  +
  +	/** 
  +	 * Default ctor. Uses the default properties file for antidote.
  +	 * 
  +	 */
  +    public ResourceManager() {
  +        this("org.apache.tools.ant.gui.resources.antidote");
  +    }
  +
  +	/** 
  +	 * Standard ctor.
  +	 * 
  +	 * @param propName Fully qualified name of the resources to use.
  +	 */
  +    public ResourceManager(String propName) {
  +        _resources = ResourceBundle.getBundle(propName);
  +    }
   
   	/** 
   	 * Get a string resource for the given class.
  
  
  
  1.2       +4 -1      jakarta-ant/src/antidote/org/apache/tools/ant/gui/version.txt
  
  Index: version.txt
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/antidote/org/apache/tools/ant/gui/version.txt,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- version.txt	2000/11/03 12:04:24	1.1
  +++ version.txt	2000/11/10 20:41:09	1.2
  @@ -1,3 +1,6 @@
   VERSION=@VERSION@
   DATE=@DATE@
  -CONTRIBUTORS=Simeon H.K. Fitch, Ant Development Team
  +CONTRIBUTORS=\
  +    Simeon H.K. Fitch, \
  +    Ant Development Team, \
  +    Icons Copyright &copy; 1998 Dean S. Jones
  
  
  
  1.1                  jakarta-ant/src/antidote/org/apache/tools/ant/gui/LabelFieldGBC.java
  
  Index: LabelFieldGBC.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.awt.GridBagConstraints;
  import java.awt.Insets;
  import java.awt.Container;
  import javax.swing.JLabel;
  
  /**
   * Convenience specialization of the GridBagConstraints for laying
   * out label:field pairs.
   * 
   * @version $Revision: 1.1 $ 
   * @author Simeon Fitch 
   */
  public class LabelFieldGBC extends GridBagConstraints {
  
  	/** 
  	 * Default ctor. Sets up the default settings.
  	 * 
  	 */
  	public LabelFieldGBC() {
  		// Add small abount of padding.
  		insets = new Insets(1,3,1,3);
  		// All vertical layout is relative
  		gridy = RELATIVE;
  		// Grid dimensions are equal (one label field pair per row).
  		gridheight = 1;
  		gridwidth = 1;
  	}
  
  	/** 
  	 * Set up constraint values for placing a label before a field.
  	 * 
  	 * @return Constraints for a label.
  	 */
  	public LabelFieldGBC forLabel() {
  		// Labels should only take up as much room as needed. 
  		fill = NONE;
  		// Set location to left side.
  		gridx = 0;
  		// Move it over to be as close to field as possible.
  		anchor = EAST;
  		// Don't take up any extra.
  		weightx = 0.0;
  		return this;
  	}
  
  	/** 
  	 * Provide the same setup as forLabel(), but allow it to expand vertically
  	 * to use up any extra space there may be.
  	 * 
  	 * @return Constraints for label that sucks up vertical space.
  	 */
  	public LabelFieldGBC forLastLabel() {
  		forLabel();
  		fill = VERTICAL;
  		weighty = 1.0;
  		return this;
  	}
  
  	/** 
  	 * Set up constraint values for placing a field after a label.
  	 * 
  	 * @return Constraints for a field.
  	 */
  	public LabelFieldGBC forField() {
  		// The field should take up as much space as is necessary.
  		fill = HORIZONTAL;
  		// Set the location to the right side.
  		gridx = 1;
  		// Center the field in the space available (a noop in this case).
  		anchor = CENTER;
  		// Take up any extra space.
  		weightx = 1.0;
  		return this;
  	}
  
  	/** 
  	 * Provide the same setup as forField(), but allow it to expand vertically
  	 *
  	 * 
  	 * @return Constraintes for field that sucks up vertical space.
  	 */
  	public LabelFieldGBC forLastField() {
  		forField();
  		fill = BOTH;
  		weighty = 1.0;
  		return this;
  	}
  
  }