chrisw 2003/01/28 14:03:44
Modified: src/java/org/apache/tools/ant/gui/acs ACSFactory.java
src/java/org/apache/tools/ant/gui/customizer
FilePropertyEditor.java
src/java/org/apache/tools/ant/gui/modules/edit
AttributePropertyEditor.java
src/java/org/apache/tools/ant/gui/xml DOMAttributes.java
src/java/org/apache/tools/ant/gui Main.java
Added: src/java/org/apache/tools/ant/gui/customizer
BooleanPropertyEditor.java
DynamicTableCellEditor.java LinePropertyEditor.java
Log:
Fix for 16510 + Manual fixing the fix (Editing a cell with no attribute
selected) + formating + 2��� - 2000
Revision Changes Path
1.5 +4 -4
jakarta-ant-antidote/src/java/org/apache/tools/ant/gui/acs/ACSFactory.java
Index: ACSFactory.java
===================================================================
RCS file:
/home/cvs/jakarta-ant-antidote/src/java/org/apache/tools/ant/gui/acs/ACSFactory.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- ACSFactory.java 13 Jan 2003 14:11:19 -0000 1.4
+++ ACSFactory.java 28 Jan 2003 22:03:43 -0000 1.5
@@ -82,7 +82,7 @@
* Factory for loading Ant Construction set elements.
*
* @version $Revision$
- * @author Simeon Fitch, Christoph Wilhelms<a href="mailto:[EMAIL
PROTECTED]">[EMAIL PROTECTED]</a>
+ * @author Simeon Fitch, Christoph Wilhelms<a href="mailto:[EMAIL
PROTECTED]">[EMAIL PROTECTED]</a>, Craig Campbell
*/
public class ACSFactory {
/** Singleton instance of the factory. */
@@ -184,8 +184,8 @@
(name.equals ("description") && type.equals
("java.lang.String"))*/)) {
continue;
}
-// info._attributes.put(name, type); // for debug
purpose only
- info._attributes.put(name, "");
+ info._attributes.put(name, type); // type is now needed
for associating attribute name with a custom editor
+// info._attributes.put(name, "");
}
}
else info._attributes = null;
1.2 +5 -4
jakarta-ant-antidote/src/java/org/apache/tools/ant/gui/customizer/FilePropertyEditor.java
Index: FilePropertyEditor.java
===================================================================
RCS file:
/home/cvs/jakarta-ant-antidote/src/java/org/apache/tools/ant/gui/customizer/FilePropertyEditor.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- FilePropertyEditor.java 8 Apr 2001 23:42:12 -0000 1.1
+++ FilePropertyEditor.java 28 Jan 2003 22:03:44 -0000 1.2
@@ -1,7 +1,7 @@
/*
* The Apache Software License, Version 1.1
*
- * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * Copyright (c) 2001-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -67,7 +67,7 @@
* Custom property editor for File types.
*
* @version $Revision$
- * @author Simeon Fitch
+ * @author Simeon Fitch, Craig Campbell
*/
public class FilePropertyEditor extends AbstractPropertyEditor {
/** Area for typing in the file name. */
@@ -90,7 +90,8 @@
_container.add(_widget, BorderLayout.CENTER);
- JButton b = new JButton("Browse...");
+ JButton b = new JButton("...");
+ b.setBorder(BorderFactory.createEtchedBorder());
b.addActionListener(new ActionHandler());
_container.add(b, BorderLayout.EAST);
}
1.1
jakarta-ant-antidote/src/java/org/apache/tools/ant/gui/customizer/BooleanPropertyEditor.java
Index: BooleanPropertyEditor.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999, 2000 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Ant", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 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.awt.event.ActionEvent;
import java.awt.event.ActionListener;
/**
* Custom property editor for editing boolean values.
*
* @version 1.0
* @author Craig Campbell
*/
public class BooleanPropertyEditor extends AbstractPropertyEditor {
/** Editing widget. */
private JCheckBox _widget = null;
/**
* Default ctor.
*
*/
public BooleanPropertyEditor() {
_widget = new JCheckBox();
_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 Boolean(" + 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 = getValue();
if(!(value instanceof Boolean)) {
value = new Boolean(false);
}
_widget.setSelected(((Boolean)value).booleanValue());
}
/**
* Set the component lable
* @param name Component label
*/
public void setText(String name) {
_widget.setText(name);
}
/**
* Get the component 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 new Boolean(_widget.isSelected());
}
/**
* 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) {
Boolean val = null;
try {
val = new Boolean(text);
}
catch(IllegalArgumentException ex) {
val = new Boolean(false);
}
setValue(val);
}
/**
* Get the componenet as humand readable 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 String.valueOf(_widget.isSelected());
}
}
1.1
jakarta-ant-antidote/src/java/org/apache/tools/ant/gui/customizer/DynamicTableCellEditor.java
Index: DynamicTableCellEditor.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Ant", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 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 javax.swing.*;
import javax.swing.table.TableColumn;
import java.util.*;
import java.io.File;
import java.awt.*;
/**
* Widget for dynamically constructing a cell editor based on the
* a type that gets registered with the editor.
*
* @version $Revision: 1.1 $
* @author Craig Campbell, Christoph Wilhelms
*/
public class DynamicTableCellEditor extends DefaultCellEditor {
static {
PropertyEditorManager.registerEditor(
String.class, LinePropertyEditor.class);
PropertyEditorManager.registerEditor(
String[].class, StringArrayPropertyEditor.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);
PropertyEditorManager.registerEditor(
Properties.class, PropertiesPropertyEditor.class);
PropertyEditorManager.registerEditor(
File.class, FilePropertyEditor.class);
PropertyEditorManager.registerEditor(
Object.class, ObjectPropertyEditor.class);
PropertyEditorManager.registerEditor(
boolean.class, BooleanPropertyEditor.class);
PropertyEditorManager.registerEditor(
Boolean.class, BooleanPropertyEditor.class);
}
/** Property name that PropertyDescriptors can save in their property
* dictionaries for for specifiying a display sorting order. The value
* sould be of type Integer. */
public static final String SORT_ORDER = "sortOrder";
/** keep the map from editor to key through all instances of object */
private static HashMap _editor2Key = new HashMap();
/** keep the map from key to editor through all instances of object */
private static HashMap _key2Editor = new HashMap();
/** keep a list of editor listeners */
private EditorChangeListener _eListener = new EditorChangeListener();
/** the value to return for the given editor */
private String _value = null;
/** Current editor */
private PropertyEditor _editor = null;
/** Read-only flag. */
private boolean _readOnly = false;
/** List of property change listeners interested when the bean
* being edited has been changed. */
private java.util.List _changeListeners = new LinkedList();
/**
*Default constructor.
*
*/
public DynamicTableCellEditor() {
super(new JTextField());
}
/**
* Register a key with a specified type. The type is
* checked against registered editors and if found the
* key then points to the editor for that type.
*
* @param key unique identifier
* @param type the class to find the editor
*/
public void register(String key, Class type) {
if(_key2Editor.containsKey(key))
return;
// Find the editor. If none exists revert to a string editor
PropertyEditor editor = PropertyEditorManager.findEditor(type);
if(editor == null)
editor = PropertyEditorManager.findEditor(java.lang.String.class);
// Add a listener to the editor so we know when to update
// the bean's fields.
editor.addPropertyChangeListener(_eListener);
// System.out.println("registered key:" + key + " to editor:" +
editor); // dbg purposes only
// Map the key to the editor and the editor to the key for quick
lookup.
_key2Editor.put(key, editor);
_editor2Key.put(editor, key);
}
/**
* Add the given listener. Will receive a change event for
* changes to the bean being edited.
*
* @param l Listner to add.
*/
public void addPropertyChangeListener(PropertyChangeListener l) {
_changeListeners.add(l);
}
/**
* Remove the given property change listener.
*
* @param l Listener to remove.
*/
public void removePropertyChangeListener(PropertyChangeListener l) {
_changeListeners.remove(l);
}
/**
* Fire a property change event to each listener.
*
* @param bean Bean being edited.
* @param propName Name of the property.
* @param oldValue Old value.
* @param newValue New value.
*/
protected void firePropertyChange(Object bean, String propName,
Object oldValue, Object newValue) {
PropertyChangeEvent e = new PropertyChangeEvent(
bean, propName, oldValue, newValue);
Iterator it = _changeListeners.iterator();
while(it.hasNext()) {
PropertyChangeListener l = (PropertyChangeListener) it.next();
l.propertyChange(e);
}
}
/************************************************************************
* TableCellEditor/CellEditor implementation methods
************************************************************************/
/**
* Get the <code>value</code> that the editor contains.
*
* @return value found in the editor
*/
public Object getCellEditorValue() {
return (_editor!=null?_editor.getValue():"");
}
/** Sets an initial <code>value</code> for the editor. This will cause
* the editor to <code>stopEditing</code> and lose any partially
* edited value if the editor is editing when this method is called. <p>
*
* Returns the component that should be added to the client's
* <code>Component</code> hierarchy. Once installed in the client's
* hierarchy this component will then be able to draw and receive
* user input.
*
* @param table the <code>JTable</code> that is asking the
* editor to edit; can be <code>null</code>
* @param value the value of the cell to be edited; it is
* up to the specific editor to interpret
* and draw the value. For example, if
value is
* the string "true", it could be rendered
as a
* string or it could be rendered as a
check
* box that is checked. <code>null</code>
* is a valid value
* @param isSelected true if the cell is to be rendered with
* highlighting
* @param row the row of the cell being edited
* @param column the column of the cell being edited
* @return the component for editing
*/
public Component getTableCellEditorComponent(JTable table,
Object value,
boolean isSelected,
int row,
int column) {
// We need to get the key from the first column in the table
// which will always be found at column 0.
Object key = table.getModel().getValueAt(row, 0);
// Lookup the editor.
_editor = (PropertyEditor)_key2Editor.get(key);
// initialize the return value to be a JTextField if the
// editor does not contain a custom editor
Component retVal = new JTextField();
if(_editor != null) {
// Set the editor value from the parameter
_editor.setAsText((String)value);
// XXX What we need to do right here is provide a component
// that makes use of the "paintable" capability of the editor.
Component custom = _editor.getCustomEditor();
if(custom != null) {
retVal = custom;
}
}
return retVal;
}
/** Asks the editor if it can start editing using <code>anEvent</code>.
* <code>anEvent</code> is in the invoking component coordinate system.
* The editor can not assume the Component returned by
* <code>getCellEditorComponent</code> is installed. This method
* is intended for the use of client to avoid the cost of setting up
* and installing the editor component if editing is not possible.
* If editing can be started this method returns true.
*
* @param anEvent the event the editor should use to consider
* whether to begin editing or not
* @return true if editing can be started
* @see #shouldSelectCell
*/
public boolean isCellEditable(EventObject anEvent) {
return !_readOnly;
}
/** Class for receiving change events from the PropertyEditor objects. */
private class EditorChangeListener implements PropertyChangeListener {
public void propertyChange(PropertyChangeEvent e) {
PropertyEditor editor = (PropertyEditor) e.getSource();
Object oldValue = _value;
_value = editor.getAsText();
firePropertyChange(
editor, (String)_editor2Key.get(editor), oldValue, _value);
}
}
}
1.1
jakarta-ant-antidote/src/java/org/apache/tools/ant/gui/customizer/LinePropertyEditor.java
Index: LinePropertyEditor.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Ant", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 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.awt.BorderLayout;
/**
* Custom property editor for single line text.
*
* @version $Revision: 1.1 $
* @author Craig Campbell
*/
public class LinePropertyEditor extends AbstractPropertyEditor {
/** Area for typing in the file name. */
private JTextField _widget = null;
/** Container for the editor. */
private JPanel _container = null;
/**
* Default ctor.
*
*/
public LinePropertyEditor() {
_container = new JPanel(new BorderLayout());
_widget = new JTextField();
_widget.addFocusListener(new FocusHandler(this));
_container.add(_widget, BorderLayout.CENTER);
}
/**
* Get the child editing component. Uses JComponent so we can have tool
* tips, etc.
*
* @return Child editing component.
*/
protected Component getChild() {
return _container;
}
/**
* 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 String(" + 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 == null) {
value = "";
}
if(!(value instanceof String)) {
throw new IllegalArgumentException(
value.getClass().getName() + " is not of type String");
}
Object old = _widget.getText();
_widget.setText(((String)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 {
_widget.setText(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.2 +25 -17
jakarta-ant-antidote/src/java/org/apache/tools/ant/gui/modules/edit/AttributePropertyEditor.java
Index: AttributePropertyEditor.java
===================================================================
RCS file:
/home/cvs/jakarta-ant-antidote/src/java/org/apache/tools/ant/gui/modules/edit/AttributePropertyEditor.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- AttributePropertyEditor.java 13 Jan 2003 13:31:24 -0000 1.1
+++ AttributePropertyEditor.java 28 Jan 2003 22:03:44 -0000 1.2
@@ -58,8 +58,8 @@
import java.awt.Component;
import java.awt.Dimension;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
import java.util.ArrayList;
import java.util.Collections;
@@ -75,13 +75,14 @@
import javax.swing.table.TableColumn;
import org.apache.tools.ant.gui.customizer.AbstractPropertyEditor;
+import org.apache.tools.ant.gui.customizer.DynamicTableCellEditor;
import org.apache.tools.ant.gui.xml.DOMAttributes;
/**
* Custom property editor for introspected Attributes.
*
* @version $Revision$
- * @author Christoph Wilhelms<a href="mailto:[EMAIL PROTECTED]">Christoph
Wilhelms</a>
+ * @author Christoph Wilhelms<a href="mailto:[EMAIL PROTECTED]">Christoph
Wilhelms</a>, Craig Campbell
*/
public class AttributePropertyEditor extends AbstractPropertyEditor {
@@ -173,21 +174,28 @@
TableColumn tableColumn = _table.getColumnModel().getColumn(0);
tableColumn.setCellEditor(new DefaultCellEditor(_combo));
- // When the combo box is updated, update the table.
- /*
- _combo.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- JComboBox cb = (JComboBox)e.getSource();
- String newSelection = (String)cb.getSelectedItem();
-
- // Should we update the table?
- if (newSelection != null && _table.getEditingRow() > 0) {
- _table.getModel().setValueAt(newSelection,
- _table.getEditingRow(), _table.getEditingColumn() );
+ // Set the second column to use a DynamicEditor
+ TableColumn secondCol = _table.getColumnModel().getColumn(1);
+ final DynamicTableCellEditor cellEditor = new
DynamicTableCellEditor();
+ secondCol.setCellEditor(cellEditor);
+
+ // Listen for property changes to update the cell editor with
+ // registered types for editing.
+ _table.addPropertyChangeListener(new PropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent e) {
+ String selection = (String)_table.getModel().getValueAt(
+ _table.getSelectedRow(), 0);
+ if(selection != null && !selection.equals("")) {
+ Class type = null;
+ try {
+ type = _attributes.getType(selection);
+ cellEditor.register(selection, type);
+ } catch (ClassNotFoundException exp) {
+ exp.printStackTrace();
+ }
}
}
});
- */
_table.clearSelection();
}
@@ -316,7 +324,7 @@
* @return Object at location, or null if none.
*/
public Object getValueAt(int row, int column) {
- if(row < _attributes.size()) {
+ if(((row < _attributes.size()) && (row < _keys.size())) && row
> -1) {
switch(column) {
case NAME:
return _keys.get(row);
1.2 +25 -6
jakarta-ant-antidote/src/java/org/apache/tools/ant/gui/xml/DOMAttributes.java
Index: DOMAttributes.java
===================================================================
RCS file:
/home/cvs/jakarta-ant-antidote/src/java/org/apache/tools/ant/gui/xml/DOMAttributes.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- DOMAttributes.java 13 Jan 2003 13:31:24 -0000 1.1
+++ DOMAttributes.java 28 Jan 2003 22:03:44 -0000 1.2
@@ -54,10 +54,7 @@
package org.apache.tools.ant.gui.xml;
-import java.io.IOException;
-
import java.util.Properties;
-import java.util.Enumeration;
import java.util.Map;
import java.util.Iterator;
@@ -65,11 +62,12 @@
* Represents the intospected/refelcted attributes.
*
* @version $Revision$
- * @author Christoph Wilhelms<a href="mailto:[EMAIL PROTECTED]">[EMAIL
PROTECTED]</a>
+ * @author Christoph Wilhelms<a href="mailto:[EMAIL PROTECTED]">[EMAIL
PROTECTED]</a>, Craig Campbell
*/
public class DOMAttributes extends Properties {
String[] _elements = null;
+ private Map _mapElements = null;
/**
* Default constructor
@@ -81,7 +79,7 @@
/**
* Constructor
*
- * @param element provides information about possible attributes.
+ * @param elements provides information about possible attributes.
*/
public DOMAttributes(Map elements) {
if (elements != null) {
@@ -93,6 +91,7 @@
i++;
}
_elements = a;
+ _mapElements = elements; // save for searching for type.
}
}
@@ -111,5 +110,25 @@
*/
public void setAttributes(String[] attribs) {
_elements = attribs;
+ }
+
+ /**
+ * Allow the searching of type for individual attributes
+ *
+ * @param name attribute name
+ * @return Class - associated type.
+ */
+ public Class getType(String name) throws ClassNotFoundException {
+ if(name == null)
+ return null;
+ String typeName = (String)_mapElements.get(name);
+ if(typeName.equals("boolean"))
+ return boolean.class;
+ else if(typeName.equals("int"))
+ return double.class;
+ else if(typeName.equals("double"))
+ return int.class;
+ else
+ return Class.forName(typeName);
}
}
1.6 +38 -38
jakarta-ant-antidote/src/java/org/apache/tools/ant/gui/Main.java
Index: Main.java
===================================================================
RCS file:
/home/cvs/jakarta-ant-antidote/src/java/org/apache/tools/ant/gui/Main.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- Main.java 4 Jan 2003 10:31:08 -0000 1.5
+++ Main.java 28 Jan 2003 22:03:44 -0000 1.6
@@ -1,7 +1,7 @@
/*
* The Apache Software License, Version 1.1
*
- * Copyright (c) 2��� - 2003 The Apache Software Foundation. All rights
+ * Copyright (c) 2000 - 2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -72,43 +72,43 @@
/**
* Launch point for the Antidote GUI. Configurs it as an application.
- *
- * @version $Revision$
- * @author Simeon Fitch
+ *
+ * @version $Revision$
+ * @author Simeon Fitch
*/
public class Main {
- /**
- * Application start.
- *
- * @param args TBD
- */
+ /**
+ * Application start.
+ *
+ * @param args TBD
+ */
public static void main(String[] args) {
XMLHelper.init();
-
+
Args settings = new Args(args);
-
+
try {
javax.swing.UIManager.setLookAndFeel("net.sourceforge.mlf.metouia.MetouiaLookAndFeel");
}
catch (Exception e) {}
-
+
try {
-
+
MainFrame f = new MainFrame("Antidote");
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
AppContext context = new AppContext(f);
f.setContext(context);
-
+
if(!settings.isWizardMode()) {
EventResponder resp = new EventResponder(context);
Antidote gui = new Antidote(context);
-
+
JMenuBar menu = context.getActions().createMenuBar();
f.setJMenuBar(menu);
gui.setJMenuBar(menu);
f.getContentPane().add(BorderLayout.CENTER, gui);
- f.getContentPane().add(BorderLayout.NORTH,
- context.getActions().createToolBar());
+ f.getContentPane().add(BorderLayout.NORTH,
+ context.getActions().createToolBar());
// Add the project selection menu.
ProjectSelectionMenu ps = new ProjectSelectionMenu(context);
@@ -117,9 +117,9 @@
// Add debugging items.
if(settings.isDebugMode()) {
context.getEventBus().addMember(
- EventBus.VETOING, new EventDebugMonitor());
+ EventBus.VETOING, new EventDebugMonitor());
}
-
+
// Load a build file if one is provided.
if(settings.getBuildFile() != null) {
LoadFileCmd load = new LoadFileCmd(context);
@@ -134,39 +134,39 @@
// it will launch the regular antidote screen with the
// results of the wizard.
wiz.addWizardListener(new WizardListener() {
- public void finished(Object model) {
- BuildData data = (BuildData) model;
- System.out.println(data.createProject());
- System.exit(0);
- }
- public void canceled() {
- System.exit(0);
- }
-
- });
-
+ public void finished(Object model) {
+ BuildData data = (BuildData) model;
+ System.out.println(data.createProject());
+ System.exit(0);
+ }
+ public void canceled() {
+ System.exit(0);
+ }
+
+ });
+
f.getContentPane().add(BorderLayout.CENTER, wiz);
}
-
- ImageIcon icon =
- context.getResources().loadImageIcon("icon-small.gif");
+
+ ImageIcon icon =
+ context.getResources().loadImageIcon("icon-small.gif");
if(icon != null) {
f.setIconImage(icon.getImage());
}
else {
System.out.println("Application icon not found.");
}
-
+
// Send notice we are starting up
context.getEventBus().postEvent(
- new AppStartupEvent(context));
-
+ new AppStartupEvent(context));
+
f.pack();
f.setVisible(true);
-
+
// Send notice we are shutting down
context.getEventBus().postEvent(
- new AppShutdownEvent(context));
+ new AppShutdownEvent(context));
}
catch(Exception ex) {
ex.printStackTrace();
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>