Attached is the Antidote patch file and a jar file with new classes that add the ability to write BuildEvent contents to a console window.
Thanks, Simeon ===== Mustard Seed Software mailto:[EMAIL PROTECTED] __________________________________________________ Do You Yahoo!? Thousands of Stores. Millions of Products. All in one Place. http://shopping.yahoo.com/
? patchfile.txt
? TODO
? docs/design-overview.html
? org/apache/tools/ant/gui/BuildEventForwarder.java
? org/apache/tools/ant/gui/LogLevelEnum.java
? org/apache/tools/ant/gui/command/BuildCmd.java
? org/apache/tools/ant/gui/event/AntBuildEvent.java
? org/apache/tools/ant/gui/event/BuildEventType.java
? org/apache/tools/ant/gui/resources/default.gif
? org/apache/tools/ant/gui/resources/icon-small.bmp
? org/apache/tools/ant/gui/resources/icon-small.gif
? org/apache/tools/ant/gui/resources/start.gif
? org/apache/tools/ant/gui/resources/stop.gif
Index: ChangeLog
===================================================================
RCS file: /home/cvspublic/jakarta-ant/src/antidote/ChangeLog,v
retrieving revision 1.1
diff -u -r1.1 ChangeLog
--- ChangeLog 2000/11/03 12:04:19 1.1
+++ ChangeLog 2000/11/05 20:55:17
@@ -1,3 +1,43 @@
+2000-11-05 Simeon H.K. Fitch <[EMAIL PROTECTED]>
+
+ * org/apache/tools/ant/gui/LogLevelEnum.java: Added log level
+ enumeration for use with combo boxes (drops nicely into default model).
+
+ * org/apache/tools/ant/gui/event/BuildEventType.java: Added
+ delivering of event to a BuildListener based on enumeration value.
+
+ * org/apache/tools/ant/gui/ProjectProxy.java: Added generation of
+ BuildEvent on project start and finish, as the project itself
+ doesn't generate theses events (unfortunately).
+
+ * org/apache/tools/ant/gui/Console.java: Added filtering level,
+ and clearing of buffer when a new build starts.
+
+ * org/apache/tools/ant/gui/AntEditor.java: Added automatic border
+ for all subclasses.
+
+2000-11-04 Simeon H.K. Fitch <[EMAIL PROTECTED]>
+
+ * org/apache/tools/ant/gui/ProjectProxy.java: Added inner class to
+ execute the build in a separate thread.
+
+ * org/apache/tools/ant/gui/event/EventBus.java: Added check to see
+ if postEvent() is being called on the AWTEvent thread, and if not,
+ post the dispatching of the event to that thread. This is needed
+ as most of the listeners will be bound to GUI components and will
+ be updating their state (which must occur on the event thread).
+
+ * org/apache/tools/ant/gui/ProjectProxy.java: Added a
+ BuildListener to forward events to the EventBus.
+
+2000-11-03 Simeon H.K. Fitch <[EMAIL PROTECTED]>
+
+ * org/apache/tools/ant/gui/Antidote.java: Removed hard-coded
+ Console class.
+
+ * org/apache/tools/ant/gui/Console.java: Changed to a real
+ AntEditor class, initialized by the config file.
+
2000-11-02 Simeon H.K. Fitch <[EMAIL PROTECTED]>
* org/apache/tools/ant/gui/event/EventBus.java: Added interrupt
Index: build.xml
===================================================================
RCS file: /home/cvspublic/jakarta-ant/src/antidote/build.xml,v
retrieving revision 1.1
diff -u -r1.1 build.xml
--- build.xml 2000/11/03 12:04:19 1.1
+++ build.xml 2000/11/05 20:55:18
@@ -50,8 +50,8 @@
<javac srcdir="${src.dir}"
destdir="${build.classes}"
debug="on"
- deprecation="off"
- optimize="on" >
+ deprecation="on"
+ optimize="off" >
<classpath refid="classpath" />
</javac>
Index: org/apache/tools/ant/gui/ActionManager.java
===================================================================
RCS file:
/home/cvspublic/jakarta-ant/src/antidote/org/apache/tools/ant/gui/ActionManager.java,v
retrieving revision 1.1
diff -u -r1.1 ActionManager.java
--- org/apache/tools/ant/gui/ActionManager.java 2000/11/03 12:04:23 1.1
+++ org/apache/tools/ant/gui/ActionManager.java 2000/11/05 20:55:20
@@ -113,7 +113,24 @@
while(tok.hasMoreTokens()) {
String name = tok.nextToken();
JMenu menu = new JMenu(name);
- retval.add(menu);
+
+ // XXX should be in config file
+ menu.setMnemonic(name.charAt(0));
+
+ // XXX need to i18n here...
+ if(name.equalsIgnoreCase("help")) {
+ try {
+ retval.setHelpMenu(menu);
+ }
+ catch(Error err) {
+ // Catch the "not implemented" error in
+ // some (all?) Swing implementations
+ retval.add(menu);
+ }
+ }
+ else {
+ retval.add(menu);
+ }
menus.put(name, menu);
}
@@ -130,10 +147,13 @@
menus.put(parent, menu);
}
- if(action.isPreceededBySeparator()) {
+ // See if we should add a separator.
+ if(action.isPreceededBySeparator() &&
+ menu.getMenuComponentCount() > 0) {
menu.addSeparator();
}
JMenuItem item = menu.add(action);
+ item.setAccelerator(action.getAccelerator());
addNiceStuff(item, action);
}
}
@@ -171,6 +191,13 @@
// Set the action command so that it is consitent
// no matter what language the display is in.
button.setActionCommand(action.getID());
+
+ // XXX this should be moved to the config file.
+ String label = button.getText();
+ if(label != null) {
+ button.setMnemonic(label.charAt(0));
+ }
+
String tip = action.getShortDescription();
if(tip != null) {
button.setToolTipText(tip);
@@ -202,6 +229,7 @@
/** Property name for the parent menu item. */
public static final String PARENT_MENU_NAME = "parentMenuName";
public static final String SEPARATOR = "separator";
+ public static final String ACCELERATOR = "accelerator";
/** Unique id. */
private String _id = null;
@@ -215,9 +243,15 @@
_id = id;
putValue(NAME, getString(id, "name"));
putValue(SHORT_DESCRIPTION, getString(id, "shortDescription"));
- putValue(PARENT_MENU_NAME, getString(id, "parentMenuName"));
- putValue(SEPARATOR, getString(id, "separator"));
+ putValue(PARENT_MENU_NAME, getString(id, PARENT_MENU_NAME));
+ putValue(SEPARATOR, getString(id, SEPARATOR));
+
+ String accelerator = getString(id, ACCELERATOR);
+ if(accelerator != null) {
+ putValue(ACCELERATOR, KeyStroke.getKeyStroke(accelerator));
+ }
+
String iconName = getString(id, "icon");
if(iconName != null) {
try {
@@ -232,7 +266,6 @@
ex.printStackTrace();
}
}
-
}
/**
@@ -289,6 +322,10 @@
*/
public Icon getIcon() {
return (Icon) getValue(SMALL_ICON);
+ }
+
+ public KeyStroke getAccelerator() {
+ return (KeyStroke) getValue(ACCELERATOR);
}
/**
Index: org/apache/tools/ant/gui/AntEditor.java
===================================================================
RCS file:
/home/cvspublic/jakarta-ant/src/antidote/org/apache/tools/ant/gui/AntEditor.java,v
retrieving revision 1.1
diff -u -r1.1 AntEditor.java
--- org/apache/tools/ant/gui/AntEditor.java 2000/11/03 12:04:23 1.1
+++ org/apache/tools/ant/gui/AntEditor.java 2000/11/05 20:55:20
@@ -54,6 +54,7 @@
package org.apache.tools.ant.gui;
import javax.swing.JPanel;
+import javax.swing.BorderFactory;
/**
* Abstract base class for an "editor", which is really anything that
@@ -78,6 +79,7 @@
*/
protected AntEditor(AppContext context) {
_context = context;
+ setBorder(BorderFactory.createTitledBorder(getName()));
}
/**
Index: org/apache/tools/ant/gui/Antidote.java
===================================================================
RCS file:
/home/cvspublic/jakarta-ant/src/antidote/org/apache/tools/ant/gui/Antidote.java,v
retrieving revision 1.1
diff -u -r1.1 Antidote.java
--- org/apache/tools/ant/gui/Antidote.java 2000/11/03 12:04:23 1.1
+++ org/apache/tools/ant/gui/Antidote.java 2000/11/05 20:55:22
@@ -66,11 +66,6 @@
* @author Simeon Fitch
*/
public class Antidote extends JPanel {
-
-
- /** Logging console. */
- private Console _console = null;
-
/** Source of application state data. */
private AppContext _context = null;
@@ -83,18 +78,25 @@
_context = context;
- _console = new Console(_context);
-
-
// Add the various editors/views to the editing area.
JSplitPane splitter = new JSplitPane();
splitter.add(JSplitPane.LEFT, populateEditors("left"));
splitter.add(JSplitPane.RIGHT, populateEditors("right"));
-
- add(BorderLayout.CENTER, splitter);
+ // This is necessary because, frankly, the JSplitPane widget
+ // sucks, and doesn't provide enought (working) control over the
+ // initial size of it's subcomponents. setDividerLocation(double)
+ // doesn't seem to work until after the widget is visible.
+ splitter.setPreferredSize(new Dimension(500, 300));
+
+ // Top bottom splitter.
+ JSplitPane splitter2 = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
+ splitter2.setOneTouchExpandable(true);
- add(BorderLayout.SOUTH, _console);
+ splitter2.add(JSplitPane.TOP, splitter);
+ splitter2.add(JSplitPane.BOTTOM, populateEditors("bottom"));
+ add(BorderLayout.CENTER, splitter2);
+ splitter2.resetToPreferredSizes();
setPreferredSize(new Dimension(640, 480));
}
Index: 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.1
diff -u -r1.1 Console.java
--- org/apache/tools/ant/gui/Console.java 2000/11/03 12:04:24 1.1
+++ org/apache/tools/ant/gui/Console.java 2000/11/05 20:55:24
@@ -52,10 +52,13 @@
* <http://www.apache.org/>.
*/
package org.apache.tools.ant.gui;
-
+import org.apache.tools.ant.gui.event.*;
import javax.swing.*;
-import java.awt.GridLayout;
+import javax.swing.text.Document;
+import java.awt.BorderLayout;
+import java.awt.FlowLayout;
import java.awt.Dimension;
+import java.util.EventObject;
/**
* Logging console display.
@@ -63,22 +66,114 @@
* @version $Revision: 1.1 $
* @author Simeon Fitch
*/
-public class Console extends JPanel {
- private AppContext _context = null;
+public class Console extends AntEditor {
+ /** Area where messages are printed. */
private JTextPane _text = null;
-
+ /** Selection of logging levels. */
+ private JComboBox _logLevel = null;
+
+ /**
+ * Standard ctor.
+ *
+ * @param context Application context;
+ */
public Console(AppContext context) {
- setLayout(new GridLayout(1,1));
- _context = context;
+ super(context);
+ context.getEventBus().addMember(EventBus.MONITORING, new Handler());
+ setLayout(new BorderLayout());
_text = new JTextPane();
_text.setEditable(false);
JScrollPane scroller = new JScrollPane(_text);
+ scroller.setVerticalScrollBarPolicy(
+ JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
+ add(BorderLayout.CENTER, scroller);
+
+ JPanel controls = new JPanel(new FlowLayout(FlowLayout.LEFT));
+ JLabel label = new JLabel(
+ context.getResources().getString(getClass(), "logLevel"));
+ controls.add(label);
+ _logLevel = new JComboBox(LogLevelEnum.getValues());
+ controls.add(_logLevel);
- add(scroller);
+ add(BorderLayout.NORTH, controls);
- _text.setText(
- "This is the console area. \nLots of stuff to see here...");
- setPreferredSize(new Dimension(200, 40));
}
+
+ /** 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 posed to the member.
+ *
+ * @param event Event to post.
+ */
+ public void eventPosted(EventObject event) {
+ AntBuildEvent buildEvent = (AntBuildEvent) event;
+ String text = null;
+
+ Document doc = _text.getDocument();
+
+ switch(buildEvent.getType().getValue()) {
+ case BuildEventType.BUILD_STARTED_VAL:
+ try {
+ doc.remove(0, doc.getLength());
+ }
+ catch(Exception ex) {
+ // Intentionally ignored.
+ }
+ break;
+ case BuildEventType.TARGET_STARTED_VAL:
+ text = buildEvent.getEvent().getTarget().getName() + ":";
+ break;
+ case BuildEventType.TARGET_FINISHED_VAL:
+ case BuildEventType.TASK_STARTED_VAL:
+ case BuildEventType.TASK_FINISHED_VAL:
+ break;
+ case BuildEventType.MESSAGE_LOGGED_VAL:
+ text = buildEvent.toString();
+ break;
+ }
+
+ // Filter out events that are below our selected filterint level.
+ LogLevelEnum level = (LogLevelEnum) _logLevel.getSelectedItem();
+ if(buildEvent.getEvent().getPriority() > level.getValue()) return;
+
+ if(text != null) {
+ try {
+ doc.insertString(doc.getLength(), text, null);
+ doc.insertString(doc.getLength(), "\n", null);
+ }
+ catch(Exception ex) {
+ // XXX log me.
+ ex.printStackTrace();
+ }
+ }
+ }
+ }
+
+ /** 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 AntBuildEvent;
+ }
+ }
+
}
Index: org/apache/tools/ant/gui/EventResponder.java
===================================================================
RCS file:
/home/cvspublic/jakarta-ant/src/antidote/org/apache/tools/ant/gui/EventResponder.java,v
retrieving revision 1.1
diff -u -r1.1 EventResponder.java
--- org/apache/tools/ant/gui/EventResponder.java 2000/11/03 12:04:24
1.1
+++ org/apache/tools/ant/gui/EventResponder.java 2000/11/05 20:55:26
@@ -117,6 +117,9 @@
if(command.equals(OpenCmd.ACTION_NAME)) {
new OpenCmd(_context).execute();
}
+ else if(command.equals(BuildCmd.ACTION_NAME)) {
+ new BuildCmd(_context).execute();
+ }
else if(command.equals(CloseCmd.ACTION_NAME)) {
new CloseCmd(_context).execute();
}
Index: org/apache/tools/ant/gui/Main.java
===================================================================
RCS file:
/home/cvspublic/jakarta-ant/src/antidote/org/apache/tools/ant/gui/Main.java,v
retrieving revision 1.1
diff -u -r1.1 Main.java
--- org/apache/tools/ant/gui/Main.java 2000/11/03 12:04:24 1.1
+++ org/apache/tools/ant/gui/Main.java 2000/11/05 20:55:27
@@ -52,7 +52,7 @@
* <http://www.apache.org/>.
*/
package org.apache.tools.ant.gui;
-
+import org.apache.tools.ant.gui.util.WindowUtils;
import javax.swing.*;
import java.awt.BorderLayout;
@@ -82,10 +82,19 @@
f.getContentPane().add(BorderLayout.NORTH,
context.getActions().createToolBar());
+ ImageIcon icon =
+ context.getResources().getImageIcon("icon-small.gif");
+ if(icon != null) {
+ f.setIconImage(icon.getImage());
+ }
+ else {
+ System.out.println("Application icon not found.");
+ }
f.pack();
+
f.setVisible(true);
// Hack around linux window placement annoyance.
- f.setLocation(100, 100);
+ WindowUtils.centerWindow(f);
}
catch(Exception ex) {
Index: 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.1
diff -u -r1.1 ProjectNavigator.java
--- org/apache/tools/ant/gui/ProjectNavigator.java 2000/11/03 12:04:24
1.1
+++ org/apache/tools/ant/gui/ProjectNavigator.java 2000/11/05 20:55:28
@@ -85,7 +85,7 @@
JScrollPane scroller = new JScrollPane(_tree);
add(scroller);
- setPreferredSize(new Dimension(100, 100));
+ setPreferredSize(new Dimension(150, 100));
}
Index: 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.1
diff -u -r1.1 ProjectProxy.java
--- org/apache/tools/ant/gui/ProjectProxy.java 2000/11/03 12:04:24 1.1
+++ org/apache/tools/ant/gui/ProjectProxy.java 2000/11/05 20:55:30
@@ -54,10 +54,15 @@
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.gui.event.*;
import java.io.File;
import java.io.IOException;
import javax.swing.tree.TreeModel;
import javax.swing.text.Document;
+import java.util.Enumeration;
/**
* This class provides the gateway interface to the data model for
@@ -70,47 +75,62 @@
*/
public class ProjectProxy {
+ /** Application context */
+ private AppContext _context = null;
/** The file where the project was last saved. */
private File _file = null;
-
/** The real Ant Project instance. */
private Project _project = null;
+ /** Private the current thread executing a build. */
+ private Thread _buildThread = null;
/**
- * Default constructor. NB: right now it is private, but
- * will be opened up once the gui supports creating new projects.
- *
- */
- private ProjectProxy() {
- }
-
- /**
* File loading ctor.
*
* @param file File containing build file to load.
*/
- public ProjectProxy(File file) throws IOException {
- this();
+ public ProjectProxy(AppContext context, File file) throws IOException {
_file = file;
+ _context = context;
loadProject();
}
-
+ /**
+ * Load the project from the build file.
+ *
+ */
private void loadProject() throws IOException {
_project = new Project();
- _project.init();
+ synchronized(_project) {
+ _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 replicated here.
+ // 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
+ // replicated here.
- // XXX need to provide a way to pass in externally defined properties.
- // Perhaps define an external Antidote properties file.
- _project.setUserProperty("ant.file" , _file.getAbsolutePath());
- ProjectHelper.configureProject(_project, _file);
+ // XXX need to provide a way to pass in externally
+ // defined properties. Perhaps define an external
+ // Antidote properties file.
+ _project.setUserProperty("ant.file" , _file.getAbsolutePath());
+ ProjectHelper.configureProject(_project, _file);
+ }
}
/**
+ * 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.
+ *
+ */
+ public void build() throws BuildException {
+ if(_project == null) return;
+
+ _buildThread = new Thread(new BuildRunner());
+ _buildThread.start();
+ }
+
+ /**
* Get the file where the project is saved to. If the project
* is a new one that has never been saved the this will return null.
*
@@ -146,4 +166,56 @@
}
return null;
}
+
+ /**
+ * Convenience method for causeing the project to fire a build event.
+ * Implemented because the corresponding method in the Project class
+ * is not publically accessible.
+ *
+ * @param event Event to fire.
+ */
+ private void fireBuildEvent(BuildEvent event, BuildEventType type) {
+ synchronized(_project) {
+ Enumeration enum = _project.getBuildListeners().elements();
+ while(enum.hasMoreElements()) {
+ BuildListener l = (BuildListener) enum.nextElement();
+ type.fireEvent(event, l);
+ }
+ }
+ }
+
+ /** Class for executing the build in a separate thread. */
+ private class BuildRunner implements Runnable {
+ public void run() {
+ synchronized(_project) {
+ // Add the build listener for
+ // dispatching BuildEvent objects to the
+ // EventBus.
+ BuildEventForwarder handler =
+ new BuildEventForwarder(_context);
+ _project.addBuildListener(handler);
+ 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());
+ }
+ catch(BuildException ex) {
+ BuildEvent errorEvent = new BuildEvent(_project);
+ errorEvent.setException(ex);
+ errorEvent.setMessage(ex.getMessage(), Project.MSG_ERR);
+ fireBuildEvent(errorEvent, BuildEventType.MESSAGE_LOGGED);
+ }
+ finally {
+ fireBuildEvent(new BuildEvent(
+ _project), BuildEventType.BUILD_FINISHED);
+ _project.removeBuildListener(handler);
+ _buildThread = null;
+ }
+ }
+ }
+ }
+
}
Index: org/apache/tools/ant/gui/ResourceManager.java
===================================================================
RCS file:
/home/cvspublic/jakarta-ant/src/antidote/org/apache/tools/ant/gui/ResourceManager.java,v
retrieving revision 1.1
diff -u -r1.1 ResourceManager.java
--- org/apache/tools/ant/gui/ResourceManager.java 2000/11/03 12:04:24
1.1
+++ org/apache/tools/ant/gui/ResourceManager.java 2000/11/05 20:55:31
@@ -55,6 +55,9 @@
import java.util.*;
import java.text.MessageFormat;
+import javax.swing.ImageIcon;
+import java.net.URL;
+import java.io.File;
/**
* Singleton class for accessing various resources by the application.
@@ -141,6 +144,24 @@
public String getMessage(Class clazz, String name, Object[] arguments) {
String format = getString(clazz, name);
return MessageFormat.format(format, arguments);
+ }
+
+ /**
+ * Get the image as an ImageIcon with the given file name.
+ * For example "open.gif". The image is loaded from the resources package.
+ *
+ * @param fileName Image file to load.
+ * @return Image as an ImageIcon, or null if not found.
+ */
+ public ImageIcon getImageIcon(String fileName) {
+ ImageIcon icon = null;
+
+ URL location = getClass().getResource("resources/" + fileName);
+
+ if(location != null) {
+ icon = new ImageIcon(location);
+ }
+ return icon;
}
}
Index: org/apache/tools/ant/gui/command/LoadFileCmd.java
===================================================================
RCS file:
/home/cvspublic/jakarta-ant/src/antidote/org/apache/tools/ant/gui/command/LoadFileCmd.java,v
retrieving revision 1.1
diff -u -r1.1 LoadFileCmd.java
--- org/apache/tools/ant/gui/command/LoadFileCmd.java 2000/11/03 12:04:29
1.1
+++ org/apache/tools/ant/gui/command/LoadFileCmd.java 2000/11/05 20:55:32
@@ -95,7 +95,7 @@
}
else {
try {
- ProjectProxy project = new ProjectProxy(_file);
+ ProjectProxy project = new ProjectProxy(_context, _file);
_context.setProject(project);
}
catch(IOException ex) {
Index: org/apache/tools/ant/gui/event/EventBus.java
===================================================================
RCS file:
/home/cvspublic/jakarta-ant/src/antidote/org/apache/tools/ant/gui/event/EventBus.java,v
retrieving revision 1.1
diff -u -r1.1 EventBus.java
--- org/apache/tools/ant/gui/event/EventBus.java 2000/11/03 12:04:30
1.1
+++ org/apache/tools/ant/gui/event/EventBus.java 2000/11/05 20:55:34
@@ -54,7 +54,7 @@
package org.apache.tools.ant.gui.event;
import java.util.*;
-
+import javax.swing.SwingUtilities;
/**
* An event "bus" providing a centralized place for posting
* and recieving generic application events. To receive events a class must
@@ -142,29 +142,55 @@
* @param event Event to post.
*/
public void postEvent(EventObject event) {
- synchronized(_memberSet) {
- // XXX need to insert code here to test whether we are being
- // executed by the AWTEventQueue, or some other thread. If
- // the latter, then we need to insert our execution on the
- // AWTEventQueue thread as all code executing commands assumes
- // that context.
+ EventDispatcher disp = new EventDispatcher(event);
- for(int i = 0; i < _memberSet.length; i++) {
- if(_memberSet[i] == null) continue;
+ // Events need to be dispatched on the AWTEvent thread, as the UI
+ // components assume that.
+ if(SwingUtilities.isEventDispatchThread()) {
+ disp.run();
+ }
+ else {
+ SwingUtilities.invokeLater(disp);
+ }
+ }
- Iterator it = _memberSet[i].iterator();
- while(it.hasNext()) {
- BusMember next = (BusMember) it.next();
- BusFilter filter = next.getBusFilter();
- if(filter == null ||
filter.accept(event)) {
- next.eventPosted(event);
- }
- // Check to see if the member cancelled
the event. If so
- // then don't send it on to the other
members.
- if(event instanceof AntEvent &&
- ((AntEvent)event).isCancelled())
break;
- }
- }
+ /** Class that performs the duty of dispatching events to the members. */
+ private class EventDispatcher implements Runnable {
+ /** Event to dispatch. */
+ private EventObject _event = null;
+
+ /**
+ * Standard ctor.
+ *
+ * @param event Event to dispatch.
+ */
+ public EventDispatcher(EventObject event) {
+ _event = event;
+ }
+
+ /**
+ * Perform dispatching.
+ *
+ */
+ public void run() {
+ synchronized(_memberSet) {
+ for(int i = 0; i < _memberSet.length; i++) {
+ if(_memberSet[i] == null) continue;
+
+ Iterator it = _memberSet[i].iterator();
+ while(it.hasNext()) {
+ BusMember next = (BusMember) it.next();
+ BusFilter filter = next.getBusFilter();
+ if(filter == null || filter.accept(_event)) {
+ next.eventPosted(_event);
+ }
+ // Check to see if the member cancelled the event. If
so
+ // then don't send it on to the other members.
+ if(_event instanceof AntEvent &&
+ ((AntEvent)_event).isCancelled()) break;
+ }
+ }
+ }
}
}
}
Index: 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.1
diff -u -r1.1 action.properties
--- org/apache/tools/ant/gui/resources/action.properties 2000/11/03
12:04:31 1.1
+++ org/apache/tools/ant/gui/resources/action.properties 2000/11/05
20:55:35
@@ -1,21 +1,24 @@
-menus=File, Help
+menus=File, Build, Help
-actions=open, close, exit, about
+actions=open, close, exit, about, startBuild, stopBuild
new.name=New
new.shortDescription=Create a new project
new.parentMenuName=File
new.icon=new.gif
+new.accelerator=control N
open.name=Open
open.shortDescription=Open an existing project
open.parentMenuName=File
open.icon=open.gif
+open.accelerator=control O
save.name=Save
save.shortDescription=Save the current project
save.parentMenuName=File
save.icon=save.gif
+save.accelerator=control S
close.name=Close
close.shortDescription=Close the current project
@@ -30,3 +33,17 @@
about.shortDescription=About this application
about.parentMenuName=Help
about.separator=true;
+
+startBuild.name=Start
+startBuild.shortDescription=Start build of selected target
+startBuild.parentMenuName=Build
+startBuild.icon=start.gif
+startBuild.separator=true
+startBuild.accelerator=control B
+
+stopBuild.name=Stop
+stopBuild.shortDescription=Stop the current build
+stopBuild.parentMenuName=Build
+stopBuild.icon=stop.gif
+stopBuild.accelerator=control K
+
Index: 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.1
diff -u -r1.1 antidote.properties
--- org/apache/tools/ant/gui/resources/antidote.properties 2000/11/03
12:04:31 1.1
+++ org/apache/tools/ant/gui/resources/antidote.properties 2000/11/05
20:55:36
@@ -9,10 +9,16 @@
org.apache.tools.ant.gui.Antidote.left.editors=\
org.apache.tools.ant.gui.ProjectNavigator
+# Configure the editors that appear on the bottom of the UI.
+org.apache.tools.ant.gui.Antidote.bottom.editors=\
+ org.apache.tools.ant.gui.Console
+
# 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.ProjectNavigator.name=Task Navigator
+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:
org.apache.tools.ant.gui.XMLFileFilter.description=XML Files
Index: org/apache/tools/ant/gui/util/WindowUtils.java
===================================================================
RCS file:
/home/cvspublic/jakarta-ant/src/antidote/org/apache/tools/ant/gui/util/WindowUtils.java,v
retrieving revision 1.1
diff -u -r1.1 WindowUtils.java
--- org/apache/tools/ant/gui/util/WindowUtils.java 2000/11/03 12:04:32
1.1
+++ org/apache/tools/ant/gui/util/WindowUtils.java 2000/11/05 20:55:37
@@ -82,7 +82,7 @@
}
/**
- * Center the given child window with repsect to the child window.
+ * Center the given child window with repsect to the parent window.
*
* @param parent Window to base centering on.
* @param child Window to center.
@@ -94,4 +94,15 @@
bounds.y + (bounds.height -
size.height)/2);
}
+ /**
+ * Center the given child window with repsect to the root.
+ *
+ * @param child Window to center.
+ */
+ public static void centerWindow(Window child) {
+ Dimension rsize = child.getToolkit().getScreenSize();
+ Dimension size = child.getSize();
+ child.setLocation((rsize.width - size.width)/2,
+ (rsize.height - size.height)/2);
+ }
}
newfiles.jar
Description: newfiles.jar
