From 821004a5407db28a7482cff8f928d92b7615ea36 Mon Sep 17 00:00:00 2001 From: metasim Date: Tue, 14 Nov 2000 21:50:36 +0000 Subject: [PATCH] Added ability to define state transition condtions for the enabled state of GUI actions. As specific events are fired in the GUI the enabled state is updated for specific actions. git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@268185 13f79535-47bb-0310-9956-ffa450edef68 --- src/antidote/ChangeLog | 25 ++ .../apache/tools/ant/gui/ActionManager.java | 157 +++------- .../org/apache/tools/ant/gui/AntAction.java | 284 ++++++++++++++++++ .../tools/ant/gui/BuildEventForwarder.java | 6 + .../org/apache/tools/ant/gui/Console.java | 13 +- .../tools/ant/gui/EventToActionMapper.java | 147 +++++++++ .../tools/ant/gui/command/CloseCmd.java | 2 + .../ant/gui/event/BuildFinishedEvent.java | 101 +++++++ .../ant/gui/event/BuildStartedEvent.java | 101 +++++++ .../ant/gui/event/ProjectClosedEvent.java | 86 ++++++ .../tools/ant/gui/resources/action.properties | 37 ++- 11 files changed, 830 insertions(+), 129 deletions(-) create mode 100644 src/antidote/org/apache/tools/ant/gui/AntAction.java create mode 100644 src/antidote/org/apache/tools/ant/gui/EventToActionMapper.java create mode 100644 src/antidote/org/apache/tools/ant/gui/event/BuildFinishedEvent.java create mode 100644 src/antidote/org/apache/tools/ant/gui/event/BuildStartedEvent.java create mode 100644 src/antidote/org/apache/tools/ant/gui/event/ProjectClosedEvent.java diff --git a/src/antidote/ChangeLog b/src/antidote/ChangeLog index 60eae2817..2ba900041 100644 --- a/src/antidote/ChangeLog +++ b/src/antidote/ChangeLog @@ -1,3 +1,28 @@ +2000-11-14 Simeon H.K. Fitch + + * org/apache/tools/ant/gui/Antidote.java: Added top area widget, + which is *not* managed inside a split pane. + + * org/apache/tools/ant/gui/ProjectNavigator.java: Added minimum + size to keep resizing of parent from hiding widget. + + * org/apache/tools/ant/gui/ActionManager.java: Large functionality + addtion for allowing action enabled/disabled state to be defined + in the configuration file. The triggering of state changes is + based on the firing of specific events. + + * org/apache/tools/ant/gui/AntAction.java: Broke out from inner + class of ActionManager to its own self (I'm my own man!). + + * org/apache/tools/ant/gui/command/CloseCmd.java: Added firing of + ProjectClosedEvent so state updates could occur. + + * org/apache/tools/ant/gui/resources/action.properties: Added + enabledOn and disabledOn event specifications. + + * org/apache/tools/ant/gui/Console.java: Improved reporting level + handling (some events weren't getting reported). + 2000-11-10 Simeon H.K. Fitch * org/apache/tools/ant/gui/PropertyEditor.java: Added new diff --git a/src/antidote/org/apache/tools/ant/gui/ActionManager.java b/src/antidote/org/apache/tools/ant/gui/ActionManager.java index 921a4979f..10e85dd44 100644 --- a/src/antidote/org/apache/tools/ant/gui/ActionManager.java +++ b/src/antidote/org/apache/tools/ant/gui/ActionManager.java @@ -55,10 +55,7 @@ package org.apache.tools.ant.gui; import org.apache.tools.ant.gui.event.*; import javax.swing.*; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; import java.util.*; -import java.net.URL; /** * Manager of antidote actions. Receives its configuration from the action @@ -80,6 +77,10 @@ public class ActionManager { /** Event bus. */ private EventBus _bus = null; + /** Class for storing the event type to action type + * mapping for setting enabled state. */ + private EventToActionMapper _mapper = null; + /** * Standard ctor. @@ -88,6 +89,9 @@ public class ActionManager { */ public ActionManager(EventBus bus) { _bus = bus; + bus.addMember(EventBus.RESPONDING, new Enabler()); + + _mapper = new EventToActionMapper(); // Configure the set of actions. String toTok = _resources.getString("actions"); @@ -95,8 +99,16 @@ public class ActionManager { _actionIDs = new String[tok.countTokens()]; for(int i = 0; i < _actionIDs.length; i++) { _actionIDs[i] = tok.nextToken(); - _actions.put(_actionIDs[i], new AntAction(_actionIDs[i])); + AntAction action = new AntAction(_resources, _bus, _actionIDs[i]); + _actions.put(_actionIDs[i], action); + + + // For each action we need to add the reverse event trigger + // lookup. + _mapper.addAction(action); + } + } /** @@ -204,137 +216,44 @@ public class ActionManager { } } - /** - * Convenience method for looking put a resource with the name - * "id.key". Will return null if the resource doesn't exist. - * - * @param id Action id. - * @param key Key name for the action. - * @return String resource for composite key, or null if not found. - */ - private String getString(String id, String key) { - String retval = null; - try { - retval = _resources.getString(id + "." + key); - } - catch(MissingResourceException ex) { - // Its ok to be missing a resource name... - // Too bad the API throws an exception in this case. - } - return retval; - } - - /** Class representing an action in the Antidote application. */ - private class AntAction extends AbstractAction { - /** 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; + /** Class for updating the enabled status of icons based + * on the events seen. */ + private class Enabler implements BusMember { + private final Filter _filter = new Filter(); /** - * Standard ctor. + * Get the filter to that is used to determine if an event should + * to to the member. * - * @param id Unique id for the action + * @return Filter to use. */ - public AntAction(String id) { - _id = id; - putValue(NAME, getString(id, "name")); - putValue(SHORT_DESCRIPTION, getString(id, "shortDescription")); - 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 { - URL imageLoc = - AntAction.class.getResource("resources/" + iconName); - if(imageLoc != null) { - putValue(SMALL_ICON, new ImageIcon(imageLoc)); - } - } - catch(Exception ex) { - // XXX log me. - ex.printStackTrace(); - } - } + public BusFilter getBusFilter() { + return _filter; } /** - * Unique id for the action. + * Receives all events. * - * @return Action id. + * @param event Event to post. */ - public String getID() { - return _id; - } - - /** - * Get the name of the menu in the menu bar that this action shoul - * appear under. - * - * @return Menu to appear under, or null if not a menu action. - */ - public String getParentMenuName() { - return (String) getValue(PARENT_MENU_NAME); - } - - /** - * Get the localized name for the action. - * - * @return Name - */ - public String getName() { - return (String) getValue(NAME); - } - - /** - * Get the short description. Used in tool tips. - * - * @return Short description. - */ - public String getShortDescription() { - return (String) getValue(SHORT_DESCRIPTION); - } - - /** - * Determine if a separator should appear before the action. - * - * @return True if add separator, false otherwise. - */ - public boolean isPreceededBySeparator() { - return Boolean.valueOf( - String.valueOf(getValue(SEPARATOR))).booleanValue(); + public void eventPosted(EventObject event) { + _mapper.applyEvent(event); } + } + /** Class providing filtering for project events. */ + private static class Filter implements BusFilter { /** - * Get the icon. + * Determines if the given event should be accepted. * - * @return Icon for action, or null if none. + * @param event Event to test. + * @return True if event should be given to BusMember, false otherwise. */ - public Icon getIcon() { - return (Icon) getValue(SMALL_ICON); + public boolean accept(EventObject event) { + return true; } + } - public KeyStroke getAccelerator() { - return (KeyStroke) getValue(ACCELERATOR); - } - /** - * Pass the action on to the EventBus. - * - * @param e Event to forward. - */ - public void actionPerformed(ActionEvent e) { - _bus.postEvent(e); - } - } } diff --git a/src/antidote/org/apache/tools/ant/gui/AntAction.java b/src/antidote/org/apache/tools/ant/gui/AntAction.java new file mode 100644 index 000000000..4ed82e100 --- /dev/null +++ b/src/antidote/org/apache/tools/ant/gui/AntAction.java @@ -0,0 +1,284 @@ +/* + * The Apache Software License, Version 1.1 + * + * Copyright (c) 1999, 2000 The Apache Software Foundation. All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, if + * any, must include the following acknowlegement: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowlegement may appear in the software itself, + * if and wherever such third-party acknowlegements normally appear. + * + * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software + * Foundation" must not be used to endorse or promote products derived + * from this software without prior written permission. For written + * permission, please contact apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache" + * nor may "Apache" appear in their names without prior written + * permission of the Apache Group. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * . + */ +package org.apache.tools.ant.gui; + +import javax.swing.*; +import java.net.URL; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.*; + +import org.apache.tools.ant.gui.event.EventBus; + +/** + * Class representing an action in the Antidote application. + * + * @version $Revision$ + * @author Simeon Fitch + */ +public class AntAction extends AbstractAction { + /** 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"; + public static final String ENABLED = "enabled"; + public static final String ENABLE_ON = "enableOn"; + public static final String DISABLE_ON = "disableOn"; + + /** Property resources. */ + private ResourceBundle _resources = null; + /** Event bus. */ + private EventBus _bus = null; + /** Unique id. */ + private String _id = null; + + /** Events that the action should cause transition to the + * enabled(true) state. */ + private Class[] _enableOn = null; + /** Events that the action should cause transition to the + * enabled(false) state. */ + private Class[] _disableOn = null; + + + /** + * Standard ctor. + * + * @param id Unique id for the action + */ + public AntAction(ResourceBundle resources, EventBus bus, String id) { + _resources = resources; + _bus = bus; + _id = id; + putValue(NAME, getString("name")); + putValue(SHORT_DESCRIPTION, getString("shortDescription")); + putValue(PARENT_MENU_NAME, getString(PARENT_MENU_NAME)); + putValue(SEPARATOR, getString(SEPARATOR)); + + + // Set the default enabled state. + String enabled = getString(ENABLED); + if(enabled != null) { + setEnabled(Boolean.valueOf(enabled).booleanValue()); + } + + // Set an accellerator if any. + String accelerator = getString(ACCELERATOR); + if(accelerator != null) { + putValue(ACCELERATOR, KeyStroke.getKeyStroke(accelerator)); + } + + // Add an icon if any (which means it'll show up on the tool bar). + String iconName = getString("icon"); + if(iconName != null) { + try { + URL imageLoc = + AntAction.class.getResource("resources/" + iconName); + if(imageLoc != null) { + putValue(SMALL_ICON, new ImageIcon(imageLoc)); + } + } + catch(Exception ex) { + // XXX log me. + ex.printStackTrace(); + } + } + + _enableOn = resolveClasses(getString(ENABLE_ON)); + _disableOn = resolveClasses(getString(DISABLE_ON)); + + } + + /** + * Convenience method for looking put a resource with the name + * "id.key". Will return null if the resource doesn't exist. + * + * @param key Key name for the action. + * @return String resource for composite key, or null if not found. + */ + private String getString(String key) { + String retval = null; + try { + retval = _resources.getString(_id + "." + key); + } + catch(MissingResourceException ex) { + // Its ok to be missing a resource name... + // Too bad the API throws an exception in this case. + } + return retval; + } + + + /** + * Parse out the list of classes from the given string and + * resolve them into classes. + * + * @param classNames Comma delimited list of class names. + */ + private Class[] resolveClasses(String classNames) { + if(classNames == null) return null; + + StringTokenizer tok = new StringTokenizer(classNames, ", "); + Vector vals = new Vector(); + while(tok.hasMoreTokens()) { + String name = tok.nextToken(); + try { + vals.addElement(Class.forName(name)); + } + catch(ClassNotFoundException ex) { + //XXX log me. + System.err.println( + "Warning: the event class " + name + + " was not found. Please check config file."); + } + } + + Class[] retval = new Class[vals.size()]; + vals.copyInto(retval); + return retval; + } + + /** + * Unique id for the action. + * + * @return Action id. + */ + public String getID() { + return _id; + } + + /** + * Get the name of the menu in the menu bar that this action shoul + * appear under. + * + * @return Menu to appear under, or null if not a menu action. + */ + public String getParentMenuName() { + return (String) getValue(PARENT_MENU_NAME); + } + + /** + * Get the localized name for the action. + * + * @return Name + */ + public String getName() { + return (String) getValue(NAME); + } + + /** + * Get the short description. Used in tool tips. + * + * @return Short description. + */ + public String getShortDescription() { + return (String) getValue(SHORT_DESCRIPTION); + } + + /** + * Determine if a separator should appear before the action. + * + * @return True if add separator, false otherwise. + */ + public boolean isPreceededBySeparator() { + return Boolean.valueOf( + String.valueOf(getValue(SEPARATOR))).booleanValue(); + } + + /** + * Get the icon. + * + * @return Icon for action, or null if none. + */ + public Icon getIcon() { + return (Icon) getValue(SMALL_ICON); + } + + /** + * Get the accelerator keystroke. + * + * @return Accelerator + */ + public KeyStroke getAccelerator() { + return (KeyStroke) getValue(ACCELERATOR); + } + + + /** + * Get the event types which should cause this to go to the + * enabled state. + * + */ + public Class[] getEnableOnEvents() { + return _enableOn; + } + + /** + * Get the event types which should cause this to go to + * this disabled state. + * + */ + public Class[] getDisableOnEvents() { + return _disableOn; + } + + /** + * Pass the action on to the EventBus. + * + * @param e Event to forward. + */ + public void actionPerformed(ActionEvent e) { + _bus.postEvent(e); + } +} + diff --git a/src/antidote/org/apache/tools/ant/gui/BuildEventForwarder.java b/src/antidote/org/apache/tools/ant/gui/BuildEventForwarder.java index c92b54bec..288b7e930 100644 --- a/src/antidote/org/apache/tools/ant/gui/BuildEventForwarder.java +++ b/src/antidote/org/apache/tools/ant/gui/BuildEventForwarder.java @@ -76,6 +76,9 @@ public class BuildEventForwarder implements BuildListener { */ public void buildStarted(BuildEvent event){ postEvent(event, BuildEventType.BUILD_STARTED); + // We doubly post this event. + _context.getEventBus().postEvent( + new BuildStartedEvent(_context, event)); } /** @@ -86,6 +89,9 @@ public class BuildEventForwarder implements BuildListener { */ public void buildFinished(BuildEvent event) { postEvent(event, BuildEventType.BUILD_FINISHED); + // We doubly post this event. + _context.getEventBus().postEvent( + new BuildFinishedEvent(_context, event)); } /** diff --git a/src/antidote/org/apache/tools/ant/gui/Console.java b/src/antidote/org/apache/tools/ant/gui/Console.java index e544858b3..4e5a388fa 100644 --- a/src/antidote/org/apache/tools/ant/gui/Console.java +++ b/src/antidote/org/apache/tools/ant/gui/Console.java @@ -148,6 +148,8 @@ public class Console extends AntEditor { switch(buildEvent.getType().getValue()) { case BuildEventType.BUILD_STARTED_VAL: clearDisplay(); + case BuildEventType.BUILD_FINISHED_VAL: + text = buildEvent.getType().toString(); break; case BuildEventType.TARGET_STARTED_VAL: text = buildEvent.getEvent().getTarget().getName() + ":"; @@ -157,13 +159,16 @@ public class Console extends AntEditor { case BuildEventType.TASK_FINISHED_VAL: break; case BuildEventType.MESSAGE_LOGGED_VAL: - text = buildEvent.toString(); + // Filter out events that are below our + // selected filterint level. + LogLevelEnum level = + (LogLevelEnum) _logLevel.getSelectedItem(); + if(buildEvent.getEvent().getPriority() <= level.getValue()) { + 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 { diff --git a/src/antidote/org/apache/tools/ant/gui/EventToActionMapper.java b/src/antidote/org/apache/tools/ant/gui/EventToActionMapper.java new file mode 100644 index 000000000..5b6a631d6 --- /dev/null +++ b/src/antidote/org/apache/tools/ant/gui/EventToActionMapper.java @@ -0,0 +1,147 @@ +/* + * The Apache Software License, Version 1.1 + * + * Copyright (c) 1999, 2000 The Apache Software Foundation. All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, if + * any, must include the following acknowlegement: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowlegement may appear in the software itself, + * if and wherever such third-party acknowlegements normally appear. + * + * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software + * Foundation" must not be used to endorse or promote products derived + * from this software without prior written permission. For written + * permission, please contact apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache" + * nor may "Apache" appear in their names without prior written + * permission of the Apache Group. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * . + */ +package org.apache.tools.ant.gui; +import java.util.*; + +/** + * The purpose of this class is to manage the + * mappings between event type and action enabled state. + * + * @version $Revision$ + * @author Simeon Fitch + */ +class EventToActionMapper { + + /** Lookup for enable(true) events. Key is event type, value is + * a list of actions that are changed by the event. */ + private Map _enableOn = new HashMap(); + /** Lookup for enable(false) events. Key is event type, value is + * a list of actions that are changed by the event. */ + private Map _disableOn = new HashMap(); + + + public EventToActionMapper() { + + } + + /** + * Add an action. + * + * @param action Action to add. + */ + public void addAction(AntAction action) { + putAction(action, action.getEnableOnEvents(), _enableOn); + putAction(action, action.getDisableOnEvents(), _disableOn); + } + + + /** + * For the given action store it in the event type mapping + * for each of the given types. + * + * @param action Action to store. + * @param clazzes Array of types to store it under. + * @param storage The place to store the association. + */ + private void putAction(AntAction action, Class[] clazzes, Map storage) { + if(clazzes == null) return; + + for(int i = 0; i < clazzes.length; i++) { + List values = (List) storage.get(clazzes[i]); + if(values == null) { + values = new ArrayList(1); + storage.put(clazzes[i], values); + } + + values.add(action); + } + } + + + /** + * For the given event change the state of any actions that + * have been registered as needing a transition as a result of + * the event. + * + * @param event The event to apply. + */ + public void applyEvent(EventObject event) { + if(event == null) return; + + List vals = null; + + vals = (List) _enableOn.get(event.getClass()); + changeState(vals, true); + + vals = (List) _disableOn.get(event.getClass()); + changeState(vals, false); + } + + /** + * Set the enabled state of the given actions. + * + * @param actions List of AntActions to set state for. + * @param state The state to set them to. + */ + private void changeState(List actions, boolean state) { + if(actions == null) return; + + for(int i = 0, len = actions.size(); i < len; i++) { + AntAction action = (AntAction) actions.get(i); + action.setEnabled(state); + } + } + + +} diff --git a/src/antidote/org/apache/tools/ant/gui/command/CloseCmd.java b/src/antidote/org/apache/tools/ant/gui/command/CloseCmd.java index 3af1acbb1..6f8b11840 100644 --- a/src/antidote/org/apache/tools/ant/gui/command/CloseCmd.java +++ b/src/antidote/org/apache/tools/ant/gui/command/CloseCmd.java @@ -53,6 +53,7 @@ */ package org.apache.tools.ant.gui.command; import org.apache.tools.ant.gui.AppContext; +import org.apache.tools.ant.gui.event.ProjectClosedEvent; /** @@ -83,5 +84,6 @@ public class CloseCmd implements Command { */ public void execute() { _context.setProject(null); + _context.getEventBus().postEvent(new ProjectClosedEvent(_context)); } } diff --git a/src/antidote/org/apache/tools/ant/gui/event/BuildFinishedEvent.java b/src/antidote/org/apache/tools/ant/gui/event/BuildFinishedEvent.java new file mode 100644 index 000000000..edf73d177 --- /dev/null +++ b/src/antidote/org/apache/tools/ant/gui/event/BuildFinishedEvent.java @@ -0,0 +1,101 @@ +/* + * The Apache Software License, Version 1.1 + * + * Copyright (c) 1999, 2000 The Apache Software Foundation. All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, if + * any, must include the following acknowlegement: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowlegement may appear in the software itself, + * if and wherever such third-party acknowlegements normally appear. + * + * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software + * Foundation" must not be used to endorse or promote products derived + * from this software without prior written permission. For written + * permission, please contact apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache" + * nor may "Apache" appear in their names without prior written + * permission of the Apache Group. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * . + */ +package org.apache.tools.ant.gui.event; +import org.apache.tools.ant.BuildEvent; +import org.apache.tools.ant.gui.AppContext; +import org.apache.tools.ant.gui.command.NoOpCmd; +import org.apache.tools.ant.gui.command.Command; + + +/** + * Build finished. This event is a duplication of the information posted as + * an AntBuildEvent when a build finishes. + * + * @version $Revision$ + * @author Simeon Fitch + */ +public class BuildFinishedEvent extends AntEvent { + + /** The originating event from Ant. */ + private BuildEvent _orig = null; + + /** + * Standard ctor. + * + * @param context The application context. + * @param orig The originating event. + */ + public BuildFinishedEvent(AppContext context, BuildEvent orig) { + super(context); + _orig = orig; + } + + /** + * Get the originating event. + * + * @return Originating event. + */ + public BuildEvent getBuildEvent() { + return _orig; + } + + /** + * Create the appropriate response command to this event. + * + * @return Command representing an appropriate response to this event. + */ + public Command createDefaultCmd() { + return new NoOpCmd(); + } +} diff --git a/src/antidote/org/apache/tools/ant/gui/event/BuildStartedEvent.java b/src/antidote/org/apache/tools/ant/gui/event/BuildStartedEvent.java new file mode 100644 index 000000000..9e54605c4 --- /dev/null +++ b/src/antidote/org/apache/tools/ant/gui/event/BuildStartedEvent.java @@ -0,0 +1,101 @@ +/* + * The Apache Software License, Version 1.1 + * + * Copyright (c) 1999, 2000 The Apache Software Foundation. All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, if + * any, must include the following acknowlegement: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowlegement may appear in the software itself, + * if and wherever such third-party acknowlegements normally appear. + * + * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software + * Foundation" must not be used to endorse or promote products derived + * from this software without prior written permission. For written + * permission, please contact apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache" + * nor may "Apache" appear in their names without prior written + * permission of the Apache Group. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * . + */ +package org.apache.tools.ant.gui.event; +import org.apache.tools.ant.BuildEvent; +import org.apache.tools.ant.gui.AppContext; +import org.apache.tools.ant.gui.command.NoOpCmd; +import org.apache.tools.ant.gui.command.Command; + + +/** + * Build started. This event is a duplication of the information posted as + * an AntBuildEvent when a build starts. + * + * @version $Revision$ + * @author Simeon Fitch + */ +public class BuildStartedEvent extends AntEvent { + + /** The originating event from Ant. */ + private BuildEvent _orig = null; + + /** + * Standard ctor. + * + * @param context The application context. + * @param orig The originating event. + */ + public BuildStartedEvent(AppContext context, BuildEvent orig) { + super(context); + _orig = orig; + } + + /** + * Get the originating event. + * + * @return Originating event. + */ + public BuildEvent getBuildEvent() { + return _orig; + } + + /** + * Create the appropriate response command to this event. + * + * @return Command representing an appropriate response to this event. + */ + public Command createDefaultCmd() { + return new NoOpCmd(); + } +} diff --git a/src/antidote/org/apache/tools/ant/gui/event/ProjectClosedEvent.java b/src/antidote/org/apache/tools/ant/gui/event/ProjectClosedEvent.java new file mode 100644 index 000000000..cf3504af4 --- /dev/null +++ b/src/antidote/org/apache/tools/ant/gui/event/ProjectClosedEvent.java @@ -0,0 +1,86 @@ +/* + * The Apache Software License, Version 1.1 + * + * Copyright (c) 1999, 2000 The Apache Software Foundation. All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, if + * any, must include the following acknowlegement: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowlegement may appear in the software itself, + * if and wherever such third-party acknowlegements normally appear. + * + * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software + * Foundation" must not be used to endorse or promote products derived + * from this software without prior written permission. For written + * permission, please contact apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache" + * nor may "Apache" appear in their names without prior written + * permission of the Apache Group. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * . + */ +package org.apache.tools.ant.gui.event; +import org.apache.tools.ant.gui.AppContext; +import org.apache.tools.ant.gui.command.NoOpCmd; +import org.apache.tools.ant.gui.command.Command; + + +/** + * Provides notification that the project was closed. + * + * @version $Revision$ + * @author Simeon Fitch + */ +public class ProjectClosedEvent extends AntEvent { + + + /** + * Standard ctor. + * + * @param context The application context. + */ + public ProjectClosedEvent(AppContext context) { + super(context); + } + + /** + * Create the appropriate response command to this event. + * + * @return Command representing an appropriate response to this event. + */ + public Command createDefaultCmd() { + return new NoOpCmd(); + } +} diff --git a/src/antidote/org/apache/tools/ant/gui/resources/action.properties b/src/antidote/org/apache/tools/ant/gui/resources/action.properties index 40819e5d5..cab6c8f9b 100644 --- a/src/antidote/org/apache/tools/ant/gui/resources/action.properties +++ b/src/antidote/org/apache/tools/ant/gui/resources/action.properties @@ -1,38 +1,48 @@ +# Define the primary menubar items. menus=File, Build, Options, Help -actions=open, close, exit, about, startBuild, changeLookAndFeel +# Declare the list of known actions. +actions=\ + open, save, close, exit, about, startBuild, stopBuild, changeLookAndFeel -new.name=New -new.shortDescription=Create a new project -new.parentMenuName=File -new.icon=new.gif -new.accelerator=control N +# Configure the decalred actions. open.name=Open open.shortDescription=Open an existing project open.parentMenuName=File open.icon=open.gif open.accelerator=control O +open.enabled=true save.name=Save save.shortDescription=Save the current project save.parentMenuName=File save.icon=save.gif save.accelerator=control S +save.enabled=false close.name=Close close.shortDescription=Close the current project close.parentMenuName=File +close.enabled=false +close.disableOn= \ + org.apache.tools.ant.gui.event.ProjectClosedEvent, \ + org.apache.tools.ant.gui.event.BuildStartedEvent +close.enableOn= \ + org.apache.tools.ant.gui.event.NewProjectEvent, \ + org.apache.tools.ant.gui.event.BuildFinishedEvent exit.name=Exit exit.shortDescription=Quit the application exit.parentMenuName=File exit.separator=true +exit.enabled=true about.name=About about.shortDescription=About this application about.parentMenuName=Help about.separator=true; +about.enabled=true startBuild.name=Start startBuild.shortDescription=Start build of selected target @@ -40,13 +50,28 @@ startBuild.parentMenuName=Build startBuild.icon=start.gif startBuild.separator=true startBuild.accelerator=control B +startBuild.enabled=false +startBuild.enableOn=\ + org.apache.tools.ant.gui.event.NewProjectEvent, \ + org.apache.tools.ant.gui.event.BuildFinishedEvent +startBuild.disableOn=\ + org.apache.tools.ant.gui.event.BuildStartedEvent, \ + org.apache.tools.ant.gui.event.ProjectClosedEvent stopBuild.name=Stop stopBuild.shortDescription=Stop the current build stopBuild.parentMenuName=Build stopBuild.icon=stop.gif stopBuild.accelerator=control K +stopBuild.enabled=false +stopBuild.enableOn=\ + org.apache.tools.ant.gui.event.BuildStartedEvent +stopBuild.disableOn=\ + org.apache.tools.ant.gui.event.BuildFinishedEvent changeLookAndFeel.name=Look and Feel... changeLookAndFeel.shortDescription=Change the Look and Feel changeLookAndFeel.parentMenuName=Options +changeLookAndFeel.enabled=true + +