Browse Source

Started addition of a generic Bean editor/property sheet and supporting

infrastructure for Ant Elements.


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@268168 13f79535-47bb-0310-9956-ffa450edef68
master
metasim 24 years ago
parent
commit
d830141f77
28 changed files with 1987 additions and 241 deletions
  1. +5
    -0
      src/antidote/ChangeLog
  2. +1
    -0
      src/antidote/org/apache/tools/ant/gui/Console.java
  3. +144
    -0
      src/antidote/org/apache/tools/ant/gui/LabelFieldGBC.java
  4. +17
    -103
      src/antidote/org/apache/tools/ant/gui/PropertyEditor.java
  5. +19
    -3
      src/antidote/org/apache/tools/ant/gui/ResourceManager.java
  6. +74
    -0
      src/antidote/org/apache/tools/ant/gui/acs/ACSBeanDescriptor.java
  7. +35
    -98
      src/antidote/org/apache/tools/ant/gui/acs/ACSElement.java
  8. +129
    -0
      src/antidote/org/apache/tools/ant/gui/acs/ACSNamedElement.java
  9. +5
    -5
      src/antidote/org/apache/tools/ant/gui/acs/ACSProjectElement.java
  10. +106
    -0
      src/antidote/org/apache/tools/ant/gui/acs/ACSProjectElementBeanInfo.java
  11. +2
    -19
      src/antidote/org/apache/tools/ant/gui/acs/ACSTargetElement.java
  12. +108
    -0
      src/antidote/org/apache/tools/ant/gui/acs/ACSTargetElementBeanInfo.java
  13. +175
    -0
      src/antidote/org/apache/tools/ant/gui/acs/ACSTreeNodeElement.java
  14. +118
    -0
      src/antidote/org/apache/tools/ant/gui/acs/BaseBeanInfo.java
  15. +14
    -0
      src/antidote/org/apache/tools/ant/gui/acs/beaninfo.properties
  16. +244
    -0
      src/antidote/org/apache/tools/ant/gui/customizer/AbstractPropertyEditor.java
  17. +173
    -0
      src/antidote/org/apache/tools/ant/gui/customizer/DoublePropertyEditor.java
  18. +286
    -0
      src/antidote/org/apache/tools/ant/gui/customizer/DynamicCustomizer.java
  19. +175
    -0
      src/antidote/org/apache/tools/ant/gui/customizer/IntegerPropertyEditor.java
  20. +153
    -0
      src/antidote/org/apache/tools/ant/gui/customizer/StringPropertyEditor.java
  21. +0
    -12
      src/antidote/org/apache/tools/ant/gui/resources/antidote.properties
  22. BIN
      src/antidote/org/apache/tools/ant/gui/resources/default.gif
  23. BIN
      src/antidote/org/apache/tools/ant/gui/resources/new.gif
  24. BIN
      src/antidote/org/apache/tools/ant/gui/resources/open.gif
  25. BIN
      src/antidote/org/apache/tools/ant/gui/resources/save.gif
  26. BIN
      src/antidote/org/apache/tools/ant/gui/resources/start.gif
  27. BIN
      src/antidote/org/apache/tools/ant/gui/resources/stop.gif
  28. +4
    -1
      src/antidote/org/apache/tools/ant/gui/version.txt

+ 5
- 0
src/antidote/ChangeLog View File

@@ -1,3 +1,8 @@
2000-11-10 Simeon H.K. Fitch <simeon@fitch.net>

* org/apache/tools/ant/gui/PropertyEditor.java: Added new
DynamicCustomizer class instead of HTML based info.

2000-11-09 Simeon H.K. Fitch <simeon@fitch.net>

* org/apache/tools/ant/gui/ProjectProxy.java: Started rework of


+ 1
- 0
src/antidote/org/apache/tools/ant/gui/Console.java View File

@@ -95,6 +95,7 @@ public class Console extends AntEditor {
context.getResources().getString(getClass(), "logLevel"));
controls.add(label);
_logLevel = new JComboBox(LogLevelEnum.getValues());
_logLevel.setSelectedItem(LogLevelEnum.INFO);
controls.add(_logLevel);
add(BorderLayout.NORTH, controls);


+ 144
- 0
src/antidote/org/apache/tools/ant/gui/LabelFieldGBC.java View File

@@ -0,0 +1,144 @@
/*
* 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$
* @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;
}

}

+ 17
- 103
src/antidote/org/apache/tools/ant/gui/PropertyEditor.java View File

@@ -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.*;
@@ -68,8 +70,8 @@ import java.awt.BorderLayout;
*/
class PropertyEditor extends AntEditor {

/** Text pane. */
private JEditorPane _text = null;
/** The property sheet. */
private DynamicCustomizer _customizer = null;

/**
* Standard ctor.
@@ -80,115 +82,27 @@ class PropertyEditor extends AntEditor {
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);
if(item != null) {
_customizer = new DynamicCustomizer(item.getClass(), true);
_customizer.setObject(item);
add(BorderLayout.CENTER, _customizer);
}
validate();
}

/**
* 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(", ");
}
}
args.add(buf.toString());

return args.toArray();
}

/**
* 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 @@ class PropertyEditor extends AntEditor {
public void eventPosted(EventObject event) {
TargetSelectionEvent e = (TargetSelectionEvent) event;
ACSTargetElement[] targets = e.getSelectedTargets();
displayTargetInfo(targets);
updateDisplay(targets.length == 0 ? null : targets[0]);
}

}


+ 19
- 3
src/antidote/org/apache/tools/ant/gui/ResourceManager.java View File

@@ -67,9 +67,25 @@ import java.io.File;
* @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.


+ 74
- 0
src/antidote/org/apache/tools/ant/gui/acs/ACSBeanDescriptor.java View File

@@ -0,0 +1,74 @@
/*
* 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 org.apache.tools.ant.gui.ResourceManager;
import java.beans.*;

/**
* Specialized BeanDescriptor for providing more descriptive information.
*
* @version $Revision$
* @author Simeon Fitch
*/
class ACSBeanDescriptor extends BeanDescriptor {
public ACSBeanDescriptor(BaseBeanInfo type) {
super(type.getType());
setDisplayName(
type.getResources().getString(type.getClass(), "beanName"));
setShortDescription(
type.getResources().getString(type.getClass(), "beanDescription"));
}
}

+ 35
- 98
src/antidote/org/apache/tools/ant/gui/acs/ACSElement.java View File

@@ -53,11 +53,10 @@
*/
package org.apache.tools.ant.gui.acs;


import org.w3c.dom.Node;
import com.sun.xml.tree.ElementNode;
import javax.swing.tree.TreeNode;
import java.util.*;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeSupport;

/**
* Abstract base class for all Ant Construction Set
@@ -65,9 +64,10 @@ import java.util.*;
*
* @version $Revision$
* @author Simeon Fitch */
public abstract class ACSElement extends ElementNode implements TreeNode {
/** Cache of TreeNode only children. */
private List _treeNodeCache = null;
public abstract class ACSElement extends ElementNode {

/** Event support. */
private PropertyChangeSupport _propSupport = null;

/**
* Default ctor.
@@ -87,105 +87,42 @@ public abstract class ACSElement extends ElementNode implements TreeNode {
}

/**
* Get the cache of TreeNode only children.
* Add a change listener.
*
* @return List of TreeNodes that are children.
* @param l Listener to add.
*/
private List getCache() {
if(_treeNodeCache == null) {
_treeNodeCache = new ArrayList();
for(int i = 0; i < getLength(); i++) {
if(item(i) instanceof TreeNode) {
_treeNodeCache.add(item(i));
}
}
public void addPropertyChangeListener(PropertyChangeListener l) {
if(_propSupport == null) {
_propSupport = new PropertyChangeSupport(this);
}

return _treeNodeCache;
}
/**
* Returns the child <code>TreeNode</code> at index
* <code>childIndex</code>.
*/
public TreeNode getChildAt(int childIndex) {
List nodes = getCache();
return (TreeNode) nodes.get(childIndex);
_propSupport.addPropertyChangeListener(l);
}

/**
* Returns the number of children <code>TreeNode</code>s the receiver
* contains.
*/
public int getChildCount() {
List nodes = getCache();
return nodes.size();
}

/**
* Returns the parent <code>TreeNode</code> of the receiver.
*/
public TreeNode getParent() {
return (TreeNode) getParent();
}

/**
* Returns the index of <code>node</code> in the receivers children.
* If the receiver does not contain <code>node</code>, -1 will be
* returned.
*/
public int getIndex(TreeNode node) {
List nodes = getCache();
return nodes.indexOf(node);
}

/**
* Returns true if the receiver allows children.
*/
public boolean getAllowsChildren() {
return true;
}

/**
* Returns true if the receiver is a leaf.
*/
public boolean isLeaf() {
List nodes = getCache();
return nodes.size() <= 0;
}

/**
* Returns the children of the reciever as an Enumeration.
*/
public Enumeration children() {
return new NodeEnum();
}

/** Internal iterator for the child nodes. */
private class NodeEnum implements Enumeration {
/** Current child index. */
private int _index = 0;

/**
* Determine if there are more elements to visit.
*
* @return True if nextElement() can be called, false otherwise.
*/
public boolean hasMoreElements() {
List nodes = getCache();
return _index < nodes.size();
/**
* Remove a change listener
*
* @param l Listener to remove.
*/
public void removePropertyChangeListener(PropertyChangeListener l) {
if(_propSupport == null) {
_propSupport = new PropertyChangeSupport(this);
}
_propSupport.removePropertyChangeListener(l);
}

/**
* Get the next element. hasMoreElements() must currently return true.
*
* @return Next element
*/
public Object nextElement() {
List nodes = getCache();
return nodes.get(_index++);
/**
* Fire a change event to all listener.
*
* @param propName Name of the property.
* @param oldValue The old value.
* @param newValue The new value.
*/
protected void firePropertyChange(
String propName, Object oldValue, Object newValue) {
if(_propSupport != null) {
_propSupport.firePropertyChange(propName, oldValue, newValue);
}

}

}

+ 129
- 0
src/antidote/org/apache/tools/ant/gui/acs/ACSNamedElement.java View File

@@ -0,0 +1,129 @@
/*
* 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;
import java.util.StringTokenizer;

/**
* Class representing an element with a name and description.
*
* @version $Revision$
* @author Simeon Fitch
*/
public class ACSNamedElement extends ACSTreeNodeElement {
/** The 'name' property name. */
public static final String NAME = "name";
/** The discription property name. */
public static final String DESCRIPTION = "description";

/**
* Default ctor.
*
*/
public ACSNamedElement() {

}

/**
* Get the target name.
*
* @return Target name.
*/
public String getName() {
return getAttribute(NAME);
}

/**
* Set the name.
*
* @param name New name value.
*/
public void setName(String name) {
String old = getName();
setAttribute(NAME, name);
firePropertyChange(NAME, old, name);
}

/**
* Get the long description of the target.
*
* @return Target description.
*/
public String getDescription() {
return getAttribute(DESCRIPTION);
}

/**
* Set the description
*
* @param description New description value.
*/
public void setDescription(String description) {
String old = getDescription();
setAttribute(DESCRIPTION, description);
firePropertyChange(DESCRIPTION, old, description);
}

/**
* Get the display name.
*
* @return Display name.
*/
public String getDisplayName() {
return getTagName() + ": " + getName();
}


}

+ 5
- 5
src/antidote/org/apache/tools/ant/gui/acs/ACSProjectElement.java View File

@@ -61,18 +61,18 @@ import com.sun.xml.tree.ElementNode;
* @version $Revision$
* @author Simeon Fitch
*/
public class ACSProjectElement extends ACSElement {
public class ACSProjectElement extends ACSNamedElement {
public ACSProjectElement() {

}

/**
* Get the project name.
* Get the type that this BeanInfo represents.
*
* @return Project name.
* @return Type.
*/
public String getName() {
return getAttribute("name");
public Class getType() {
return ACSProjectElement.class;
}

/**


+ 106
- 0
src/antidote/org/apache/tools/ant/gui/acs/ACSProjectElementBeanInfo.java View File

@@ -0,0 +1,106 @@
/*
* 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 ACSTargetElement class.
*
* @version $Revision$
* @author Simeon Fitch
*/
public class ACSProjectElementBeanInfo extends BaseBeanInfo {
/**
* Default ctor.
*
*/
public ACSProjectElementBeanInfo() {
}

/**
* Get the type that this BeanInfo represents.
*
* @return Type.
*/
public Class getType() {
return ACSProjectElement.class;
}

/**
* Get the property descriptors.
*
* @return Property descriptors.
*/
public PropertyDescriptor[] getPropertyDescriptors() {
PropertyDescriptor[] retval = null;

try {
retval = new PropertyDescriptor[] {
new PropertyDescriptor(ACSProjectElement.NAME,
ACSProjectElement.class),
new PropertyDescriptor(ACSProjectElement.DESCRIPTION,
ACSProjectElement.class)

};
}
catch(IntrospectionException ex) {
ex.printStackTrace();
throw new Error(ex.toString());
}

return retval;
}

}

+ 2
- 19
src/antidote/org/apache/tools/ant/gui/acs/ACSTargetElement.java View File

@@ -62,31 +62,14 @@ import java.util.StringTokenizer;
* @version $Revision$
* @author Simeon Fitch
*/
public class ACSTargetElement extends ACSElement {
public class ACSTargetElement extends ACSNamedElement {

/**
* Default ctor.
*
*/
public ACSTargetElement() {

}

/**
* Get the target name.
*
* @return Target name.
*/
public String getName() {
return getAttribute("name");
}

/**
* Get the long description of the target.
*
* @return Target description.
*/
public String getDescription() {
return getAttribute("description");
}

/**


+ 108
- 0
src/antidote/org/apache/tools/ant/gui/acs/ACSTargetElementBeanInfo.java View File

@@ -0,0 +1,108 @@
/*
* 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 ACSTargetElement class.
*
* @version $Revision$
* @author Simeon Fitch
*/
public class ACSTargetElementBeanInfo extends BaseBeanInfo {
/**
* Default ctor.
*
*/
public ACSTargetElementBeanInfo() {
}

/**
* Get the type that this BeanInfo represents.
*
* @return Type.
*/
public Class getType() {
return ACSTargetElement.class;
}

/**
* Get the property descriptors.
*
* @return Property descriptors.
*/
public PropertyDescriptor[] getPropertyDescriptors() {
PropertyDescriptor[] retval = null;

try {
retval = new PropertyDescriptor[] {
new PropertyDescriptor(getResources().getString(
getClass(),ACSTargetElement.NAME),
ACSTargetElement.class),
new PropertyDescriptor(getResources().getString(
getClass(),ACSTargetElement.DESCRIPTION),
ACSTargetElement.class)

};
}
catch(IntrospectionException ex) {
ex.printStackTrace();
throw new Error(ex.toString());
}

return retval;
}

}

+ 175
- 0
src/antidote/org/apache/tools/ant/gui/acs/ACSTreeNodeElement.java View File

@@ -0,0 +1,175 @@
/*
* 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 org.w3c.dom.Node;
import com.sun.xml.tree.ElementNode;
import javax.swing.tree.TreeNode;
import java.util.*;

/**
* Abstract base class for all ACSElement classes that are also tree node.
*
* @version $Revision$
* @author Simeon Fitch
*/
public abstract class ACSTreeNodeElement extends ACSElement
implements TreeNode {

/** Cache of TreeNode only children. */
private List _treeNodeCache = null;

/**
* Get the cache of TreeNode only children.
*
* @return List of TreeNodes that are children.
*/
private List getCache() {
if(_treeNodeCache == null) {
_treeNodeCache = new ArrayList();
for(int i = 0; i < getLength(); i++) {
if(item(i) instanceof TreeNode) {
_treeNodeCache.add(item(i));
}
}
}

return _treeNodeCache;
}
/**
* Returns the child <code>TreeNode</code> at index
* <code>childIndex</code>.
*/
public TreeNode getChildAt(int childIndex) {
List nodes = getCache();
return (TreeNode) nodes.get(childIndex);
}

/**
* Returns the number of children <code>TreeNode</code>s the receiver
* contains.
*/
public int getChildCount() {
List nodes = getCache();
return nodes.size();
}

/**
* Returns the parent <code>TreeNode</code> of the receiver.
*/
public TreeNode getParent() {
return (TreeNode) getParent();
}

/**
* Returns the index of <code>node</code> in the receivers children.
* If the receiver does not contain <code>node</code>, -1 will be
* returned.
*/
public int getIndex(TreeNode node) {
List nodes = getCache();
return nodes.indexOf(node);
}

/**
* Returns true if the receiver allows children.
*/
public boolean getAllowsChildren() {
return true;
}

/**
* Returns true if the receiver is a leaf.
*/
public boolean isLeaf() {
List nodes = getCache();
return nodes.size() <= 0;
}

/**
* Returns the children of the reciever as an Enumeration.
*/
public Enumeration children() {
return new NodeEnum();
}

/** Internal iterator for the child nodes. */
private class NodeEnum implements Enumeration {
/** Current child index. */
private int _index = 0;

/**
* Determine if there are more elements to visit.
*
* @return True if nextElement() can be called, false otherwise.
*/
public boolean hasMoreElements() {
List nodes = getCache();
return _index < nodes.size();
}

/**
* Get the next element. hasMoreElements() must currently return true.
*
* @return Next element
*/
public Object nextElement() {
List nodes = getCache();
return nodes.get(_index++);
}

}
}

+ 118
- 0
src/antidote/org/apache/tools/ant/gui/acs/BaseBeanInfo.java View File

@@ -0,0 +1,118 @@
/*
* 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 org.apache.tools.ant.gui.ResourceManager;
import java.beans.*;

/**
* Abstract base class for ACS BeanInfo classes.
*
* @version $Revision$
* @author Simeon Fitch
*/
abstract class BaseBeanInfo extends SimpleBeanInfo {

/** Resource provider for bean info. */
private static ResourceManager _resources = new ResourceManager(
"org.apache.tools.ant.gui.acs.beaninfo");

/**
* Default ctor.
*
*/
protected BaseBeanInfo() {
}

/**
* Get the local resources.
*
* @return Resources.
*/
ResourceManager getResources() {
return _resources;
}

/**
* Get the bean descriptor.
*
* @return Bean descriptor.
*/
public BeanDescriptor getBeanDescriptor() {
return new ACSBeanDescriptor(this);
}

/**
* Get the type that this BeanInfo represents.
*
* @return Type.
*/
public abstract Class getType();

/**
* Gets the beans <code>PropertyDescriptor</code>s.
*
* @return An array of PropertyDescriptors describing the editable
* properties supported by this bean. May return null if the
* information should be obtained by automatic analysis.
* <p>
* If a property is indexed, then its entry in the result array will
* belong to the IndexedPropertyDescriptor subclass of PropertyDescriptor.
* A client of getPropertyDescriptors can use "instanceof" to check
* if a given PropertyDescriptor is an IndexedPropertyDescriptor.
*/
public abstract PropertyDescriptor[] getPropertyDescriptors();


}

+ 14
- 0
src/antidote/org/apache/tools/ant/gui/acs/beaninfo.properties View File

@@ -0,0 +1,14 @@
# Properties file for BeanInfo strings

org.apache.tools.ant.gui.acs.ACSTargetElementBeanInfo.beanName=Target
org.apache.tools.ant.gui.acs.ACSTargetElementBeanInfo.beanDescription=\
An executable target in the build.
org.apache.tools.ant.gui.acs.ACSTargetElementBeanInfo.name=Name
org.apache.tools.ant.gui.acs.ACSTargetElementBeanInfo.description=Description

org.apache.tools.ant.gui.acs.ACSProjectElementBeanInfo.beanName=Project
org.apache.tools.ant.gui.acs.ACSProjectElementBeanInfo.beanDescription=\
The top level project in the build definition.
org.apache.tools.ant.gui.acs.ACSProjectElementBeanInfo.name=Name
org.apache.tools.ant.gui.acs.ACSProjectElementBeanInfo.description=Description


+ 244
- 0
src/antidote/org/apache/tools/ant/gui/customizer/AbstractPropertyEditor.java View File

@@ -0,0 +1,244 @@
/*
* 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 java.beans.*;
import java.awt.Graphics;
import java.awt.Component;
import java.awt.Rectangle;
import javax.swing.JComponent;
import java.awt.event.FocusEvent;
import java.awt.event.FocusAdapter;

/**
* Abstract base class for the custom type property editors.
*
* @version $Revision$
* @author Simeon Fitch
*/
public abstract class AbstractPropertyEditor implements PropertyEditor {

/** Bean property change property name. */
public static final String BEAN_PROP = "BeanEditorProperty";

private PropertyChangeSupport _listeners = new PropertyChangeSupport(this);
/**
* Default constructor.
*
*/
protected AbstractPropertyEditor() {
}

/**
* Paint a representation of the value into a given area of screen
* real estate. Note that the propertyEditor is responsible for doing
* its own clipping so that it fits into the given rectangle.
* <p>
* If the PropertyEditor doesn't honor paint requests (see isPaintable)
* this method should be a silent noop.
* <p>
* The given Graphics object will have the default font, color, etc of
* the parent container. The PropertyEditor may change graphics attributes
* such as font and color and doesn't need to restore the old values.
*
* @param gfx Graphics object to paint into.
* @param box Rectangle within graphics object into which we should paint.
*/
public void paintValue(Graphics gfx, Rectangle box) {
Object o = getValue();
String s = o == null ? "<null>" : o.toString();
gfx.drawString(s, box.x, box.y);
}


/**
* Fire a property change event to listeners.
*
* @param oldValue Old value.
* @param newValue New value.
*/
public void firePropertyChange(Object oldValue, Object newValue) {
_listeners.firePropertyChange(BEAN_PROP, oldValue, newValue);
}

/**
* Add a property change listener. XXX This may cause undesired
* side affects with merging property changes with JPanel class.
* Need to test for a while.
*
* @param l Change listener.
*/
public void addPropertyChangeListener(PropertyChangeListener l) {
_listeners.addPropertyChangeListener(l);
}

/**
* Remove a property change listener.
*
* @param l Change listener.
*/
public void removePropertyChangeListener(PropertyChangeListener l) {
_listeners.removePropertyChangeListener(l);
}

/**
* @return True if the class will honor the paintValue method.
*/
public boolean isPaintable() {
return true;
}

/**
* If the property value must be one of a set of known tagged values,
* then this method should return an array of the tags. This can
* be used to represent (for example) enum values. If a PropertyEditor
* supports tags, then it should support the use of setAsText with
* a tag value as a way of setting the value and the use of getAsText
* to identify the current value.
*
* @return The tag values for this property. May be null if this
* property cannot be represented as a tagged value.
*
*/
public String[] getTags() {
return null;
}

/**
* A PropertyEditor may choose to make available a full custom Component
* that edits its property value. It is the responsibility of the
* PropertyEditor to hook itself up to its editor Component itself and
* to report property value changes by firing a PropertyChange event.
* <P>
* The higher-level code that calls getCustomEditor may either embed
* the Component in some larger property sheet, or it may put it in
* its own individual dialog, or ...
*
* @return A java.awt.Component that will allow a human to directly
* edit the current property value. May be null if this is
* not supported.
*/
public Component getCustomEditor() {
return getChild();
}

/**
* @return True if the propertyEditor can provide a custom editor.
*/
public boolean supportsCustomEditor() {
return true;
}

/**
* 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 "";
}

/**
* Get the child editing component.
*
* @return Child editing component.
*/
protected abstract Component getChild();

/** Helper class for detecting changes and generating change events
* on a focus lost event. */
protected static class FocusHandler extends FocusAdapter {
/** Last value of the editor. */
private Object _value = null;
/** Editor of interest. */
private AbstractPropertyEditor _editor = null;

/**
* Standard constructor.
*
* @param editor Editor of interest.
*/
public FocusHandler(AbstractPropertyEditor editor) {
_editor = editor;
}

/**
* Called when focus is gained.
*
* @param e Focus event.
*/
public void focusGained(FocusEvent e) {
_value = _editor.getValue();
}
/**
* Called when focus is lost. Checks to see if value changed and
* fires a change event if needed.
*
* @param e Focus event.
*/
public void focusLost(FocusEvent e) {
if((_value != null && !_value.equals(_editor.getValue())) ||
(_value == null && _editor.getValue() != null)) {
_editor.firePropertyChange(_value, _editor.getValue());
}
}
}
}

+ 173
- 0
src/antidote/org/apache/tools/ant/gui/customizer/DoublePropertyEditor.java View File

@@ -0,0 +1,173 @@
/*
* 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;

/**
* Custom property editor for editing double values.
*
* @version $Revision$
* @author Simeon Fitch
*/
public class DoublePropertyEditor extends AbstractPropertyEditor {
/** Editing widget. */
private JTextField _widget = null;

/**
* Default ctor.
*
*/
public DoublePropertyEditor() {
_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 "new Double(" + 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) {
Object old = _widget.getText();
if(!(value instanceof Double)) {
value = new Double(0);
}

_widget.setText(value.toString());
firePropertyChange(old, value);
}

/**
* @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() {
Double retval = null;
try {
retval = new Double(_widget.getText());
}
catch(NumberFormatException ex) {
retval = new Double(0);
_widget.setText(retval.toString());
}
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) {
Object old = _widget.getText();
Double val = null;
try {
val = new Double(text);
}
catch(NumberFormatException ex) {
val = new Double(0);
}
text = val.toString();
_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();
}
}



+ 286
- 0
src/antidote/org/apache/tools/ant/gui/customizer/DynamicCustomizer.java View File

@@ -0,0 +1,286 @@
/*
* 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 org.apache.tools.ant.gui.LabelFieldGBC;
import java.lang.reflect.*;
import java.beans.*;
import javax.swing.*;
import java.util.Hashtable;
import java.util.Enumeration;
import java.awt.GridBagLayout;
import java.awt.GridBagConstraints;
import java.awt.Component;

/**
* Widget for dynamically constructing a property editor based on the
* an Object's BeanInfo. Essentially a property sheet.
*
* @version $Revision$
* @author Simeon Fitch
*/
public class DynamicCustomizer extends JPanel {
static {
PropertyEditorManager.registerEditor(
String.class, StringPropertyEditor.class);
PropertyEditorManager.registerEditor(
int.class, IntegerPropertyEditor.class);
PropertyEditorManager.registerEditor(
Integer.class, IntegerPropertyEditor.class);
PropertyEditorManager.registerEditor(
double.class, DoublePropertyEditor.class);
PropertyEditorManager.registerEditor(
Double.class, DoublePropertyEditor.class);
}

/** The type that this editor instance can handle. */
private Class _type = null;
/** The value currently being edited. */
private Object _value = null;
/** Mapping from PropertyDescriptor to PropertyEditor. */
private Hashtable _prop2Editor = new Hashtable();
/** Mapping from PropertyEditor to field PropertyDescriptor. */
private Hashtable _editor2Prop = new Hashtable();
/** Listener for receiving change events from the editors. */
private EditorChangeListener _eListener = new EditorChangeListener();
/** Read-only flag. */
private boolean _readOnly = false;


/**
* Standard constructor.
*
* @param type Type that you are going to be creating and editor for.
*/
public DynamicCustomizer(Class type) {
this(type, false);
}

/**
* Standard constructor.
*
* @param type Type that you are going to be creating and editor for.
* @param readOnly Set to true to create a read-only customizer.
*/
public DynamicCustomizer(Class type, boolean readOnly) {
super(new GridBagLayout());
_readOnly = readOnly;
_type = type;
LabelFieldGBC gbc = new LabelFieldGBC();
try {
BeanInfo info = Introspector.getBeanInfo(type);
setBorder(BorderFactory.createTitledBorder(
info.getBeanDescriptor().getDisplayName()));
PropertyDescriptor[] props = info.getPropertyDescriptors();
for(int i = 0; i < props.length; i++) {
if(props[i].getName().equals("class")) continue;
JLabel label = new JLabel(props[i].getDisplayName() + ":");
// Lookup the editor.
PropertyEditor editor = getEditorForProperty(props[i]);
if(editor == null) continue;
// Add a listener to the editor so we know when to update
// the bean's fields.
editor.addPropertyChangeListener(_eListener);
// XXX What we need to do right here is provide a component
// that makes use of the "paintable" capability of the editor.
Component comp = editor.getCustomEditor();
if(comp == null) {
comp = new JLabel("<<null editor>>");
}
// See if it is a read-only property. If so, then just
// display it.
if(_readOnly || props[i].getWriteMethod() == null) {
comp.setEnabled(false);
}

// Setup the accellerator key.
label.setLabelFor(comp);
label.setDisplayedMnemonic(label.getText().charAt(0));

// Set the tool tip text, if any.
String tip = props[i].getShortDescription();
if(tip != null) {
label.setToolTipText(tip);
if(comp instanceof JComponent) {
((JComponent)comp).setToolTipText(tip);
}
}


// Add the label and fields.
add(label, gbc.forLabel());
add(comp, gbc.forField());

// Set the mappings between editor and property, etc. for
// quick lookup later.
_prop2Editor.put(props[i], editor);
_editor2Prop.put(editor, props[i]);
}
// Filler...
add(new JLabel(), gbc.forLastLabel());

}
catch(Exception ex) {
ex.printStackTrace();
}
}


/**
* Set the object to be edited.
*
* @param value The object to be edited.
*/
public void setObject(Object value) {
if(!(_type.isInstance(value))) {
throw new IllegalArgumentException(
value.getClass() + " is not of type " + _type);
}
_value = value;
// Iterate over each property, doing a lookup on the associated editor
// and setting the editor's value to the value of the property.
Enumeration enum = _prop2Editor.keys();
while(enum.hasMoreElements()) {
PropertyDescriptor desc = (PropertyDescriptor) enum.nextElement();
PropertyEditor editor = (PropertyEditor) _prop2Editor.get(desc);
Method reader = desc.getReadMethod();
if(reader != null) {
try {
Object val = reader.invoke(_value, null);
editor.setValue(val);
}
catch(IllegalAccessException ex) {
ex.printStackTrace();
}
catch(InvocationTargetException ex) {
ex.getTargetException().printStackTrace();
}
}
}
}

private PropertyEditor getEditorForProperty(PropertyDescriptor prop) {
PropertyEditor retval = null;
Class type = prop.getPropertyEditorClass();
if(type != null) {
try {
retval = (PropertyEditor) type.newInstance();
}
catch(Exception ex) {
ex.printStackTrace();
}
}
// Handle case where there is no special editor
// associated with the property. In that case we ask the
// PropertyEditor manager for the editor registered for the
// given property type.
if(retval == null) {
retval = PropertyEditorManager.findEditor(prop.getPropertyType());
}

return retval;
}

/** Class for receiving change events from teh PropertyEditor objects. */
private class EditorChangeListener implements PropertyChangeListener {
public void propertyChange(PropertyChangeEvent e) {
PropertyEditor editor = (PropertyEditor) e.getSource();
PropertyDescriptor prop =
(PropertyDescriptor) _editor2Prop.get(editor);
Method writer = prop.getWriteMethod();
if(writer != null) {
try {
Object[] params = { editor.getValue() };
writer.invoke(_value, params);
//firePropertyChange(
//prop.getName(), null, editor.getValue());
}
catch(IllegalAccessException ex) {
ex.printStackTrace();
}
catch(InvocationTargetException ex) {
ex.getTargetException().printStackTrace();
}
}
}
}


/**
* Test code.
*
* @param args First arg is the class name to create
*/
public static void main(String[] args) {

try {
Class c = Class.forName(args[0]);
JFrame f = new JFrame(c.getName());
DynamicCustomizer custom =
new DynamicCustomizer(c);
custom.setObject(c.newInstance());
f.getContentPane().add(custom);
f.pack();
f.setVisible(true);
}
catch(Exception ex) {
ex.printStackTrace();
}
}
}

+ 175
- 0
src/antidote/org/apache/tools/ant/gui/customizer/IntegerPropertyEditor.java View File

@@ -0,0 +1,175 @@
/*
* 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;

/**
* Custom property editor for integer types.
*
* @version $Revision$
* @author Simeon Fitch
*/
public class IntegerPropertyEditor extends AbstractPropertyEditor {
/** Editing widget. */
private JTextField _widget = null;

/**
* Default ctor.
*
*/
public IntegerPropertyEditor() {
_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 "new Integer(" + 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) {
Object old = _widget.getText();
if(!(value instanceof Integer)) {
value = new Integer(0);
}

_widget.setText(value.toString());
firePropertyChange(old, value);
}

/**
* @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() {
Integer retval = null;
try {
retval = new Integer(_widget.getText());
}
catch(NumberFormatException ex) {
retval = new Integer(0);
_widget.setText(retval.toString());
}
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) {
Object old = _widget.getText();
Integer val = null;
try {
val = new Integer(text);
}
catch(NumberFormatException ex) {
val = new Integer(0);
}
text = val.toString();
_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();
}


}



+ 153
- 0
src/antidote/org/apache/tools/ant/gui/customizer/StringPropertyEditor.java View File

@@ -0,0 +1,153 @@
/*
* 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;

/**
* Custom property editor for string types.
*
* @version $Revision$
* @author Simeon Fitch
*/
public class StringPropertyEditor extends AbstractPropertyEditor {
private JTextField _widget = null;

/**
* Default ctor.
*
*/
public StringPropertyEditor() {
_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) {
Object old = _widget.getText();
_widget.setText(String.valueOf(value));
firePropertyChange(old, value);
}

/**
* @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() {
return _widget.getText();
}

/**
* 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();
}


}



+ 0
- 12
src/antidote/org/apache/tools/ant/gui/resources/antidote.properties View File

@@ -18,18 +18,6 @@ org.apache.tools.ant.gui.SourceEditor.name=Source

org.apache.tools.ant.gui.PropertyEditor.name=Target Info
org.apache.tools.ant.gui.PropertyEditor.noTargets=No targets selected.
org.apache.tools.ant.gui.PropertyEditor.oneTarget=\
<html><table>\
<tr><td align="right" valign="top"><b>Name</b>:</td><td>{0}</td></tr>\
<tr><td align="right" valign="top"><b>Description</b>:</td><td>{1}</td></tr>\
<tr><td align="right" valign="top"><b>Depends</b>:</td><td>{2}</td></tr>\
</table></html>

org.apache.tools.ant.gui.PropertyEditor.manyTargets=\
<html><table>\
<tr><td align="right"><b>Names</b>:</td><td>{0}</td></tr>\
<tr><td align="right"><b>Depends</b>:</td><td>{1}</td></tr>\
</table></html>

org.apache.tools.ant.gui.ProjectNavigator.name=Project
org.apache.tools.ant.gui.Console.name=Console


BIN
src/antidote/org/apache/tools/ant/gui/resources/default.gif View File

Before After
Width: 26  |  Height: 26  |  Size: 1.2 KiB Width: 20  |  Height: 20  |  Size: 987 B

BIN
src/antidote/org/apache/tools/ant/gui/resources/new.gif View File

Before After
Width: 24  |  Height: 24  |  Size: 139 B Width: 20  |  Height: 20  |  Size: 997 B

BIN
src/antidote/org/apache/tools/ant/gui/resources/open.gif View File

Before After
Width: 24  |  Height: 24  |  Size: 146 B Width: 20  |  Height: 20  |  Size: 1001 B

BIN
src/antidote/org/apache/tools/ant/gui/resources/save.gif View File

Before After
Width: 24  |  Height: 24  |  Size: 184 B Width: 20  |  Height: 20  |  Size: 981 B

BIN
src/antidote/org/apache/tools/ant/gui/resources/start.gif View File

Before After
Width: 24  |  Height: 24  |  Size: 888 B Width: 20  |  Height: 20  |  Size: 988 B

BIN
src/antidote/org/apache/tools/ant/gui/resources/stop.gif View File

Before After
Width: 24  |  Height: 24  |  Size: 888 B Width: 20  |  Height: 20  |  Size: 989 B

+ 4
- 1
src/antidote/org/apache/tools/ant/gui/version.txt View File

@@ -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

Loading…
Cancel
Save