com.sibvisions.rad.ui.swing.impl
Class SwingApplication

java.lang.Object
  extended by com.sibvisions.rad.ui.awt.impl.AwtResource<C>
      extended by com.sibvisions.rad.ui.awt.impl.AwtComponent<C>
          extended by com.sibvisions.rad.ui.awt.impl.AwtContainer<C>
              extended by com.sibvisions.rad.ui.swing.impl.container.SwingAbstractFrame<JFrame>
                  extended by com.sibvisions.rad.ui.swing.impl.container.SwingFrame
                      extended by com.sibvisions.rad.ui.swing.impl.SwingApplication
All Implemented Interfaces:
ComponentListener, KeyListener, MouseListener, WindowListener, EventListener, ILauncher, IFrame, IToolBarPanel, IWindow, IAlignmentConstants, IComponent, IContainer, IResource, IExceptionListener, INamedObject

public class SwingApplication
extends SwingFrame
implements ILauncher

The SwingApplication is the IApplication implementation for swing applications with full access to the JFrame.


Field Summary
static String PROPERTY_APPLICATION
          the property name for the application (client properties).
 
Fields inherited from class com.sibvisions.rad.ui.swing.impl.container.SwingAbstractFrame
bDisposed, eventWindowActivated, eventWindowClosed, eventWindowClosing, eventWindowDeactivated, eventWindowDeiconified, eventWindowIconified, eventWindowOpened, iconImage, menuBar
 
Fields inherited from class com.sibvisions.rad.ui.awt.impl.AwtComponent
eventComponentMoved, eventComponentResized, eventSource, factory, parent
 
Fields inherited from class com.sibvisions.rad.ui.awt.impl.AwtResource
resource
 
Fields inherited from interface javax.rad.application.ILauncher
ENVIRONMENT_DESKTOP, ENVIRONMENT_HEADLESS, ENVIRONMENT_MOBILE, ENVIRONMENT_WEB, PARAM_APPLICATIONLANGUAGE, PARAM_APPLICATIONNAME, PARAM_CODEBASE, PARAM_ENVIRONMENT, PARAM_LOGFACTORY, PARAM_SERVERBASE, PARAM_UIFACTORY
 
Fields inherited from interface javax.rad.ui.container.IFrame
ICONIFIED, MAXIMIZED_BOTH, MAXIMIZED_HORIZ, MAXIMIZED_VERT, NORMAL
 
Fields inherited from interface javax.rad.ui.container.IToolBarPanel
AREA_BOTTOM, AREA_LEFT, AREA_RIGHT, AREA_TOP
 
Fields inherited from interface javax.rad.ui.IAlignmentConstants
ALIGN_BOTTOM, ALIGN_CENTER, ALIGN_LEFT, ALIGN_RIGHT, ALIGN_STRETCH, ALIGN_TOP
 
Constructor Summary
SwingApplication()
          Creates a new instance of SwingApplication.
SwingApplication(String pApplicationClassName, String pConfigFileName, String[] pParams)
          Creates a new instance of SwingApplication with the desired application.
 
Method Summary
protected  void addIntern(Component pComponent, Object pConstraints, int pIndex)
          Internal function, for adding physical component and supporting layers.
 void cancelPendingThreads()
          Cancel/Interrupts all pending threads.
 IImage capture(int pWidth, int pHeight)
          Creates an image/screenshot of the component.
 void dispose()
          Marks the frame as disposed.
 IApplication getApplication()
          Gets the launched application.
 String getEnvironmentName()
          Gets the name of the environment for this launcher.
 void getFileHandle(IFileHandleReceiver pFileHandleReceiver, String pTitle)
          Technology independent getFileHandle.
 String getParameter(String pName)
          Gets a configuration parameter of the application.
 String getRegistryKey(String pKey)
          Gets the value for a specific key from the applications registry.
 void handleException(Throwable pThrowable)
          Notification for the listener to handle an exception occured in another part of the program.
static void main(String[] pArguments)
          Starts the application as frame.
protected  void removeIntern(Component pComponent)
          Internal function, for adding physical component and supporting layers.
 void saveFileHandle(IFileHandle pFileHandle, String pTitle)
          Technology independent saveFileHandle.
protected  void setLayoutIntern(LayoutManager pLayoutManager)
          Internal function, for setting the layout.
 void setMenuBar(IMenuBar pMenuBar)
          Sets the menubar for this frame.
 void setParameter(String pName, String pValue)
          Sets a configuration parameter of the application.
 void setRegistryKey(String pKey, String pValue)
          Sets the value for a specific key to the applications registry.
 void showDocument(String pDocumentName, IRectangle pBounds, String pTarget)
          Requests that external application shows a document indicated by the pDocumentname argument.
 void showFileHandle(IFileHandle pFileHandle)
          Technology independent showFileHandle.
 void showFileHandle(IFileHandle pFileHandle, IRectangle pBounds, String pTarget)
          Technology independent showFileHandle.
 void startup(String pApplicationClassName, String pConfigFileName, String[] pParams)
          Starts the application in the UI thread.
 
Methods inherited from class com.sibvisions.rad.ui.swing.impl.container.SwingFrame
centerRelativeTo, getState, getTitle, isActive, isResizable, pack, setIconImage, setResizable, setState, setTitle, setVisible, toBack, toFront, windowActivated, windowClosed, windowClosing, windowDeactivated, windowDeiconified, windowIconified, windowOpened
 
Methods inherited from class com.sibvisions.rad.ui.swing.impl.container.SwingAbstractFrame
addToolBar, addToolBar, addToolBarIntern, eventWindowActivated, eventWindowClosed, eventWindowClosing, eventWindowDeactivated, eventWindowDeiconified, eventWindowIconified, eventWindowOpened, getIconImage, getMenuBar, getToolBar, getToolBarArea, getToolBarCount, indexOfToolBar, isDisposed, removeAllToolBars, removeToolBar, removeToolBar, removeToolBarIntern, setCursor, setToolBarArea
 
Methods inherited from class com.sibvisions.rad.ui.awt.impl.AwtContainer
add, add, add, add, checkAdd, getComponent, getComponentCount, getLayout, indexOf, remove, remove, removeAll, setLayout
 
Methods inherited from class com.sibvisions.rad.ui.awt.impl.AwtComponent
componentHidden, componentMoved, componentResized, componentShown, createImage, eventComponentMoved, eventComponentResized, eventKeyPressed, eventKeyReleased, eventKeyTyped, eventMouseClicked, eventMouseEntered, eventMouseExited, eventMousePressed, eventMouseReleased, getBackground, getBounds, getCursor, getEventSource, getFactory, getFont, getForeground, getHorizontalAlignment, getLocation, getLocationRelativeTo, getMaximumSize, getMinimumSize, getName, getParent, getPreferredSize, getSize, getToolTipText, getVerticalAlignment, isBackgroundSet, isCursorSet, isEnabled, isFocusable, isFontSet, isForegroundSet, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isVisible, keyPressed, keyReleased, keyTyped, mouseClicked, mouseEntered, mouseExited, mousePressed, mouseReleased, requestFocus, setBackground, setBounds, setEnabled, setEventSource, setFactory, setFocusable, setFont, setForeground, setHorizontalAlignment, setLocation, setLocationRelativeTo, setMaximumSize, setMinimumSize, setName, setParent, setPreferredSize, setSize, setToolTipText, setVerticalAlignment, validate
 
Methods inherited from class com.sibvisions.rad.ui.awt.impl.AwtResource
equals, getResource, hashCode, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface javax.rad.ui.container.IFrame
getIconImage, getMenuBar, getState, getTitle, isResizable, setIconImage, setResizable, setState, setTitle
 
Methods inherited from interface javax.rad.ui.container.IWindow
centerRelativeTo, eventWindowActivated, eventWindowClosed, eventWindowClosing, eventWindowDeactivated, eventWindowDeiconified, eventWindowIconified, eventWindowOpened, isActive, isDisposed, pack, toBack, toFront
 
Methods inherited from interface javax.rad.ui.container.IToolBarPanel
addToolBar, addToolBar, getToolBar, getToolBarArea, getToolBarCount, indexOfToolBar, removeAllToolBars, removeToolBar, removeToolBar, setToolBarArea
 
Methods inherited from interface javax.rad.ui.IContainer
add, add, add, add, getComponent, getComponentCount, getLayout, indexOf, remove, remove, removeAll, setLayout
 
Methods inherited from interface javax.rad.ui.IComponent
eventComponentMoved, eventComponentResized, eventKeyPressed, eventKeyReleased, eventKeyTyped, eventMouseClicked, eventMouseEntered, eventMouseExited, eventMousePressed, eventMouseReleased, getBackground, getBounds, getCursor, getEventSource, getFactory, getFont, getForeground, getLocation, getLocationRelativeTo, getMaximumSize, getMinimumSize, getName, getParent, getPreferredSize, getSize, getToolTipText, isBackgroundSet, isCursorSet, isEnabled, isFocusable, isFontSet, isForegroundSet, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isVisible, requestFocus, setBackground, setBounds, setCursor, setEnabled, setEventSource, setFocusable, setFont, setForeground, setLocation, setLocationRelativeTo, setMaximumSize, setMinimumSize, setName, setParent, setPreferredSize, setSize, setToolTipText, setVisible
 
Methods inherited from interface javax.rad.ui.IResource
getResource
 

Field Detail

PROPERTY_APPLICATION

public static final String PROPERTY_APPLICATION
the property name for the application (client properties).

See Also:
Constant Field Values
Constructor Detail

SwingApplication

public SwingApplication()
Creates a new instance of SwingApplication. Use this constructor if you need access to the frame before the application is started.

See Also:
startup(String, String, String[])

SwingApplication

public SwingApplication(String pApplicationClassName,
                        String pConfigFileName,
                        String[] pParams)
Creates a new instance of SwingApplication with the desired application.

Parameters:
pApplicationClassName - the full qualified class name of the IApplication to run.
pConfigFileName - gives the name of the configuration file (default: application.xml)
pParams - additional or preferred parameters. The parameters overrides the parameters from the config file
Method Detail

main

public static void main(String[] pArguments)
Starts the application as frame. The first argument should give the full qualified class name of the application to run.

Parameters:
pArguments - the launcher arguments: main-class [config.xml key1=value1 key2=value2]

startup

public void startup(String pApplicationClassName,
                    String pConfigFileName,
                    String[] pParams)
Starts the application in the UI thread.

Parameters:
pApplicationClassName - the full qualified class name of the IApplication to run.
pConfigFileName - gives the name of the configuration file (default: application.xml)
pParams - additional or preferred parameters. The parameters overrides the parameters from the config file

dispose

public void dispose()
Marks the frame as disposed.

Specified by:
dispose in interface IWindow
Overrides:
dispose in class SwingFrame
See Also:
IWindow.pack(), IComponent.setVisible(boolean)

setMenuBar

public void setMenuBar(IMenuBar pMenuBar)
Sets the menubar for this frame.

Specified by:
setMenuBar in interface IFrame
Overrides:
setMenuBar in class SwingFrame
Parameters:
pMenuBar - the menubar being placed in the frame
See Also:
IFrame.getMenuBar()

setLayoutIntern

protected void setLayoutIntern(LayoutManager pLayoutManager)
Internal function, for setting the layout.

Overrides:
setLayoutIntern in class SwingAbstractFrame<JFrame>
Parameters:
pLayoutManager - the layout

addIntern

protected void addIntern(Component pComponent,
                         Object pConstraints,
                         int pIndex)
Internal function, for adding physical component and supporting layers.

Overrides:
addIntern in class SwingAbstractFrame<JFrame>
Parameters:
pComponent - the Component to be added
pConstraints - an object expressing layout contraints for this
pIndex - the position in the container's list at which to insert the Component; -1 means insert at the end component
See Also:
AwtContainer.add(IComponent, Object, int)

removeIntern

protected void removeIntern(Component pComponent)
Internal function, for adding physical component and supporting layers.

Overrides:
removeIntern in class SwingAbstractFrame<JFrame>
Parameters:
pComponent - the Component to be removed
See Also:
AwtContainer.remove(int)

capture

public IImage capture(int pWidth,
                      int pHeight)
Creates an image/screenshot of the component.

Specified by:
capture in interface IComponent
Overrides:
capture in class AwtComponent<JFrame>
Parameters:
pWidth - the expected width
pHeight - the expected height
Returns:
the image/screenshot

getParameter

public String getParameter(String pName)
Gets a configuration parameter of the application.

Specified by:
getParameter in interface ILauncher
Parameters:
pName - the parameter name
Returns:
the value of the parameter or null if the parameter does not exist

setParameter

public void setParameter(String pName,
                         String pValue)
Sets a configuration parameter of the application.

Specified by:
setParameter in interface ILauncher
Parameters:
pName - the parameter name
pValue - the value for the parameter or null to delete the parameter

showDocument

public void showDocument(String pDocumentName,
                         IRectangle pBounds,
                         String pTarget)
                  throws Throwable
Requests that external application shows a document indicated by the pDocumentname argument. The target argument indicates where the document should be displayed. Applications can also ignore the target information.

Specified by:
showDocument in interface ILauncher
Parameters:
pDocumentName - the location/filename of the document. (local or network adress)
pBounds - the bounds for the document, if supported from the implementation
pTarget - a String indicating where to display the document.
Throws:
Throwable - if the document couldn't opened/shown

showFileHandle

public void showFileHandle(IFileHandle pFileHandle,
                           IRectangle pBounds,
                           String pTarget)
                    throws Throwable
Technology independent showFileHandle. A file chooser dialog should occur. This Function returns immediate.

Specified by:
showFileHandle in interface ILauncher
Parameters:
pFileHandle - the IFileHandle to save.
pBounds - the bounds for the document, if supported from the implementation
pTarget - a String indicating where to display the document.
Throws:
Throwable - if an error occurs during saving the file.

showFileHandle

public void showFileHandle(IFileHandle pFileHandle)
                    throws Throwable
Technology independent showFileHandle. A file chooser dialog should occur. This Function returns immediate.

Specified by:
showFileHandle in interface ILauncher
Parameters:
pFileHandle - the IFileHandle to save.
Throws:
Throwable - if an error occurs during saving the file.

saveFileHandle

public void saveFileHandle(IFileHandle pFileHandle,
                           String pTitle)
                    throws Throwable
Technology independent saveFileHandle. A file chooser dialog should occur. This Function returns immediate.

Specified by:
saveFileHandle in interface ILauncher
Parameters:
pFileHandle - the IFileHandle to save.
pTitle - the title for the dialog or null to set a default title
Throws:
Throwable - if an error occurs during saving the file.

getFileHandle

public void getFileHandle(IFileHandleReceiver pFileHandleReceiver,
                          String pTitle)
                   throws Throwable
Technology independent getFileHandle. A file chooser dialog should occur, and as result this function informs the IFileHandle receiver.

Specified by:
getFileHandle in interface ILauncher
Parameters:
pFileHandleReceiver - the IFileHandle receiver that should receive the file.
pTitle - the title for the dialog or null to set a default title
Throws:
Throwable - if an error occurs during getting the file.

cancelPendingThreads

public void cancelPendingThreads()
Cancel/Interrupts all pending threads.

Specified by:
cancelPendingThreads in interface ILauncher

setRegistryKey

public void setRegistryKey(String pKey,
                           String pValue)
Sets the value for a specific key to the applications registry. The registry is a local store for persistent values.

Specified by:
setRegistryKey in interface ILauncher
Parameters:
pKey - the key to set
pValue - the value to set or null to remove the key from the registry

getRegistryKey

public String getRegistryKey(String pKey)
Gets the value for a specific key from the applications registry.

Specified by:
getRegistryKey in interface ILauncher
Parameters:
pKey - the key to get
Returns:
the value for the key or null if the key is not available

getEnvironmentName

public String getEnvironmentName()
Gets the name of the environment for this launcher. The environment could be used to en-/disable features.

Specified by:
getEnvironmentName in interface ILauncher
Returns:
the name of the environment, e.g. ILauncher.ENVIRONMENT_HEADLESS, ILauncher.ENVIRONMENT_DESKTOP

handleException

public void handleException(Throwable pThrowable)
Notification for the listener to handle an exception occured in another part of the program.

Specified by:
handleException in interface IExceptionListener
Parameters:
pThrowable - the occured exception

getApplication

public IApplication getApplication()
Gets the launched application.

Returns:
the application


Copyright © 2009 SIB Visions GmbH. All Rights Reserved.