View Javadoc

1   package siouxsie.mvc.impl;
2   
3   import java.beans.PropertyChangeListener;
4   import java.beans.PropertyChangeSupport;
5   import java.util.Map;
6   
7   import siouxsie.mvc.ActionTriggerDescription;
8   import siouxsie.mvc.IActionTrigger;
9   
10  /**
11   * Trigger the controller. Can be used in view.
12   * @author Arnaud Cogoluegnes
13   * @version $Id$
14   */
15  @SuppressWarnings("unchecked")
16  public class ActionTrigger implements IActionTrigger {
17  	
18  	private PropertyChangeSupport model = new PropertyChangeSupport(this);
19  	
20  	// TODO: really necessary?
21  	private ActionTriggerDescription _actionTriggerDescription;
22  
23  	/*
24  	 * (non-Javadoc)
25  	 * @see siouxsie.mvc.IActionTrigger#triggerActionLaunch(java.lang.String, java.lang.String, java.util.Map)
26  	 */
27  	public void triggerActionLaunch(String actionName, String nameSpace,
28  			Map<?,?> parameters) {
29  		
30  		ActionTriggerDescription old = this._actionTriggerDescription;
31  		
32  		_actionTriggerDescription = new ActionTriggerDescription(
33  				actionName,nameSpace,parameters
34  		);
35  		
36  		// the action description can be retrieved from the event
37  		// that's why the getter is not really necessary
38  		model.firePropertyChange(
39  			IActionTrigger.PROPERTY_ACTION_TRIGGER_DESCRIPTION,
40  			old,this._actionTriggerDescription
41  		);
42  		
43  		//controller.executeAction(actionName, nameSpace, parameters);
44  
45  	}
46  	
47  	/*
48  	 * (non-Javadoc)
49  	 * @see siouxsie.mvc.IActionTrigger#addPropertyChangeListener(java.beans.PropertyChangeListener)
50  	 */
51  	public void addPropertyChangeListener(PropertyChangeListener listener) {
52  		model.addPropertyChangeListener(listener);		
53  	}
54  	
55  	/*
56  	 * (non-Javadoc)
57  	 * @see siouxsie.mvc.IActionTrigger#removePropertyChangeListener(java.beans.PropertyChangeListener)
58  	 */
59  	public void removePropertyChangeListener(PropertyChangeListener listener) {
60  		model.removePropertyChangeListener(listener);		
61  	}
62  	
63  	/*
64  	 * (non-Javadoc)
65  	 * @see siouxsie.mvc.IActionTrigger#getActionTriggerDescription()
66  	 */
67  	public ActionTriggerDescription getActionTriggerDescription() {
68  		return _actionTriggerDescription;
69  	}
70  
71  }