org.kalmeo.kuix.core
Class Kuix

java.lang.Object
  extended by org.kalmeo.kuix.core.Kuix

public final class Kuix
extends java.lang.Object

This class is the central class for Kuix framework management. It pertmits to load XML files, load CSS files. It contains the FrameHandler object instance that manages Frames.

Author:
bbeaulant

Field Summary
static boolean firstIsLeft
           
 
Method Summary
static PopupBox alert(java.lang.String message)
          Open an alert box with the message text and default style class.
static PopupBox alert(java.lang.String message, int options)
          Open an alert box with options.
static PopupBox alert(java.lang.String message, int options, java.lang.String firstAction, java.lang.String secondAction)
          Create an open an alert box.
static PopupBox alert(java.lang.String message, java.lang.Throwable throwable)
          Open an alert box with the Throwable object message and 'alerterror' style class.
static PopupBox alert(java.lang.Throwable throwable)
          Open an alert box with the Throwable object message and 'alerterror' style class.
static void callActionMethod(Method method)
          Call the specified action method
static void cleanUp()
          Clean all instances
static void clearStyleCache(Widget target, boolean propagateToChildren)
          Clear style cache from the specified Widget and its childs
protected static java.lang.String composeAltertMessage(java.lang.String message, java.lang.Throwable throwable)
          Compose an alert message by using the given message and throwable.
static void customizeAlertLabels(java.io.ByteArrayInputStream okLabelRenderer, java.io.ByteArrayInputStream cancelLabelRenderer, java.io.ByteArrayInputStream yesLabelRenderer, java.io.ByteArrayInputStream noLabelRenderer)
          Cutomize Kuix alert labels.
static void customizeScreenMenuLabels(java.io.ByteArrayInputStream selectLabelRenderer, java.io.ByteArrayInputStream cancelLabelRenderer)
          Cutomize Kuix screen menu labels.
static KuixCanvas getCanvas()
          Returns the KuixCanvas unique instance.
static KuixConverter getConverter()
           
static FrameHandler getFrameHandler()
           
static java.lang.String getLocale()
          Returns the last used locale, or null if never set.
static java.lang.String getMessage(java.lang.String key)
          Finds a localized string in a message bundle.
static java.lang.String getMessage(java.lang.String key, java.lang.Object[] args)
          Finds a localized string in a message bundle and formats the message by passing requested parameters.
static java.io.ByteArrayInputStream getResourceAsByteArrayInputStream(java.lang.Class clazz, java.lang.String path)
          Convert resource to a ByteArrayInputStream.
static java.util.Vector getStyles(Widget widget)
          Returns the list of Style associated to the widget or null if no style was found.
static java.io.InputStream getXmlResourceInputStream(java.lang.String xmlFilePath)
          Returns a new InputStream relative to the desired xmlFilePath.
static boolean initI18nSupport()
          Initializes internationalization support based on currently set locale (obtained from "microedition.locale" system property).
static boolean initI18nSupport(java.lang.String locale)
          Explicit initialization of the internationalization support.
static boolean initI18nSupport(java.lang.String messageBundle, java.lang.String locale)
          Explicit initialization of the internationalization support.
static void initialize(Display display, KuixCanvas canvas, KuixConverter converter)
          Initialize the Kuix engine be giving the KuixCanvas object instance.
static boolean isInitialized()
          Returns the Kuix engine initialization state.
static void loadCss(java.io.InputStream inputStream)
          Parse an load a CSS style definitions and register them.
static void loadCss(java.lang.String cssFilePath)
          Parse an load a CSS style definitions and register it into the StyleManager.
static boolean loadI18nBundle(java.lang.String messageBundle)
          Load a new bundle and append messages to the messages table.
static void loadMenuContent(Menu menu, java.io.InputStream inputStream, DataProvider dataProvider)
          Reload the first menu content from an xml definition provides by an inputStream.
static void loadMenuContent(Menu menu, java.lang.String xmlFilePath, DataProvider dataProvider)
          Reload the menu content from an xml definition.
static Screen loadScreen(java.io.InputStream inputStream, DataProvider dataProvider)
          Load a Screen widget from an XML InputStream.
static Screen loadScreen(java.lang.String xmlFilePath, DataProvider dataProvider)
          Load a Screen widget from a XML file.
static Widget loadWidget(java.io.InputStream inputStream, DataProvider dataProvider)
          Load a Widget from an XML InputStream.
static Widget loadWidget(java.lang.String xmlFilePath, DataProvider dataProvider)
          Load a Widget from a XML file.
static void loadXml(Widget rootWidget, java.io.InputStream inputStream)
          Parse and load an XML UI definition and place the content as child of rootWidget.
static void loadXml(Widget rootWidget, java.io.InputStream inputStream, DataProvider dataProvider)
          Parse and load an XML UI definition and place the content as child of rootWidget.
static void loadXml(Widget rootWidget, java.io.InputStream inputStream, DataProvider dataProvider, boolean append, boolean mergeRootWidget)
          Parse an load an XML ui definition and place the content as child of rootWidget.
static Method parseMethod(java.lang.String data, Widget owner)
          Returns the parsed Method, or null if no method could be extract.
static java.lang.String processI18nPattern(java.lang.String pattern)
          Process the internationalization and replace found keys by their values.
static void registerStyle(Style style)
          Register a Style.
static void removeAllStyles()
          Remove all registred styles
static PopupBox showPopupBox(java.io.InputStream inputStream, DataProvider dataProvider)
          Create and display a PopupBox from its XML definition.
static PopupBox showPopupBox(java.lang.String xmlFilePath, DataProvider dataProvider)
          Create and display a PopupBox from its XML definition.
static PopupBox showPopupBox(java.lang.String styleClass, int duration, java.lang.Object content, java.lang.Object firstLabel, java.lang.String firstAction, java.lang.Object secondLabel, java.lang.String secondAction, java.lang.String onCloseAction)
          Create and display a PopupBox.
static PopupBox splash(int duration, Widget content, java.lang.String onCloseAction)
          Display a splash PopupBox
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

firstIsLeft

public static boolean firstIsLeft
Method Detail

getFrameHandler

public static FrameHandler getFrameHandler()
Returns:
the frameHandler

getConverter

public static KuixConverter getConverter()
Returns:
the converter

getCanvas

public static KuixCanvas getCanvas()
Returns the KuixCanvas unique instance.

Returns:
the canvas

isInitialized

public static boolean isInitialized()
Returns the Kuix engine initialization state.

Returns:
true if the engine is initialized with a KuixCanvas.

initialize

public static void initialize(Display display,
                              KuixCanvas canvas,
                              KuixConverter converter)
Initialize the Kuix engine be giving the KuixCanvas object instance.

Parameters:
display - the Display instance. Set this value to null if you don't want the canvas is displayed during this method.
canvas -
converter -

cleanUp

public static void cleanUp()
Clean all instances


customizeAlertLabels

public static void customizeAlertLabels(java.io.ByteArrayInputStream okLabelRenderer,
                                        java.io.ByteArrayInputStream cancelLabelRenderer,
                                        java.io.ByteArrayInputStream yesLabelRenderer,
                                        java.io.ByteArrayInputStream noLabelRenderer)
Cutomize Kuix alert labels.

Parameters:
okLabelRenderer - the renderer (xml input stream) used as ok label
cancelLabelRenderer - the renderer (xml input stream) used as cancel label
yesLabelRenderer - the renderer (xml input stream) used as yes label
noLabelRenderer - the renderer (xml input stream) used as no label

customizeScreenMenuLabels

public static void customizeScreenMenuLabels(java.io.ByteArrayInputStream selectLabelRenderer,
                                             java.io.ByteArrayInputStream cancelLabelRenderer)
Cutomize Kuix screen menu labels.

Parameters:
selectLabelRenderer - the renderer (xml input stream) used as select label
cancelLabelRenderer - the renderer (xml input stream) used as cancel label

showPopupBox

public static PopupBox showPopupBox(java.lang.String xmlFilePath,
                                    DataProvider dataProvider)
Create and display a PopupBox from its XML definition.

Parameters:
xmlFilePath -
dataProvider -
Returns:
The PopupBox instance

showPopupBox

public static PopupBox showPopupBox(java.io.InputStream inputStream,
                                    DataProvider dataProvider)
Create and display a PopupBox from its XML definition.

Parameters:
inputStream -
dataProvider -
Returns:
The PopupBox instance

showPopupBox

public static PopupBox showPopupBox(java.lang.String styleClass,
                                    int duration,
                                    java.lang.Object content,
                                    java.lang.Object firstLabel,
                                    java.lang.String firstAction,
                                    java.lang.Object secondLabel,
                                    java.lang.String secondAction,
                                    java.lang.String onCloseAction)
Create and display a PopupBox. This method is a full feature of all PopupBox helpers like alert, splash.

Parameters:
styleClass - The PopupBox style class
duration - the duration of the PopupBox
content - the content could be a Widget or a String
firstLabel - the label or widget of the first button
firstAction - action of the first button
secondLabel - the label or widget of the second button
secondAction - action of the second button
buttonOnActions - The ordred buttons onAction
Returns:
The PopupBox instance

splash

public static PopupBox splash(int duration,
                              Widget content,
                              java.lang.String onCloseAction)
Display a splash PopupBox

Parameters:
duration - the duration of the splash (in ms)
content - the splash widget content
Returns:
The PopupBox instance

alert

public static PopupBox alert(java.lang.String message,
                             int options,
                             java.lang.String firstAction,
                             java.lang.String secondAction)
Create an open an alert box. An alert can only display text content. It is usful to display simple text message, error, ask question, etc...
The associated buttons are construct from the options parameter.

Example:

 alert("Hello world", KuixConstants.ALERT_OK | KuixConstants.ALERT_INFO, "doOk", null, null, null);
 alert("Is it rainning ?", KuixConstants.ALERT_YES | KuixConstants.ALERT_NO | KuixConstants.ALERT_QUESTION, null, null, "doYes", "doNo");
 
Caution :
- KuixConstants.ALERT_OK and KuixConstants.ALERT_YES are always placed on the first menuItem and then couldn't be displaye together.
- KuixConstants.ALERT_CANCEL and KuixConstants.ALERT_NO are always placed on the second menuItem and then couldn't be displaye together.

Parameters:
message - the text message to display
options - the options KuixConstants
okAction - the ok onAction name
yesAction - the yes onAction name
noAction - the no onAction name
cancelAction - the cancel onAction name
Returns:
The PopupBox instance

alert

public static PopupBox alert(java.lang.String message,
                             int options)
Open an alert box with options. This alert is a PopupBox with a single text message an single OK button. If you try to use other buttons with options, they will be ignored.

Parameters:
message - the message to display
options - KuixConstants
Returns:
The PopupBox instance

alert

public static PopupBox alert(java.lang.String message)
Open an alert box with the message text and default style class.

Parameters:
message - the message to display
Returns:
The PopupBox instance

alert

public static PopupBox alert(java.lang.String message,
                             java.lang.Throwable throwable)
Open an alert box with the Throwable object message and 'alerterror' style class.

Parameters:
message - the message to display
throwable - the Throwable to get message or class name
Returns:
The PopupBox instance

alert

public static PopupBox alert(java.lang.Throwable throwable)
Open an alert box with the Throwable object message and 'alerterror' style class.

Parameters:
throwable - the Throwable to get message or class name
Returns:
The PopupBox instance

composeAltertMessage

protected static java.lang.String composeAltertMessage(java.lang.String message,
                                                       java.lang.Throwable throwable)
Compose an alert message by using the given message and throwable.

Parameters:
message -
throwable -
Returns:
the composed String.

loadScreen

public static Screen loadScreen(java.lang.String xmlFilePath,
                                DataProvider dataProvider)
Load a Screen widget from a XML file. If xmlFilePath is a relative path (i.e: myScreen.xml) the default xml folder location is automaticaly added and the path become : /xml/myScreen.xml. Absolute paths are kept.

Parameters:
xmlFilePath -
dataProvider -
Returns:
The loaded Screen widget instance

loadScreen

public static Screen loadScreen(java.io.InputStream inputStream,
                                DataProvider dataProvider)
Load a Screen widget from an XML InputStream.

Parameters:
inputStream -
dataProvider -
Returns:
The loaded Screen widget instance

loadWidget

public static Widget loadWidget(java.lang.String xmlFilePath,
                                DataProvider dataProvider)
Load a Widget from a XML file. If xmlFilePath is a relative path (i.e: myWidget.xml) the default xml folder location is automaticaly added and the path become : /xml/myWidget.xml. Absolute paths are kept.

Parameters:
xmlFilePath -
dataProvider -
Returns:
The loaded Widget instance

loadWidget

public static Widget loadWidget(java.io.InputStream inputStream,
                                DataProvider dataProvider)
Load a Widget from an XML InputStream.
The desiredWidgetClass need to extends Widget and correspond to the root xml widget tag.

Parameters:
inputStream -
dataProvider -
Returns:
The loaded Widget instance

loadMenuContent

public static void loadMenuContent(Menu menu,
                                   java.lang.String xmlFilePath,
                                   DataProvider dataProvider)
Reload the menu content from an xml definition.
Caution that this method cleanUp and removeAll previous menu content, but not its attributes (like id or class).

Parameters:
menu -
xmlFilePath -
dataProvider -
Since:
1.0.1

loadMenuContent

public static void loadMenuContent(Menu menu,
                                   java.io.InputStream inputStream,
                                   DataProvider dataProvider)
Reload the first menu content from an xml definition provides by an inputStream.
Caution that this method cleanUp and removeAll previous menu content, but not its attributes (like id or class).

Parameters:
menu -
inputStream -
dataProvider -
Since:
1.0.1

loadXml

public static void loadXml(Widget rootWidget,
                           java.io.InputStream inputStream)
Parse and load an XML UI definition and place the content as child of rootWidget. Initial rootWidget content is removed.

Parameters:
rootWidget -
inputStream -
Throws:
java.lang.Exception

loadXml

public static void loadXml(Widget rootWidget,
                           java.io.InputStream inputStream,
                           DataProvider dataProvider)
Parse and load an XML UI definition and place the content as child of rootWidget. Initial rootWidget content is removed.

Parameters:
rootWidget -
inputStream -
dataProvider -
Throws:
java.lang.Exception

loadXml

public static void loadXml(Widget rootWidget,
                           java.io.InputStream inputStream,
                           DataProvider dataProvider,
                           boolean append,
                           boolean mergeRootWidget)
Parse an load an XML ui definition and place the content as child of rootWidget.

Parameters:
rootWidget -
inputStream -
dataProvider -
append - if false loaded content replace current rootWidget's content.
mergeRootWidget - if true and if loaded content's root widget tag equals rootWidget's tag the given rootWidget instance represents the new content root else a new widget instance is created and added to the rootWidget.
Throws:
java.lang.Exception

loadCss

public static void loadCss(java.lang.String cssFilePath)
Parse an load a CSS style definitions and register it into the StyleManager. If cssFilePath is a relative path (i.e: myStyle.css) the default css folder location is automaticaly added and the path become : /css/myStyle.css. Absolute paths are kept.

Parameters:
cssFilePath -

loadCss

public static void loadCss(java.io.InputStream inputStream)
Parse an load a CSS style definitions and register them.

Parameters:
inputStream -

callActionMethod

public static void callActionMethod(Method method)
Call the specified action method

Parameters:
method -

getXmlResourceInputStream

public static java.io.InputStream getXmlResourceInputStream(java.lang.String xmlFilePath)
Returns a new InputStream relative to the desired xmlFilePath.
If xmlFilePath is a relative path (i.e: myResource.xml) the default xml folder location is automaticaly added and the path become : /xml/myResource.xml. Absolute paths are kept.

Parameters:
xmlFilePath -
Returns:
a new InputStream relative to the desired xml resource

getResourceAsByteArrayInputStream

public static java.io.ByteArrayInputStream getResourceAsByteArrayInputStream(java.lang.Class clazz,
                                                                             java.lang.String path)
Convert resource to a ByteArrayInputStream.

Parameters:
clazz - The Class where the getResourceAsStream() function is called.
path - Path of the resource file
Returns:
The corresponding ByteArrayInputStream, or null if an error occure.

parseMethod

public static Method parseMethod(java.lang.String data,
                                 Widget owner)
Returns the parsed Method, or null if no method could be extract.

Parameters:
data -
owner -
Returns:
The parsed Method

registerStyle

public static void registerStyle(Style style)
Register a Style. If an equivalent Style was already registred the new style properties are copied.

Parameters:
style -

getStyles

public static java.util.Vector getStyles(Widget widget)
Returns the list of Style associated to the widget or null if no style was found.

Parameters:
widget -
Returns:
The list of Style associated to the widget

removeAllStyles

public static void removeAllStyles()
Remove all registred styles


clearStyleCache

public static void clearStyleCache(Widget target,
                                   boolean propagateToChildren)
Clear style cache from the specified Widget and its childs

Parameters:
target -
propagateToChildren -

initI18nSupport

public static boolean initI18nSupport()
Initializes internationalization support based on currently set locale (obtained from "microedition.locale" system property). The initialization method is called automatically when a call to getMessage(java.lang.String) method is attempted for the first time. You can call this method explicitly to see whether there was any problem with initialization of the i18n support. Method returns a status of the successfulness.

Returns:
true if the intialization was succesfull, false if there was any problem.

initI18nSupport

public static boolean initI18nSupport(java.lang.String locale)
Explicit initialization of the internationalization support. This method is usually called when a particular locale used in the application. E.g. the application contains only french messages (no default messages, only messages_fr.properties files is available), you should initialize the i18n support (by calling initI18nSupport("fr");) before using getMessage(java.lang.String) method for the first time.

Parameters:
locale - locale which will be used to determine which message file from bundle will be used
Returns:
true if the intialization was succesfull, false if there was any problem.

initI18nSupport

public static boolean initI18nSupport(java.lang.String messageBundle,
                                      java.lang.String locale)
Explicit initialization of the internationalization support. This method is usually called when a particular locale used in the application. E.g. the application contains only french messages (no default messages, only messages_fr.properties files is available), you should initialize the i18n support (by calling initI18nSupport("fr");) before using getMessage(java.lang.String) method for the first time.

Parameters:
messageBundle - full custom messages bundle path
locale - locale which will be used to determine which message file from bundle will be used
Returns:
true if the intialization was succesfull, false if there was any problem.

loadI18nBundle

public static boolean loadI18nBundle(java.lang.String messageBundle)
Load a new bundle and append messages to the messages table.

Parameters:
messageBundle -
Returns:
true if the intialization was succesfull, false if there was any problem.

getMessage

public static final java.lang.String getMessage(java.lang.String key)
Finds a localized string in a message bundle.

Parameters:
key - key of the localized string to look for
Returns:
the localized string. If key is not found, then DEFAULT_UNKNOWN_I18N_MESSAGE string is returned

getLocale

public static java.lang.String getLocale()
Returns the last used locale, or null if never set.

Returns:
the locale

getMessage

public static final java.lang.String getMessage(java.lang.String key,
                                                java.lang.Object[] args)
Finds a localized string in a message bundle and formats the message by passing requested parameters.

Parameters:
key - key of the localized string to look for
args - array of arguments to use for formatting the message
Returns:
the localized string. If key is not found, then DEFAULT_UNKNOWN_I18N_MESSAGE string is returned

processI18nPattern

public static java.lang.String processI18nPattern(java.lang.String pattern)
Process the internationalization and replace found keys by their values.

Syntax : %KEY% if value is like KEY=Hello world, thanks for using Kuix.

Syntax : %KEY(arg0,arg1)% if value is like KEY=Hello {0}, thanks for using {1}.

Parameters:
pattern -
Returns:
The processed String


Copyright © 2007-2008 Kalmeo. All Rights Reserved.