of event can be cancelled. git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@268191 13f79535-47bb-0310-9956-ffa450edef68master
| @@ -6,20 +6,9 @@ TODO List: | |||||
| - Normalize the Ant data model to represent a more consistent | - Normalize the Ant data model to represent a more consistent | ||||
| tree structure, and more bean-like API. | 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 | * Better define the data model architecture, and how it interfaces | ||||
| with the Ant data model. | 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 | * Project properties viewer, including the ability to view | ||||
| dependencies (local and cascading). | dependencies (local and cascading). | ||||
| @@ -27,10 +16,3 @@ TODO List: | |||||
| * Build launching capability. | * 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. | |||||
| @@ -236,9 +236,12 @@ public class ActionManager { | |||||
| * 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 | |||||
| * it should be cancelled. | |||||
| */ | */ | ||||
| public void eventPosted(EventObject event) { | |||||
| public boolean eventPosted(EventObject event) { | |||||
| _mapper.applyEvent(event); | _mapper.applyEvent(event); | ||||
| return true; | |||||
| } | } | ||||
| } | } | ||||
| @@ -135,11 +135,13 @@ public class Console extends AntEditor { | |||||
| * 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 | |||||
| * it should be cancelled. | |||||
| */ | */ | ||||
| public void eventPosted(EventObject event) { | |||||
| public boolean eventPosted(EventObject event) { | |||||
| if(event instanceof NewProjectEvent) { | if(event instanceof NewProjectEvent) { | ||||
| clearDisplay(); | clearDisplay(); | ||||
| return; | |||||
| return true; | |||||
| } | } | ||||
| AntBuildEvent buildEvent = (AntBuildEvent) event; | AntBuildEvent buildEvent = (AntBuildEvent) event; | ||||
| @@ -181,6 +183,8 @@ public class Console extends AntEditor { | |||||
| ex.printStackTrace(); | ex.printStackTrace(); | ||||
| } | } | ||||
| } | } | ||||
| return true; | |||||
| } | } | ||||
| } | } | ||||
| /** Class providing filtering for project events. */ | /** Class providing filtering for project events. */ | ||||
| @@ -108,8 +108,10 @@ class EventResponder { | |||||
| * 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 | |||||
| * it should be cancelled. | |||||
| */ | */ | ||||
| public void eventPosted(EventObject event) { | |||||
| public boolean eventPosted(EventObject event) { | |||||
| String command = ((ActionEvent)event).getActionCommand(); | String command = ((ActionEvent)event).getActionCommand(); | ||||
| // XXX turn this switch structure into a command | // XXX turn this switch structure into a command | ||||
| @@ -136,6 +138,7 @@ class EventResponder { | |||||
| // XXX log me. | // XXX log me. | ||||
| System.err.println("Unhandled action: " + command); | 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. | * 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 | |||||
| * it should be cancelled. | |||||
| */ | */ | ||||
| public void eventPosted(EventObject event) { | |||||
| public boolean eventPosted(EventObject event) { | |||||
| AntEvent e = (AntEvent) event; | AntEvent e = (AntEvent) event; | ||||
| Command cmd = e.createDefaultCmd(); | Command cmd = e.createDefaultCmd(); | ||||
| cmd.execute(); | cmd.execute(); | ||||
| return true; | |||||
| } | } | ||||
| } | } | ||||
| @@ -108,8 +108,10 @@ class ProjectNavigator extends AntEditor { | |||||
| * 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 | |||||
| * it should be cancelled. | |||||
| */ | */ | ||||
| public void eventPosted(EventObject event) { | |||||
| public boolean eventPosted(EventObject event) { | |||||
| ProjectProxy project = getAppContext().getProject(); | ProjectProxy project = getAppContext().getProject(); | ||||
| if(project == null) { | if(project == null) { | ||||
| @@ -123,6 +125,7 @@ class ProjectNavigator extends AntEditor { | |||||
| _tree.setModel(project.getTreeModel()); | _tree.setModel(project.getTreeModel()); | ||||
| _tree.setSelectionModel(project.getTreeSelectionModel()); | _tree.setSelectionModel(project.getTreeSelectionModel()); | ||||
| } | } | ||||
| return true; | |||||
| } | } | ||||
| } | } | ||||
| @@ -127,11 +127,14 @@ class PropertyEditor extends AntEditor { | |||||
| * Called when an event is to be posted to the member. | * Called when an event is to be posted to the member. | ||||
| * | * | ||||
| * @param event Event to post. | * @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; | ElementSelectionEvent e = (ElementSelectionEvent) event; | ||||
| ACSElement[] elements = e.getSelectedElements(); | ACSElement[] elements = e.getSelectedElements(); | ||||
| updateDisplay(elements); | updateDisplay(elements); | ||||
| return true; | |||||
| } | } | ||||
| } | } | ||||
| @@ -102,12 +102,15 @@ class SourceEditor extends AntEditor { | |||||
| * 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 | |||||
| * it should be cancelled. | |||||
| */ | */ | ||||
| public void eventPosted(EventObject event) { | |||||
| public boolean eventPosted(EventObject event) { | |||||
| ProjectProxy project = getAppContext().getProject(); | ProjectProxy project = getAppContext().getProject(); | ||||
| _text.setDocument(project == null ? new PlainDocument() : | _text.setDocument(project == null ? new PlainDocument() : | ||||
| project.getDocument()); | project.getDocument()); | ||||
| return true; | |||||
| } | } | ||||
| } | } | ||||
| @@ -124,8 +124,10 @@ public class TargetMonitor extends AntEditor { | |||||
| * 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 | |||||
| * it should be cancelled. | |||||
| */ | */ | ||||
| public void eventPosted(EventObject event) { | |||||
| public boolean eventPosted(EventObject event) { | |||||
| ElementSelectionEvent e = (ElementSelectionEvent) event; | ElementSelectionEvent e = (ElementSelectionEvent) event; | ||||
| String text = _defText; | String text = _defText; | ||||
| @@ -146,6 +148,8 @@ public class TargetMonitor extends AntEditor { | |||||
| } | } | ||||
| setText(text); | setText(text); | ||||
| return true; | |||||
| } | } | ||||
| } | } | ||||
| @@ -85,22 +85,6 @@ public abstract class AntEvent extends EventObject { | |||||
| return (AppContext) getSource(); | 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. | * Create the appropriate default response command to this event. | ||||
| @@ -74,7 +74,9 @@ public interface BusMember { | |||||
| * 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. | ||||
| */ | |||||
| public void eventPosted(EventObject event); | |||||
| * @return true if event should be propogated, false if | |||||
| * it should be cancelled. | |||||
| */ | |||||
| public boolean eventPosted(EventObject event); | |||||
| } | } | ||||
| @@ -174,6 +174,7 @@ public class EventBus { | |||||
| */ | */ | ||||
| public void run() { | public void run() { | ||||
| synchronized(_memberSet) { | synchronized(_memberSet) { | ||||
| outerLoop: | |||||
| for(int i = 0; i < _memberSet.length; i++) { | for(int i = 0; i < _memberSet.length; i++) { | ||||
| if(_memberSet[i] == null) continue; | if(_memberSet[i] == null) continue; | ||||
| @@ -182,12 +183,12 @@ public class EventBus { | |||||
| BusMember next = (BusMember) it.next(); | BusMember next = (BusMember) it.next(); | ||||
| BusFilter filter = next.getBusFilter(); | BusFilter filter = next.getBusFilter(); | ||||
| if(filter == null || filter.accept(_event)) { | 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; | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||