public class SwingEngine extends Object
| Modifier and Type | Field and Description |
|---|---|
protected ClassLoader |
cl
Localizer, setup by parameters found in the xml descriptor.
|
static boolean |
DEBUG_MODE
Debug / Release Mode
|
static String |
MAC_OSX_LOCALE_VARIANT
Mac OSX locale variant to localize strings like quit etc.
|
static String |
MAC_OSX_OS_NAME
Mac OSX identifier in System.getProperty(os.name)
|
| Constructor and Description |
|---|
SwingEngine()
Default ctor for a SwingEngine.
|
SwingEngine(ClassLoader cl,
String resource)
Deprecated.
|
SwingEngine(Object client)
Constructor to be used if the SwingEngine is not extend but used through object composition.
|
SwingEngine(String resource)
Constructs a new SwingEngine, rendering the provided XML into a javax.swing UI
|
| Modifier and Type | Method and Description |
|---|---|
int |
cleanup()
Removes all un-displayable compontents from the id map and deletes the components collection (for recreation at the
next request).
|
Component |
find(String id)
Returns the UI component with the given name or null.
|
void |
forget(String id)
Removes the id from the internal from the id map, to make the given id available for re-use.
|
Iterator |
getAllComponentItertor()
Returns an Iterator for all parsed GUI components.
|
static Frame |
getAppFrame() |
ClassLoader |
getClassLoader() |
Object |
getClient()
Returns the object which instantiated this SwingEngine.
|
Iterator |
getDescendants(Component c)
Walks the whole tree to add all components into the
components |
Iterator |
getIdComponentItertor()
Returns an Iterator for id-ed parsed GUI components.
|
Map<String,Object> |
getIdMap()
Returns the id map, containing all id-ed parsed GUI components.
|
Localizer |
getLocalizer() |
Container |
getRootComponent()
Returns the root component of the generated Swing UI.
|
TagLibrary |
getTaglib() |
void |
insert(Document jdoc,
Container container)
Inserts swing objects rendered from an XML document into the given container.
|
void |
insert(InputStream reader,
Container container)
Inserts swing objects rendered from an XML reader into the given container.
|
void |
insert(String resource,
Container container)
Inserts swing objects rendered from an XML reader into the given container.
|
void |
insert(URL url,
Container container)
Inserts swing object rendered from an XML document into the given container.
|
static boolean |
isMacOSX()
Indicates if currently running on Mac OS X
|
static boolean |
isMacOSXSupported()
Indicates state of Mac OS X support (default is true = ON).
|
protected void |
mapMembers(Object obj)
Introspects the given object's class and initializes its non-transient fields with objects that have been instanced
during parsing.
|
Container |
render(Document jdoc)
Gets the parsing of the XML file started.
|
Container |
render(File xml_file)
Gets the parsing of the XML file started.
|
Container |
render(InputStream xml_reader)
Gets the parsing of the XML file started.
|
Container |
render(String resource)
Gets the parsing of the XML file started.
|
Container |
render(URL url)
Gets the parsing of the XML started.
|
boolean |
setActionListener(Component c,
ActionListener al)
Recursively Sets an ActionListener
Backtracking algorithm: if al was set for a child component, its not being set for its parent
.
|
static void |
setAppFrame(Frame frame)
Sets the SwingEngine's global application frame variable, to be used as a parent for all child dialogs.
|
void |
setClassLoader(ClassLoader cl)
Sets a classloader to be used for all getResourse..() and loadClass() calls.
|
static void |
setDefaultLocale(Locale locale)
Sets the SwingEngine's global locale, to be used by all SwingEngine instances.
|
void |
setLocale(Locale l)
Sets the locale to be used during parsing / String conversion
|
static void |
setMacOSXSuport(boolean osx)
Enables or disables support of Mac OS X GUIs
|
void |
setResourceBundle(String bundlename)
Sets the ResourceBundle to be used during parsing / String conversion
|
static void |
setResourceBundleName(String bundlename)
Sets the SwingEngine's global resource bundle name, to be used by all SwingEngine instances.
|
void |
test()
Displays the GUI during a RAD session.
|
protected static void |
traverse(Component c,
Collection collection)
Walks the whole tree to add all components into the
components |
public static final String MAC_OSX_OS_NAME
public static final String MAC_OSX_LOCALE_VARIANT
public static boolean DEBUG_MODE
protected ClassLoader cl
public SwingEngine()
public SwingEngine(Object client)
client - Object owner of this instancepublic SwingEngine(String resource)
resource - Stringpublic SwingEngine(ClassLoader cl, String resource)
resource - Stringpublic Container render(URL url) throws Exception
url - URL url pointing to an XML descriptorObject- instanced swing object tree rootExceptionpublic Container render(String resource) throws Exception
resource - String xml-file path infoObject- instanced swing object tree rootExceptionpublic Container render(File xml_file) throws Exception
xml_file - File xml-fileObject- instanced swing object tree rootExceptionpublic Container render(InputStream xml_reader) throws Exception
xml_reader - Reader xml-file path infoObject- instanced swing object tree rootExceptionpublic Container render(Document jdoc) throws Exception
jdoc - Document xml gui descritptorObject- instanced swing object tree rootExceptionpublic void insert(URL url, Container container) throws Exception
Differently to the render methods, insert does NOT consider the root node of the XML document.
NOTE:
insert() does NOT clear() the idmap before rendering. Therefore, if this SwingEngine's parser was used before, the idmap still contains (key/value) pairs (id, JComponent obj. references).
If insert() is NOT used to insert in a previously (with this very SwingEngine) rendered UI, it is highly recommended to clear the idmap:
mySwingEngine.getIdMap().clear()
url - URL url pointing to an XML descriptor *container - Container target, the swing obj, are added to.Exceptionpublic void insert(InputStream reader, Container container) throws Exception
Differently to the render methods, insert does NOT consider the root node of the XML document.
NOTE:
insert() does NOT clear() the idmap before rendering. Therefore, if this SwingEngine's parser was used before, the idmap still contains (key/value) pairs (id, JComponent obj. references).
If insert() is NOT used to insert in a previously (with this very SwingEngine) rendered UI, it is highly recommended to clear the idmap:
mySwingEngine.getIdMap().clear()
reader - Reader xml-file path infocontainer - Container target, the swing obj, are added to.Exceptionpublic void insert(String resource, Container container) throws Exception
Differently to the render methods, insert does NOT consider the root node of the XML document.
NOTE:
insert() does NOT clear() the idmap before rendering. Therefore, if this SwingEngine's parser was used before, the idmap still contains (key/value) pairs (id, JComponent obj. references).
If insert() is NOT used to insert in a previously (with this very SwingEngine) rendered UI, it is highly recommended to clear the idmap:
mySwingEngine.getIdMap().clear()
resource - String xml-file path infocontainer - Container target, the swing obj, are added to.Exceptionpublic void insert(Document jdoc, Container container) throws Exception
Differently to the parse methods, insert does NOT consider the root node of the XML document.
NOTE:
insert() does NOT clear() the idmap before rendering. Therefore, if this SwingEngine's parser was used before, the idmap still contains (key/value) pairs (id, JComponent obj. references).
If insert() is NOT used to insert in a previously (with this very SwingEngine) rendered UI, it is highly recommended to clear the idmap:
mySwingEngine.getIdMap().clear()
jdoc - Document xml-doc path infocontainer - Container target, the swing obj, are added toException - Exception exception thrown by the parserpublic static void setResourceBundleName(String bundlename)
bundle attribute is places in the root tag of an XML
descriptor.bundlename - String the resource bundle name.public static void setDefaultLocale(Locale locale)
locale attribute is places in the root tag of an XML descriptor.locale - Localepublic static void setAppFrame(Frame frame)
frame - Window the parent for all future dialogs.public static Frame getAppFrame()
Window a parent for all dialogs.public Object getClient()
Objecy SwingEngine client object
Note:
This is the object used through introspection the actions and fileds are set.
public Container getRootComponent()
Component- the root component of the javax.swing uipublic Iterator getAllComponentItertor()
Iterator GUI components itearatorpublic Iterator getIdComponentItertor()
Iterator GUI components itearatorpublic Map<String,Object> getIdMap()
Map GUI components mappublic int cleanup()
A component is made undisplayable either when it is removed from a displayable containment hierarchy or when its containment hierarchy is made undisplayable. A containment hierarchy is made undisplayable when its ancestor window is disposed.
int number of removed componentes.public void forget(String id)
id - String assigned namepublic Component find(String id)
id - String assigned nameComponent- the GUI component with the given name or null if not found.public void setLocale(Locale l)
l - Localepublic void setResourceBundle(String bundlename)
bundlename - Stringpublic Localizer getLocalizer()
Localizer- the Localizer, which is used for localization.public TagLibrary getTaglib()
TagLibrary- the Taglibray to insert custom tags.
Note:ConverterLibrary and TagLibray need to be set up before rendering is called.
public void setClassLoader(ClassLoader cl)
cl - ClassLoaderClassLoader.loadClass(java.lang.String),
ClassLoader.getResource(java.lang.String)public ClassLoader getClassLoader()
ClassLoader- the Classloader used for all getResourse..() and loadClass()
calls.public boolean setActionListener(Component c, ActionListener al)
Backtracking algorithm: if al was set for a child component, its not being set for its parent.
c - Component start componental - ActionListenerboolean true, if ActionListener was set.public Iterator getDescendants(Component c)
components collection.c - Component recursive start component.
Note:There is another collection available that only tracks
those object that were provided with an idattribute, which hold an unique id
Iterator to walk all components, not just the id components.protected void mapMembers(Object obj)
obj - Object target object to be mapped with instanced tagsprotected static void traverse(Component c, Collection collection)
components collection.c - Component recursive start component.collection - Collection target collection.
Note:There is another collection available that only tracks
those object that were provided with an idattribute, which hold an unique id
public static void setMacOSXSuport(boolean osx)
osx - booleanpublic static boolean isMacOSXSupported()
boolean- indicating MacOS support is enabledpublic static boolean isMacOSX()
boolean- indicating if currently running on a MACpublic void test()
Copyright (c) 2002 - 2015 - Wolf Paulus - wolfpaulus.com. All rights reserved.