org.objectweb.jac.aspects.gui
Class EventHandler

java.lang.Object
  |
  +--org.objectweb.jac.aspects.gui.EventHandler
All Implemented Interfaces:
FieldUpdate

public class EventHandler
extends Object
implements FieldUpdate

This handler manages events received from GUIs (web and swing for now). It is especially used for lists and arrays (onSelection, onView, etc ...)


Constructor Summary
EventHandler()
           
 
Method Summary
 void fieldUpdated(Object substance, FieldItem field, Object value, Object param)
          Upcalled when a field was modified.
static EventHandler get()
           
 void handleResult(DisplayContext context, HandlerResult hres)
           
static void initAutocreatedObject(Object created, Object substance, FieldItem role)
          Initialize an autocreated object by setting
 void maybeInvalidatePane(ViewFactory factory, DisplayContext context, CustomizedView customizedView, String selectedPaneID)
          Removes the content of pane when another pane's content is changed
 void onAddToCollection(DisplayContext context, AddEvent add)
          This method is upcalled when an object is added to a collection.
 void onAddToCollection(DisplayContext context, AddEvent add, boolean noAutoCreate)
          This method is upcalled when an object is added to a collection.
 Object onCreateObject(DisplayContext context, ClassItem cli, Object substance, FieldItem field)
          This method is upcalled when an object has to be created in an object chooser.
 void onDropObject(DisplayContext context, Object target, Object droppedObject, Object source, boolean copy)
           
 InvokeThread onInvoke(DisplayContext context, InvokeEvent invoke)
          Upcalled when an invocation is performed on an object.
 InvokeThread onInvoke(DisplayContext context, InvokeEvent invoke, boolean askFormParameters, String[] attrNames, Object[] attrValues)
          Invoke a method in the general case.
 InvokeThread onInvoke(DisplayContext context, InvokeEvent invoke, String[] attrNames, Object[] attrValues)
          Upcalled when an invocation is performed on an object.
 void onInvokeDirect(DisplayContext context, Object substance, AbstractMethodItem method, Object[] parameters)
          Upcalled when a direct invocation is performed on an object (no parameters will be asked by the GUI).
 Object onInvokeSynchronous(DisplayContext context, InvokeEvent invoke)
          Invoke a method and waits for the result (and returns it).
 void onNodeSelection(DisplayContext context, AbstractNode node, boolean forceView)
          Upcalled when a tree node is selected.
 void onRemoveFromCollection(DisplayContext context, RemoveEvent remove, boolean askFormParameters)
          This method is upcalled when an object is removed from a collection.
 void onSelection(DisplayContext context, MemberItem container, Object selectedObject, FieldItem field, Object extraOption)
          Upcalled when a selection occurs on a field.
 void onSelection(DisplayContext context, MemberItem container, Object selectedObject, FieldItem field, Object extraOption, boolean forceView)
          Upcalled when a selection occurs on a field.
 void onView(DisplayContext context, MemberItem container, Object selectedObject, FieldItem field, Object extraOption)
          Upcalled when a view is asked on an object.
 void setFocus(View top, FieldItem field, Object option)
          Gives focus to the view which is a field editor for a given field.
static FieldItem setOppositeRole(FieldItem field)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EventHandler

public EventHandler()
Method Detail

get

public static EventHandler get()

onSelection

public void onSelection(DisplayContext context,
                        MemberItem container,
                        Object selectedObject,
                        FieldItem field,
                        Object extraOption)
Upcalled when a selection occurs on a field.

Parameters:
context - the context
container - ???
selectedObject - the selected object
field - ???
extraOption -

onView

public void onView(DisplayContext context,
                   MemberItem container,
                   Object selectedObject,
                   FieldItem field,
                   Object extraOption)
Upcalled when a view is asked on an object.

Parameters:
context - the context
container - ???
selectedObject - the selected object
field - ???
extraOption -

onSelection

public void onSelection(DisplayContext context,
                        MemberItem container,
                        Object selectedObject,
                        FieldItem field,
                        Object extraOption,
                        boolean forceView)
Upcalled when a selection occurs on a field. Displays a view of the selected object.

Parameters:
context - the context
container - member (reference, collection, or method) that references the selected object (the result in case of a method)
selectedObject - the selected object
field - give focus to this field in the view of the selected object
extraOption -
forceView - when true, a window containing the selected object is opened if we could not find a place where to put the new view.

handleResult

public void handleResult(DisplayContext context,
                         HandlerResult hres)

maybeInvalidatePane

public void maybeInvalidatePane(ViewFactory factory,
                                DisplayContext context,
                                CustomizedView customizedView,
                                String selectedPaneID)
Removes the content of pane when another pane's content is changed

Parameters:
selectedPaneID - ID of the selected pane

setFocus

public void setFocus(View top,
                     FieldItem field,
                     Object option)
Gives focus to the view which is a field editor for a given field.

Parameters:
top - view to start searching from. All subviews of this view will be recursively inspected.
field - the field whose editor to search for
option - an option that will be passed when calling onSetFocus() on the FieldEditor.
See Also:
FieldEditor.onSetFocus(Object)

initAutocreatedObject

public static void initAutocreatedObject(Object created,
                                         Object substance,
                                         FieldItem role)
Initialize an autocreated object by setting


onNodeSelection

public void onNodeSelection(DisplayContext context,
                            AbstractNode node,
                            boolean forceView)
Upcalled when a tree node is selected.

Parameters:
context - the display context
node - the selected tree node
forceView - if true, the subtance of the node is opened in a new window

onInvokeDirect

public void onInvokeDirect(DisplayContext context,
                           Object substance,
                           AbstractMethodItem method,
                           Object[] parameters)
Upcalled when a direct invocation is performed on an object (no parameters will be asked by the GUI).

Parameters:
context - the display context
substance - the object that holds the method
method - the method to invoke
parameters - the parameters of the method

onInvoke

public InvokeThread onInvoke(DisplayContext context,
                             InvokeEvent invoke)
Upcalled when an invocation is performed on an object.

Parameters:
context - the display context
invoke -
Returns:
the thread the method was invoked in
See Also:
onInvoke(DisplayContext,InvokeEvent,String[],Object[]), onInvoke(DisplayContext,InvokeEvent,boolean,String[],Object[])

onInvoke

public InvokeThread onInvoke(DisplayContext context,
                             InvokeEvent invoke,
                             String[] attrNames,
                             Object[] attrValues)
Upcalled when an invocation is performed on an object.

Parameters:
context - the display context
invoke -
attrNames - the contextual attributes names to pass
attrValues - the contextual attributes values
Returns:
the thread the method was invoked in
See Also:
onInvoke(DisplayContext,InvokeEvent), onInvoke(DisplayContext,InvokeEvent,boolean,String[],Object[])

onInvoke

public InvokeThread onInvoke(DisplayContext context,
                             InvokeEvent invoke,
                             boolean askFormParameters,
                             String[] attrNames,
                             Object[] attrValues)
Invoke a method in the general case. Sets the necessary attributes in the context. The method is invoked in a new thread.

Parameters:
context - the display context
invoke -
attrNames - the contextual attributes names to pass
attrValues - the contextual attributes values
Returns:
the thread the method was invoked in
See Also:
onInvoke(DisplayContext,InvokeEvent), onInvoke(DisplayContext,InvokeEvent,String[],Object[])

onInvokeSynchronous

public Object onInvokeSynchronous(DisplayContext context,
                                  InvokeEvent invoke)
Invoke a method and waits for the result (and returns it).

Parameters:
context - the display context
invoke - the method invocation to perform

onAddToCollection

public void onAddToCollection(DisplayContext context,
                              AddEvent add)
This method is upcalled when an object is added to a collection.

Parameters:
context - the display context
add - the add that triggered the event

onAddToCollection

public void onAddToCollection(DisplayContext context,
                              AddEvent add,
                              boolean noAutoCreate)
This method is upcalled when an object is added to a collection.

Parameters:
context - the display context
add - the add that triggered the event
noAutoCreate - if true, does not auto create the object to add, whatever the configuration for the collection.

onRemoveFromCollection

public void onRemoveFromCollection(DisplayContext context,
                                   RemoveEvent remove,
                                   boolean askFormParameters)
This method is upcalled when an object is removed from a collection.

Parameters:
context - the display context
remove -
askFormParameters - wether to to display an input box for the parameters of the remover method

onCreateObject

public Object onCreateObject(DisplayContext context,
                             ClassItem cli,
                             Object substance,
                             FieldItem field)
This method is upcalled when an object has to be created in an object chooser.

Parameters:
context - the display context
cli - the class of the object to create
substance -
field - a field to which the created object will be "added". May be null.

onDropObject

public void onDropObject(DisplayContext context,
                         Object target,
                         Object droppedObject,
                         Object source,
                         boolean copy)

fieldUpdated

public void fieldUpdated(Object substance,
                         FieldItem field,
                         Object value,
                         Object param)
Description copied from interface: FieldUpdate
Upcalled when a field was modified.

Specified by:
fieldUpdated in interface FieldUpdate
Parameters:
substance - the object of which a field was updated
field - the updated field
value - new value of the vield
param - extra infos (unused)
See Also:
ViewControlWrapper.registerField(Wrappee,FieldItem,FieldUpdate,Object)

setOppositeRole

public static FieldItem setOppositeRole(FieldItem field)