Browse Source

Changed mechanism by which BusMembers cancel event propogation so that any type

of event can be cancelled.


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@268191 13f79535-47bb-0310-9956-ffa450edef68
master
metasim 24 years ago
parent
commit
6a47866639
11 changed files with 45 additions and 50 deletions
  1. +0
    -18
      src/antidote/TODO
  2. +4
    -1
      src/antidote/org/apache/tools/ant/gui/ActionManager.java
  3. +6
    -2
      src/antidote/org/apache/tools/ant/gui/Console.java
  4. +8
    -2
      src/antidote/org/apache/tools/ant/gui/EventResponder.java
  5. +4
    -1
      src/antidote/org/apache/tools/ant/gui/ProjectNavigator.java
  6. +4
    -1
      src/antidote/org/apache/tools/ant/gui/PropertyEditor.java
  7. +4
    -1
      src/antidote/org/apache/tools/ant/gui/SourceEditor.java
  8. +5
    -1
      src/antidote/org/apache/tools/ant/gui/TargetMonitor.java
  9. +0
    -16
      src/antidote/org/apache/tools/ant/gui/event/AntEvent.java
  10. +4
    -2
      src/antidote/org/apache/tools/ant/gui/event/BusMember.java
  11. +6
    -5
      src/antidote/org/apache/tools/ant/gui/event/EventBus.java

+ 0
- 18
src/antidote/TODO View File

@@ -6,20 +6,9 @@ TODO List:
- Normalize the Ant data model to represent a more consistent
tree structure, and more bean-like API.

* Cause console to clear when a project is closed.

* Better define the data model architecture, and how it interfaces
with the Ant data model.

* Define a list of proposed changes for the Ant datamodel,
specifically the Project class and the ability to stop running builds,
and reduction of code duplication in launching builds.

* Project navigator (currently stubbed out in the ProjectNavigator class).

* Implement a ListSelectionModel that is backed by a set of selected
targets.

* Project properties viewer, including the ability to view
dependencies (local and cascading).

@@ -27,10 +16,3 @@ TODO List:

* Build launching capability.

* Build monitoring console.

* Get some icons!

* Create a listener for the ActionManager that knows how to change
the enanbled state of the various actions based on the
application state.

+ 4
- 1
src/antidote/org/apache/tools/ant/gui/ActionManager.java View File

@@ -236,9 +236,12 @@ public class ActionManager {
* Receives all events.
*
* @param event Event to post.
* @return true if event should be propogated, false if
* it should be cancelled.
*/
public void eventPosted(EventObject event) {
public boolean eventPosted(EventObject event) {
_mapper.applyEvent(event);
return true;
}
}



+ 6
- 2
src/antidote/org/apache/tools/ant/gui/Console.java View File

@@ -135,11 +135,13 @@ public class Console extends AntEditor {
* 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.
*/
public void eventPosted(EventObject event) {
public boolean eventPosted(EventObject event) {
if(event instanceof NewProjectEvent) {
clearDisplay();
return;
return true;
}

AntBuildEvent buildEvent = (AntBuildEvent) event;
@@ -181,6 +183,8 @@ public class Console extends AntEditor {
ex.printStackTrace();
}
}

return true;
}
}
/** Class providing filtering for project events. */


+ 8
- 2
src/antidote/org/apache/tools/ant/gui/EventResponder.java View File

@@ -108,8 +108,10 @@ class EventResponder {
* 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.
*/
public void eventPosted(EventObject event) {
public boolean eventPosted(EventObject event) {
String command = ((ActionEvent)event).getActionCommand();

// XXX turn this switch structure into a command
@@ -136,6 +138,7 @@ class EventResponder {
// XXX log me.
System.err.println("Unhandled action: " + command);
}
return true;
}
}

@@ -164,11 +167,14 @@ class EventResponder {
* 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.
*/
public void eventPosted(EventObject event) {
public boolean eventPosted(EventObject event) {
AntEvent e = (AntEvent) event;
Command cmd = e.createDefaultCmd();
cmd.execute();
return true;
}
}



+ 4
- 1
src/antidote/org/apache/tools/ant/gui/ProjectNavigator.java View File

@@ -108,8 +108,10 @@ class ProjectNavigator extends AntEditor {
* 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.
*/
public void eventPosted(EventObject event) {
public boolean eventPosted(EventObject event) {
ProjectProxy project = getAppContext().getProject();

if(project == null) {
@@ -123,6 +125,7 @@ class ProjectNavigator extends AntEditor {
_tree.setModel(project.getTreeModel());
_tree.setSelectionModel(project.getTreeSelectionModel());
}
return true;
}
}



+ 4
- 1
src/antidote/org/apache/tools/ant/gui/PropertyEditor.java View File

@@ -127,11 +127,14 @@ class PropertyEditor extends AntEditor {
* Called when an event is to be posted to the member.
*
* @param event Event to post.
* @return true if event should be propogated, false if
* it should be cancelled.
*/
public void eventPosted(EventObject event) {
public boolean eventPosted(EventObject event) {
ElementSelectionEvent e = (ElementSelectionEvent) event;
ACSElement[] elements = e.getSelectedElements();
updateDisplay(elements);
return true;
}

}


+ 4
- 1
src/antidote/org/apache/tools/ant/gui/SourceEditor.java View File

@@ -102,12 +102,15 @@ class SourceEditor extends AntEditor {
* 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.
*/
public void eventPosted(EventObject event) {
public boolean eventPosted(EventObject event) {
ProjectProxy project = getAppContext().getProject();

_text.setDocument(project == null ? new PlainDocument() :
project.getDocument());
return true;
}
}



+ 5
- 1
src/antidote/org/apache/tools/ant/gui/TargetMonitor.java View File

@@ -124,8 +124,10 @@ public class TargetMonitor extends AntEditor {
* 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.
*/
public void eventPosted(EventObject event) {
public boolean eventPosted(EventObject event) {
ElementSelectionEvent e = (ElementSelectionEvent) event;
String text = _defText;

@@ -146,6 +148,8 @@ public class TargetMonitor extends AntEditor {
}

setText(text);

return true;
}
}



+ 0
- 16
src/antidote/org/apache/tools/ant/gui/event/AntEvent.java View File

@@ -85,22 +85,6 @@ public abstract class AntEvent extends EventObject {
return (AppContext) getSource();
}

/**
* Determine if the event has been cancelled.
*
* @return True if cancelled, false otherwise.
*/
public boolean isCancelled() {
return _cancelled;
}

/**
* Tag the event as being canceled.
*
*/
public void cancel() {
_cancelled = true;
}

/**
* Create the appropriate default response command to this event.


+ 4
- 2
src/antidote/org/apache/tools/ant/gui/event/BusMember.java View File

@@ -74,7 +74,9 @@ public interface BusMember {
* Called when an event is to be posed to the member.
*
* @param event Event to post.
*/
public void eventPosted(EventObject event);
* @return true if event should be propogated, false if
* it should be cancelled.
*/
public boolean eventPosted(EventObject event);

}

+ 6
- 5
src/antidote/org/apache/tools/ant/gui/event/EventBus.java View File

@@ -174,6 +174,7 @@ public class EventBus {
*/
public void run() {
synchronized(_memberSet) {
outerLoop:
for(int i = 0; i < _memberSet.length; i++) {
if(_memberSet[i] == null) continue;
@@ -182,12 +183,12 @@ public class EventBus {
BusMember next = (BusMember) it.next();
BusFilter filter = next.getBusFilter();
if(filter == null || filter.accept(_event)) {
next.eventPosted(_event);
// If false then callee canceled the event
// propogation.
if(!next.eventPosted(_event)) {
break outerLoop;
}
}
// Check to see if the member cancelled the event. If so
// then don't send it on to the other members.
if(_event instanceof AntEvent &&
((AntEvent)_event).isCancelled()) break;
}
}
}


Loading…
Cancel
Save