org.opensubsystems.core.application.swt
Class SWTThickClientGui

java.lang.Object
  extended by org.opensubsystems.core.application.swt.SWTThickClientGui
All Implemented Interfaces:
ThickClientGui

public class SWTThickClientGui
extends java.lang.Object
implements ThickClientGui

Implementation of ThickClientGui using SWT library.

Version:
$Id: SWTThickClientGui.java,v 1.15 2007/01/07 06:14:22 bastafidli Exp $
Author:
Miro Halas
Code reviewer:
Miro Halas
Code reviewed:
1.11 2006/04/05 04:58:04 bastafidli

Field Summary
static int DEFAULT_MODULE_ICON_HEIGHT
          Default height of the icon to access modules.
static int DEFAULT_MODULE_ICON_TEXT
          Default size of the text under icon to access modules.
static int DEFAULT_MODULE_ICON_WIDTH
          Default width of the icon to access modules.
protected  org.eclipse.swt.graphics.Image m_blueImage
          Blue image to use in module toolbar.
protected  ThickClient m_client
          Client for which to display the gui.
protected  org.eclipse.swt.widgets.Composite m_clientArea
          Control representing client area of the application.
protected  org.eclipse.swt.widgets.Display m_display
          Display object used to render on the screen.
protected  org.eclipse.swt.graphics.Image m_grayImage
          Gray image to use in module toolbar.
protected  org.eclipse.swt.graphics.Image m_greenImage
          Green image to use in module toolbar.
protected  org.eclipse.swt.graphics.Image m_iconImage
          Icon to use for the application.or null if no icon was defined.
protected  int m_iMainWindowStyle
          Style used to construct the main window.
protected  org.eclipse.swt.graphics.Image m_logoImage
          Logo of the customer to display when the application is starting.
protected  org.eclipse.swt.widgets.CoolBar m_mainToolBar
          Main toolbar of the application
protected  java.util.Map m_mapModuleToolItems
          Toolbar buttons created for individual modules.
protected  org.eclipse.swt.widgets.ToolBar m_moduleBar
          Toolbar containing buttons representing modules allowing user to switch from module to module.
protected  org.eclipse.swt.graphics.Font m_moduleBarFont
          Font used by buttons at module bar.
protected  org.eclipse.swt.widgets.CoolItem m_moduleBarItem
          Toolbar item containing module toolbar.
protected  org.eclipse.swt.graphics.Image m_redImage
          Red image to use in module toolbar.
protected  org.eclipse.swt.widgets.Shell m_shell
          Main window shell.
protected  org.eclipse.swt.graphics.Image m_splashImage
          Splash image to display when the application is starting.
protected  org.eclipse.swt.graphics.Image m_yellowImage
          Yellow image to use in module toolbar.
static java.lang.String SWT_GUI_TECHNOLOGY
          Name of GUI technology used to build the thick client.
static int SWT_MESSAGE_ERROR
          Flags required to display error message.
static int SWT_MESSAGE_INFO
          Flags required to display information message.
static int SWT_MESSAGE_YES_NO_QUESTION
          Flags required to display message with yes/no question.
 
Fields inherited from interface org.opensubsystems.core.application.ThickClientGui
GUI_ANYWHERE, GUI_FULLSCREEN, GUI_LEFTSCREEN, GUI_RIGHTSCREEN, MESSAGE_ANSWER_YES, MESSAGE_STYLE_ERROR, MESSAGE_STYLE_INFO, MESSAGE_STYLE_YES_NO_QUESTION, MESSAGE_TITLE_ERROR, MESSAGE_TITLE_INFO, MESSAGE_TITLE_QUESTION
 
Constructor Summary
SWTThickClientGui()
          Construct instance of the thick client gui.
 
Method Summary
 void activateModule(ThickClientModule module)
          Activate specified module so that it is available for user interaction.
protected  void addModule(ThickClientModule module)
          Add module to the gui
 void createClientArea()
          Create client area of the application.
 void createDisplayResources(boolean bHideCursor)
          Initialize any resources which are required by gui.
 void createMainWindow()
          Create the main window of the application with all the default elements, such as toolbar and main client area.
 void createModules(java.util.Map mapModules)
          Create graphical representation of specified modules
 void destroyClientArea()
          Release and destroy resources allocated for the client area.
 void destroyDisplayResources()
          Release resources allocated by GUI.
 void destroyMainWindow()
          Destroy all resources allocated when main window was created.
 void destroyModules(java.util.Map mapModules)
          Destroy graphical representation of specified modules
 org.eclipse.swt.graphics.Rectangle determineClientArea(org.eclipse.swt.widgets.Display display, int iScreenPosition, boolean bFixedSize)
          Determine the client area which should be occupied by the GUI.
 void displayMainWindow(int iScreenPosition, boolean bFixedSize)
          Display the main application window.
protected  int displayMessage(org.eclipse.swt.widgets.Shell shell, java.lang.String strTitle, java.lang.String strMessage, int iStyle)
          Display message to user.
 java.lang.Object displayMessage(org.eclipse.swt.widgets.Shell shell, java.lang.String strTitle, java.lang.String strMessage, java.lang.Object additionalInfo)
          Display message to user.
 java.lang.Object displayMessage(java.lang.String strTitle, java.lang.String strMessage, java.lang.Object additionalInfo)
          Display message to user.
protected  java.lang.Object getAnswer(int iAnswer)
          Convert the passed in SWT answer into a predefined answer
 org.eclipse.swt.widgets.Composite getClientArea()
          Get client area of the application
 org.eclipse.swt.widgets.Display getDisplay()
          Get display device used by the aplication.
 java.lang.String getGuiTechnology()
          Return String identifier for the GUI technology used by the instance of thick client.
 org.eclipse.swt.graphics.Image getIconImage()
          Get icon to use for this application.
 org.eclipse.swt.widgets.Shell getShell()
          Get main shell of the aplication.
 org.eclipse.swt.graphics.Image[] getSolidColorImages()
          Get images representing solid colors
protected  int getStyle(java.lang.Object objStyle)
          Convert the passed in style into valid SWT style.
 void init(ThickClient client)
          Initialize the gui for a give client
 void interactWithUser()
          Main message loop which processes messages for the application caused by user actions such as typing or mouse clicks.
 void pasivateModule(ThickClientModule module)
          Pasivate the specified module so that it is not available for user interaction anymore.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SWT_GUI_TECHNOLOGY

public static final java.lang.String SWT_GUI_TECHNOLOGY
Name of GUI technology used to build the thick client.

See Also:
Constant Field Values

DEFAULT_MODULE_ICON_WIDTH

public static final int DEFAULT_MODULE_ICON_WIDTH
Default width of the icon to access modules.

See Also:
Constant Field Values

DEFAULT_MODULE_ICON_HEIGHT

public static final int DEFAULT_MODULE_ICON_HEIGHT
Default height of the icon to access modules.

See Also:
Constant Field Values

DEFAULT_MODULE_ICON_TEXT

public static final int DEFAULT_MODULE_ICON_TEXT
Default size of the text under icon to access modules.

See Also:
Constant Field Values

SWT_MESSAGE_YES_NO_QUESTION

public static final int SWT_MESSAGE_YES_NO_QUESTION
Flags required to display message with yes/no question.

See Also:
Constant Field Values

SWT_MESSAGE_ERROR

public static final int SWT_MESSAGE_ERROR
Flags required to display error message.

See Also:
Constant Field Values

SWT_MESSAGE_INFO

public static final int SWT_MESSAGE_INFO
Flags required to display information message.

See Also:
Constant Field Values

m_client

protected ThickClient m_client
Client for which to display the gui.


m_iMainWindowStyle

protected int m_iMainWindowStyle
Style used to construct the main window.


m_iconImage

protected org.eclipse.swt.graphics.Image m_iconImage
Icon to use for the application.or null if no icon was defined.


m_blueImage

protected org.eclipse.swt.graphics.Image m_blueImage
Blue image to use in module toolbar.


m_redImage

protected org.eclipse.swt.graphics.Image m_redImage
Red image to use in module toolbar.


m_greenImage

protected org.eclipse.swt.graphics.Image m_greenImage
Green image to use in module toolbar.


m_yellowImage

protected org.eclipse.swt.graphics.Image m_yellowImage
Yellow image to use in module toolbar.


m_grayImage

protected org.eclipse.swt.graphics.Image m_grayImage
Gray image to use in module toolbar.


m_display

protected org.eclipse.swt.widgets.Display m_display
Display object used to render on the screen.


m_shell

protected org.eclipse.swt.widgets.Shell m_shell
Main window shell.


m_moduleBarFont

protected org.eclipse.swt.graphics.Font m_moduleBarFont
Font used by buttons at module bar.


m_clientArea

protected org.eclipse.swt.widgets.Composite m_clientArea
Control representing client area of the application.


m_mainToolBar

protected org.eclipse.swt.widgets.CoolBar m_mainToolBar
Main toolbar of the application


m_moduleBar

protected org.eclipse.swt.widgets.ToolBar m_moduleBar
Toolbar containing buttons representing modules allowing user to switch from module to module.


m_moduleBarItem

protected org.eclipse.swt.widgets.CoolItem m_moduleBarItem
Toolbar item containing module toolbar.


m_splashImage

protected org.eclipse.swt.graphics.Image m_splashImage
Splash image to display when the application is starting.


m_logoImage

protected org.eclipse.swt.graphics.Image m_logoImage
Logo of the customer to display when the application is starting.


m_mapModuleToolItems

protected java.util.Map m_mapModuleToolItems
Toolbar buttons created for individual modules. Key is the module name value is the tool item.

Constructor Detail

SWTThickClientGui

public SWTThickClientGui()
Construct instance of the thick client gui.

Method Detail

getDisplay

public org.eclipse.swt.widgets.Display getDisplay()
Get display device used by the aplication.

Returns:
Display

getShell

public org.eclipse.swt.widgets.Shell getShell()
Get main shell of the aplication.

Returns:
Shell

getClientArea

public org.eclipse.swt.widgets.Composite getClientArea()
Get client area of the application

Returns:
Composite

getIconImage

public org.eclipse.swt.graphics.Image getIconImage()
Get icon to use for this application.

Returns:
Image

getSolidColorImages

public org.eclipse.swt.graphics.Image[] getSolidColorImages()
Get images representing solid colors

Returns:
Image[] - array of solid color images in order, blue, red, green yellow, gray

init

public void init(ThickClient client)
Initialize the gui for a give client

Specified by:
init in interface ThickClientGui
Parameters:
client - - client to initialize the gui for

createDisplayResources

public void createDisplayResources(boolean bHideCursor)
Initialize any resources which are required by gui. These resources are usually required to be created only once and then can be reused over and over. This method doesn't do any cleanup in case of problems. Regardless if this method suceeds or fails, caller is responsible for calling destroyDisplayResources in finally clause.

Specified by:
createDisplayResources in interface ThickClientGui
Parameters:
bHideCursor - - hide cursor since it might be distracting

destroyDisplayResources

public void destroyDisplayResources()
Release resources allocated by GUI. This releases resources allocated in createDisplayResources and any global resources.

Specified by:
destroyDisplayResources in interface ThickClientGui

createMainWindow

public void createMainWindow()
Create the main window of the application with all the default elements, such as toolbar and main client area.

Specified by:
createMainWindow in interface ThickClientGui

destroyMainWindow

public void destroyMainWindow()
Destroy all resources allocated when main window was created. This must be called in finally clause of try block where createMainWindow was called.

Specified by:
destroyMainWindow in interface ThickClientGui

createModules

public void createModules(java.util.Map mapModules)
                   throws OSSException
Create graphical representation of specified modules

Specified by:
createModules in interface ThickClientGui
Parameters:
mapModules - - key is module identification and value is the module itself (ThickClientModule).
Throws:
OSSException - - an error has occured

destroyModules

public void destroyModules(java.util.Map mapModules)
Destroy graphical representation of specified modules

Specified by:
destroyModules in interface ThickClientGui
Parameters:
mapModules - - key is module identification and value is the module itself (ThickClientModule).

pasivateModule

public void pasivateModule(ThickClientModule module)
Pasivate the specified module so that it is not available for user interaction anymore.

Specified by:
pasivateModule in interface ThickClientGui
Parameters:
module - - module to pasivate

activateModule

public void activateModule(ThickClientModule module)
Activate specified module so that it is available for user interaction.

Specified by:
activateModule in interface ThickClientGui
Parameters:
module - - module to activate

createClientArea

public void createClientArea()
Create client area of the application.

Specified by:
createClientArea in interface ThickClientGui

destroyClientArea

public void destroyClientArea()
Release and destroy resources allocated for the client area. This must be called in finally clause of try block where createMainArea was called.

Specified by:
destroyClientArea in interface ThickClientGui

displayMainWindow

public void displayMainWindow(int iScreenPosition,
                              boolean bFixedSize)
Display the main application window. This method should be called when the application is ready to be displayed on the screen and interact with the user.

Specified by:
displayMainWindow in interface ThickClientGui
Parameters:
iScreenPosition - - screen position where to display the gui
bFixedSize - - should the gui be fixed size

interactWithUser

public void interactWithUser()
Main message loop which processes messages for the application caused by user actions such as typing or mouse clicks.

Specified by:
interactWithUser in interface ThickClientGui

getGuiTechnology

public java.lang.String getGuiTechnology()
Return String identifier for the GUI technology used by the instance of thick client.

Specified by:
getGuiTechnology in interface ThickClientGui
Returns:
String - name of the GUI technology used for the thick client

determineClientArea

public org.eclipse.swt.graphics.Rectangle determineClientArea(org.eclipse.swt.widgets.Display display,
                                                              int iScreenPosition,
                                                              boolean bFixedSize)
Determine the client area which should be occupied by the GUI. Based on the options specified when the user was started this may try to maximize the area occupied by the application or position it to a specific location of the screen.

Parameters:
display - - display which is used to display GUI
iScreenPosition - - screen position for which to determine the area, one of the GUI constants
bFixedSize - - should the gui be fixed size
Returns:
Rectangle - area which should be occupied by GUI

displayMessage

public java.lang.Object displayMessage(java.lang.String strTitle,
                                       java.lang.String strMessage,
                                       java.lang.Object additionalInfo)
Display message to user.

Specified by:
displayMessage in interface ThickClientGui
Parameters:
strTitle - - title of the message, look at constants in this interface
strMessage - - message to display
additionalInfo - - additional information to pass in, this may be implementation specific, look at constants in this interface
Returns:
Object - result of the message, this may be implementation specific

displayMessage

public java.lang.Object displayMessage(org.eclipse.swt.widgets.Shell shell,
                                       java.lang.String strTitle,
                                       java.lang.String strMessage,
                                       java.lang.Object additionalInfo)
Display message to user.

Parameters:
shell - - shell which should display the message
strTitle - - title of the message, look at constants in this interface
strMessage - - message to display
additionalInfo - - additional information to pass in, this may be implementation specific, look at constants in this interface
Returns:
Object - result of the message, this may be implementation specific

displayMessage

protected int displayMessage(org.eclipse.swt.widgets.Shell shell,
                             java.lang.String strTitle,
                             java.lang.String strMessage,
                             int iStyle)
Display message to user.

Parameters:
shell - - shell which should display the message
strTitle - - title of the message
strMessage - - message to display
iStyle - - style of the message box to display
Returns:
int - result of the message box

addModule

protected void addModule(ThickClientModule module)
Add module to the gui

Parameters:
module - - module to add

getStyle

protected int getStyle(java.lang.Object objStyle)
Convert the passed in style into valid SWT style.

Parameters:
objStyle - - one of the style constants in ThickClientGui
Returns:
int - valid SWT style

getAnswer

protected java.lang.Object getAnswer(int iAnswer)
Convert the passed in SWT answer into a predefined answer

Parameters:
iAnswer - - SWT answer
Returns:
Object - one of asnwers defined in ThickClientGui or an Integer value of the answer


Copyright © 2003 - 2006 OpenSubsystems s.r.o.