org.eclipse.e4.xwt
Class XWT

java.lang.Object
  extended by org.eclipse.e4.xwt.XWT

public class XWT
extends java.lang.Object

XWT is the main class of the XWT framework. It provides most of the services in API.

Author:
jliu and yyang

Constructor Summary
XWT()
           
 
Method Summary
static void addTracking(Tracking tracking)
          Add a tracking option
static java.lang.Object convertFrom(java.lang.Class<?> targetType, java.lang.String string)
          Data conversion service from String to a given type
static java.lang.Object convertFrom(IMetaclass type, java.lang.String string)
          Data conversion service from String to a given type
static org.eclipse.swt.widgets.Composite findCompositeParent(org.eclipse.swt.widgets.Widget context)
          Find the closet parent of type Composite
static org.eclipse.core.databinding.conversion.IConverter findConvertor(java.lang.Class<?> source, java.lang.Class<?> target)
          Find a Data converter
static java.lang.Object findElementByName(org.eclipse.swt.widgets.Widget context, java.lang.String name)
          Find a named UI element.
static ILoadingContext findLoadingContext(java.lang.Object container)
           
static org.eclipse.e4.xwt.impl.NameContext findNameContext(org.eclipse.swt.widgets.Widget widget)
          A NameContext is a manager of UI element's name in a scope.
static org.eclipse.swt.widgets.Shell findShell(org.eclipse.swt.widgets.Widget context)
          Find the root shell
static IMetaclass[] getAllMetaclasses()
          Metaclass services to return all registered Metaclasses.
static java.lang.Object getCLR(org.eclipse.swt.widgets.Widget widget)
          Get the CLR (Common Language Runtime) object.
static ICommand getCommand(java.lang.String name)
          Find a command by name
static java.util.Map<java.lang.String,ICommand> getCommands()
          Return all registered commands
static org.eclipse.e4.xwt.XWT.ConverterService getConverterService()
           
static java.lang.Object getDataContext(org.eclipse.swt.widgets.Widget element)
          Get the DataContext of given element
static ILoadingContext getLoadingContext()
           
static ILoadingContext getLoadingContext(org.eclipse.swt.widgets.Composite object)
           
static ILogger getLogger()
          Get the system logger.
static IMetaclass getMetaclass(java.lang.Object object)
          Get the Metaclass of the given object
static IMetaclass getMetaclass(java.lang.String tagName, java.lang.String ns)
          Get the corresponding Metaclass
static java.lang.String getNamespace(java.lang.Class<?> javaclass)
          This namespace service returns the associated or declared namespace for a given class.
static java.util.Set<Tracking> getTrackings()
          Get all tracking options
static boolean IsInitialized()
          Check if the framework is initialized.
static boolean isTracking(Tracking tracking)
          Test if the tracking on argument is enabled.
static org.eclipse.swt.widgets.Control load(org.eclipse.swt.widgets.Composite parent, java.io.InputStream stream, java.net.URL file, int styles, java.lang.Object dataContext)
          load the content from a stream with a style and a DataContext.
static org.eclipse.swt.widgets.Control load(org.eclipse.swt.widgets.Composite parent, java.io.InputStream stream, java.net.URL file, int styles, java.lang.Object dataContext, ResourceDictionary dictionary)
          load the content from a stream with a style, a DataContext and a ResourceDictionary.
static org.eclipse.swt.widgets.Control load(org.eclipse.swt.widgets.Composite parent, java.io.InputStream stream, java.net.URL file, java.lang.Object dataContext)
          load the content from a stream with a given DataContext.
static org.eclipse.swt.widgets.Control load(org.eclipse.swt.widgets.Composite parent, java.net.URL file)
          Load the file content under a Composite.
static org.eclipse.swt.widgets.Control load(org.eclipse.swt.widgets.Composite parent, java.net.URL file, int styles, java.lang.Object dataContext)
          Load the file content under a Composite with a style and a DataContext.
static org.eclipse.swt.widgets.Control load(org.eclipse.swt.widgets.Composite parent, java.net.URL file, int styles, java.lang.Object dataContext, ResourceDictionary dictionary)
          Load the file content under a Composite with a style, a DataContext and a ResourceDictionary.
static org.eclipse.swt.widgets.Control load(org.eclipse.swt.widgets.Composite parent, java.net.URL file, java.lang.Object dataContext)
          Load the file content under a Composite with a DataContext.
static org.eclipse.swt.widgets.Control load(java.io.InputStream stream, java.net.URL file)
          load the file content.
static org.eclipse.swt.widgets.Control load(java.io.InputStream stream, java.net.URL url, ILoadData loadData)
          Generic load method
static org.eclipse.swt.widgets.Control load(java.net.URL file)
          Load the file content.
static org.eclipse.swt.widgets.Control load(java.net.URL file, int styles, java.lang.Object dataContext)
          Load the file content with a DataContext.
static org.eclipse.swt.widgets.Control load(java.net.URL file, int styles, java.lang.Object dataContext, ResourceDictionary dictionary)
          Load the file content with a DataContext and a ResourceDictionary.
static org.eclipse.swt.widgets.Control load(java.net.URL file, java.lang.Object dataContext)
          Load the file content with a DataContext.
static void open(java.net.URL url)
          Open and show the file content in a new Shell.
static void open(java.net.URL url, java.lang.Object dataContext)
          load the file content.
static void open(java.net.URL url, java.lang.Object dataContext, ResourceDictionary dictionary)
          load the file content.
static IMetaclass register(java.lang.Class<?> javaclass, java.lang.String namespace)
          Register UI type
static void registerCommand(java.lang.String name, ICommand command)
          Register a command to a name
static void registerConvertor(org.eclipse.core.databinding.conversion.IConverter converter)
          Register a Data converter
static IMetaclass registerMetaclass(java.lang.Class type)
          Register UI type
static void registerMetaclassFactory(IMetaclassFactory metaclassFactory)
          Register Metaclass factory
static void removeTracking(Tracking tracking)
          Remove a tracking option.
static void setDataContext(org.eclipse.swt.widgets.Widget widget, java.lang.Object dataContext)
          Change the DataContext of given element
static void setLoadingContext(ILoadingContext loadingContext)
           
static void setLogger(ILogger logger)
          Change the system logger
static void unregisterCommand(java.lang.String name)
          Unregister a command
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XWT

public XWT()
Method Detail

getLogger

public static ILogger getLogger()
Get the system logger.

Returns:

setLogger

public static void setLogger(ILogger logger)
Change the system logger

Parameters:
logger -

IsInitialized

public static boolean IsInitialized()
Check if the framework is initialized.

Returns:

getNamespace

public static java.lang.String getNamespace(java.lang.Class<?> javaclass)
This namespace service returns the associated or declared namespace for a given class.

Parameters:
javaclass -
Returns:

findNameContext

public static org.eclipse.e4.xwt.impl.NameContext findNameContext(org.eclipse.swt.widgets.Widget widget)
A NameContext is a manager of UI element's name in a scope. A name in a NameContext must be unique.

Parameters:
widget -
Returns:

findElementByName

public static java.lang.Object findElementByName(org.eclipse.swt.widgets.Widget context,
                                                 java.lang.String name)
Find a named UI element.

Parameters:
context - the start point of research.
name -
Returns:

getDataContext

public static java.lang.Object getDataContext(org.eclipse.swt.widgets.Widget element)
Get the DataContext of given element

Parameters:
context -
Returns:

setDataContext

public static void setDataContext(org.eclipse.swt.widgets.Widget widget,
                                  java.lang.Object dataContext)
Change the DataContext of given element

Parameters:
context -

getCLR

public static java.lang.Object getCLR(org.eclipse.swt.widgets.Widget widget)
Get the CLR (Common Language Runtime) object. If no CLR object is found in this element, the research will be propagated in it parent.

Parameters:
widget -
Returns:

findShell

public static org.eclipse.swt.widgets.Shell findShell(org.eclipse.swt.widgets.Widget context)
Find the root shell

Parameters:
context -
Returns:

findCompositeParent

public static org.eclipse.swt.widgets.Composite findCompositeParent(org.eclipse.swt.widgets.Widget context)
Find the closet parent of type Composite

Parameters:
context -
Returns:

getMetaclass

public static IMetaclass getMetaclass(java.lang.Object object)
Get the Metaclass of the given object

Parameters:
context -
Returns:

load

public static org.eclipse.swt.widgets.Control load(java.net.URL file)
                                            throws java.lang.Exception
Load the file content. All widget will be created but they are showed. This method return the root element.

Throws:
java.lang.Exception

load

public static org.eclipse.swt.widgets.Control load(java.net.URL file,
                                                   int styles,
                                                   java.lang.Object dataContext)
                                            throws java.lang.Exception
Load the file content with a DataContext. All widget will be created but they are showed. This method returns the root element. The DataContext will be associated to the root element.

Throws:
java.lang.Exception

load

public static org.eclipse.swt.widgets.Control load(java.net.URL file,
                                                   int styles,
                                                   java.lang.Object dataContext,
                                                   ResourceDictionary dictionary)
                                            throws java.lang.Exception
Load the file content with a DataContext and a ResourceDictionary. All widget will be created but they are showed. This method returns the root element. The DataContext will be associated to the root element.

Throws:
java.lang.Exception

load

public static org.eclipse.swt.widgets.Control load(java.net.URL file,
                                                   java.lang.Object dataContext)
                                            throws java.lang.Exception
Load the file content with a DataContext. All widget will be created but they are showed. This method returns the root element. The DataContext will be associated to the root element.

Throws:
java.lang.Exception

load

public static org.eclipse.swt.widgets.Control load(org.eclipse.swt.widgets.Composite parent,
                                                   java.net.URL file)
                                            throws java.lang.Exception
Load the file content under a Composite. All widget will be created. This method returns the root element. The DataContext will be associated to the root element.

Throws:
java.lang.Exception

load

public static org.eclipse.swt.widgets.Control load(org.eclipse.swt.widgets.Composite parent,
                                                   java.net.URL file,
                                                   java.lang.Object dataContext)
                                            throws java.lang.Exception
Load the file content under a Composite with a DataContext. All widget will be created. This method returns the root element. The DataContext will be associated to the root element.

Throws:
java.lang.Exception

load

public static org.eclipse.swt.widgets.Control load(org.eclipse.swt.widgets.Composite parent,
                                                   java.net.URL file,
                                                   int styles,
                                                   java.lang.Object dataContext)
                                            throws java.lang.Exception
Load the file content under a Composite with a style and a DataContext. All widget will be created. This method returns the root element. The DataContext will be associated to the root element.

Throws:
java.lang.Exception

load

public static org.eclipse.swt.widgets.Control load(org.eclipse.swt.widgets.Composite parent,
                                                   java.net.URL file,
                                                   int styles,
                                                   java.lang.Object dataContext,
                                                   ResourceDictionary dictionary)
                                            throws java.lang.Exception
Load the file content under a Composite with a style, a DataContext and a ResourceDictionary. All widget will be created. This method returns the root element. The DataContext will be associated to the root element.

Throws:
java.lang.Exception

open

public static void open(java.net.URL url)
                 throws java.lang.Exception
Open and show the file content in a new Shell.

Throws:
java.lang.Exception

load

public static org.eclipse.swt.widgets.Control load(java.io.InputStream stream,
                                                   java.net.URL file)
                                            throws java.lang.Exception
load the file content. The corresponding UI element is not yet created

Throws:
java.lang.Exception

load

public static org.eclipse.swt.widgets.Control load(org.eclipse.swt.widgets.Composite parent,
                                                   java.io.InputStream stream,
                                                   java.net.URL file,
                                                   java.lang.Object dataContext)
                                            throws java.lang.Exception
load the content from a stream with a given DataContext. The root elements will be hold by Composite parent

Throws:
java.lang.Exception

load

public static org.eclipse.swt.widgets.Control load(org.eclipse.swt.widgets.Composite parent,
                                                   java.io.InputStream stream,
                                                   java.net.URL file,
                                                   int styles,
                                                   java.lang.Object dataContext)
                                            throws java.lang.Exception
load the content from a stream with a style and a DataContext. The root elements will be hold by Composite parent

Throws:
java.lang.Exception

load

public static org.eclipse.swt.widgets.Control load(org.eclipse.swt.widgets.Composite parent,
                                                   java.io.InputStream stream,
                                                   java.net.URL file,
                                                   int styles,
                                                   java.lang.Object dataContext,
                                                   ResourceDictionary dictionary)
                                            throws java.lang.Exception
load the content from a stream with a style, a DataContext and a ResourceDictionary. The root elements will be hold by Composite parent

Throws:
java.lang.Exception

open

public static void open(java.net.URL url,
                        java.lang.Object dataContext)
                 throws java.lang.Exception
load the file content. The corresponding UI element is not yet created

Throws:
java.lang.Exception

open

public static void open(java.net.URL url,
                        java.lang.Object dataContext,
                        ResourceDictionary dictionary)
                 throws java.lang.Exception
load the file content. The corresponding UI element is not yet created

Throws:
java.lang.Exception

convertFrom

public static java.lang.Object convertFrom(IMetaclass type,
                                           java.lang.String string)
Data conversion service from String to a given type

Parameters:
type -
string -
Returns:

convertFrom

public static java.lang.Object convertFrom(java.lang.Class<?> targetType,
                                           java.lang.String string)
Data conversion service from String to a given type

Parameters:
targetType -
string -
Returns:

load

public static org.eclipse.swt.widgets.Control load(java.io.InputStream stream,
                                                   java.net.URL url,
                                                   ILoadData loadData)
                                            throws java.lang.Exception
Generic load method

Parameters:
stream -
url -
loadData -
Returns:
Throws:
java.lang.Exception

getAllMetaclasses

public static IMetaclass[] getAllMetaclasses()
Metaclass services to return all registered Metaclasses.

Parameters:
stream -
url -
loadData -
Returns:
Throws:
java.lang.Exception

getMetaclass

public static IMetaclass getMetaclass(java.lang.String tagName,
                                      java.lang.String ns)
Get the corresponding Metaclass

Parameters:
tagName -
ns - The namespace
Returns:

registerMetaclass

public static IMetaclass registerMetaclass(java.lang.Class type)
Register UI type

Parameters:
javaclass -

registerMetaclassFactory

public static void registerMetaclassFactory(IMetaclassFactory metaclassFactory)
Register Metaclass factory

Parameters:
javaclass -

register

public static IMetaclass register(java.lang.Class<?> javaclass,
                                  java.lang.String namespace)
Register UI type

Parameters:
javaclass -

getConverterService

public static org.eclipse.e4.xwt.XWT.ConverterService getConverterService()

findConvertor

public static org.eclipse.core.databinding.conversion.IConverter findConvertor(java.lang.Class<?> source,
                                                                               java.lang.Class<?> target)
Find a Data converter

Parameters:
converter -
type -

registerConvertor

public static void registerConvertor(org.eclipse.core.databinding.conversion.IConverter converter)
Register a Data converter

Parameters:
converter -
type -

findLoadingContext

public static ILoadingContext findLoadingContext(java.lang.Object container)

getLoadingContext

public static ILoadingContext getLoadingContext(org.eclipse.swt.widgets.Composite object)

getLoadingContext

public static ILoadingContext getLoadingContext()

setLoadingContext

public static void setLoadingContext(ILoadingContext loadingContext)

addTracking

public static void addTracking(Tracking tracking)
Add a tracking option

Parameters:
tracking -

isTracking

public static boolean isTracking(Tracking tracking)
Test if the tracking on argument is enabled.

Parameters:
tracking -
Returns:

getTrackings

public static java.util.Set<Tracking> getTrackings()
Get all tracking options

Returns:

removeTracking

public static void removeTracking(Tracking tracking)
Remove a tracking option.

Parameters:
tracking -

registerCommand

public static void registerCommand(java.lang.String name,
                                   ICommand command)
Register a command to a name

Parameters:
name -
command -

getCommand

public static ICommand getCommand(java.lang.String name)
Find a command by name

Parameters:
name -
Returns:

getCommands

public static java.util.Map<java.lang.String,ICommand> getCommands()
Return all registered commands

Returns:

unregisterCommand

public static void unregisterCommand(java.lang.String name)
Unregister a command

Parameters:
name -