nl.coderight.jazz
Class Application

java.lang.Object
  extended by nl.coderight.jazz.Controller
      extended by nl.coderight.jazz.Application

public abstract class Application
extends Controller

Application is the root Controller of the Hierarchical Model-View-Controller (HMVC) layers.

 The HMVC pattern decomposes an application into a hierarchy of parent-child MVC layers.
 For more information about HMVC article 
 
 MyApp
   +- MyAppView
   +- MyAppModel
   |
   +- MyController_1
   |    +- MyView_1
   |    +- MyModel_1
   |    |
   |    +- MyController_1_1
   |    |    +- MyView_1_1
   |    |    +- MyModel_1_1
   |    |
   |    +- etc.
   |
   +- etc.
 

Example:

 public class MyApp extends Application {
  private MyAppModel myModel;
  private MyAppView myView;

  public void execute() {
    myModel = new MyAppModel();
    myView = new MyAppView();
    setModel(myModel);
    setView(myView);
    showView();
  }

  public void init() {
    setCrossPlatformLookAndFeel();
  }

  public static void main(String[] args) {
    new MyApp().start();
  }
 

Default event-handlers:

Default the following settings are used:

See Also:
Model, View, Controller

Nested Class Summary
 
Nested classes/interfaces inherited from class nl.coderight.jazz.Controller
Controller.EventNotHandledException
 
Constructor Summary
Application()
          Constructor (default WindowMode.SINGLE_WINDOW).
Application(ViewManager.WindowMode windowMode)
          Constructor for custom WindowMode.
Application(ViewManager.WindowMode windowMode, ViewManager.ScreenMode fullscreen)
          Constructor for custom WindowMode and ScreenMode.
 
Method Summary
 void exit()
          Exit application.
 String getApplicationName()
          Returns application name (from JazzLicense).
 String getApplicationVersion()
          Return application version (from AppLauncher).
 List<Module> getInstalledModules()
          Returns a list of installed modules.
 String getSystemInfo()
           
 void handleEvent(ApplicationEvent evt)
           
 void handleEvent(MessageEvent evt)
          Default handling of MessageEvent.
 void handleEvent(ProgressEvent evt)
          Default handling of ProgressEvent.
 void handleEvent(ViewEvent evt)
          Default handling of ViewEvent.
 void hide()
          Hides the application window.
 void hideSplashScreen()
          Hides the SplashScreen.
abstract  void init()
          Invoked when application is started.
 void installModule(Module module)
          Installs a Module.
static void main(String[] args)
           
protected  void onEventNotHandled(Event event)
          Invoked when an event is not handled.
protected  void onExit()
          Invoked when the application exits.
protected  void onIdle()
          Invoked when idle time is set.
protected  void onStart()
          Invoked when the application starts.
 void setCrossPlatformLookAndFeel()
          Sets cross-platform look and feel.
 void setIdleTime(int time)
          Sets idle time in milliseconds.
 void setLookAndFeel(LookAndFeel laf)
          Sets custom look and feel.
 void setLookAndFeel(String laf)
          Sets custom look and feel.
 void setNimbusLookAndFeel()
          Sets Nimbus look and feel.
 void setResourceManager(ResourceManager resourceManager)
          Sets the ResourceManager.
 void setSplashScreen(SplashScreen splashScreen)
          Sets application SplashScreen.
 void setSystemLookAndFeel()
          Sets system look and feel.
 void setSystemTrayIcon(SystemTrayIcon systemTrayIcon)
          Sets the SystemTrayIcon.
 void setUncaughtExceptionHandler(Thread.UncaughtExceptionHandler uncaughtExceptionHandler)
          Sets the UncaughtExceptionHandler.
 void show()
          Shows the application window.
 void showMessage(String message, MessageEvent.MessageEventType messageEventType)
          Displays an alert dialog.
 void showSplashScreen()
          Shows the SplashScreen.
 void start()
          Start application on the Event Dispatch Thread.
 
Methods inherited from class nl.coderight.jazz.Controller
closeView, execute, executeController, executeTask, getApplication, getModel, getView, handleEvent, onAfterShowView, onBeforeShowView, propagateEvent, setModel, setView, showView, showView
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Application

public Application()
Constructor (default WindowMode.SINGLE_WINDOW).


Application

public Application(ViewManager.WindowMode windowMode)
Constructor for custom WindowMode.


Application

public Application(ViewManager.WindowMode windowMode,
                   ViewManager.ScreenMode fullscreen)
Constructor for custom WindowMode and ScreenMode.

Method Detail

getApplicationName

public final String getApplicationName()
Returns application name (from JazzLicense).

Since:
1.5

getApplicationVersion

public String getApplicationVersion()
Return application version (from AppLauncher).

Since:
1.5

start

public final void start()
Start application on the Event Dispatch Thread.

Invokes the following sequence of methods:


init

public abstract void init()
Invoked when application is started.
 Use this for example to open a (database) connection,
 set the look and feel and configure the application.
 

See Also:
start()

show

public void show()
Shows the application window.

Since:
1.4
See Also:
hide()

hide

public void hide()
Hides the application window.

Use this for example with SystemTrayIcon to run the application in the background.

Since:
1.4
See Also:
show()

exit

public final void exit()
Exit application.

See Also:
onExit()

installModule

public final void installModule(Module module)
Installs a Module.


getInstalledModules

public final List<Module> getInstalledModules()
Returns a list of installed modules.


setSplashScreen

public final void setSplashScreen(SplashScreen splashScreen)
Sets application SplashScreen.

The splash screen is displayed when the application starts and closed when the first view becomes visible (if auto close true).


showSplashScreen

public void showSplashScreen()
Shows the SplashScreen.

See Also:
setSplashScreen(SplashScreen)

hideSplashScreen

public void hideSplashScreen()
Hides the SplashScreen.

See Also:
setSplashScreen(SplashScreen)

setSystemLookAndFeel

public final void setSystemLookAndFeel()
Sets system look and feel.


setCrossPlatformLookAndFeel

public final void setCrossPlatformLookAndFeel()
Sets cross-platform look and feel.


setNimbusLookAndFeel

public final void setNimbusLookAndFeel()
Sets Nimbus look and feel.


setLookAndFeel

public final void setLookAndFeel(String laf)
Sets custom look and feel.


setLookAndFeel

public final void setLookAndFeel(LookAndFeel laf)
Sets custom look and feel.


setResourceManager

public final void setResourceManager(ResourceManager resourceManager)
Sets the ResourceManager.


setSystemTrayIcon

public final void setSystemTrayIcon(SystemTrayIcon systemTrayIcon)
Sets the SystemTrayIcon.

Since:
1.3

setUncaughtExceptionHandler

public final void setUncaughtExceptionHandler(Thread.UncaughtExceptionHandler uncaughtExceptionHandler)
Sets the UncaughtExceptionHandler.

Since:
1.4

showMessage

public void showMessage(String message,
                        MessageEvent.MessageEventType messageEventType)
Displays an alert dialog.


handleEvent

public final void handleEvent(ApplicationEvent evt)

handleEvent

public final void handleEvent(ViewEvent evt)
Description copied from class: Controller
Default handling of ViewEvent.
 OPEN: change the mouse cursor shape to Cursor.WAIT_CURSOR
 SHOW: change the mouse cursor shape to Cursor.DEFAULT_CURSOR
 

Overrides:
handleEvent in class Controller

handleEvent

public void handleEvent(MessageEvent evt)
Default handling of MessageEvent.

MessageEventType.PLAIN is shown as an alert dialog.

Overrides:
handleEvent in class Controller
See Also:
Controller.handleEvent(MessageEvent)

handleEvent

public void handleEvent(ProgressEvent evt)
Default handling of ProgressEvent.
 START -> change the mouse cursor shape to Cursor.WAIT_CURSOR
 STOP  -> change the mouse cursor shape to Cursor.DEFAULT_CURSOR
 

Overrides:
handleEvent in class Controller
See Also:
Controller.handleEvent(ProgressEvent), ProgressMonitor

setIdleTime

public final void setIdleTime(int time)
Sets idle time in milliseconds.

Use this for example to logout a user after a given time of inactivity.

Parameters:
time - in milliseconds to wait before the onIdle method is called
Since:
1.6
See Also:
onIdle()

onIdle

protected void onIdle()
Invoked when idle time is set.

See Also:
setIdleTime(int)

onStart

protected void onStart()
Invoked when the application starts.

Use this for example to open a database.

See Also:
start()

onExit

protected void onExit()
Invoked when the application exits.

use this for example to close a database.

See Also:
exit()

onEventNotHandled

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

NOTE! default implementation shows a message dialog. You should override this method for example to write not handled events to a log file.

Overrides:
onEventNotHandled in class Controller

getSystemInfo

public final String getSystemInfo()

main

public static void main(String[] args)


Copyright 2010 CodeRight, All rights reserved.