nl.coderight.jazz
Class Controller

java.lang.Object
  extended by nl.coderight.jazz.Controller
Direct Known Subclasses:
Application, Module

public abstract class Controller
extends Object

Controller is part of the HMVC pattern.

 Example:

 public class MyController extends Controller {
  private MyModel myModel;
  private MyView myView;
   
        public void handleEvent(MyEvent evt) {
                switch (evt.getType()) {
                case EDIT:
                        executeController(new MyController());
                        break;
                                                
                case EXPORT:
                        executeTask(new ExportTask());
                        break;                  
                }
        }

        public void execute() {
     myModel = new MyModel();
     myView = new MyView();
     setModel(myModel);
     setView(myView);
     showView();
  }
 }
 

Default event-handlers:


Nested Class Summary
static class Controller.EventNotHandledException
          RuntimeException, thrown when an event is not handled.
 
Constructor Summary
Controller()
          Default constructor.
 
Method Summary
 void closeView()
          Close the View.
abstract  void execute()
          Executes this controller.
 void executeController(Controller controller)
          Executes a Controller asynchronously.
 void executeTask(Task task)
          Executes a Task asynchronously.
 Application getApplication()
          Returns the Application.
 Model getModel()
          Returns the Model for this controller.
 View getView()
          Returns the View for this controller.
 void handleEvent(FormModelEvent evt)
           
 void handleEvent(ProgressEvent evt)
          Default handling of ProgressEvent.
 void handleEvent(ViewEvent evt)
          Default handling of ViewEvent.
protected  void onAfterShowView()
          Invoked after view is visible.
protected  void onBeforeShowView()
          Invoked before view is visible.
protected  void onEventNotHandled(Event event)
          Invoked when an event is not handled.
 void propagateEvent(Event event)
          Propagate Event to parent Controller.
 void scheduleTask(Task task, nl.coderight.jazz.Task.Schedule schedule)
          Schedules a Task asynchronously.
 void setModel(Model model)
          Sets the Model for this controller.
 void setView(View view)
          Sets the View for this controller.
 void showView()
          Show the View with default modality (MODELESS).
 void showView(Dialog.ModalityType modality)
          Show the View with given modality.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Controller

public Controller()
Default constructor.

Method Detail

scheduleTask

public final void scheduleTask(Task task,
                               nl.coderight.jazz.Task.Schedule schedule)
Schedules a Task asynchronously.

See Also:
Task.FixedDelaySchedule, Task.FixedRateSchedule

executeTask

public final void executeTask(Task task)
Executes a Task asynchronously.


executeController

public final void executeController(Controller controller)
Executes a Controller asynchronously.


execute

public abstract void execute()
Executes this controller.
 
 Example:
 public void execute() {
                model = new Model();
                view = new View();
                setModel(model);
                setView(view);
                showView();
 }
 


getView

public final View getView()
Returns the View for this controller.


setView

public final void setView(View view)
Sets the View for this controller.


getModel

public final Model getModel()
Returns the Model for this controller.


setModel

public final void setModel(Model model)
Sets the Model for this controller.


showView

public final void showView()
Show the View with default modality (MODELESS).

See Also:
#showView(ModalityType)

showView

public final void showView(Dialog.ModalityType modality)
Show the View with given modality.


closeView

public final void closeView()
Close the View.


getApplication

public final Application getApplication()
Returns the Application.


handleEvent

public void handleEvent(ViewEvent evt)
Default handling of ViewEvent.
 OPEN: change the mouse cursor shape to Cursor.WAIT_CURSOR
 SHOW: change the mouse cursor shape to Cursor.DEFAULT_CURSOR
 


handleEvent

public void handleEvent(ProgressEvent evt)
Default handling of ProgressEvent.
 When the View has a ProgressMonitor:
 START  -> ProgressMonitor.startProgress(ProgressEvent)
 UPDATE -> ProgressMonitor.updateProgress(ProgressEvent)
 STOP   -> ProgressMonitor.stopProgress(ProgressEvent)
 

See Also:
View.setProgressMonitor(ProgressMonitor), ProgressMonitor

handleEvent

public final void handleEvent(FormModelEvent evt)

propagateEvent

public final void propagateEvent(Event event)
                          throws Controller.EventNotHandledException
Propagate Event to parent Controller.

Throws:
Controller.EventNotHandledException

onBeforeShowView

protected void onBeforeShowView()
Invoked before view is visible.


onAfterShowView

protected void onAfterShowView()
Invoked after view is visible.


onEventNotHandled

protected void onEventNotHandled(Event event)
Invoked when an event is not handled.



Copyright 2010 CodeRight, All rights reserved.