ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From meta...@locus.apache.org
Subject cvs commit: jakarta-ant/src/antidote/org/apache/tools/ant/gui ActionManager.java AntAction.java Antidote.java AppContext.java EventResponder.java Main.java ProjectProxy.java
Date Thu, 16 Nov 2000 18:32:23 GMT
metasim     00/11/16 10:32:23

  Modified:    src/antidote/org/apache/tools/ant/gui ActionManager.java
                        AntAction.java Antidote.java AppContext.java
                        EventResponder.java Main.java ProjectProxy.java
  Log:
  Added option to turn on notification of emacs on a build error so that emacs
  goes to the file and location of the error. Also added the ability to provide a
  build file to load at startup from the command line.
  
  Revision  Changes    Path
  1.5       +17 -4     jakarta-ant/src/antidote/org/apache/tools/ant/gui/ActionManager.java
  
  Index: ActionManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/antidote/org/apache/tools/ant/gui/ActionManager.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- ActionManager.java	2000/11/15 21:25:33	1.4
  +++ ActionManager.java	2000/11/16 18:32:23	1.5
  @@ -61,7 +61,7 @@
    * Manager of antidote actions. Receives its configuration from the action
    * ResourceBundle.
    * 
  - * @version $Revision: 1.4 $ 
  + * @version $Revision: 1.5 $ 
    * @author Simeon Fitch 
    */
   public class ActionManager {
  @@ -164,9 +164,22 @@
                      menu.getMenuComponentCount() > 0) {
                       menu.addSeparator();
                   }
  -                JMenuItem item = menu.add(action);
  -                item.setAccelerator(action.getAccelerator());
  -                addNiceStuff(item, action);
  +
  +                if(!action.isToggle()) {
  +                    JMenuItem item = menu.add(action);
  +                    item.setAccelerator(action.getAccelerator());
  +                    addNiceStuff(item, action);
  +                }
  +                else {
  +                    JCheckBoxMenuItem b = 
  +                        new JCheckBoxMenuItem(action.getName());
  +                    b.setActionCommand(action.getID());
  +                    b.addActionListener(action);
  +                    b.setAction(action);
  +                    addNiceStuff(b, action);
  +                    menu.add(b);
  +                }
  +
               }
           }
   
  
  
  
  1.2       +19 -1     jakarta-ant/src/antidote/org/apache/tools/ant/gui/AntAction.java
  
  Index: AntAction.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/antidote/org/apache/tools/ant/gui/AntAction.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- AntAction.java	2000/11/14 21:47:51	1.1
  +++ AntAction.java	2000/11/16 18:32:23	1.2
  @@ -64,7 +64,7 @@
   /**
    * Class representing an action in the Antidote application. 
    * 
  - * @version $Revision: 1.1 $ 
  + * @version $Revision: 1.2 $ 
    * @author Simeon Fitch 
    */
   public class AntAction extends AbstractAction {
  @@ -75,6 +75,7 @@
       public static final String ENABLED = "enabled";
       public static final String ENABLE_ON = "enableOn";
       public static final String DISABLE_ON = "disableOn";
  +    public static final String TOGGLE = "toggle";
   
       /** Property resources. */
       private  ResourceBundle _resources =  null;
  @@ -89,6 +90,8 @@
       /** Events that the action should cause transition to the 
        *  enabled(false) state. */
       private Class[] _disableOn = null;
  +    /** Flag indicating toggle action. */
  +    private boolean _toggle = false;
   
   
       /** 
  @@ -118,6 +121,12 @@
               putValue(ACCELERATOR, KeyStroke.getKeyStroke(accelerator));
           }
   
  +        // Check to see if action is a toggle action.
  +        String toggle = getString(TOGGLE);
  +        if(toggle != null) {
  +            _toggle = Boolean.valueOf(toggle).booleanValue();
  +        }
  +
           // Add an icon if any (which means it'll show up on the tool bar).
           String iconName = getString("icon");
           if(iconName != null) {
  @@ -270,6 +279,15 @@
   	 */
       public Class[] getDisableOnEvents() {
           return _disableOn;
  +    }
  +
  +	/** 
  +	 * True if this is a toggle action, false otherwise.
  +	 * 
  +	 * @return True if this is a toggle action, false otherwise.
  +	 */
  +    public boolean isToggle() {
  +        return _toggle;
       }
   
       /** 
  
  
  
  1.4       +2 -2      jakarta-ant/src/antidote/org/apache/tools/ant/gui/Antidote.java
  
  Index: Antidote.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/antidote/org/apache/tools/ant/gui/Antidote.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- Antidote.java	2000/11/14 19:47:58	1.3
  +++ Antidote.java	2000/11/16 18:32:23	1.4
  @@ -62,7 +62,7 @@
    * The root class for the Ant GUI. Assembles all the graphical components
    * based on the configuration files.
    * 
  - * @version $Revision: 1.3 $ 
  + * @version $Revision: 1.4 $ 
    * @author Simeon Fitch 
    */
   public class Antidote extends JPanel {
  @@ -100,7 +100,7 @@
   
           add(BorderLayout.NORTH, populateEditors("top"));
   
  -        setPreferredSize(new Dimension(640, 480));
  +        setPreferredSize(new Dimension(640, 600));
       }
   
   
  
  
  
  1.2       +39 -2     jakarta-ant/src/antidote/org/apache/tools/ant/gui/AppContext.java
  
  Index: AppContext.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/antidote/org/apache/tools/ant/gui/AppContext.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- AppContext.java	2000/11/03 12:04:23	1.1
  +++ AppContext.java	2000/11/16 18:32:23	1.2
  @@ -52,15 +52,16 @@
    * <http://www.apache.org/>.
    */
   package org.apache.tools.ant.gui;
  +import org.apache.tools.ant.BuildListener;
   import org.apache.tools.ant.gui.event.*;
   import java.awt.Frame;
  +import java.util.*;
   
  -
   /**
    * A container for the state information for the application. Provides
    * a centeralized place to gain access to resources and data.
    * 
  - * @version $Revision: 1.1 $ 
  + * @version $Revision: 1.2 $ 
    * @author Simeon Fitch 
    */
   public class AppContext {
  @@ -70,6 +71,8 @@
       private ResourceManager _resources = new ResourceManager();
       /** Application actions. */
       private ActionManager _actions = new ActionManager(_eventBus);
  +    /** List of build listeners to register when build starts. */
  +    private List _buildListeners = new LinkedList();
   
       /** Parent frame used in various operations. XXX what do we do 
        *  in the applet context. */
  @@ -81,6 +84,10 @@
   
       public AppContext(Frame parent) {
           _parentFrame = parent;
  +        // Add the build listener for dispatching BuildEvent
  +        // objects to the EventBus.
  +        BuildEventForwarder handler = new BuildEventForwarder(this);
  +        addBuildListener(handler);
       }
   
   	/** 
  @@ -126,6 +133,36 @@
   	 */
       public ProjectProxy getProject() {
           return _project;
  +    }
  +
  +
  +	/** 
  +	 * Add a build listener.
  +	 * 
  +	 * @param l Listener to add.
  +	 */
  +    public void addBuildListener(BuildListener l) {
  +        _buildListeners.add(l);
  +    }
  +
  +	/** 
  +	 * Remove a build listener.
  +	 * 
  +	 * @param l Listener to remove.
  +	 */
  +    public void removeBuildListener(BuildListener l) {
  +        _buildListeners.remove(l);
  +    }
  +
  +	/** 
  +	 * Get the set of current build listeners.
  +	 * 
  +     * @return Set of current build listeners.
  +	 */
  +    public BuildListener[] getBuildListeners() {
  +        BuildListener[] retval = new BuildListener[_buildListeners.size()];
  +        _buildListeners.toArray(retval);
  +        return retval;
       }
   
   	/** 
  
  
  
  1.5       +9 -2      jakarta-ant/src/antidote/org/apache/tools/ant/gui/EventResponder.java
  
  Index: EventResponder.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/antidote/org/apache/tools/ant/gui/EventResponder.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- EventResponder.java	2000/11/15 21:25:33	1.4
  +++ EventResponder.java	2000/11/16 18:32:23	1.5
  @@ -57,13 +57,13 @@
   import org.apache.tools.ant.gui.command.*;
   import java.util.EventObject;
   import java.awt.event.ActionEvent;
  -import javax.swing.JFrame;
  +import javax.swing.*;
   
   /**
    * The purpose of this class is to watch for events that require some sort
    * of action, like opening a file.
    * 
  - * @version $Revision: 1.4 $ 
  + * @version $Revision: 1.5 $ 
    * @author Simeon Fitch 
    */
   class EventResponder {
  @@ -133,6 +133,13 @@
               }
               else if(command.equals(ChangeLookAndFeelCmd.ACTION_NAME)) {
                   new ChangeLookAndFeelCmd(_context).execute();
  +            }
  +            else if(command.equals(ChangeLookAndFeelCmd.ACTION_NAME)) {
  +                new ChangeLookAndFeelCmd(_context).execute();
  +            }
  +            else if(command.equals(EmacsNotifyCmd.ACTION_NAME)) {
  +                AbstractButton source = (AbstractButton) event.getSource();
  +                new EmacsNotifyCmd(_context, source.isSelected()).execute();
               }
               else {
   				// XXX log me.
  
  
  
  1.4       +12 -5     jakarta-ant/src/antidote/org/apache/tools/ant/gui/Main.java
  
  Index: Main.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/antidote/org/apache/tools/ant/gui/Main.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- Main.java	2000/11/14 19:55:45	1.3
  +++ Main.java	2000/11/16 18:32:23	1.4
  @@ -52,14 +52,15 @@
    * <http://www.apache.org/>.
    */
   package org.apache.tools.ant.gui;
  -import org.apache.tools.ant.gui.util.WindowUtils;
  +import org.apache.tools.ant.gui.command.LoadFileCmd;
   import javax.swing.*;
   import java.awt.BorderLayout;
  +import java.io.File;
   
   /**
    * Launch point for the Antidote GUI. Configurs it as an application.
    * 
  - * @version $Revision: 1.3 $ 
  + * @version $Revision: 1.4 $ 
    * @author Simeon Fitch 
    */
   public class Main {
  @@ -74,7 +75,9 @@
           String vmVersion = System.getProperty("java.vm.vendor");
           if(vmVersion.indexOf("Blackdown") > 0 &&
              vmVersion.indexOf("RC") > 0) {
  -            System.err.println("Warning: Antidote will not work with VM version Blackdown-1.3.0-RC1.");
  +            System.err.println(
  +                "Warning: Antidote will not work with VM version " +
  +                "Blackdown-1.3.0-RC1.");
               System.err.println("Your version: " + vmVersion);
           }
   
  @@ -101,9 +104,13 @@
               f.pack();
   
               f.setVisible(true);
  -            // Hack around linux window placement annoyance.
  -            WindowUtils.centerWindow(f);
   
  +
  +            // XXX this will change once full command line argument parsing
  +            // is supported.
  +            if(args.length > 0) {
  +                new LoadFileCmd(context, new File(args[0])).execute();
  +            }
           }
           catch(Exception ex) {
               ex.printStackTrace();
  
  
  
  1.6       +25 -22    jakarta-ant/src/antidote/org/apache/tools/ant/gui/ProjectProxy.java
  
  Index: ProjectProxy.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/antidote/org/apache/tools/ant/gui/ProjectProxy.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- ProjectProxy.java	2000/11/11 04:52:20	1.5
  +++ ProjectProxy.java	2000/11/16 18:32:23	1.6
  @@ -62,8 +62,7 @@
   import javax.swing.tree.TreeSelectionModel;
   import javax.swing.event.TreeSelectionEvent;
   import javax.swing.event.TreeSelectionListener;
  -import java.util.Enumeration;
  -import java.util.Vector;
  +import java.util.*;
   
   /**
    * This class provides the gateway interface to the data model for
  @@ -71,7 +70,7 @@
    * (or other external datamodel) occurs. This class also provides various
    * views into the data model, such as TreeModel, Documenet, etc.
    * 
  - * @version $Revision: 1.5 $ 
  + * @version $Revision: 1.6 $ 
    * @author Simeon Fitch 
    */
   public class ProjectProxy {
  @@ -96,6 +95,7 @@
           _file = file;
           _context = context;
           loadProject();
  +
       }
   
   	/** 
  @@ -109,15 +109,6 @@
       }
   
   	/** 
  -	 * 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.
  @@ -128,12 +119,13 @@
           project.init();
           // XXX there is a bunch of stuff in the class
           // org.apache.tools.ant.Main that needs to be
  -        // abstracted out so that it doesn't have to be
  +        // refactored out so that it doesn't have to be
           // replicated here.
           
           // XXX need to provide a way to pass in externally
           // defined properties.  Perhaps define an external
  -        // Antidote properties file.
  +        // Antidote properties file. JAVA_HOME may have to be set, 
  +        // as well as checking the .ant.properties
           project.setUserProperty("ant.file" , _file.getAbsolutePath());
           ProjectHelper.configureProject(project, _file);
   
  @@ -189,7 +181,14 @@
   
       /** Class for executing the build in a separate thread. */
       private class BuildRunner implements Runnable {
  +        /** The project to execute build on. */
           private Project _project = null;
  +
  +        /** 
  +         * Standard ctor.
  +         * 
  +         * @param project Project to execute build on.
  +         */
           public BuildRunner(Project project) {
               _project = project;
           }
  @@ -214,13 +213,14 @@
            * 
            */
           public void run() {
  -            // Add the build listener for
  -            // dispatching BuildEvent objects to the
  -            // EventBus.
  -            BuildEventForwarder handler = 
  -                new BuildEventForwarder(_context);
  -            _project.addBuildListener(handler);
  +            // Add the build listeners
  +            BuildListener[] listeners = _context.getBuildListeners();
  +            for(int i = 0; i < listeners.length; i++) {
  +                _project.addBuildListener(listeners[i]);
  +            }
  +
               try {
  +
                   fireBuildEvent(new BuildEvent(
                       _project), BuildEventType.BUILD_STARTED);
                   
  @@ -250,8 +250,11 @@
               finally {
                   fireBuildEvent(new BuildEvent(
                       _project), BuildEventType.BUILD_FINISHED);
  -                _project.removeBuildListener(handler);
  -                _buildThread = null;
  +
  +                // Remove the build listeners.
  +                for(int i = 0; i < listeners.length; i++) {
  +                    _project.removeBuildListener(listeners[i]);
  +                }
               }
           }
       }
  
  
  

Mime
View raw message