The attached patch file and new classes add the
ability to Antidote to select one or more targets to
build, and to view their description and dependencies
(immediate, not flattened). The TODO file is also
included.

This is the first "pseudo-usable" release, as one can
invoke a selected target repeatedly.

Simeon Fitch


=====
Mustard Seed Software
mailto:[EMAIL PROTECTED]

__________________________________________________
Do You Yahoo!?
Thousands of Stores.  Millions of Products.  All in one Place.
http://shopping.yahoo.com/
? src/antidote/TODO
? src/antidote/org/apache/tools/ant/gui/TargetSelectionModel.java
? src/antidote/org/apache/tools/ant/gui/event/TargetSelectionEvent.java
Index: src/antidote/docs/gui-requirements.html
===================================================================
RCS file: /home/cvspublic/jakarta-ant/src/antidote/docs/gui-requirements.html,v
retrieving revision 1.1
diff -u -r1.1 gui-requirements.html
--- src/antidote/docs/gui-requirements.html     2000/11/03 12:04:21     1.1
+++ src/antidote/docs/gui-requirements.html     2000/11/07 13:33:14
@@ -5,7 +5,7 @@
   </HEAD> 
   <BODY> 
     <H1>Ant GUI Feature List</H1>
-    <P>Version 0.3 (2000/10/31)</P>
+    <P>Version 0.4 (2000/11/06)</P>
     <P>Authors: 
     <A HREF="mailto:[EMAIL PROTECTED]">Simeon H.K. Fitch</A>,
     <A HREF="mailto:[EMAIL PROTECTED]">Chris Todd</A>,
@@ -31,7 +31,6 @@
 
     <P>The features are in a loose order of expressed interested by
     contributors.</P>
-    
 
     <!-- Section List -->
     <OL TYPE="A">
@@ -68,7 +67,6 @@
       </OL>
       <BR>
 
-
       <LI><H2>Build Wizard (auto-configure)</H2></LI>
       <P>To make starting a new project with Ant as easy as possible, the a
       wizard type of UI can be used where the user provides some basic
@@ -155,7 +153,9 @@
           introspection to discover attribute set, then reference some other
           mechanism for attributes that are manifested as properties.</I>
           </LI>
-          <LI>Report errors in the XML source.</LI>
+          <LI>Report errors in the XML source.</LI> 
+          <LI>Provide a list of recently opened documents for 
+          quick reloading.</LI>
         </OL>
         <LI>View project contents.</LI>
         <OL TYPE="a">
Index: src/antidote/org/apache/tools/ant/gui/Console.java
===================================================================
RCS file: 
/home/cvspublic/jakarta-ant/src/antidote/org/apache/tools/ant/gui/Console.java,v
retrieving revision 1.2
diff -u -r1.2 Console.java
--- src/antidote/org/apache/tools/ant/gui/Console.java  2000/11/06 12:52:42     
1.2
+++ src/antidote/org/apache/tools/ant/gui/Console.java  2000/11/07 13:33:17
@@ -54,6 +54,7 @@
 package org.apache.tools.ant.gui;
 import org.apache.tools.ant.gui.event.*;
 import javax.swing.*;
+import javax.swing.plaf.ComponentUI;
 import javax.swing.text.Document;
 import java.awt.BorderLayout;
 import java.awt.FlowLayout;
@@ -82,7 +83,7 @@
         context.getEventBus().addMember(EventBus.MONITORING, new Handler());
         setLayout(new BorderLayout());
 
-        _text = new JTextPane();
+        _text = new NoWrapTextPane();
         _text.setEditable(false);
         JScrollPane scroller = new JScrollPane(_text);
         scroller.setVerticalScrollBarPolicy(
@@ -162,7 +163,6 @@
             }
         }
     }
-
     /** Class providing filtering for project events. */
     private static class Filter implements BusFilter {
         /** 
@@ -173,6 +173,22 @@
          */
         public boolean accept(EventObject event) {
             return event instanceof AntBuildEvent;
+        }
+    }
+
+    /** Specialization of JTextPane to provide proper wrapping behavior. */
+    private static class NoWrapTextPane extends JTextPane {
+        /** 
+         * Overridden to ensure that the JTextPane is only
+         * forced to match the viewport if it is smaller than
+         * the viewport.
+         * 
+         * @return True if smaller than viewport, false otherwise.
+         */
+        public boolean getScrollableTracksViewportWidth() {
+            ComponentUI ui = getUI();
+            return getParent() != null ? ui.getPreferredSize(this).width <=
+                getParent().getSize().width : true;
         }
     }
 
Index: src/antidote/org/apache/tools/ant/gui/ProjectNavigator.java
===================================================================
RCS file: 
/home/cvspublic/jakarta-ant/src/antidote/org/apache/tools/ant/gui/ProjectNavigator.java,v
retrieving revision 1.2
diff -u -r1.2 ProjectNavigator.java
--- src/antidote/org/apache/tools/ant/gui/ProjectNavigator.java 2000/11/06 
12:52:43     1.2
+++ src/antidote/org/apache/tools/ant/gui/ProjectNavigator.java 2000/11/07 
13:33:17
@@ -116,9 +116,11 @@
                 // XXX this needs to be tested against 
                 // different version of Swing...
                 _tree.setModel(null);
+                _tree.setSelectionModel(null);
             }
             else {
                 _tree.setModel(project.getTreeModel());
+                _tree.setSelectionModel(project.getTreeSelectionModel());
             }
         }
     }
Index: src/antidote/org/apache/tools/ant/gui/ProjectProxy.java
===================================================================
RCS file: 
/home/cvspublic/jakarta-ant/src/antidote/org/apache/tools/ant/gui/ProjectProxy.java,v
retrieving revision 1.2
diff -u -r1.2 ProjectProxy.java
--- src/antidote/org/apache/tools/ant/gui/ProjectProxy.java     2000/11/06 
12:52:43     1.2
+++ src/antidote/org/apache/tools/ant/gui/ProjectProxy.java     2000/11/07 
13:33:19
@@ -52,17 +52,17 @@
  * <http://www.apache.org/>.
  */
 package org.apache.tools.ant.gui;
-import org.apache.tools.ant.Project;
-import org.apache.tools.ant.ProjectHelper;
-import org.apache.tools.ant.BuildEvent;
-import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.BuildListener;
+import org.apache.tools.ant.*;
 import org.apache.tools.ant.gui.event.*;
 import java.io.File;
 import java.io.IOException;
 import javax.swing.tree.TreeModel;
 import javax.swing.text.Document;
+import javax.swing.tree.TreeSelectionModel;
+import javax.swing.event.TreeSelectionEvent;
+import javax.swing.event.TreeSelectionListener;
 import java.util.Enumeration;
+import java.util.Vector;
 
 /**
  * This class provides the gateway interface to the data model for
@@ -81,8 +81,10 @@
     private File _file = null;
     /** The real Ant Project instance. */
     private Project _project = null;
-    /** Private the current thread executing a build. */
+    /** The current thread executing a build. */
     private Thread _buildThread = null;
+    /** The selection model for selected targets. */
+    private TargetSelectionModel _selections = null;
 
        /** 
         * File loading ctor.
@@ -101,6 +103,8 @@
         */
     private void loadProject() throws IOException {
         _project = new Project();
+        _selections = new TargetSelectionModel();
+        _selections.addTreeSelectionListener(new SelectionForwarder());
         synchronized(_project) {
             _project.init();
 
@@ -118,6 +122,15 @@
     }
 
        /** 
+        * Called to indicate that the project is no longer going to be used
+     * by the GUI, and that any cleanup should occur.
+        * 
+        */
+    //public void close() {
+    //
+    //}
+
+       /** 
         * Build the project with the current target (or the default target
      * if none is selected.  Build occurs on a separate thread, so method
      * returns immediately.
@@ -153,6 +166,15 @@
     }
 
        /** 
+        * Get the tree selection model for selected targets.
+        * 
+        * @return Selection model.
+        */
+    public TreeSelectionModel getTreeSelectionModel() {
+        return _selections;
+    }
+
+       /** 
         * Get the Document perspective on the data.
         * 
         * @return Document view on project.
@@ -197,10 +219,23 @@
                 try {
                     fireBuildEvent(new BuildEvent(
                         _project), BuildEventType.BUILD_STARTED);
-                    // XXX add code to indicate target execution
-                    // on the targets that are selected.
-                    _project.executeTarget(
-                        _project.getDefaultTarget());
+
+                    // Generate list of targets to execute.
+                    Target[] targets = _selections.getSelectedTargets();
+                    Vector targetNames = new Vector();
+                    if(targets.length == 0) {
+                        targetNames.add(_project.getDefaultTarget());
+                    }
+                    else {
+                        for(int i = 0; i < targets.length; i++) {
+                            targetNames.add(targets[i].getName());
+                        }
+                    }
+
+                    // Execute build on selected targets. XXX It would be 
+                    // nice if the Project API supported passing in target 
+                    // objects rather than String names.
+                    _project.executeTargets(targetNames);
                 }
                 catch(BuildException ex) {
                     BuildEvent errorEvent = new BuildEvent(_project);
@@ -215,6 +250,14 @@
                     _buildThread = null;
                 }
             }
+        }
+    }
+
+    /** Forwards selection events to the event bus. */
+    private class SelectionForwarder implements TreeSelectionListener {
+        public void valueChanged(TreeSelectionEvent e) {
+            _context.getEventBus().postEvent(new TargetSelectionEvent(
+                _context, _selections.getSelectedTargets()));
         }
     }
 
Index: src/antidote/org/apache/tools/ant/gui/PropertyEditor.java
===================================================================
RCS file: 
/home/cvspublic/jakarta-ant/src/antidote/org/apache/tools/ant/gui/PropertyEditor.java,v
retrieving revision 1.1
diff -u -r1.1 PropertyEditor.java
--- src/antidote/org/apache/tools/ant/gui/PropertyEditor.java   2000/11/03 
12:04:24     1.1
+++ src/antidote/org/apache/tools/ant/gui/PropertyEditor.java   2000/11/07 
13:33:20
@@ -52,7 +52,13 @@
  * <http://www.apache.org/>.
  */
 package org.apache.tools.ant.gui;
+import org.apache.tools.ant.Target;
+import org.apache.tools.ant.gui.event.*;
 import javax.swing.*;
+import java.util.*;
+import java.io.StringReader;
+import java.io.IOException;
+import java.awt.BorderLayout;
 
 /**
  * Stub for a property editor.
@@ -62,8 +68,162 @@
  */
 class PropertyEditor extends AntEditor {
 
+    /** Text pane. */
+    private JEditorPane _text = null;
+
+       /** 
+        * Standard ctor.
+        * 
+        * @param context Application context. 
+        */
        public PropertyEditor(AppContext context) {
         super(context);
-               add(new JLabel(getName()));
+        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);
+
+        add(BorderLayout.CENTER, _text);
        }
+
+       /** 
+        * Populate the display with the given target info.
+        * 
+        * @param targets Targets to display info for.
+        */
+    private void displayTargetInfo(Target[] 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;
+        }
+
+        if(text != null) {
+            _text.setText(text);
+        }
+    }
+
+       /** 
+        * Get the parameters for the formatted message presented for a single
+     * target.
+        * 
+        * @param target Target to generate params for.
+     * @return Argument list for the formatted message.
+        */
+    private Object[] getTargetParams(Target target) {
+        List args = new LinkedList();
+        args.add(target.getName());
+        args.add(target.getDescription() == null ? 
+                 "" : target.getDescription());
+        StringBuffer buf = new StringBuffer();
+        Enumeration enum = target.getDependencies();
+        while(enum.hasMoreElements()) {
+            buf.append(enum.nextElement());
+            if(enum.hasMoreElements()) {
+                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(Target[] 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(", ");
+            }
+
+            Enumeration enum = targets[i].getDependencies();
+            while(enum.hasMoreElements()) {
+                depends.add(enum.nextElement());
+            }
+        }
+
+        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 {
+        private final Filter _filter = new Filter();
+
+        /** 
+         * Get the filter to that is used to determine if an event should
+         * to to the member.
+         * 
+         * @return Filter to use.
+         */
+        public BusFilter getBusFilter() {
+            return _filter;
+        }
+
+        /** 
+         * Called when an event is to be posted to the member.
+         * 
+         * @param event Event to post.
+         */
+        public void eventPosted(EventObject event) {
+            TargetSelectionEvent e = (TargetSelectionEvent) event;
+            Target[] targets = e.getSelectedTargets();
+            displayTargetInfo(targets);
+        }
+
+    }
+    /** Class providing filtering for project events. */
+    private static class Filter implements BusFilter {
+        /** 
+         * Determines if the given event should be accepted.
+         * 
+         * @param event Event to test.
+         * @return True if event should be given to BusMember, false otherwise.
+         */
+        public boolean accept(EventObject event) {
+            return event instanceof TargetSelectionEvent;
+        }
+    }
 }
Index: src/antidote/org/apache/tools/ant/gui/resources/action.properties
===================================================================
RCS file: 
/home/cvspublic/jakarta-ant/src/antidote/org/apache/tools/ant/gui/resources/action.properties,v
retrieving revision 1.2
diff -u -r1.2 action.properties
--- src/antidote/org/apache/tools/ant/gui/resources/action.properties   
2000/11/06 12:52:50     1.2
+++ src/antidote/org/apache/tools/ant/gui/resources/action.properties   
2000/11/07 13:33:21
@@ -1,6 +1,6 @@
 menus=File, Build, Help
 
-actions=open, close, exit, about, startBuild, stopBuild
+actions=open, close, exit, about, startBuild
 
 new.name=New
 new.shortDescription=Create a new project
Index: src/antidote/org/apache/tools/ant/gui/resources/antidote.properties
===================================================================
RCS file: 
/home/cvspublic/jakarta-ant/src/antidote/org/apache/tools/ant/gui/resources/antidote.properties,v
retrieving revision 1.2
diff -u -r1.2 antidote.properties
--- src/antidote/org/apache/tools/ant/gui/resources/antidote.properties 
2000/11/06 12:52:50     1.2
+++ src/antidote/org/apache/tools/ant/gui/resources/antidote.properties 
2000/11/07 13:33:21
@@ -15,7 +15,22 @@
 
 # Set specific class properties.
 org.apache.tools.ant.gui.SourceEditor.name=Source
-org.apache.tools.ant.gui.PropertyEditor.name=Properties
+
+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"><b>Name</b>:</td><td>{0}</td></tr>\
+<tr><td align="right"><b>Description</b>:</td><td>{1}</td></tr>\
+<tr><td align="right"><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
 org.apache.tools.ant.gui.Console.logLevel=Log message level:

Attachment: newfiles.jar
Description: newfiles.jar

Reply via email to