org.objectweb.jac.aspects.gui
Class GenericFactory

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

public class GenericFactory
extends Object

This class implements static methods that generically create GUI items. Depending on the actual view factory, the created items are for SWING, WEB or other GUI.


Constructor Summary
GenericFactory()
           
 
Method Summary
protected static void addChoices(ComboBoxModel choice, ClassItem type, Enum enum, Object substance, FieldItem field, boolean nullAllowed, String nullLabel, Predicate predicate)
          Adds choices within a container containing a combobox and sort them.
static boolean compositeViewIsEmpty(CompositeView view)
          Returns true is the CompositeView contains a view other than CompositeView.
static FieldEditor createEnumEditor(ViewFactory factory, DisplayContext context, Object substance, FieldItem field, String editorName, Enum enum, boolean nullAllowed, String nullLabel)
           
static DialogView createInputDialog(Object substance, AbstractMethodItem method, Object[] parameters, DisplayContext context)
          Builds a dialog box to enter the parameters of method
static MenuView createMenu(ViewFactory factory, DisplayContext context, String label, Menu content)
          Creates a menu in a a customized gui.
protected static CompositeView createObjectView(ViewFactory factory, DisplayContext context, ObjectView view, Object substance, String category)
          Create a view of an object, including only the attributes of a category.
static View createObjectView(ViewFactory factory, DisplayContext context, String viewName, Object substance)
          Creates a view on an object.
static View createObjectViewNoTab(ViewFactory factory, DisplayContext context, Object substance)
          Creates a view of an object (containing no tabs).
static View createParameters(ViewFactory factory, DisplayContext context, AbstractMethodItem method, Object substance, Object[] parameters)
          Create a view containing editor components for the parameters of a method.
static FieldEditor createReferenceEditor(ViewFactory factory, DisplayContext context, Object substance, FieldItem field, String editorName, ClassItem type, Predicate predicate, boolean nullAllowed, String nullLabel, boolean isCreationAllowed)
          A generic view builder for a reference editor.
static void fillObjectView(CompositeView view, ClassItem cli, String viewName, Object substance)
           
static View getCollectionPane(ViewFactory factory, DisplayContext context, Object substance, ObjectView objectView, CollectionItemView memberView, CollectionItem collection)
          Builds a view that will display a given collection field of an object.
protected static View getEditButton(ViewFactory factory, Object substance, FieldItem field, DisplayContext context)
          Constructs an edit button for reference views.
static FieldEditor getEditorComponent(ViewFactory factory, DisplayContext context, Object substance, AbstractMethodItem method, int i, boolean embedded, Object value)
          Returns a ValueEditor suitable for editing the i-th parameter of a method.
static View getFieldPane(ViewFactory factory, DisplayContext context, Object substance, ObjectView objectView, FieldItem field, boolean embedded)
           
protected static CompositeView getMethodsPane(ViewFactory factory, DisplayContext context, Object substance, Collection methods, String category, ObjectView objectView)
          Gets a composite panel containing a set of methods that are held by the substance object.
static MethodView getMethodView(AbstractMethodItem method, Object substance, DisplayContext context, ViewFactory factory, MemberItemView memberView)
          Build view for a method
protected static View getPrimitiveFieldPane(ViewFactory factory, DisplayContext context, Object substance, FieldItem field, ObjectView objectView, MemberItemView memberView, boolean embedded)
          Returns a view of a primitive field.
protected static View getReferenceFieldPane(ViewFactory factory, DisplayContext context, Object substance, FieldItem field, boolean embedded, ObjectView objectView, MemberItemView memberView)
          Build a view containing a label for the name of the field, and the view of the reference.
protected static boolean getViewer(Object substance, FieldItem field, Object value, CompositeView container, ViewFactory factory, DisplayContext context)
          Instantiates a viewer for a value of a field and add it to a container.
static void initCustomized(ViewFactory factory, DisplayContext context, CompositeView internalView, CustomizedGUI customized, Map panels)
          Initialize the panels of a customized gui.
static void setMenuBars(ViewFactory factory, DisplayContext context, CustomizedView view, Hashtable menuBars)
          Build the menu bar of a customized gui.
static void setStatusBar(ViewFactory factory, DisplayContext context, CustomizedView view, MethodItem statusBar, String position)
          Sets a status bar to a customized view.
static void setToolBar(ViewFactory factory, DisplayContext context, CustomizedView view, Collection toolbar)
          Build the toolbar of a customized gui.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GenericFactory

public GenericFactory()
Method Detail

createObjectView

public static View createObjectView(ViewFactory factory,
                                    DisplayContext context,
                                    String viewName,
                                    Object substance)
Creates a view on an object.

Parameters:
factory - the used factory
context - the display context (passed to ceated sub-item so that they know displays and customized)
viewName - name of the view to build
substance - the object to build a view of

fillObjectView

public static void fillObjectView(CompositeView view,
                                  ClassItem cli,
                                  String viewName,
                                  Object substance)

createObjectViewNoTab

public static View createObjectViewNoTab(ViewFactory factory,
                                         DisplayContext context,
                                         Object substance)
Creates a view of an object (containing no tabs).

Parameters:
factory - the used factory
context - the display context (passed to ceated sub-item so that they know displays and customized)
substance - the viewed object

compositeViewIsEmpty

public static boolean compositeViewIsEmpty(CompositeView view)
Returns true is the CompositeView contains a view other than CompositeView.


createObjectView

protected static CompositeView createObjectView(ViewFactory factory,
                                                DisplayContext context,
                                                ObjectView view,
                                                Object substance,
                                                String category)
Create a view of an object, including only the attributes of a category.

Parameters:
factory - the ViewFactory
context - the DisplayContext
substance - the object to build the view of
category - the category; if null, all fields are shown
Returns:
a CompositeView representing the object

getFieldPane

public static View getFieldPane(ViewFactory factory,
                                DisplayContext context,
                                Object substance,
                                ObjectView objectView,
                                FieldItem field,
                                boolean embedded)

getViewer

protected static boolean getViewer(Object substance,
                                   FieldItem field,
                                   Object value,
                                   CompositeView container,
                                   ViewFactory factory,
                                   DisplayContext context)
Instantiates a viewer for a value of a field and add it to a container.


getPrimitiveFieldPane

protected static View getPrimitiveFieldPane(ViewFactory factory,
                                            DisplayContext context,
                                            Object substance,
                                            FieldItem field,
                                            ObjectView objectView,
                                            MemberItemView memberView,
                                            boolean embedded)
Returns a view of a primitive field. It contains a label and the value of the field.

Parameters:
factory - the view factory
context - the display context
substance - the object the field is part of
field - the field item
objectView - the object view that contains the field view
memberView - the view to build the field for
embedded - use embbeded editors

getReferenceFieldPane

protected static View getReferenceFieldPane(ViewFactory factory,
                                            DisplayContext context,
                                            Object substance,
                                            FieldItem field,
                                            boolean embedded,
                                            ObjectView objectView,
                                            MemberItemView memberView)
Build a view containing a label for the name of the field, and the view of the reference.

Parameters:
factory - the view factory
context - the display context
substance - the object the field is part of
field - the field item
embedded - use embbeded editors

addChoices

protected static void addChoices(ComboBoxModel choice,
                                 ClassItem type,
                                 Enum enum,
                                 Object substance,
                                 FieldItem field,
                                 boolean nullAllowed,
                                 String nullLabel,
                                 Predicate predicate)
Adds choices within a container containing a combobox and sort them.

Parameters:
choice - combo box model to fill
type - type of objects to fill the model with
field - associated field item
nullAllowed - boolean telling wether the add null to themodel
nullLabel - if nullAllowed==true, the label to use for the null value (if not null)
predicate - if not null, only add objects which match this predicate

getEditButton

protected static View getEditButton(ViewFactory factory,
                                    Object substance,
                                    FieldItem field,
                                    DisplayContext context)
Constructs an edit button for reference views.


getCollectionPane

public static View getCollectionPane(ViewFactory factory,
                                     DisplayContext context,
                                     Object substance,
                                     ObjectView objectView,
                                     CollectionItemView memberView,
                                     CollectionItem collection)
                              throws ViewFactory.UnhandledViewTypeException
Builds a view that will display a given collection field of an object.

Parameters:
factory - the view factory to use to build other inner views
context - the display context
substance - the object that contains the collection
collection - the collection to show
Returns:
the associated view
Throws:
ViewFactory.UnhandledViewTypeException
See Also:
TableModel

getMethodsPane

protected static CompositeView getMethodsPane(ViewFactory factory,
                                              DisplayContext context,
                                              Object substance,
                                              Collection methods,
                                              String category,
                                              ObjectView objectView)
                                       throws ViewFactory.UnhandledViewTypeException
Gets a composite panel containing a set of methods that are held by the substance object.

Throws:
ViewFactory.UnhandledViewTypeException

getMethodView

public static MethodView getMethodView(AbstractMethodItem method,
                                       Object substance,
                                       DisplayContext context,
                                       ViewFactory factory,
                                       MemberItemView memberView)
Build view for a method

Parameters:
method - the method item to build a view for
substance - the object the method shall be invoked on
context - display context
factory - a view factory
Returns:
a MethodView

createParameters

public static View createParameters(ViewFactory factory,
                                    DisplayContext context,
                                    AbstractMethodItem method,
                                    Object substance,
                                    Object[] parameters)

Create a view containing editor components for the parameters of a method.

Parameters of type org.objectweb.jac.aspects.gui.DisplayContext are not displayed.

If method is a MixinMethodItem, the first parameter is at index 1 of the parameters array.

Parameters:
factory - the ViewFactory
context - the DisplayContext
method - the method whose parameters you the view of
substance - the object on which the method will be called. It used to get a default value if the method is a setter.
parameters -
Returns:
a CompositeView containing an editor component for each parameter of the method. The returned View implements the EditorContainer interface

getEditorComponent

public static FieldEditor getEditorComponent(ViewFactory factory,
                                             DisplayContext context,
                                             Object substance,
                                             AbstractMethodItem method,
                                             int i,
                                             boolean embedded,
                                             Object value)
Returns a ValueEditor suitable for editing the i-th parameter of a method.

Parameters:
factory - the view factory
substance - the substance object
method - the method that contains the parameter
i - the parameter index
embedded - wether the editor is an embedded field editor. If true, the component will commit changes when it looses the focus (only works for swing).
value - the initial edited value. Used only if non null.

initCustomized

public static void initCustomized(ViewFactory factory,
                                  DisplayContext context,
                                  CompositeView internalView,
                                  CustomizedGUI customized,
                                  Map panels)
Initialize the panels of a customized gui.

Parameters:
factory - the view factory
context - the display context
internalView - the CompositeView which holds the panels
customized - the CustomizedGUI
panels - if not null, overrides the content of panels (panelID -> PanelContent)

setStatusBar

public static void setStatusBar(ViewFactory factory,
                                DisplayContext context,
                                CustomizedView view,
                                MethodItem statusBar,
                                String position)
Sets a status bar to a customized view.

Parameters:
factory - the used factory
context - the passed context
view - the customized that will hold the status bar
statusBar - the method item that defines the text to print within the status bar
position - the position (Constants.TOP||Constants.BOTTOM)

setMenuBars

public static void setMenuBars(ViewFactory factory,
                               DisplayContext context,
                               CustomizedView view,
                               Hashtable menuBars)
Build the menu bar of a customized gui.

Parameters:
factory - the view factory
context - the display context
view - the CustomizedView where to put the menu bar
menuBars - the menuBars

createMenu

public static MenuView createMenu(ViewFactory factory,
                                  DisplayContext context,
                                  String label,
                                  Menu content)
Creates a menu in a a customized gui.

Parameters:
factory - the view factory
context - the display context
content - the content of the menu view

setToolBar

public static void setToolBar(ViewFactory factory,
                              DisplayContext context,
                              CustomizedView view,
                              Collection toolbar)
Build the toolbar of a customized gui.

Parameters:
factory - the view factory
context - the display context
view - the CustomizedView where to put the menu bar
toolbar - the toolbar definition

createInputDialog

public static DialogView createInputDialog(Object substance,
                                           AbstractMethodItem method,
                                           Object[] parameters,
                                           DisplayContext context)
Builds a dialog box to enter the parameters of method

Parameters:
substance - object the method will be invoked on
method - the method
parameters - an array where to store the value enteres by the user
context - a display context
See Also:
createParameters(ViewFactory,DisplayContext,AbstractMethodItem,Object,Object[])

createReferenceEditor

public static FieldEditor createReferenceEditor(ViewFactory factory,
                                                DisplayContext context,
                                                Object substance,
                                                FieldItem field,
                                                String editorName,
                                                ClassItem type,
                                                Predicate predicate,
                                                boolean nullAllowed,
                                                String nullLabel,
                                                boolean isCreationAllowed)
A generic view builder for a reference editor. Returns a combox box or a text input depending on the field's configuration

Parameters:
factory -
context -
substance - the object holding the field
field - the field to build an editor for (may be null)
editorName - the name of the editor to build
type - the type of the objects to choose from
predicate - a predicate used to filter proposed objects in the case of a combobox.
nullAllowed - wether the user is authorised to select the null value
isCreationAllowed - wether the user is authorised to create new instances of type
See Also:
ClassAppearenceGuiConf.selectWithIndexedField(ClassItem,CollectionItem,String)

createEnumEditor

public static FieldEditor createEnumEditor(ViewFactory factory,
                                           DisplayContext context,
                                           Object substance,
                                           FieldItem field,
                                           String editorName,
                                           Enum enum,
                                           boolean nullAllowed,
                                           String nullLabel)