metasim 01/03/12 11:51:45
Modified: src/antidote/org/apache/tools/ant/gui/command BuildCmd.java
src/antidote/org/apache/tools/ant/gui/core
ActionManager.java AntAction.java
EventToActionMapper.java
src/antidote/org/apache/tools/ant/gui/modules/console
BuildConsole.java
src/antidote/org/apache/tools/ant/gui/resources
action.properties
Added: src/antidote/org/apache/tools/ant/gui/command
ShowOrHideConsoleCmd.java
src/antidote/org/apache/tools/ant/gui/event
ConsoleNotVisibleEvent.java
ConsoleVisibleEvent.java ShowConsoleEvent.java
src/antidote/org/apache/tools/ant/gui/resources console.gif
src/antidote/org/apache/tools/ant/gui/util
CheckableButtonModel.java
Log:
Committed Nick Davis' patch to add action toggleability.
Revision Changes Path
1.8 +18 -12
jakarta-ant/src/antidote/org/apache/tools/ant/gui/command/BuildCmd.java
Index: BuildCmd.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/src/antidote/org/apache/tools/ant/gui/command/BuildCmd.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- BuildCmd.java 2001/01/08 19:43:20 1.7
+++ BuildCmd.java 2001/03/12 19:51:30 1.8
@@ -56,12 +56,13 @@
import org.apache.tools.ant.gui.event.ErrorEvent;
import org.apache.tools.ant.gui.acs.ACSProjectElement;
import org.apache.tools.ant.gui.acs.ACSTargetElement;
+import org.apache.tools.ant.gui.event.ShowConsoleEvent;
/**
* Starts an Ant build.
- *
- * @version $Revision: 1.7 $
- * @author Simeon Fitch
+ *
+ * @version $Revision: 1.8 $
+ * @author Simeon Fitch
*/
public class BuildCmd extends AbstractCommand {
@@ -70,37 +71,42 @@
/** Targets to build. */
private ACSTargetElement[] _targets = null;
- /**
+ /**
* Standard ctor.
- *
+ *
*/
- public BuildCmd(AppContext context) {
+ public BuildCmd(AppContext context) {
super(context);
}
- /**
+ /**
* Set the specific project to build (instead of the default).
- *
+ *
* @param project Project to build.
*/
public void setProject(ACSProjectElement project) {
_project = project;
}
- /**
+ /**
* Set the specific targets to build (instead of the default).
- *
+ *
* @param targets Array of targets to build.
*/
public void setTargets(ACSTargetElement[] targets) {
_targets = targets;
}
- /**
+ /**
* Start the Ant build.
- *
+ *
*/
public void run() {
+
+ // Show the build console
+ getContext().getEventBus().postEvent(
+ new ShowConsoleEvent(getContext()));
+
if(_project == null) {
_project =
getContext().getSelectionManager().getSelectedProject();
}
1.1
jakarta-ant/src/antidote/org/apache/tools/ant/gui/command/ShowOrHideConsoleCmd.java
Index: ShowOrHideConsoleCmd.java
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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: 1.1 $
* @author Nick Davis<a href="mailto:[EMAIL PROTECTED]">[EMAIL PROTECTED]</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;
}
}
1.5 +69 -27
jakarta-ant/src/antidote/org/apache/tools/ant/gui/core/ActionManager.java
Index: ActionManager.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/src/antidote/org/apache/tools/ant/gui/core/ActionManager.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- ActionManager.java 2001/01/12 19:02:32 1.4
+++ ActionManager.java 2001/03/12 19:51:33 1.5
@@ -55,16 +55,19 @@
import org.apache.tools.ant.gui.event.*;
import org.apache.tools.ant.gui.command.Command;
+import org.apache.tools.ant.gui.util.CheckableButtonModel;
import javax.swing.*;
+import javax.accessibility.*;
import java.util.*;
+import java.beans.*;
import java.lang.reflect.Constructor;
/**
* Manager of antidote actions. Receives its configuration from the action
* ResourceBundle.
- *
- * @version $Revision: 1.4 $
- * @author Simeon Fitch
+ *
+ * @version $Revision: 1.5 $
+ * @author Simeon Fitch
*/
public class ActionManager {
/** Parameters for the Command constructor. */
@@ -86,9 +89,9 @@
private EventToActionMapper _mapper = null;
- /**
+ /**
* Standard ctor.
- *
+ *
* @param bus Event bus to post events to.
* @param resources Location of resources.
*/
@@ -113,9 +116,9 @@
}
}
- /**
+ /**
* Create a menubar for the application based on the configuration file.
- *
+ *
* @return Menubar.
*/
public JMenuBar createMenuBar() {
@@ -162,7 +165,7 @@
}
// See if we should add a separator.
- if(action.isPreceededBySeparator() &&
+ if(action.isPreceededBySeparator() &&
menu.getMenuComponentCount() > 0) {
menu.addSeparator();
}
@@ -173,10 +176,14 @@
addNiceStuff(item, action);
}
else {
- JCheckBoxMenuItem b =
+ JCheckBoxMenuItem b =
new JCheckBoxMenuItem(action.getName());
b.setActionCommand(action.getID());
b.addActionListener(action);
+
+ action.addPropertyChangeListener(
+ new PropertyWatcher(b));
+
// XXX eck. This is a 1.3 feature. Fix ME!
// Need to provide binding between action and widget.
// b.setAction(action);
@@ -190,14 +197,14 @@
return retval;
}
- /**
+ /**
* Create a tool bar based on the current configuration.
- *
+ *
* @return Toolbar ready for action.
*/
public JToolBar createToolBar() {
JToolBar retval = new JToolBar();
-
+
for(int i = 0; i < _actionIDs.length; i++) {
AntAction action = (AntAction) _actions.get(_actionIDs[i]);
// If it has an icon, then we add it to the toolbar.
@@ -209,6 +216,15 @@
JButton button = retval.add(action);
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);
}
}
@@ -216,12 +232,12 @@
return retval;
}
- /**
+ /**
* Create a popup menu with the given actionIDs.
* XXX check this for object leak. Does the button
* get added to the action as a listener? There are also some
* changes to this behavior in 1.3.
- *
+ *
* @param actionIDs List of action IDs for actions
* to appear in popup menu.
* @return Popup menu to display.
@@ -240,9 +256,9 @@
return retval;
}
- /**
+ /**
* Get the command assocaited with the Action with the given id.
- *
+ *
* @param actionID Id of action to get command for.
* @return Command associated with action, or null if none available.
*/
@@ -253,7 +269,7 @@
Class clazz = action.getCommandClass();
if(clazz != null) {
try {
- Constructor ctor =
+ Constructor ctor =
clazz.getConstructor(COMMAND_CTOR_PARAMS);
retval = (Command) ctor.newInstance(
new Object[] { context });
@@ -268,10 +284,10 @@
}
- /**
+ /**
* Add tool tip, Mnemonic, etc.
- *
- * @param button Button to work on.
+ *
+ * @param button Button to work on.
* @param action Associated action.
*/
private void addNiceStuff(AbstractButton button, AntAction action) {
@@ -297,19 +313,19 @@
private class Enabler implements BusMember {
private final Filter _filter = new Filter();
- /**
+ /**
* Get the filter to that is used to determine if an event should
* to to the member.
- *
+ *
* @return Filter to use.
*/
public BusFilter getBusFilter() {
return _filter;
}
-
- /**
+
+ /**
* Receives all events.
- *
+ *
* @param event Event to post.
* @return true if event should be propogated, false if
* it should be cancelled.
@@ -322,9 +338,9 @@
/** Class providing filtering for project events. */
private static class Filter implements BusFilter {
- /**
+ /**
* Determines if the given event should be accepted.
- *
+ *
* @param event Event to test.
* @return True if event should be given to BusMember, false
otherwise.
*/
@@ -333,5 +349,31 @@
}
}
+ /** 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());
+ }
+ }
+ }
}
1.4 +72 -45
jakarta-ant/src/antidote/org/apache/tools/ant/gui/core/AntAction.java
Index: AntAction.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/src/antidote/org/apache/tools/ant/gui/core/AntAction.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- AntAction.java 2001/01/04 21:11:12 1.3
+++ AntAction.java 2001/03/12 19:51:34 1.4
@@ -54,18 +54,20 @@
package org.apache.tools.ant.gui.core;
import javax.swing.*;
+import javax.accessibility.*;
import java.net.URL;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
+import java.beans.*;
import java.util.*;
import org.apache.tools.ant.gui.event.EventBus;
/**
- * Class representing an action in the Antidote application.
- *
- * @version $Revision: 1.3 $
- * @author Simeon Fitch
+ * Class representing an action in the Antidote application.
+ *
+ * @version $Revision: 1.4 $
+ * @author Simeon Fitch
*/
public class AntAction extends AbstractAction {
/** Property name for the parent menu item. */
@@ -76,6 +78,8 @@
public static final String ENABLE_ON = "enableOn";
public static final String DISABLE_ON = "disableOn";
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";
/** Property resources. */
@@ -85,22 +89,28 @@
/** Unique id. */
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. */
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. */
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. */
private boolean _toggle = false;
-
- /**
+ /**
* Standard ctor.
- *
+ *
* @param id Unique id for the action
*/
public AntAction(ResourceManager resources, EventBus bus, String id) {
+
_resources = resources;
_bus = bus;
_id = id;
@@ -149,13 +159,14 @@
_enableOn = resolveClasses(getString(ENABLE_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
* "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.
*/
@@ -166,16 +177,16 @@
}
catch(MissingResourceException ex) {
// 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;
}
- /**
+ /**
* 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) {
@@ -191,7 +202,7 @@
catch(ClassNotFoundException ex) {
//XXX log me.
System.err.println(
- "Warning: the event class " + name +
+ "Warning: the event class " + name +
" was not found. Please check config file.");
}
}
@@ -201,46 +212,46 @@
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() {
@@ -248,18 +259,18 @@
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() {
@@ -267,27 +278,43 @@
}
- /**
+ /**
* 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
+ /**
+ * Get the event types which should cause this to go to
* this disabled state.
- *
+ *
*/
public Class[] getDisableOnEvents() {
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.
- *
+ *
* @return True if this is a toggle action, false otherwise.
*/
public boolean isToggle() {
@@ -295,18 +322,18 @@
}
- /**
+ /**
* Get the assciated command class.
- *
+ *
* @return Command class.
*/
public Class getCommandClass() {
return (Class) getValue(COMMAND);
}
- /**
+ /**
* Pass the action on to the EventBus.
- *
+ *
* @param e Event to forward.
*/
public void actionPerformed(ActionEvent e) {
1.3 +47 -15
jakarta-ant/src/antidote/org/apache/tools/ant/gui/core/EventToActionMapper.java
Index: EventToActionMapper.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/src/antidote/org/apache/tools/ant/gui/core/EventToActionMapper.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- EventToActionMapper.java 2001/01/03 14:18:20 1.2
+++ EventToActionMapper.java 2001/03/12 19:51:35 1.3
@@ -52,14 +52,16 @@
* <http://www.apache.org/>.
*/
package org.apache.tools.ant.gui.core;
+
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.
- *
- * @version $Revision: 1.2 $
- * @author Simeon Fitch
+ *
+ * @version $Revision: 1.3 $
+ * @author Simeon Fitch
*/
class EventToActionMapper {
@@ -69,29 +71,37 @@
/** 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();
+ /** 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.
- *
+ *
*/
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);
+ putAction(action, action.getCheckedTrueOnEvents(), _checkedTrueOn);
+ putAction(action, action.getCheckedFalseOnEvents(), _checkedFalseOn);
}
- /**
+ /**
* 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.
@@ -109,11 +119,11 @@
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
* the event.
- *
+ *
* @param event The event to apply.
*/
public void applyEvent(EventObject event) {
@@ -126,11 +136,17 @@
vals = (List) _disableOn.get(event.getClass());
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.
- *
+ *
* @param actions List of AntActions to set state for.
* @param state The state to set them to.
*/
@@ -140,6 +156,22 @@
for(int i = 0, len = actions.size(); i < len; i++) {
AntAction action = (AntAction) actions.get(i);
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));
}
}
}
1.1
jakarta-ant/src/antidote/org/apache/tools/ant/gui/event/ConsoleNotVisibleEvent.java
Index: ConsoleNotVisibleEvent.java
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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: 1.1 $
* @author Nick Davis<a href="mailto:[EMAIL PROTECTED]">[EMAIL PROTECTED]</a>
*/
public class ConsoleNotVisibleEvent extends AntEvent {
/**
* Standard ctor.
*
* @param context application context.
*/
public ConsoleNotVisibleEvent(AppContext context) {
super(context);
}
}
1.1
jakarta-ant/src/antidote/org/apache/tools/ant/gui/event/ConsoleVisibleEvent.java
Index: ConsoleVisibleEvent.java
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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: 1.1 $
* @author Nick Davis<a href="mailto:[EMAIL PROTECTED]">[EMAIL PROTECTED]</a>
*/
public class ConsoleVisibleEvent extends AntEvent {
/**
* Standard ctor.
*
* @param context application context.
*/
public ConsoleVisibleEvent(AppContext context) {
super(context);
}
}
1.1
jakarta-ant/src/antidote/org/apache/tools/ant/gui/event/ShowConsoleEvent.java
Index: ShowConsoleEvent.java
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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: 1.1 $
* @author Nick Davis<a href="mailto:[EMAIL PROTECTED]">[EMAIL PROTECTED]</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);
}
}
1.6 +51 -31
jakarta-ant/src/antidote/org/apache/tools/ant/gui/modules/console/BuildConsole.java
Index: BuildConsole.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/src/antidote/org/apache/tools/ant/gui/modules/console/BuildConsole.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- BuildConsole.java 2001/02/09 13:14:03 1.5
+++ BuildConsole.java 2001/03/12 19:51:40 1.6
@@ -63,14 +63,16 @@
import java.awt.FlowLayout;
import java.awt.Dimension;
import java.awt.Color;
+import java.awt.event.ComponentAdapter;
+import java.awt.event.ComponentEvent;
import java.util.EventObject;
import java.util.Date;
/**
* Logging console display.
- *
- * @version $Revision: 1.5 $
- * @author Simeon Fitch
+ *
+ * @version $Revision: 1.6 $
+ * @author Simeon Fitch
*/
public class BuildConsole extends AntModule {
/** Area where messages are printed. */
@@ -81,17 +83,17 @@
private ConsoleStyleContext _styles = null;
/** ClearLog Button. */
private JButton _clearLog = null;
-
- /**
+
+ /**
* Default ctor.
*/
public BuildConsole() {
}
- /**
+ /**
* Using the given AppContext, initialize the display.
- *
+ *
* @param context Application context.
*/
public void contextualize(AppContext context) {
@@ -114,7 +116,7 @@
_logLevel = new JComboBox(LogLevelEnum.getValues());
_logLevel.setSelectedItem(LogLevelEnum.INFO);
controls.add(_logLevel);
-
+
// Padding.
controls.add(Box.createHorizontalStrut(10));
_clearLog = new JButton(
@@ -125,12 +127,30 @@
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.
- *
+ *
*/
private void clearDisplay() {
Document doc = _text.getDocument();
@@ -146,19 +166,19 @@
private class Handler implements BusMember {
private final Filter _filter = new Filter();
- /**
+ /**
* Get the filter to that is used to determine if an event should
* to to the member.
- *
+ *
* @return Filter to use.
*/
public BusFilter getBusFilter() {
return _filter;
}
-
- /**
+
+ /**
* Called when an event is to be posed to the member.
- *
+ *
* @param event Event to post.
* @return true if event should be propogated, false if
* it should be cancelled.
@@ -176,7 +196,7 @@
case BuildEventType.BUILD_STARTED_VAL:
case BuildEventType.BUILD_FINISHED_VAL:
- text = buildEvent.getType().toString() +
+ text = buildEvent.getType().toString() +
" (" + new Date().toString() + ")";
style = _styles.getHeadingStyle();
break;
@@ -191,7 +211,7 @@
case BuildEventType.MESSAGE_LOGGED_VAL:
// Filter out events that are below our
// selected filterint level.
- LogLevelEnum level =
+ LogLevelEnum level =
(LogLevelEnum) _logLevel.getSelectedItem();
int priority = buildEvent.getEvent().getPriority();
if(priority <= level.getValue()) {
@@ -226,9 +246,9 @@
/** Class providing filtering for project events. */
private static class Filter implements BusFilter {
- /**
+ /**
* Determines if the given event should be accepted.
- *
+ *
* @param event Event to test.
* @return True if event should be given to BusMember, false
otherwise.
*/
@@ -255,9 +275,9 @@
Color.blue
};
- /**
+ /**
* Default ctor.
- *
+ *
*/
public ConsoleStyleContext() {
Style defaultStyle = getStyle(DEFAULT_STYLE);
@@ -283,9 +303,9 @@
StyleConstants.setUnderline(subheading, false);
}
- /**
+ /**
* Get the style to use for the given logging level.
- *
+ *
* @param level Logging level.
* @return Style to use for display.
*/
@@ -294,36 +314,36 @@
return retval == null ? getDefaultStyle() : retval;
}
- /**
+ /**
* Get the default style.
- *
+ *
* @return Default style.
*/
Style getDefaultStyle() {
return getStyle(DEFAULT_STYLE);
}
- /**
+ /**
* Get the style to use for headings.
- *
+ *
* @return Heading style.
*/
Style getHeadingStyle() {
return getStyle(HEADING_STYLE);
}
- /**
+ /**
* Get the style to use for subheadings.
- *
+ *
* @return Subheading style.
*/
Style getSubheadingStyle() {
return getStyle(SUBHEADING_STYLE);
}
- /**
+ /**
* Get a StyledDocument initialized with this.
- *
+ *
* @return SytledDocument.
*/
StyledDocument getStyledDocument() {
1.16 +17 -2
jakarta-ant/src/antidote/org/apache/tools/ant/gui/resources/action.properties
Index: action.properties
===================================================================
RCS file:
/home/cvs/jakarta-ant/src/antidote/org/apache/tools/ant/gui/resources/action.properties,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- action.properties 2001/01/12 20:42:45 1.15
+++ action.properties 2001/03/12 19:51:42 1.16
@@ -1,11 +1,11 @@
# Define the primary menubar items.
-menus=File, Build, Projects, Help
+menus=File, View, Build, Projects, Help
# Declare the list of known actions.
actions=\
new, open, save, saveas, close, exit, about, \
newTarget, newTask, newProperty \
- startBuild, stopBuild
+ startBuild, stopBuild, viewConsole
# Configure the decalred actions.
new.name=New Project...
@@ -149,3 +149,18 @@
org.apache.tools.ant.gui.event.PropertySelectionEvent, \
org.apache.tools.ant.gui.event.ProjectClosedEvent, \
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
1.1
jakarta-ant/src/antidote/org/apache/tools/ant/gui/resources/console.gif
<<Binary file>>
1.1
jakarta-ant/src/antidote/org/apache/tools/ant/gui/util/CheckableButtonModel.java
Index: CheckableButtonModel.java
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 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: 1.1 $
* @author Nick Davis<a href="mailto:[EMAIL PROTECTED]">[EMAIL PROTECTED]</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();
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]