org.objectweb.jac.aspects.gui
Class ViewFactory

java.lang.Object
  extended byorg.objectweb.jac.aspects.gui.ViewFactory

public class ViewFactory
extends Object

This is a generic view factory. It can be configured to use any constructor to build views of any type.


Nested Class Summary
static class ViewFactory.UnhandledViewTypeException
          Thrown to indicate that a ViewFactory is unable to build a view of the given type because no constructor is associated to this type of view.
 
Constructor Summary
ViewFactory()
           
 
Method Summary
 CompositeView createCompositeView(String label, String viewType, DisplayContext context)
           
 CompositeView createCompositeView(String label, String viewType, Object[] params, DisplayContext context)
           
 FieldEditor createEditor(String label, String viewType, Object[] params, DisplayContext context)
           
 View createObjectView(String label, Object object, DisplayContext context)
          Creates a view for an object, using the most specific view constructor available for the type of the object.
 View createObjectView(String label, Object object, Object substance, FieldItem field, DisplayContext context)
          Creates a view for an object, using the most specific view constructor available for the type of the object.
 View createView(String label, String viewType, DisplayContext context)
           
 View createView(String label, String viewType, Object[] params, DisplayContext context)
          Create a view of a given type.
 View createView(String label, String viewType, String[] params, DisplayContext context)
          Convert Strings into the type expected by the view constructor.
 boolean hasViewerFor(String viewType)
          Tells wether a view factory is able to build a view for given type.
static void init(String type, ViewFactory f)
          Init a swing factory by setting the constuctor types.
 void setViewConstructor(String viewType, AbstractMethodItem constructor)
          Set the constructor for a type of view
 void setViewConstructor(String viewType, String constructor)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ViewFactory

public ViewFactory()
Method Detail

init

public static void init(String type,
                        ViewFactory f)
Init a swing factory by setting the constuctor types.


createView

public View createView(String label,
                       String viewType,
                       Object[] params,
                       DisplayContext context)
                throws ViewFactory.UnhandledViewTypeException
Create a view of a given type.

Parameters:
label - the name of the view
viewType - the type of the view (for instance, "Object" or "Tree".
params - the parameters to pass to the view constructor
Returns:
a view of the demanded type.
Throws:
ViewFactory.UnhandledViewTypeException

createView

public View createView(String label,
                       String viewType,
                       String[] params,
                       DisplayContext context)
                throws ViewFactory.UnhandledViewTypeException
Convert Strings into the type expected by the view constructor.

Throws:
ViewFactory.UnhandledViewTypeException

createObjectView

public View createObjectView(String label,
                             Object object,
                             DisplayContext context)
Creates a view for an object, using the most specific view constructor available for the type of the object.

Parameters:
label - the label of the view to create
object - the object for which to create a view
context - the display context

createObjectView

public View createObjectView(String label,
                             Object object,
                             Object substance,
                             FieldItem field,
                             DisplayContext context)
Creates a view for an object, using the most specific view constructor available for the type of the object.

Parameters:
label - the label of the view to create
object - the object for which to create a view
substance -
field -
context - the display context

createCompositeView

public CompositeView createCompositeView(String label,
                                         String viewType,
                                         Object[] params,
                                         DisplayContext context)
                                  throws ViewFactory.UnhandledViewTypeException
Throws:
ViewFactory.UnhandledViewTypeException

createView

public View createView(String label,
                       String viewType,
                       DisplayContext context)
                throws ViewFactory.UnhandledViewTypeException
Throws:
ViewFactory.UnhandledViewTypeException

createCompositeView

public CompositeView createCompositeView(String label,
                                         String viewType,
                                         DisplayContext context)
                                  throws ViewFactory.UnhandledViewTypeException
Throws:
ViewFactory.UnhandledViewTypeException

createEditor

public FieldEditor createEditor(String label,
                                String viewType,
                                Object[] params,
                                DisplayContext context)
                         throws ViewFactory.UnhandledViewTypeException
Throws:
ViewFactory.UnhandledViewTypeException

setViewConstructor

public void setViewConstructor(String viewType,
                               AbstractMethodItem constructor)
Set the constructor for a type of view

Parameters:
viewType - the type of the view
constructor - the constructor to be used to build view of that type. It should take a ViewFactory as the first parameter

setViewConstructor

public void setViewConstructor(String viewType,
                               String constructor)

hasViewerFor

public boolean hasViewerFor(String viewType)
Tells wether a view factory is able to build a view for given type.

Parameters:
viewType - the type of the view
See Also:
setViewConstructor(String,AbstractMethodItem)