org.openbp.jaspira.gui.plugin
Class ApplicationBase

java.lang.Object
  extended by org.openbp.jaspira.plugin.AbstractPlugin
      extended by org.openbp.jaspira.gui.plugin.ApplicationBase
All Implemented Interfaces:
Plugin
Direct Known Subclasses:
Cockpit

public abstract class ApplicationBase
extends AbstractPlugin

The application base is the base class for any Jaspira application main class. Derive any main application class from this one. The constructor of this class will register the application base as a regular plugin. In order to perform initialization routines and loader plugins, override the preInstallApplication() and postInstallApplication() template methods. The application base also keeps track of the frames (JaspiraPageContainer) of the application.

Author:
Heiko Erhardt

Nested Class Summary
 class ApplicationBase.CloseEvents
          Event module.
 class ApplicationBase.MenuInteractionEvents
          Interaction module that handles activations of the application-related menu items.
 class ApplicationBase.PageInteractionEvents
          Interaction module that creates the popup menu for the Jaspira page buttons on the left of the main window.
 
Nested classes/interfaces inherited from class org.openbp.jaspira.plugin.AbstractPlugin
AbstractPlugin.StandardPluginEvents
 
Field Summary
 
Fields inherited from class org.openbp.jaspira.plugin.AbstractPlugin
PROPERTY_CONDITION, PROPERTY_DESCRIPTION, PROPERTY_ICON, PROPERTY_NAME, PROPERTY_SEQUENCE, PROPERTY_TITLE, PROPERTY_VENDOR, PROPERTY_VERSION
 
Fields inherited from interface org.openbp.jaspira.plugin.Plugin
ID_DELIMETER, LEVEL_APPLICATION, LEVEL_FRAME, LEVEL_PAGE, LEVEL_PLUGIN
 
Constructor Summary
ApplicationBase()
          Constructor.
 
Method Summary
 JaspiraPageContainer addFrame(JaspiraPage page)
          Adds the given page as new maximized frame to the application using the current graphics configuration.
 JaspiraPageContainer addFrame(JaspiraPage page, java.awt.Dimension d, int state)
          Adds the given page as new frame to the application using the current graphics configuration.
 JaspiraPageContainer addFrame(JaspiraPage page, java.awt.Dimension d, int state, java.awt.GraphicsConfiguration gc)
          Adds the given page as new frame to the application.
 JaspiraPage addPage(JaspiraPage page)
          Adds a new page to the active frame.
 void buildMenus()
          Updates the menus of the frames of the application.
protected  java.lang.Class getAboutBoxClass()
          Returns the class of the about box plugin.
 JaspiraPageContainer getActiveFrame()
          Returns the active frame of the application.
 VisiblePlugin getActivePlugin()
          Gets the active plugin or null.
 int getFrameCount()
          Returns the numbers of frames of this application.
static ApplicationBase getInstance()
          Returns the singleton instance of the application base.
 JaspiraPage getPage()
          Returns the page level parent plugin of this plugin.
 boolean hasFrameForGraphicsConfiguration(java.awt.GraphicsConfiguration gc)
          Checks if there is already a frame for the given graphics configuration.
static boolean hasInstance()
          Checks if an instance of the application base has been set.
protected  void installLookAndFeel()
          Installs the Look and feel of this application.
 void installPlugin()
          Installs the plugin and all its modules.
static boolean isInitialized()
          Checks the initialization status of the application.
protected  void postInstallApplication()
          Template method that is called after the actual installation of the application base plugin is performed.
protected  void preInstallApplication()
          Template method that is called before the actual installation of the application base plugin is performed.
 void showPage(JaspiraPage page)
          Shows the given page.
 void showStatusText(java.lang.String text)
          Shows a message in the status bar.
 
Methods inherited from class org.openbp.jaspira.plugin.AbstractPlugin
addActionKeySequence, addPlugin, addToPeerGroup, canClose, closeCanceled, containsStackedEvent, fireEvent, fireEvent, fireEvent, getAction, getChildPlugins, getClassName, getCondition, getDescendantPlugins, getDescription, getEventActionNames, getEventModules, getExternalActions, getExternalEventModuleClasses, getExternalOptionModuleClasses, getIcon, getIcon, getLevel, getName, getOptionModules, getParentPlugin, getPeerGroup, getPeerGroupNames, getPeerGroups, getPluginResourceCollection, getPluginState, getResourceCollectionContainerName, getSubClients, getSubTitle, getTitle, getUniqueId, getVendor, getVersion, handleEvent, handleKeySequence, inheritEvent, initializeFromPluginProfile, initializePlugin, initializeResources, installFirstPlugin, installPluginContent, matchesPeerGroup, matchesPeerGroups, passDown, pluginInstalled, pluginUninstalled, preClose, receiveEvent, removeFromPeerGroup, removePlugin, removeStackedEvent, requestClose, setDescription, setIcon, setName, setParentPlugin, setPluginState, setResourceCollection, setTitle, stackEvent, toString, uninstallLastPlugin, uninstallPlugin
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ApplicationBase

public ApplicationBase()
Constructor. Initializes the application. This will register the ApplicationBase as a regular plugin. This in turn will invoke the AbstractPlugin.initializePlugin() method, which may perform further plugin loading etc.

Method Detail

getInstance

public static ApplicationBase getInstance()
Returns the singleton instance of the application base. Note that this method does not construct the application base. This is usually done by instantiating the application class derived from ApplicationBase and registering it with the PluginMgr The constructor, which will be invoked by the application loader, will set the singleton instance. If the construction has not been performed, this method will throw a RuntimeException.


hasInstance

public static boolean hasInstance()
Checks if an instance of the application base has been set. This method serves the purpose to prevent getInstance() throwing an exception in cases where no application base object exists. It is e. g. used by the OptionMgr which may be used in command line applications as well.

Returns:
true getInstance() can be called safely. false No application object has been instantiated yet.

isInitialized

public static final boolean isInitialized()
Checks the initialization status of the application.

Returns:
true If the application initialization is finished.
false If the application initialization is still in progress.

installPlugin

public void installPlugin()
Installs the plugin and all its modules. Should only be called by the plugin manager.

Specified by:
installPlugin in interface Plugin
Overrides:
installPlugin in class AbstractPlugin

preInstallApplication

protected void preInstallApplication()
Template method that is called before the actual installation of the application base plugin is performed.


postInstallApplication

protected void postInstallApplication()
Template method that is called after the actual installation of the application base plugin is performed.


installLookAndFeel

protected void installLookAndFeel()
Installs the Look and feel of this application. If you want to use a different LookAndFeel or another behavior, override this method. The default LookAndFeel is the sky PLAF.


getAboutBoxClass

protected java.lang.Class getAboutBoxClass()
Returns the class of the about box plugin. Override this to return your own AboutBoxPlugin plugin.


addFrame

public JaspiraPageContainer addFrame(JaspiraPage page,
                                     java.awt.Dimension d,
                                     int state,
                                     java.awt.GraphicsConfiguration gc)
Adds the given page as new frame to the application. Creates a new frame and adds the page to it.

Parameters:
page - Page to add
d - Dimension of the new frame
state - Initial window state (regular, maximized etc.)
gc - Graphics configuration to use for the new frame
Returns:
The new frame

addFrame

public JaspiraPageContainer addFrame(JaspiraPage page,
                                     java.awt.Dimension d,
                                     int state)
Adds the given page as new frame to the application using the current graphics configuration. Convenience method.

Parameters:
page - Page to add
d - Dimension of the new frame
state - Initial window state (regular, maximized etc.)
Returns:
The new frame

addFrame

public JaspiraPageContainer addFrame(JaspiraPage page)
Adds the given page as new maximized frame to the application using the current graphics configuration. Convenience method.

Parameters:
page - Page to add
Returns:
The new frame

getFrameCount

public int getFrameCount()
Returns the numbers of frames of this application.


addPage

public JaspiraPage addPage(JaspiraPage page)
Adds a new page to the active frame. If there is no active frame, a new frame will be created.

Parameters:
page - Page to add
Returns:
The argument

showPage

public void showPage(JaspiraPage page)
Shows the given page. The method will activate the page and bring the frame it contains to the front.

Parameters:
page - Page to show

hasFrameForGraphicsConfiguration

public boolean hasFrameForGraphicsConfiguration(java.awt.GraphicsConfiguration gc)
Checks if there is already a frame for the given graphics configuration.


getActiveFrame

public JaspiraPageContainer getActiveFrame()
Returns the active frame of the application.

Returns:
The active frame or the first frame if no frame is currently active or null if there are no frames yet

getActivePlugin

public VisiblePlugin getActivePlugin()
Gets the active plugin or null.

Returns:
The active plugin of the currently focused frame or null if no frame is focused.

buildMenus

public void buildMenus()
Updates the menus of the frames of the application.


showStatusText

public void showStatusText(java.lang.String text)
Shows a message in the status bar. Fires a StatusBarTextEvent that can be caught by the status bar plugin.

Parameters:
text - Text to display

getPage

public JaspiraPage getPage()
Returns the page level parent plugin of this plugin.

Returns:
Always null; a page container does not have a page parent


Copyright © 2011. All Rights Reserved.