org.eclipse.actf.model.javapp
Class SwtGuiModel

java.lang.Object
  extended by org.eclipse.actf.model.AbstractModel
      extended by org.eclipse.actf.model.AbstractGuiModel
          extended by org.eclipse.actf.model.javapp.SwtGuiModel
All Implemented Interfaces:
IGuiModel, IModel

public class SwtGuiModel
extends AbstractGuiModel

implementation for the Eclipse SWT GUI model

Author:
Mike Squillace

Field Summary
protected  ClassLoaderCache clCache
           
static List FOCUSABLE_COMPOSITE_LIST
           
static String[] FOCUSABLE_COMPOSITE_NAMES
           
static String SWT_ADAPTOR_CLASS
           
static String SWT_MODEL
           
static String SWT_RUNTIME_HOME_KEY
           
 
Fields inherited from class org.eclipse.actf.model.AbstractGuiModel
eventIdMap
 
Fields inherited from class org.eclipse.actf.model.AbstractModel
baseType, configuration, locator, runtimeContext, treeNodeWalker
 
Constructor Summary
SwtGuiModel()
          create a new SwtGuiModel
 
Method Summary
 void asyncInvokeOnUIThread(Runnable runnable)
          asyncronously executes the given Runnable from within the UI thread.
 String[] getAlternateMethodNames(String rootName)
          Alternate method names returned include: 'set' + rootName 'add' + rootName First char of rootName is converted to upper case
 String getDefaultAliasPrefix()
          returns the default alias prefix. The default alias prefix (usually a package name) is used when a fully-qualified name is not used in the 'value' attribute of an <alias> tag
 Object getDefaultGuiRoot()
           
 INodeLocator getNodeLocator()
          retrieves a locator for finding and identifying nodes in the model.
 String[] getPackageNames()
          returns empty array Includes packages: java.lang org.eclipse.swt org.eclipse.swt.events org.eclipse.swt.widgets org.eclipse.swt.layout org.eclipse.swt.custom
 ITreeNodeWalker getTreeWalker()
          retrieve the NodeWalker for traversing elements in this model
protected  boolean internalIsVisible(Object comp)
          returns whether or not the component is visible.
 Object invokeGetter(Object obj, String name)
          invoke the getter method on the specified object.
 Object invokeGetter(Object obj, String name, Object arg)
          invoke the specified getter method on the given object, passing it the single parameter.
 Object invokeGetter(String clsName, String methName)
          invoke the getter method of the specified class.
 void invokeOnUIThread(Runnable runnable)
          executes the given Runnable from within the UI thread.
 boolean isDisposed(Object comp)
          returns whether or not the component is disposed.
 boolean isGuiRoot(Object o)
          An object must be an instance of a class that inherets from org.eclipse.swt.widgets.Shell in order to serve as a top-level component in a SWT GUI
 boolean isGuiRootType(Class c)
          An object must be an instance of a class that inherets from org.eclipse.swt.widgets.Shell in order to serve as a top-level component in a SWT GUI
 boolean isTopDown()
           
 boolean isUIThread()
          returns whether or not the currently executing thread is the UI thread.
 boolean isValid(Object comp)
          returns whether or not the specified component is valid for access. Components may be invalid because their underlying resources have been disposed, because the device that displays or renders them is destroyed, or for many other reasons. This default implementation merely checks that the component is not null.
 boolean isVisible(Object component)
          returns whether or not the specified component is currently visible
 boolean performsLinkOnCreation()
          return true since SWT components must be created and added to GUIs upon their creation
 boolean requestFocusFor(Object comp)
          request the focus for the specified component. This method should be invoked, for example, just prior to validation for a report that reflects the state of the component while visible.
 
Methods inherited from class org.eclipse.actf.model.AbstractGuiModel
getBoundingRectangle, getModelEventType, getModelEventTypes, highlight, initEventIdMap, registerModelEventListener, unregisterModelEventListener
 
Methods inherited from class org.eclipse.actf.model.AbstractModel
addModelChangeListener, fireModelChangeEvent, getBaseType, getName, getNodeId, getNodeName, getOrder, removeModelChangeListener, setFilters, setModelType, setNodeID
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.eclipse.actf.model.IModel
addModelChangeListener, getBaseType, getName, getNodeId, getNodeName, getOrder, removeModelChangeListener, setNodeID
 

Field Detail

FOCUSABLE_COMPOSITE_NAMES

public static final String[] FOCUSABLE_COMPOSITE_NAMES

FOCUSABLE_COMPOSITE_LIST

public static final List FOCUSABLE_COMPOSITE_LIST

SWT_MODEL

public static final String SWT_MODEL
See Also:
Constant Field Values

SWT_RUNTIME_HOME_KEY

public static final String SWT_RUNTIME_HOME_KEY
See Also:
Constant Field Values

SWT_ADAPTOR_CLASS

public static final String SWT_ADAPTOR_CLASS
See Also:
Constant Field Values

clCache

protected ClassLoaderCache clCache
Constructor Detail

SwtGuiModel

public SwtGuiModel()
create a new SwtGuiModel

Method Detail

getAlternateMethodNames

public String[] getAlternateMethodNames(String rootName)
Alternate method names returned include:

First char of rootName is converted to upper case

Parameters:
rootName -
Returns:
alternate method names

getDefaultAliasPrefix

public String getDefaultAliasPrefix()
returns the default alias prefix. The default alias prefix (usually a package name) is used when a fully-qualified name is not used in the 'value' attribute of an <alias> tag

Specified by:
getDefaultAliasPrefix in interface IModel
Overrides:
getDefaultAliasPrefix in class AbstractModel
Returns:
alias prefix (not including trailing '.')

getPackageNames

public String[] getPackageNames()
returns empty array

Includes packages:

Specified by:
getPackageNames in interface IModel
Overrides:
getPackageNames in class AbstractModel
Returns:
init packages
See Also:
org.eclipse.actf.core.processor.CodeProcessor

performsLinkOnCreation

public boolean performsLinkOnCreation()
return true since SWT components must be created and added to GUIs upon their creation

Returns:
true

isTopDown

public boolean isTopDown()
Returns:
true

isGuiRootType

public boolean isGuiRootType(Class c)
An object must be an instance of a class that inherets from org.eclipse.swt.widgets.Shell in order to serve as a top-level component in a SWT GUI

Parameters:
c - -- class to be tested
Returns:
true if the given class inherits from org.eclipse.swt.widgets.Shell

isGuiRoot

public boolean isGuiRoot(Object o)
An object must be an instance of a class that inherets from org.eclipse.swt.widgets.Shell in order to serve as a top-level component in a SWT GUI

Parameters:
o - -- object to be tested
Returns:
true if object is an instance of a class that inherets from org.eclipse.swt.widgets.Shell

isUIThread

public boolean isUIThread()
returns whether or not the currently executing thread is the UI thread. In SWT, the UI thread is the thread that created the org.eclipse.swt.widgets.Display instance.

Returns:
true if the current thread is the UI thread, false otherwise
See Also:
IGuiModel.isUIThread()

isVisible

public boolean isVisible(Object component)
returns whether or not the specified component is currently visible

Specified by:
isVisible in interface IGuiModel
Overrides:
isVisible in class AbstractGuiModel
Parameters:
component - - component to be tested
Returns:
whether or not the component is currently visible or showing on the screen

invokeOnUIThread

public void invokeOnUIThread(Runnable runnable)
executes the given Runnable from within the UI thread. This method will typically be called if isUIThread returns false.

Parameters:
runnable - - Runnable to be invoked in UI thread
See Also:
isUIThread()

asyncInvokeOnUIThread

public void asyncInvokeOnUIThread(Runnable runnable)
asyncronously executes the given Runnable from within the UI thread. That is, the Runnable is placed in a queue and control is returned immediately to the calling thread.

Parameters:
runnable - - Runnable to be invoked in UI thread
See Also:
IGuiModel.invokeOnUIThread(Runnable)

requestFocusFor

public boolean requestFocusFor(Object comp)
request the focus for the specified component. This method should be invoked, for example, just prior to validation for a report that reflects the state of the component while visible.

Specified by:
requestFocusFor in interface IGuiModel
Overrides:
requestFocusFor in class AbstractGuiModel
Parameters:
comp - - component for which focus is desired
Returns:
true if focus is successful, false otherwise

invokeGetter

public Object invokeGetter(Object obj,
                           String name)
                    throws Exception
invoke the getter method on the specified object. The method name must name a method that has no formal parameters.

Note: If the specified method is found and returns a boolean, then an unsuccessful invocation will result in a return value of false.

Parameters:
obj - - receiver
name - - method name
Returns:
result of invocation
Throws:
Exception

invokeGetter

public Object invokeGetter(Object obj,
                           String name,
                           Object arg)
                    throws Exception
invoke the specified getter method on the given object, passing it the single parameter.

Note: If the specified method is found and returns a boolean, then an unsuccessful invocation will result in a return value of false. *

Parameters:
obj - - the receiver
name - - the method name
arg - - single argument to method
Returns:
result of invokation
Throws:
Exception

internalIsVisible

protected boolean internalIsVisible(Object comp)
returns whether or not the component is visible. If an exception occurs, the object is assumed to be not visible and true is returned.

Parameters:
comp - SWT control
Returns:
false if and only if no exceptions occur and component is not, in fact, visible

isDisposed

public boolean isDisposed(Object comp)
returns whether or not the component is disposed. If an exception occurs, the object is assumed to be disposed and true is returned.

Parameters:
comp - SWT control
Returns:
false if and only if no exceptions occur and component is not, in fact, disposed

isValid

public boolean isValid(Object comp)
returns whether or not the specified component is valid for access. Components may be invalid because their underlying resources have been disposed, because the device that displays or renders them is destroyed, or for many other reasons. This default implementation merely checks that the component is not null.

Specified by:
isValid in interface IGuiModel
Overrides:
isValid in class AbstractGuiModel
Parameters:
comp - - component to be tested
Returns:
true if this component is valid, false otherwise
See Also:
org.eclipse.actf.core.model.InvalidComponentException

invokeGetter

public Object invokeGetter(String clsName,
                           String methName)
invoke the getter method of the specified class. The named method must take zero formal parameters.

Note: If the specified method is found and returns a boolean, then an unsuccessful invocation will result in a return value of false.

Parameters:
clsName - - class name
methName - - method name
Returns:
result of invocation

getDefaultGuiRoot

public Object getDefaultGuiRoot()

getTreeWalker

public ITreeNodeWalker getTreeWalker()
retrieve the NodeWalker for traversing elements in this model

Specified by:
getTreeWalker in interface IModel
Overrides:
getTreeWalker in class AbstractModel
Returns:
walker for traversing nodes in this model or null if no walker is available

getNodeLocator

public INodeLocator getNodeLocator()
Description copied from class: AbstractModel
retrieves a locator for finding and identifying nodes in the model. The locator can provide an XPath expression that describes a node in the model or, given a valid XPath expression, find an object in the model.

Specified by:
getNodeLocator in interface IModel
Overrides:
getNodeLocator in class AbstractModel
Returns:
node locator