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();
  }

  protected void onStart() {
          DatabaseService.getInstance().openDatabase();
        }
        
        protected void onExit() {
          DatabaseService.getInstance().closeDatabase();
        }

  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.WindowStyle windowStyle)
          Constructor for custom WindowMode and ScreenMode.
 
Method Summary
 void exit()
          Exit application.
 View getActiveView()
           
 String getApplicationName()
          Returns application name (from JazzLicense).
 String getApplicationVersion()
          Return application version (from AppLauncher).
 List<Module> getInstalledModules()
          Returns a list of installed modules.
 void handleEvent(ApplicationEvent evt)
          Default handling of ApplicationEvent.
 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 setMenuBar(MenuBar menuBar)
          Sets a MenuBar for this Application.
 void setNimbusLookAndFeel()
          Sets Nimbus look and feel.
 void setResourceManager(ResourceManager resourceManager)
          Sets the ResourceManager.
 void setSplashScreen(SplashScreen splashScreen)
          Sets application SplashScreen.
 void setStatusBar(StatusBar statusBar)
          Sets a StatusBar for this Application.
 void setSystemLookAndFeel()
          Sets system look and feel.
 void setSystemTrayIcon(SystemTrayIcon systemTrayIcon)
          Sets the SystemTrayIcon.
 void setToolBar(ToolBar toolBar)
          Sets a ToolBar for this view.
 void setToolBar(ToolBar toolBar, ToolBar.Position position)
          Sets a ToolBar for this Application.
 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, scheduleTask, 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.WindowStyle windowStyle)
Constructor for custom WindowMode and ScreenMode.

Method Detail

getApplicationName

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


getApplicationVersion

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


getActiveView

public final View getActiveView()

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.

See Also:
hide()

hide

public void hide()
Hides the application window.

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

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 final void showSplashScreen()
Shows the SplashScreen.

See Also:
setSplashScreen(SplashScreen)

hideSplashScreen

public final void hideSplashScreen()
Hides the SplashScreen.

See Also:
setSplashScreen(SplashScreen)

setMenuBar

public void setMenuBar(MenuBar menuBar)
Sets a MenuBar for this Application.


setToolBar

public void setToolBar(ToolBar toolBar)
Sets a ToolBar for this view.


setToolBar

public void setToolBar(ToolBar toolBar,
                       ToolBar.Position position)
Sets a ToolBar for this Application.


setStatusBar

public void setStatusBar(StatusBar statusBar)
Sets a StatusBar for this Application.


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.


setUncaughtExceptionHandler

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


showMessage

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


handleEvent

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


handleEvent

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

Overrides:
handleEvent in class Controller

handleEvent

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

When a StatusBar is set and MessageEventType is PLAIN, the message is displayed on the status bar. Otherwise the message is shown in an alert dialog.

See Also:
StatusBar, Application#showMessage(String, MessageEventType)

handleEvent

public void handleEvent(ProgressEvent evt)
Default handling of ProgressEvent.
 ProgressEventType.START -> change the mouse cursor shape to Cursor.WAIT_CURSOR
 ProgressEventType.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
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

main

public static void main(String[] args)


Copyright 2010 CodeRight, All rights reserved.