Definition at line 31 of file AbstractAppController.java.
Public Member Functions | |
AbstractAppController (AbstractAppModel model, AbstractAppView view, AppOption options[]) throws AppException | |
Creates a new AppController object. | |
final void | actionPerformed (ActionEvent evt) |
ActionEvent perform method. | |
synchronized void | addView (AppControllerEventListener view) |
Registers ActionListener to receive events. | |
abstract ActionEvent | processEvent (ActionEvent evt) |
Event processing method. | |
synchronized void | removeView (AppControllerEventListener view) |
Removes ActionListener from the list of listeners. | |
abstract void | startController () |
This method starts the controller and should perform any application initialization that is required. | |
String | toString () |
Returns a string representation of this object. | |
Protected Member Functions | |
void | notifyModel (ActionEvent event) |
Sends notification to update the model. | |
void | notifyViews (ActionEvent event) |
Sends notification to update the views. | |
synchronized void | setModel (AppControllerEventListener model) throws TooManyListenersException |
Registers ActionListener to receive events. | |
Protected Attributes | |
transient AppControllerEventListener | model = null |
The application model. | |
AppOption | options [] = null |
Command line options. | |
ThreadFactory | pool = Executors.defaultThreadFactory() |
The application thread pool. | |
transient List< AppControllerEventListener > | views |
The application views. |
|
Creates a new AppController object. Adds the controller as a listener to both the application model and the application view. Also adds the application model and the application view as event listeners of the controller.
Definition at line 57 of file AbstractAppController.java. References AbstractAppController.addView(), AbstractAppController.model, AbstractAppController.options, and AbstractAppController.setModel(). 00059 { 00060 this.options = options; 00061 try { 00062 model.setController(this); 00063 view.setController(this); 00064 setModel(model); 00065 addView(view); 00066 } catch(TooManyListenersException e) { 00067 throw new AppException(e.getMessage()); 00068 } 00069 }
|
|
ActionEvent perform method. This method passes events to the processEvent method for dispatch.
Definition at line 97 of file AbstractAppController.java. References AbstractAppController.notifyModel(), AbstractAppController.notifyViews(), and AbstractAppController.processEvent(). 00097 { 00098 ActionEvent event = processEvent(evt); 00099 notifyModel(event); 00100 notifyViews(event); 00101 }
|
|
Registers ActionListener to receive events.
Definition at line 108 of file AbstractAppController.java. References AbstractAppController.views. Referenced by AbstractAppController.AbstractAppController(). 00108 { 00109 if(views == null){views = new ArrayList<AppControllerEventListener>();} 00110 views.add(view); 00111 }
|
|
Sends notification to update the model.
Definition at line 134 of file AbstractAppController.java. References AbstractAppController.model, and AbstractAppController.pool. Referenced by AbstractAppController.actionPerformed(). 00134 { 00135 if((model == null) || (event == null)){return;} 00136 final AppControllerEventListener mod = model; 00137 final ActionEvent evt = event; 00138 pool.newThread(new Runnable() { 00139 public void run(){mod.actionPerformed(evt);} 00140 }).start(); 00141 }
|
|
Sends notification to update the views.
Definition at line 148 of file AbstractAppController.java. Referenced by AbstractAppController.actionPerformed(). 00148 { 00149 List list; 00150 synchronized(this) { 00151 if((views == null) || (event == null)){return;} 00152 list = (List)((ArrayList)views).clone(); 00153 } 00154 final ActionEvent evt = event; 00155 for(int i = 0;i < list.size();i++) { 00156 final AppControllerEventListener view = (AppControllerEventListener)list 00157 .get(i); 00158 pool.newThread(new Runnable() { 00159 public void run(){view.actionPerformed(evt);} 00160 }).start(); 00161 } 00162 }
|
|
Event processing method. This method is responsible for handling all events processed by the controller. This method must be implemented by all subclasses.
Referenced by AbstractAppController.actionPerformed(). |
|
Removes ActionListener from the list of listeners.
Definition at line 118 of file AbstractAppController.java. References AbstractAppController.views.
|
|
Registers ActionListener to receive events.
Definition at line 172 of file AbstractAppController.java. Referenced by AbstractAppController.AbstractAppController(). 00173 { 00174 if(model == null){this.model = null;} 00175 else { 00176 if(this.model != null){throw new TooManyListenersException();} 00177 this.model = model; 00178 } 00179 }
|
|
This method starts the controller and should perform any application initialization that is required. This method must be implemented by all subclasses. Referenced by AbstractApp.run(). |
|
Returns a string representation of this object.
Definition at line 127 of file AbstractAppController.java. 00127 {return super.toString();}
|
|
The application model.
Definition at line 34 of file AbstractAppController.java. Referenced by AbstractAppController.AbstractAppController(), and AbstractAppController.notifyModel(). |
|
Command line options.
Definition at line 37 of file AbstractAppController.java. Referenced by AbstractAppController.AbstractAppController(). |
|
The application thread pool.
Definition at line 40 of file AbstractAppController.java. Referenced by AbstractAppController.notifyModel(). |
|
The application views.
Definition at line 43 of file AbstractAppController.java. Referenced by AbstractAppController.addView(), and AbstractAppController.removeView(). |