git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@268813 13f79535-47bb-0310-9956-ffa450edef68master
@@ -56,12 +56,13 @@ import org.apache.tools.ant.gui.core.AppContext; | |||||
import org.apache.tools.ant.gui.event.ErrorEvent; | import org.apache.tools.ant.gui.event.ErrorEvent; | ||||
import org.apache.tools.ant.gui.acs.ACSProjectElement; | import org.apache.tools.ant.gui.acs.ACSProjectElement; | ||||
import org.apache.tools.ant.gui.acs.ACSTargetElement; | import org.apache.tools.ant.gui.acs.ACSTargetElement; | ||||
import org.apache.tools.ant.gui.event.ShowConsoleEvent; | |||||
/** | /** | ||||
* Starts an Ant build. | * Starts an Ant build. | ||||
* | |||||
* @version $Revision$ | |||||
* @author Simeon Fitch | |||||
* | |||||
* @version $Revision$ | |||||
* @author Simeon Fitch | |||||
*/ | */ | ||||
public class BuildCmd extends AbstractCommand { | public class BuildCmd extends AbstractCommand { | ||||
@@ -70,37 +71,42 @@ public class BuildCmd extends AbstractCommand { | |||||
/** Targets to build. */ | /** Targets to build. */ | ||||
private ACSTargetElement[] _targets = null; | private ACSTargetElement[] _targets = null; | ||||
/** | |||||
/** | |||||
* Standard ctor. | * Standard ctor. | ||||
* | |||||
* | |||||
*/ | */ | ||||
public BuildCmd(AppContext context) { | |||||
public BuildCmd(AppContext context) { | |||||
super(context); | super(context); | ||||
} | } | ||||
/** | |||||
/** | |||||
* Set the specific project to build (instead of the default). | * Set the specific project to build (instead of the default). | ||||
* | |||||
* | |||||
* @param project Project to build. | * @param project Project to build. | ||||
*/ | */ | ||||
public void setProject(ACSProjectElement project) { | public void setProject(ACSProjectElement project) { | ||||
_project = project; | _project = project; | ||||
} | } | ||||
/** | |||||
/** | |||||
* Set the specific targets to build (instead of the default). | * Set the specific targets to build (instead of the default). | ||||
* | |||||
* | |||||
* @param targets Array of targets to build. | * @param targets Array of targets to build. | ||||
*/ | */ | ||||
public void setTargets(ACSTargetElement[] targets) { | public void setTargets(ACSTargetElement[] targets) { | ||||
_targets = targets; | _targets = targets; | ||||
} | } | ||||
/** | |||||
/** | |||||
* Start the Ant build. | * Start the Ant build. | ||||
* | |||||
* | |||||
*/ | */ | ||||
public void run() { | public void run() { | ||||
// Show the build console | |||||
getContext().getEventBus().postEvent( | |||||
new ShowConsoleEvent(getContext())); | |||||
if(_project == null) { | if(_project == null) { | ||||
_project = getContext().getSelectionManager().getSelectedProject(); | _project = getContext().getSelectionManager().getSelectedProject(); | ||||
} | } | ||||
@@ -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", "Ant", and "Apache Software | |||||
* Foundation" must not be used to endorse or promote products derived | |||||
* from this software without prior written permission. For written | |||||
* permission, please contact 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 | |||||
* <http://www.apache.org/>. | |||||
*/ | |||||
package org.apache.tools.ant.gui.command; | |||||
import org.apache.tools.ant.gui.core.AppContext; | |||||
import org.apache.tools.ant.gui.event.*; | |||||
import java.awt.*; | |||||
import javax.swing.*; | |||||
/** | |||||
* Toggles the display of the console window | |||||
* | |||||
* @version $Revision$ | |||||
* @author Nick Davis<a href="mailto:nick_home_account@yahoo.com">nick_home_account@yahoo.com</a> | |||||
*/ | |||||
public class ShowOrHideConsoleCmd extends AbstractCommand { | |||||
/** Always show the console */ | |||||
boolean _alwaysShow = false; | |||||
/** | |||||
* Standard ctor. | |||||
* | |||||
* @param context Application context. | |||||
*/ | |||||
public ShowOrHideConsoleCmd(AppContext context) { | |||||
super(context); | |||||
_alwaysShow = false; | |||||
} | |||||
/** | |||||
* Standard ctor. | |||||
* | |||||
* @param context Application context. | |||||
*/ | |||||
public ShowOrHideConsoleCmd(AppContext context, boolean alwaysShow) { | |||||
super(context); | |||||
_alwaysShow = alwaysShow; | |||||
} | |||||
/** | |||||
* If the console pane is visible, hide it. | |||||
* If the console pane is not visible, show it. | |||||
*/ | |||||
public void run() { | |||||
JComponent component = (JComponent) findComponent("Console"); | |||||
JSplitPane pane = (JSplitPane) component.getParent(); | |||||
if (_alwaysShow) { | |||||
if (component.getHeight() == 0) { | |||||
pane.setDividerLocation(pane.getLastDividerLocation()); | |||||
} | |||||
} else { | |||||
if (component.getHeight() == 0) { | |||||
pane.setDividerLocation(pane.getLastDividerLocation()); | |||||
} else { | |||||
pane.setDividerLocation(1.0); | |||||
} | |||||
} | |||||
} | |||||
/** | |||||
* Starting from the top Frame, find the | |||||
* first child window with the input name. | |||||
* | |||||
* @param name The name of the <code>Component</code> | |||||
*/ | |||||
private Component findComponent(String name) { | |||||
JFrame frame = (JFrame) getContext().getParentFrame(); | |||||
JRootPane root = frame.getRootPane(); | |||||
return findChild(root.getContentPane(), name); | |||||
} | |||||
/** | |||||
* Search the <code>Container</code> for a <code>Component</code> | |||||
* with the input name. The search is recursive. | |||||
* | |||||
* @param container The <code>Container</code> to search | |||||
* @param name The name of the <code>Component</code> | |||||
*/ | |||||
private Component findChild(Container container, String name) { | |||||
Component[] components = container.getComponents(); | |||||
for (int i = 0; i < components.length; i++) { | |||||
Component component = components[i]; | |||||
if ( name.equals(component.getName()) ) { | |||||
return component; | |||||
} | |||||
if (component instanceof java.awt.Container) { | |||||
Component test = findChild( | |||||
(java.awt.Container) component, name); | |||||
if (test != null) { | |||||
return test; | |||||
} | |||||
} | |||||
} | |||||
return null; | |||||
} | |||||
} |
@@ -55,16 +55,19 @@ package org.apache.tools.ant.gui.core; | |||||
import org.apache.tools.ant.gui.event.*; | import org.apache.tools.ant.gui.event.*; | ||||
import org.apache.tools.ant.gui.command.Command; | import org.apache.tools.ant.gui.command.Command; | ||||
import org.apache.tools.ant.gui.util.CheckableButtonModel; | |||||
import javax.swing.*; | import javax.swing.*; | ||||
import javax.accessibility.*; | |||||
import java.util.*; | import java.util.*; | ||||
import java.beans.*; | |||||
import java.lang.reflect.Constructor; | import java.lang.reflect.Constructor; | ||||
/** | /** | ||||
* Manager of antidote actions. Receives its configuration from the action | * Manager of antidote actions. Receives its configuration from the action | ||||
* ResourceBundle. | * ResourceBundle. | ||||
* | |||||
* @version $Revision$ | |||||
* @author Simeon Fitch | |||||
* | |||||
* @version $Revision$ | |||||
* @author Simeon Fitch | |||||
*/ | */ | ||||
public class ActionManager { | public class ActionManager { | ||||
/** Parameters for the Command constructor. */ | /** Parameters for the Command constructor. */ | ||||
@@ -86,9 +89,9 @@ public class ActionManager { | |||||
private EventToActionMapper _mapper = null; | private EventToActionMapper _mapper = null; | ||||
/** | |||||
/** | |||||
* Standard ctor. | * Standard ctor. | ||||
* | |||||
* | |||||
* @param bus Event bus to post events to. | * @param bus Event bus to post events to. | ||||
* @param resources Location of resources. | * @param resources Location of resources. | ||||
*/ | */ | ||||
@@ -113,9 +116,9 @@ public class ActionManager { | |||||
} | } | ||||
} | } | ||||
/** | |||||
/** | |||||
* Create a menubar for the application based on the configuration file. | * Create a menubar for the application based on the configuration file. | ||||
* | |||||
* | |||||
* @return Menubar. | * @return Menubar. | ||||
*/ | */ | ||||
public JMenuBar createMenuBar() { | public JMenuBar createMenuBar() { | ||||
@@ -162,7 +165,7 @@ public class ActionManager { | |||||
} | } | ||||
// See if we should add a separator. | // See if we should add a separator. | ||||
if(action.isPreceededBySeparator() && | |||||
if(action.isPreceededBySeparator() && | |||||
menu.getMenuComponentCount() > 0) { | menu.getMenuComponentCount() > 0) { | ||||
menu.addSeparator(); | menu.addSeparator(); | ||||
} | } | ||||
@@ -173,10 +176,14 @@ public class ActionManager { | |||||
addNiceStuff(item, action); | addNiceStuff(item, action); | ||||
} | } | ||||
else { | else { | ||||
JCheckBoxMenuItem b = | |||||
JCheckBoxMenuItem b = | |||||
new JCheckBoxMenuItem(action.getName()); | new JCheckBoxMenuItem(action.getName()); | ||||
b.setActionCommand(action.getID()); | b.setActionCommand(action.getID()); | ||||
b.addActionListener(action); | b.addActionListener(action); | ||||
action.addPropertyChangeListener( | |||||
new PropertyWatcher(b)); | |||||
// XXX eck. This is a 1.3 feature. Fix ME! | // XXX eck. This is a 1.3 feature. Fix ME! | ||||
// Need to provide binding between action and widget. | // Need to provide binding between action and widget. | ||||
// b.setAction(action); | // b.setAction(action); | ||||
@@ -190,14 +197,14 @@ public class ActionManager { | |||||
return retval; | return retval; | ||||
} | } | ||||
/** | |||||
/** | |||||
* Create a tool bar based on the current configuration. | * Create a tool bar based on the current configuration. | ||||
* | |||||
* | |||||
* @return Toolbar ready for action. | * @return Toolbar ready for action. | ||||
*/ | */ | ||||
public JToolBar createToolBar() { | public JToolBar createToolBar() { | ||||
JToolBar retval = new JToolBar(); | JToolBar retval = new JToolBar(); | ||||
for(int i = 0; i < _actionIDs.length; i++) { | for(int i = 0; i < _actionIDs.length; i++) { | ||||
AntAction action = (AntAction) _actions.get(_actionIDs[i]); | AntAction action = (AntAction) _actions.get(_actionIDs[i]); | ||||
// If it has an icon, then we add it to the toolbar. | // If it has an icon, then we add it to the toolbar. | ||||
@@ -209,6 +216,15 @@ public class ActionManager { | |||||
JButton button = retval.add(action); | JButton button = retval.add(action); | ||||
button.setText(null); | button.setText(null); | ||||
// Watch for CHECKED changes | |||||
action.addPropertyChangeListener( | |||||
new PropertyWatcher(button)); | |||||
if(action.isToggle()) { | |||||
ButtonModel model = new CheckableButtonModel(); | |||||
button.setModel(model); | |||||
} | |||||
addNiceStuff(button, action); | addNiceStuff(button, action); | ||||
} | } | ||||
} | } | ||||
@@ -216,12 +232,12 @@ public class ActionManager { | |||||
return retval; | return retval; | ||||
} | } | ||||
/** | |||||
/** | |||||
* Create a popup menu with the given actionIDs. | * Create a popup menu with the given actionIDs. | ||||
* XXX check this for object leak. Does the button | * XXX check this for object leak. Does the button | ||||
* get added to the action as a listener? There are also some | * get added to the action as a listener? There are also some | ||||
* changes to this behavior in 1.3. | * changes to this behavior in 1.3. | ||||
* | |||||
* | |||||
* @param actionIDs List of action IDs for actions | * @param actionIDs List of action IDs for actions | ||||
* to appear in popup menu. | * to appear in popup menu. | ||||
* @return Popup menu to display. | * @return Popup menu to display. | ||||
@@ -240,9 +256,9 @@ public class ActionManager { | |||||
return retval; | return retval; | ||||
} | } | ||||
/** | |||||
/** | |||||
* Get the command assocaited with the Action with the given id. | * Get the command assocaited with the Action with the given id. | ||||
* | |||||
* | |||||
* @param actionID Id of action to get command for. | * @param actionID Id of action to get command for. | ||||
* @return Command associated with action, or null if none available. | * @return Command associated with action, or null if none available. | ||||
*/ | */ | ||||
@@ -253,7 +269,7 @@ public class ActionManager { | |||||
Class clazz = action.getCommandClass(); | Class clazz = action.getCommandClass(); | ||||
if(clazz != null) { | if(clazz != null) { | ||||
try { | try { | ||||
Constructor ctor = | |||||
Constructor ctor = | |||||
clazz.getConstructor(COMMAND_CTOR_PARAMS); | clazz.getConstructor(COMMAND_CTOR_PARAMS); | ||||
retval = (Command) ctor.newInstance( | retval = (Command) ctor.newInstance( | ||||
new Object[] { context }); | new Object[] { context }); | ||||
@@ -268,10 +284,10 @@ public class ActionManager { | |||||
} | } | ||||
/** | |||||
/** | |||||
* Add tool tip, Mnemonic, etc. | * Add tool tip, Mnemonic, etc. | ||||
* | |||||
* @param button Button to work on. | |||||
* | |||||
* @param button Button to work on. | |||||
* @param action Associated action. | * @param action Associated action. | ||||
*/ | */ | ||||
private void addNiceStuff(AbstractButton button, AntAction action) { | private void addNiceStuff(AbstractButton button, AntAction action) { | ||||
@@ -297,19 +313,19 @@ public class ActionManager { | |||||
private class Enabler implements BusMember { | private class Enabler implements BusMember { | ||||
private final Filter _filter = new Filter(); | private final Filter _filter = new Filter(); | ||||
/** | |||||
/** | |||||
* Get the filter to that is used to determine if an event should | * Get the filter to that is used to determine if an event should | ||||
* to to the member. | * to to the member. | ||||
* | |||||
* | |||||
* @return Filter to use. | * @return Filter to use. | ||||
*/ | */ | ||||
public BusFilter getBusFilter() { | public BusFilter getBusFilter() { | ||||
return _filter; | return _filter; | ||||
} | } | ||||
/** | |||||
/** | |||||
* Receives all events. | * Receives all events. | ||||
* | |||||
* | |||||
* @param event Event to post. | * @param event Event to post. | ||||
* @return true if event should be propogated, false if | * @return true if event should be propogated, false if | ||||
* it should be cancelled. | * it should be cancelled. | ||||
@@ -322,9 +338,9 @@ public class ActionManager { | |||||
/** Class providing filtering for project events. */ | /** Class providing filtering for project events. */ | ||||
private static class Filter implements BusFilter { | private static class Filter implements BusFilter { | ||||
/** | |||||
/** | |||||
* Determines if the given event should be accepted. | * Determines if the given event should be accepted. | ||||
* | |||||
* | |||||
* @param event Event to test. | * @param event Event to test. | ||||
* @return True if event should be given to BusMember, false otherwise. | * @return True if event should be given to BusMember, false otherwise. | ||||
*/ | */ | ||||
@@ -333,5 +349,31 @@ public class ActionManager { | |||||
} | } | ||||
} | } | ||||
/** Class which's hooks the action to toggle buttons. */ | |||||
private static class PropertyWatcher implements PropertyChangeListener { | |||||
private AbstractButton _target; | |||||
/** | |||||
* Standard ctor. | |||||
* | |||||
* @param target Button to update | |||||
*/ | |||||
public PropertyWatcher(AbstractButton target) { | |||||
_target = target; | |||||
} | |||||
/** | |||||
* Change the Selected stated of the button if the CHECKED | |||||
* property is set on the <code>action</code> | |||||
* | |||||
* @param event Event to test. | |||||
*/ | |||||
public void propertyChange(PropertyChangeEvent e) { | |||||
String propertyName = e.getPropertyName(); | |||||
if (propertyName.equals(AccessibleState.CHECKED.toString())) { | |||||
Boolean newValue = (Boolean) e.getNewValue(); | |||||
_target.setSelected(newValue.booleanValue()); | |||||
} | |||||
} | |||||
} | |||||
} | } |
@@ -54,18 +54,20 @@ | |||||
package org.apache.tools.ant.gui.core; | package org.apache.tools.ant.gui.core; | ||||
import javax.swing.*; | import javax.swing.*; | ||||
import javax.accessibility.*; | |||||
import java.net.URL; | import java.net.URL; | ||||
import java.awt.event.ActionEvent; | import java.awt.event.ActionEvent; | ||||
import java.awt.event.ActionListener; | import java.awt.event.ActionListener; | ||||
import java.beans.*; | |||||
import java.util.*; | import java.util.*; | ||||
import org.apache.tools.ant.gui.event.EventBus; | import org.apache.tools.ant.gui.event.EventBus; | ||||
/** | /** | ||||
* Class representing an action in the Antidote application. | |||||
* | |||||
* @version $Revision$ | |||||
* @author Simeon Fitch | |||||
* Class representing an action in the Antidote application. | |||||
* | |||||
* @version $Revision$ | |||||
* @author Simeon Fitch | |||||
*/ | */ | ||||
public class AntAction extends AbstractAction { | public class AntAction extends AbstractAction { | ||||
/** Property name for the parent menu item. */ | /** Property name for the parent menu item. */ | ||||
@@ -76,6 +78,8 @@ public class AntAction extends AbstractAction { | |||||
public static final String ENABLE_ON = "enableOn"; | public static final String ENABLE_ON = "enableOn"; | ||||
public static final String DISABLE_ON = "disableOn"; | public static final String DISABLE_ON = "disableOn"; | ||||
public static final String TOGGLE = "toggle"; | public static final String TOGGLE = "toggle"; | ||||
public static final String CHECKED_TRUE_ON = "checkedTrueOn"; | |||||
public static final String CHECKED_FALSE_ON = "checkedFalseOn"; | |||||
public static final String COMMAND = "command"; | public static final String COMMAND = "command"; | ||||
/** Property resources. */ | /** Property resources. */ | ||||
@@ -85,22 +89,28 @@ public class AntAction extends AbstractAction { | |||||
/** Unique id. */ | /** Unique id. */ | ||||
private String _id = null; | private String _id = null; | ||||
/** Events that the action should cause transition to the | |||||
/** Events that the action should cause transition to the | |||||
* enabled(true) state. */ | * enabled(true) state. */ | ||||
private Class[] _enableOn = null; | private Class[] _enableOn = null; | ||||
/** Events that the action should cause transition to the | |||||
/** Events that the action should cause transition to the | |||||
* enabled(false) state. */ | * enabled(false) state. */ | ||||
private Class[] _disableOn = null; | private Class[] _disableOn = null; | ||||
/** Events that the action should cause transition to the | |||||
* checked state. */ | |||||
private Class[] _checkedTrueOn = null; | |||||
/** Events that the action should cause transition to the | |||||
* not checked state. */ | |||||
private Class[] _checkedFalseOn = null; | |||||
/** Flag indicating toggle action. */ | /** Flag indicating toggle action. */ | ||||
private boolean _toggle = false; | private boolean _toggle = false; | ||||
/** | |||||
/** | |||||
* Standard ctor. | * Standard ctor. | ||||
* | |||||
* | |||||
* @param id Unique id for the action | * @param id Unique id for the action | ||||
*/ | */ | ||||
public AntAction(ResourceManager resources, EventBus bus, String id) { | public AntAction(ResourceManager resources, EventBus bus, String id) { | ||||
_resources = resources; | _resources = resources; | ||||
_bus = bus; | _bus = bus; | ||||
_id = id; | _id = id; | ||||
@@ -149,13 +159,14 @@ public class AntAction extends AbstractAction { | |||||
_enableOn = resolveClasses(getString(ENABLE_ON)); | _enableOn = resolveClasses(getString(ENABLE_ON)); | ||||
_disableOn = resolveClasses(getString(DISABLE_ON)); | _disableOn = resolveClasses(getString(DISABLE_ON)); | ||||
_checkedTrueOn = resolveClasses(getString(CHECKED_TRUE_ON)); | |||||
_checkedFalseOn = resolveClasses(getString(CHECKED_FALSE_ON)); | |||||
} | } | ||||
/** | |||||
/** | |||||
* Convenience method for looking put a resource with the name | * Convenience method for looking put a resource with the name | ||||
* "id.key". Will return null if the resource doesn't exist. | * "id.key". Will return null if the resource doesn't exist. | ||||
* | |||||
* | |||||
* @param key Key name for the action. | * @param key Key name for the action. | ||||
* @return String resource for composite key, or null if not found. | * @return String resource for composite key, or null if not found. | ||||
*/ | */ | ||||
@@ -166,16 +177,16 @@ public class AntAction extends AbstractAction { | |||||
} | } | ||||
catch(MissingResourceException ex) { | catch(MissingResourceException ex) { | ||||
// Its ok to be missing a resource name... | // Its ok to be missing a resource name... | ||||
// Too bad the API throws an exception in this case. | |||||
// Too bad the API throws an exception in this case. | |||||
} | } | ||||
return retval; | return retval; | ||||
} | } | ||||
/** | |||||
/** | |||||
* Parse out the list of classes from the given string and | * Parse out the list of classes from the given string and | ||||
* resolve them into classes. | * resolve them into classes. | ||||
* | |||||
* | |||||
* @param classNames Comma delimited list of class names. | * @param classNames Comma delimited list of class names. | ||||
*/ | */ | ||||
private Class[] resolveClasses(String classNames) { | private Class[] resolveClasses(String classNames) { | ||||
@@ -191,7 +202,7 @@ public class AntAction extends AbstractAction { | |||||
catch(ClassNotFoundException ex) { | catch(ClassNotFoundException ex) { | ||||
//XXX log me. | //XXX log me. | ||||
System.err.println( | System.err.println( | ||||
"Warning: the event class " + name + | |||||
"Warning: the event class " + name + | |||||
" was not found. Please check config file."); | " was not found. Please check config file."); | ||||
} | } | ||||
} | } | ||||
@@ -201,46 +212,46 @@ public class AntAction extends AbstractAction { | |||||
return retval; | return retval; | ||||
} | } | ||||
/** | |||||
/** | |||||
* Unique id for the action. | * Unique id for the action. | ||||
* | |||||
* | |||||
* @return Action id. | * @return Action id. | ||||
*/ | */ | ||||
public String getID() { | public String getID() { | ||||
return _id; | return _id; | ||||
} | } | ||||
/** | |||||
/** | |||||
* Get the name of the menu in the menu bar that this action shoul | * Get the name of the menu in the menu bar that this action shoul | ||||
* appear under. | * appear under. | ||||
* | |||||
* | |||||
* @return Menu to appear under, or null if not a menu action. | * @return Menu to appear under, or null if not a menu action. | ||||
*/ | */ | ||||
public String getParentMenuName() { | public String getParentMenuName() { | ||||
return (String) getValue(PARENT_MENU_NAME); | return (String) getValue(PARENT_MENU_NAME); | ||||
} | } | ||||
/** | |||||
/** | |||||
* Get the localized name for the action. | * Get the localized name for the action. | ||||
* | |||||
* | |||||
* @return Name | * @return Name | ||||
*/ | */ | ||||
public String getName() { | public String getName() { | ||||
return (String) getValue(NAME); | return (String) getValue(NAME); | ||||
} | } | ||||
/** | |||||
/** | |||||
* Get the short description. Used in tool tips. | * Get the short description. Used in tool tips. | ||||
* | |||||
* | |||||
* @return Short description. | * @return Short description. | ||||
*/ | */ | ||||
public String getShortDescription() { | public String getShortDescription() { | ||||
return (String) getValue(SHORT_DESCRIPTION); | return (String) getValue(SHORT_DESCRIPTION); | ||||
} | } | ||||
/** | |||||
/** | |||||
* Determine if a separator should appear before the action. | * Determine if a separator should appear before the action. | ||||
* | |||||
* | |||||
* @return True if add separator, false otherwise. | * @return True if add separator, false otherwise. | ||||
*/ | */ | ||||
public boolean isPreceededBySeparator() { | public boolean isPreceededBySeparator() { | ||||
@@ -248,18 +259,18 @@ public class AntAction extends AbstractAction { | |||||
String.valueOf(getValue(SEPARATOR))).booleanValue(); | String.valueOf(getValue(SEPARATOR))).booleanValue(); | ||||
} | } | ||||
/** | |||||
/** | |||||
* Get the icon. | * Get the icon. | ||||
* | |||||
* | |||||
* @return Icon for action, or null if none. | * @return Icon for action, or null if none. | ||||
*/ | */ | ||||
public Icon getIcon() { | public Icon getIcon() { | ||||
return (Icon) getValue(SMALL_ICON); | return (Icon) getValue(SMALL_ICON); | ||||
} | } | ||||
/** | |||||
/** | |||||
* Get the accelerator keystroke. | * Get the accelerator keystroke. | ||||
* | |||||
* | |||||
* @return Accelerator | * @return Accelerator | ||||
*/ | */ | ||||
public KeyStroke getAccelerator() { | public KeyStroke getAccelerator() { | ||||
@@ -267,27 +278,43 @@ public class AntAction extends AbstractAction { | |||||
} | } | ||||
/** | |||||
/** | |||||
* Get the event types which should cause this to go to the | * Get the event types which should cause this to go to the | ||||
* enabled state. | * enabled state. | ||||
* | |||||
* | |||||
*/ | */ | ||||
public Class[] getEnableOnEvents() { | public Class[] getEnableOnEvents() { | ||||
return _enableOn; | return _enableOn; | ||||
} | } | ||||
/** | |||||
* Get the event types which should cause this to go to | |||||
/** | |||||
* Get the event types which should cause this to go to | |||||
* this disabled state. | * this disabled state. | ||||
* | |||||
* | |||||
*/ | */ | ||||
public Class[] getDisableOnEvents() { | public Class[] getDisableOnEvents() { | ||||
return _disableOn; | return _disableOn; | ||||
} | } | ||||
/** | |||||
/** | |||||
* Get the event types which should cause this to go to the | |||||
* checked state. | |||||
*/ | |||||
public Class[] getCheckedTrueOnEvents() { | |||||
return _checkedTrueOn; | |||||
} | |||||
/** | |||||
* Get the event types which should cause this to go to the | |||||
* not checked state. | |||||
*/ | |||||
public Class[] getCheckedFalseOnEvents() { | |||||
return _checkedFalseOn; | |||||
} | |||||
/** | |||||
* True if this is a toggle action, false otherwise. | * True if this is a toggle action, false otherwise. | ||||
* | |||||
* | |||||
* @return True if this is a toggle action, false otherwise. | * @return True if this is a toggle action, false otherwise. | ||||
*/ | */ | ||||
public boolean isToggle() { | public boolean isToggle() { | ||||
@@ -295,18 +322,18 @@ public class AntAction extends AbstractAction { | |||||
} | } | ||||
/** | |||||
/** | |||||
* Get the assciated command class. | * Get the assciated command class. | ||||
* | |||||
* | |||||
* @return Command class. | * @return Command class. | ||||
*/ | */ | ||||
public Class getCommandClass() { | public Class getCommandClass() { | ||||
return (Class) getValue(COMMAND); | return (Class) getValue(COMMAND); | ||||
} | } | ||||
/** | |||||
/** | |||||
* Pass the action on to the EventBus. | * Pass the action on to the EventBus. | ||||
* | |||||
* | |||||
* @param e Event to forward. | * @param e Event to forward. | ||||
*/ | */ | ||||
public void actionPerformed(ActionEvent e) { | public void actionPerformed(ActionEvent e) { | ||||
@@ -52,14 +52,16 @@ | |||||
* <http://www.apache.org/>. | * <http://www.apache.org/>. | ||||
*/ | */ | ||||
package org.apache.tools.ant.gui.core; | package org.apache.tools.ant.gui.core; | ||||
import java.util.*; | import java.util.*; | ||||
import javax.accessibility.AccessibleState; | |||||
/** | /** | ||||
* The purpose of this class is to manage the | |||||
* The purpose of this class is to manage the | |||||
* mappings between event type and action enabled state. | * mappings between event type and action enabled state. | ||||
* | |||||
* @version $Revision$ | |||||
* @author Simeon Fitch | |||||
* | |||||
* @version $Revision$ | |||||
* @author Simeon Fitch | |||||
*/ | */ | ||||
class EventToActionMapper { | class EventToActionMapper { | ||||
@@ -69,29 +71,37 @@ class EventToActionMapper { | |||||
/** Lookup for enable(false) events. Key is event type, value is | /** Lookup for enable(false) events. Key is event type, value is | ||||
* a list of actions that are changed by the event. */ | * a list of actions that are changed by the event. */ | ||||
private Map _disableOn = new HashMap(); | private Map _disableOn = new HashMap(); | ||||
/** Lookup for CHECK(true) events. Key is event type, value is | |||||
* a list of actions that are changed by the event. */ | |||||
private Map _checkedTrueOn = new HashMap(); | |||||
/** Lookup for CHECK(false) events. Key is event type, value is | |||||
* a list of actions that are changed by the event. */ | |||||
private Map _checkedFalseOn = new HashMap(); | |||||
/** | |||||
/** | |||||
* Defaul ctor. | * Defaul ctor. | ||||
* | |||||
* | |||||
*/ | */ | ||||
public EventToActionMapper() { | public EventToActionMapper() { | ||||
} | } | ||||
/** | |||||
/** | |||||
* Add an action. | * Add an action. | ||||
* | |||||
* | |||||
* @param action Action to add. | * @param action Action to add. | ||||
*/ | */ | ||||
public void addAction(AntAction action) { | public void addAction(AntAction action) { | ||||
putAction(action, action.getEnableOnEvents(), _enableOn); | putAction(action, action.getEnableOnEvents(), _enableOn); | ||||
putAction(action, action.getDisableOnEvents(), _disableOn); | putAction(action, action.getDisableOnEvents(), _disableOn); | ||||
putAction(action, action.getCheckedTrueOnEvents(), _checkedTrueOn); | |||||
putAction(action, action.getCheckedFalseOnEvents(), _checkedFalseOn); | |||||
} | } | ||||
/** | |||||
/** | |||||
* For the given action store it in the event type mapping | * For the given action store it in the event type mapping | ||||
* for each of the given types. | * for each of the given types. | ||||
* | |||||
* | |||||
* @param action Action to store. | * @param action Action to store. | ||||
* @param clazzes Array of types to store it under. | * @param clazzes Array of types to store it under. | ||||
* @param storage The place to store the association. | * @param storage The place to store the association. | ||||
@@ -109,11 +119,11 @@ class EventToActionMapper { | |||||
values.add(action); | values.add(action); | ||||
} | } | ||||
} | } | ||||
/** | |||||
* For the given event change the state of any actions that | |||||
/** | |||||
* For the given event change the state of any actions that | |||||
* have been registered as needing a transition as a result of | * have been registered as needing a transition as a result of | ||||
* the event. | * the event. | ||||
* | |||||
* | |||||
* @param event The event to apply. | * @param event The event to apply. | ||||
*/ | */ | ||||
public void applyEvent(EventObject event) { | public void applyEvent(EventObject event) { | ||||
@@ -126,11 +136,17 @@ class EventToActionMapper { | |||||
vals = (List) _disableOn.get(event.getClass()); | vals = (List) _disableOn.get(event.getClass()); | ||||
changeState(vals, false); | changeState(vals, false); | ||||
vals = (List) _checkedTrueOn.get(event.getClass()); | |||||
changeChecked(vals, true); | |||||
vals = (List) _checkedFalseOn.get(event.getClass()); | |||||
changeChecked(vals, false); | |||||
} | } | ||||
/** | |||||
/** | |||||
* Set the enabled state of the given actions. | * Set the enabled state of the given actions. | ||||
* | |||||
* | |||||
* @param actions List of AntActions to set state for. | * @param actions List of AntActions to set state for. | ||||
* @param state The state to set them to. | * @param state The state to set them to. | ||||
*/ | */ | ||||
@@ -142,4 +158,20 @@ class EventToActionMapper { | |||||
action.setEnabled(state); | action.setEnabled(state); | ||||
} | } | ||||
} | } | ||||
/** | |||||
* Set the CHECKED property of the given actions. | |||||
* | |||||
* @param actions List of AntActions to set checked properties for. | |||||
* @param checked The checked value to set them to. | |||||
*/ | |||||
private void changeChecked(List actions, boolean checked) { | |||||
if(actions == null) return; | |||||
for(int i = 0, len = actions.size(); i < len; i++) { | |||||
AntAction action = (AntAction) actions.get(i); | |||||
action.putValue(AccessibleState.CHECKED.toString(), | |||||
new Boolean(checked)); | |||||
} | |||||
} | |||||
} | } |
@@ -0,0 +1,73 @@ | |||||
/* | |||||
* The Apache Software License, Version 1.1 | |||||
* | |||||
* Copyright (c) 1999, 2000 The Apache Software Foundation. All rights | |||||
* reserved. | |||||
* | |||||
* Redistribution and use in source and binary forms, with or without | |||||
* modification, are permitted provided that the following conditions | |||||
* are met: | |||||
* | |||||
* 1. Redistributions of source code must retain the above copyright | |||||
* notice, this list of conditions and the following disclaimer. | |||||
* | |||||
* 2. Redistributions in binary form must reproduce the above copyright | |||||
* notice, this list of conditions and the following disclaimer in | |||||
* the documentation and/or other materials provided with the | |||||
* distribution. | |||||
* | |||||
* 3. The end-user documentation included with the redistribution, if | |||||
* any, must include the following acknowlegement: | |||||
* "This product includes software developed by the | |||||
* Apache Software Foundation (http://www.apache.org/)." | |||||
* Alternately, this acknowlegement may appear in the software itself, | |||||
* if and wherever such third-party acknowlegements normally appear. | |||||
* | |||||
* 4. The names "The Jakarta Project", "Ant", and "Apache Software | |||||
* Foundation" must not be used to endorse or promote products derived | |||||
* from this software without prior written permission. For written | |||||
* permission, please contact 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 | |||||
* <http://www.apache.org/>. | |||||
*/ | |||||
package org.apache.tools.ant.gui.event; | |||||
import org.apache.tools.ant.gui.core.*; | |||||
/** | |||||
* Event fired when the console pane is not visible | |||||
* | |||||
* @version $Revision$ | |||||
* @author Nick Davis<a href="mailto:nick_home_account@yahoo.com">nick_home_account@yahoo.com</a> | |||||
*/ | |||||
public class ConsoleNotVisibleEvent extends AntEvent { | |||||
/** | |||||
* Standard ctor. | |||||
* | |||||
* @param context application context. | |||||
*/ | |||||
public ConsoleNotVisibleEvent(AppContext context) { | |||||
super(context); | |||||
} | |||||
} |
@@ -0,0 +1,73 @@ | |||||
/* | |||||
* The Apache Software License, Version 1.1 | |||||
* | |||||
* Copyright (c) 1999, 2000 The Apache Software Foundation. All rights | |||||
* reserved. | |||||
* | |||||
* Redistribution and use in source and binary forms, with or without | |||||
* modification, are permitted provided that the following conditions | |||||
* are met: | |||||
* | |||||
* 1. Redistributions of source code must retain the above copyright | |||||
* notice, this list of conditions and the following disclaimer. | |||||
* | |||||
* 2. Redistributions in binary form must reproduce the above copyright | |||||
* notice, this list of conditions and the following disclaimer in | |||||
* the documentation and/or other materials provided with the | |||||
* distribution. | |||||
* | |||||
* 3. The end-user documentation included with the redistribution, if | |||||
* any, must include the following acknowlegement: | |||||
* "This product includes software developed by the | |||||
* Apache Software Foundation (http://www.apache.org/)." | |||||
* Alternately, this acknowlegement may appear in the software itself, | |||||
* if and wherever such third-party acknowlegements normally appear. | |||||
* | |||||
* 4. The names "The Jakarta Project", "Ant", and "Apache Software | |||||
* Foundation" must not be used to endorse or promote products derived | |||||
* from this software without prior written permission. For written | |||||
* permission, please contact 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 | |||||
* <http://www.apache.org/>. | |||||
*/ | |||||
package org.apache.tools.ant.gui.event; | |||||
import org.apache.tools.ant.gui.core.*; | |||||
/** | |||||
* Event fired when the console pane is visible | |||||
* | |||||
* @version $Revision$ | |||||
* @author Nick Davis<a href="mailto:nick_home_account@yahoo.com">nick_home_account@yahoo.com</a> | |||||
*/ | |||||
public class ConsoleVisibleEvent extends AntEvent { | |||||
/** | |||||
* Standard ctor. | |||||
* | |||||
* @param context application context. | |||||
*/ | |||||
public ConsoleVisibleEvent(AppContext context) { | |||||
super(context); | |||||
} | |||||
} |
@@ -0,0 +1,84 @@ | |||||
/* | |||||
* The Apache Software License, Version 1.1 | |||||
* | |||||
* Copyright (c) 1999, 2000 The Apache Software Foundation. All rights | |||||
* reserved. | |||||
* | |||||
* Redistribution and use in source and binary forms, with or without | |||||
* modification, are permitted provided that the following conditions | |||||
* are met: | |||||
* | |||||
* 1. Redistributions of source code must retain the above copyright | |||||
* notice, this list of conditions and the following disclaimer. | |||||
* | |||||
* 2. Redistributions in binary form must reproduce the above copyright | |||||
* notice, this list of conditions and the following disclaimer in | |||||
* the documentation and/or other materials provided with the | |||||
* distribution. | |||||
* | |||||
* 3. The end-user documentation included with the redistribution, if | |||||
* any, must include the following acknowlegement: | |||||
* "This product includes software developed by the | |||||
* Apache Software Foundation (http://www.apache.org/)." | |||||
* Alternately, this acknowlegement may appear in the software itself, | |||||
* if and wherever such third-party acknowlegements normally appear. | |||||
* | |||||
* 4. The names "The Jakarta Project", "Ant", and "Apache Software | |||||
* Foundation" must not be used to endorse or promote products derived | |||||
* from this software without prior written permission. For written | |||||
* permission, please contact 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 | |||||
* <http://www.apache.org/>. | |||||
*/ | |||||
package org.apache.tools.ant.gui.event; | |||||
import org.apache.tools.ant.gui.core.*; | |||||
import org.apache.tools.ant.gui.command.*; | |||||
/** | |||||
* Request to show the console pane | |||||
* | |||||
* @version $Revision$ | |||||
* @author Nick Davis<a href="mailto:nick_home_account@yahoo.com">nick_home_account@yahoo.com</a> | |||||
*/ | |||||
public class ShowConsoleEvent extends AntEvent { | |||||
/** | |||||
* Standard ctor. | |||||
* | |||||
* @param context application context. | |||||
*/ | |||||
public ShowConsoleEvent(AppContext context) { | |||||
super(context); | |||||
} | |||||
/** | |||||
* Create the appropriate response command to this event, which is to | |||||
* show the console pane. | |||||
* | |||||
* @return ShowOrHideConsoleCmd command. | |||||
*/ | |||||
public Command createDefaultCmd() { | |||||
return new ShowOrHideConsoleCmd(getContext(), true); | |||||
} | |||||
} |
@@ -63,14 +63,16 @@ import java.awt.BorderLayout; | |||||
import java.awt.FlowLayout; | import java.awt.FlowLayout; | ||||
import java.awt.Dimension; | import java.awt.Dimension; | ||||
import java.awt.Color; | import java.awt.Color; | ||||
import java.awt.event.ComponentAdapter; | |||||
import java.awt.event.ComponentEvent; | |||||
import java.util.EventObject; | import java.util.EventObject; | ||||
import java.util.Date; | import java.util.Date; | ||||
/** | /** | ||||
* Logging console display. | * Logging console display. | ||||
* | |||||
* @version $Revision$ | |||||
* @author Simeon Fitch | |||||
* | |||||
* @version $Revision$ | |||||
* @author Simeon Fitch | |||||
*/ | */ | ||||
public class BuildConsole extends AntModule { | public class BuildConsole extends AntModule { | ||||
/** Area where messages are printed. */ | /** Area where messages are printed. */ | ||||
@@ -81,17 +83,17 @@ public class BuildConsole extends AntModule { | |||||
private ConsoleStyleContext _styles = null; | private ConsoleStyleContext _styles = null; | ||||
/** ClearLog Button. */ | /** ClearLog Button. */ | ||||
private JButton _clearLog = null; | private JButton _clearLog = null; | ||||
/** | |||||
/** | |||||
* Default ctor. | * Default ctor. | ||||
*/ | */ | ||||
public BuildConsole() { | public BuildConsole() { | ||||
} | } | ||||
/** | |||||
/** | |||||
* Using the given AppContext, initialize the display. | * Using the given AppContext, initialize the display. | ||||
* | |||||
* | |||||
* @param context Application context. | * @param context Application context. | ||||
*/ | */ | ||||
public void contextualize(AppContext context) { | public void contextualize(AppContext context) { | ||||
@@ -114,7 +116,7 @@ public class BuildConsole extends AntModule { | |||||
_logLevel = new JComboBox(LogLevelEnum.getValues()); | _logLevel = new JComboBox(LogLevelEnum.getValues()); | ||||
_logLevel.setSelectedItem(LogLevelEnum.INFO); | _logLevel.setSelectedItem(LogLevelEnum.INFO); | ||||
controls.add(_logLevel); | controls.add(_logLevel); | ||||
// Padding. | // Padding. | ||||
controls.add(Box.createHorizontalStrut(10)); | controls.add(Box.createHorizontalStrut(10)); | ||||
_clearLog = new JButton( | _clearLog = new JButton( | ||||
@@ -125,12 +127,30 @@ public class BuildConsole extends AntModule { | |||||
add(BorderLayout.NORTH, controls); | add(BorderLayout.NORTH, controls); | ||||
/** Anonymous class to respond to resize envents and | |||||
* post <code>ConsoleNotVisibleEvent</code> or | |||||
* <code>ConsoleVisibleEvent</code> events. | |||||
*/ | |||||
addComponentListener(new ComponentAdapter() { | |||||
public void componentResized(ComponentEvent e) { | |||||
AppContext c = BuildConsole.this.getContext(); | |||||
if (BuildConsole.this.getHeight() == 0) { | |||||
c.getEventBus().postEvent(new ConsoleNotVisibleEvent(c)); | |||||
} else { | |||||
c.getEventBus().postEvent(new ConsoleVisibleEvent(c)); | |||||
} | |||||
} | |||||
public void componentHidden(ComponentEvent e) {} | |||||
public void componentMoved(ComponentEvent e) {} | |||||
public void componentShown(ComponentEvent e) {} | |||||
}); | |||||
} | } | ||||
/** | |||||
/** | |||||
* Clear the contents of the console. | * Clear the contents of the console. | ||||
* | |||||
* | |||||
*/ | */ | ||||
private void clearDisplay() { | private void clearDisplay() { | ||||
Document doc = _text.getDocument(); | Document doc = _text.getDocument(); | ||||
@@ -146,19 +166,19 @@ public class BuildConsole extends AntModule { | |||||
private class Handler implements BusMember { | private class Handler implements BusMember { | ||||
private final Filter _filter = new Filter(); | private final Filter _filter = new Filter(); | ||||
/** | |||||
/** | |||||
* Get the filter to that is used to determine if an event should | * Get the filter to that is used to determine if an event should | ||||
* to to the member. | * to to the member. | ||||
* | |||||
* | |||||
* @return Filter to use. | * @return Filter to use. | ||||
*/ | */ | ||||
public BusFilter getBusFilter() { | public BusFilter getBusFilter() { | ||||
return _filter; | return _filter; | ||||
} | } | ||||
/** | |||||
/** | |||||
* Called when an event is to be posed to the member. | * Called when an event is to be posed to the member. | ||||
* | |||||
* | |||||
* @param event Event to post. | * @param event Event to post. | ||||
* @return true if event should be propogated, false if | * @return true if event should be propogated, false if | ||||
* it should be cancelled. | * it should be cancelled. | ||||
@@ -176,7 +196,7 @@ public class BuildConsole extends AntModule { | |||||
case BuildEventType.BUILD_STARTED_VAL: | case BuildEventType.BUILD_STARTED_VAL: | ||||
case BuildEventType.BUILD_FINISHED_VAL: | case BuildEventType.BUILD_FINISHED_VAL: | ||||
text = buildEvent.getType().toString() + | |||||
text = buildEvent.getType().toString() + | |||||
" (" + new Date().toString() + ")"; | " (" + new Date().toString() + ")"; | ||||
style = _styles.getHeadingStyle(); | style = _styles.getHeadingStyle(); | ||||
break; | break; | ||||
@@ -191,7 +211,7 @@ public class BuildConsole extends AntModule { | |||||
case BuildEventType.MESSAGE_LOGGED_VAL: | case BuildEventType.MESSAGE_LOGGED_VAL: | ||||
// Filter out events that are below our | // Filter out events that are below our | ||||
// selected filterint level. | // selected filterint level. | ||||
LogLevelEnum level = | |||||
LogLevelEnum level = | |||||
(LogLevelEnum) _logLevel.getSelectedItem(); | (LogLevelEnum) _logLevel.getSelectedItem(); | ||||
int priority = buildEvent.getEvent().getPriority(); | int priority = buildEvent.getEvent().getPriority(); | ||||
if(priority <= level.getValue()) { | if(priority <= level.getValue()) { | ||||
@@ -226,9 +246,9 @@ public class BuildConsole extends AntModule { | |||||
/** Class providing filtering for project events. */ | /** Class providing filtering for project events. */ | ||||
private static class Filter implements BusFilter { | private static class Filter implements BusFilter { | ||||
/** | |||||
/** | |||||
* Determines if the given event should be accepted. | * Determines if the given event should be accepted. | ||||
* | |||||
* | |||||
* @param event Event to test. | * @param event Event to test. | ||||
* @return True if event should be given to BusMember, false otherwise. | * @return True if event should be given to BusMember, false otherwise. | ||||
*/ | */ | ||||
@@ -255,9 +275,9 @@ public class BuildConsole extends AntModule { | |||||
Color.blue | Color.blue | ||||
}; | }; | ||||
/** | |||||
/** | |||||
* Default ctor. | * Default ctor. | ||||
* | |||||
* | |||||
*/ | */ | ||||
public ConsoleStyleContext() { | public ConsoleStyleContext() { | ||||
Style defaultStyle = getStyle(DEFAULT_STYLE); | Style defaultStyle = getStyle(DEFAULT_STYLE); | ||||
@@ -283,9 +303,9 @@ public class BuildConsole extends AntModule { | |||||
StyleConstants.setUnderline(subheading, false); | StyleConstants.setUnderline(subheading, false); | ||||
} | } | ||||
/** | |||||
/** | |||||
* Get the style to use for the given logging level. | * Get the style to use for the given logging level. | ||||
* | |||||
* | |||||
* @param level Logging level. | * @param level Logging level. | ||||
* @return Style to use for display. | * @return Style to use for display. | ||||
*/ | */ | ||||
@@ -294,36 +314,36 @@ public class BuildConsole extends AntModule { | |||||
return retval == null ? getDefaultStyle() : retval; | return retval == null ? getDefaultStyle() : retval; | ||||
} | } | ||||
/** | |||||
/** | |||||
* Get the default style. | * Get the default style. | ||||
* | |||||
* | |||||
* @return Default style. | * @return Default style. | ||||
*/ | */ | ||||
Style getDefaultStyle() { | Style getDefaultStyle() { | ||||
return getStyle(DEFAULT_STYLE); | return getStyle(DEFAULT_STYLE); | ||||
} | } | ||||
/** | |||||
/** | |||||
* Get the style to use for headings. | * Get the style to use for headings. | ||||
* | |||||
* | |||||
* @return Heading style. | * @return Heading style. | ||||
*/ | */ | ||||
Style getHeadingStyle() { | Style getHeadingStyle() { | ||||
return getStyle(HEADING_STYLE); | return getStyle(HEADING_STYLE); | ||||
} | } | ||||
/** | |||||
/** | |||||
* Get the style to use for subheadings. | * Get the style to use for subheadings. | ||||
* | |||||
* | |||||
* @return Subheading style. | * @return Subheading style. | ||||
*/ | */ | ||||
Style getSubheadingStyle() { | Style getSubheadingStyle() { | ||||
return getStyle(SUBHEADING_STYLE); | return getStyle(SUBHEADING_STYLE); | ||||
} | } | ||||
/** | |||||
/** | |||||
* Get a StyledDocument initialized with this. | * Get a StyledDocument initialized with this. | ||||
* | |||||
* | |||||
* @return SytledDocument. | * @return SytledDocument. | ||||
*/ | */ | ||||
StyledDocument getStyledDocument() { | StyledDocument getStyledDocument() { | ||||
@@ -1,11 +1,11 @@ | |||||
# Define the primary menubar items. | # Define the primary menubar items. | ||||
menus=File, Build, Projects, Help | |||||
menus=File, View, Build, Projects, Help | |||||
# Declare the list of known actions. | # Declare the list of known actions. | ||||
actions=\ | actions=\ | ||||
new, open, save, saveas, close, exit, about, \ | new, open, save, saveas, close, exit, about, \ | ||||
newTarget, newTask, newProperty \ | newTarget, newTask, newProperty \ | ||||
startBuild, stopBuild | |||||
startBuild, stopBuild, viewConsole | |||||
# Configure the decalred actions. | # Configure the decalred actions. | ||||
new.name=New Project... | new.name=New Project... | ||||
@@ -149,3 +149,18 @@ newProperty.disableOn=\ | |||||
org.apache.tools.ant.gui.event.PropertySelectionEvent, \ | org.apache.tools.ant.gui.event.PropertySelectionEvent, \ | ||||
org.apache.tools.ant.gui.event.ProjectClosedEvent, \ | org.apache.tools.ant.gui.event.ProjectClosedEvent, \ | ||||
org.apache.tools.ant.gui.event.NullSelectionEvent | org.apache.tools.ant.gui.event.NullSelectionEvent | ||||
viewConsole.name=console | |||||
viewConsole.shortDescription=Displays or hides the console pane | |||||
viewConsole.parentMenuName=View | |||||
viewConsole.icon=console.gif | |||||
viewConsole.separator=true | |||||
viewConsole.accelerator=control C | |||||
viewConsole.enabled=true | |||||
viewConsole.toggle=true | |||||
viewConsole.initalToggleValue=true | |||||
viewConsole.command=org.apache.tools.ant.gui.command.ShowOrHideConsoleCmd | |||||
viewConsole.checkedTrueOn=\ | |||||
org.apache.tools.ant.gui.event.ConsoleVisibleEvent | |||||
viewConsole.checkedFalseOn=\ | |||||
org.apache.tools.ant.gui.event.ConsoleNotVisibleEvent |
@@ -0,0 +1,144 @@ | |||||
/* | |||||
* The Apache Software License, Version 1.1 | |||||
* | |||||
* Copyright (c) 1999, 2000 The Apache Software Foundation. All rights | |||||
* reserved. | |||||
* | |||||
* Redistribution and use in source and binary forms, with or without | |||||
* modification, are permitted provided that the following conditions | |||||
* are met: | |||||
* | |||||
* 1. Redistributions of source code must retain the above copyright | |||||
* notice, this list of conditions and the following disclaimer. | |||||
* | |||||
* 2. Redistributions in binary form must reproduce the above copyright | |||||
* notice, this list of conditions and the following disclaimer in | |||||
* the documentation and/or other materials provided with the | |||||
* distribution. | |||||
* | |||||
* 3. The end-user documentation included with the redistribution, if | |||||
* any, must include the following acknowlegement: | |||||
* "This product includes software developed by the | |||||
* Apache Software Foundation (http://www.apache.org/)." | |||||
* Alternately, this acknowlegement may appear in the software itself, | |||||
* if and wherever such third-party acknowlegements normally appear. | |||||
* | |||||
* 4. The names "The Jakarta Project", "Ant", and "Apache Software | |||||
* Foundation" must not be used to endorse or promote products derived | |||||
* from this software without prior written permission. For written | |||||
* permission, please contact 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 | |||||
* <http://www.apache.org/>. | |||||
*/ | |||||
package org.apache.tools.ant.gui.util; | |||||
import java.awt.event.ActionEvent; | |||||
import javax.swing.DefaultButtonModel; | |||||
/** | |||||
* Provides a button which appears "pressed" when it is in | |||||
* a selected state. | |||||
* <p> | |||||
* Call <code>setSelected</code> to select the button. When the | |||||
* button is selected, both the PRESSED and ARMED properties are | |||||
* set which gives the button a pressed appearance. | |||||
* | |||||
* @version $Revision$ | |||||
* @author Nick Davis<a href="mailto:nick_home_account@yahoo.com">nick_home_account@yahoo.com</a> | |||||
*/ | |||||
public class CheckableButtonModel extends DefaultButtonModel { | |||||
boolean _pressed = false; | |||||
boolean _armed = false; | |||||
/** | |||||
* Constructs a CheckableButtonModel | |||||
* | |||||
*/ | |||||
public CheckableButtonModel() { | |||||
} | |||||
/** | |||||
* Sets the button to pressed or unpressed. | |||||
* | |||||
* @param b true to set the button to "pressed" | |||||
* @see #isPressed | |||||
*/ | |||||
public void setPressed(boolean b) { | |||||
if((_pressed == b) || !isEnabled()) { | |||||
return; | |||||
} | |||||
_pressed = b; | |||||
if(!_pressed && _armed) { | |||||
fireActionPerformed( | |||||
new ActionEvent(this, ActionEvent.ACTION_PERFORMED, | |||||
getActionCommand()) | |||||
); | |||||
} | |||||
fireStateChanged(); | |||||
stateMask |= PRESSED; | |||||
} | |||||
/** | |||||
* Marks the button as "armed". If the mouse button is | |||||
* released while it is over this item, the button's action event | |||||
* fires. If the mouse button is released elsewhere, the | |||||
* event does not fire and the button is disarmed. | |||||
* | |||||
* @param b true to arm the button so it can be selected | |||||
*/ | |||||
public void setArmed(boolean b) { | |||||
if((_armed == b) || !isEnabled()) { | |||||
return; | |||||
} | |||||
_armed = b; | |||||
fireStateChanged(); | |||||
stateMask |= ARMED; | |||||
} | |||||
/** | |||||
* Returns true if the button is selected. | |||||
* | |||||
* @return true if the button is "selected" | |||||
*/ | |||||
public boolean isArmed() { | |||||
return isSelected(); | |||||
} | |||||
/** | |||||
* Returns true if the button is selected. | |||||
* | |||||
* @return true if the button is "selected" | |||||
*/ | |||||
public boolean isPressed() { | |||||
return isSelected(); | |||||
} | |||||
} |