uic.output.builder
Class WidgetRepresenter

java.lang.Object
  extended byuic.output.builder.Representer
      extended byuic.output.builder.Callable
          extended byuic.output.builder.ObjectRepresenter
              extended byuic.output.builder.WidgetRepresenter
Direct Known Subclasses:
ContainerRepresenter

public class WidgetRepresenter
extends ObjectRepresenter

Any widget that has a constructor, and can be added to a container.


Nested Class Summary
static class WidgetRepresenter.EventRepresenter
           
 
Nested classes inherited from class uic.output.builder.ObjectRepresenter
ObjectRepresenter.Assignment
 
Nested classes inherited from class uic.output.builder.Callable
Callable.Argument
 
Field Summary
protected  Vector dependencies
           
protected  Vector events
           
protected  Vector methods
           
 
Fields inherited from class uic.output.builder.ObjectRepresenter
export, fieldAssignments
 
Fields inherited from class uic.output.builder.Callable
arguments
 
Fields inherited from class uic.output.builder.Representer
name, parent, staticParent
 
Constructor Summary
protected WidgetRepresenter(String name, String fullClassName)
          Convienience constructor where export is true.
protected WidgetRepresenter(String name, String fullClassName, boolean export)
          In a line where a widget is created this is the representer.
protected WidgetRepresenter(String name, String fullClassName, MethodRepresenter parent)
           
protected WidgetRepresenter(String name, String fullClassName, MethodRepresenter parent, boolean export)
           
 
Method Summary
 void addAction(MethodRepresenter initAction, CodeSnippet handlingSection)
          A widget can have a series of actions connected to it and code to handle the action at hand.
protected  void addDependency(String widgetName)
           
 void call(MethodRepresenter method)
           
 MethodRepresenter call(String method)
           
protected  void clearDependencies()
           
 MethodRepresenter deepCall(String firstMethod, String secondMethod)
          Convienience method for a case like this: this.getText().size().
 Vector getActions()
           
protected  Vector getDependencies()
           
 FieldRepresenter getField(String name)
           
 MethodRepresenter getMethod(String name)
           
 Vector getMethods()
           
 
Methods inherited from class uic.output.builder.ObjectRepresenter
export, field, getFields, setField, toString
 
Methods inherited from class uic.output.builder.Callable
addArgument, addArgument, addArgument, addArgument, addArgument, addArgument, addArgument, addArgument, addArgument, addArgument, addNullArgument, getArguments
 
Methods inherited from class uic.output.builder.Representer
getName, getParent, getStaticParent, setName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

methods

protected Vector methods

dependencies

protected Vector dependencies

events

protected Vector events
Constructor Detail

WidgetRepresenter

protected WidgetRepresenter(String name,
                            String fullClassName,
                            boolean export)
In a line where a widget is created this is the representer. The definition of widget in the context of this package is as follows; an object that methods can be called on and which can have arguments (for the constructor).

Parameters:
name - the name of the widget, like 'myPanel'
fullClassName - the classname, like javax.swing.JPanel
export - marks this widget to be a classvariable if true; otherwise it will be created in the GuiInit() method and go out of scope when leaving the method.

WidgetRepresenter

protected WidgetRepresenter(String name,
                            String fullClassName,
                            MethodRepresenter parent)

WidgetRepresenter

protected WidgetRepresenter(String name,
                            String fullClassName,
                            MethodRepresenter parent,
                            boolean export)

WidgetRepresenter

protected WidgetRepresenter(String name,
                            String fullClassName)
Convienience constructor where export is true.

Method Detail

call

public MethodRepresenter call(String method)

deepCall

public MethodRepresenter deepCall(String firstMethod,
                                  String secondMethod)
Convienience method for a case like this: this.getText().size(). Assuming the 'this' is represented by this WidgetRepresenter the call would be; myWidget.deepCall("getText", "size")

Since a method representer is returned you can call addArgument on that; be aware that the last method is returned, the 'size()' method in this example.


call

public void call(MethodRepresenter method)

getMethods

public Vector getMethods()

getField

public FieldRepresenter getField(String name)

getMethod

public MethodRepresenter getMethod(String name)

clearDependencies

protected void clearDependencies()

addDependency

protected void addDependency(String widgetName)

getDependencies

protected Vector getDependencies()

addAction

public void addAction(MethodRepresenter initAction,
                      CodeSnippet handlingSection)
A widget can have a series of actions connected to it and code to handle the action at hand. If a button is being pressed it fires an event that the controller class can listen to and subsequently do something with the button press.

In GUIs there is a high need to couple widgets together without making the controller class aware of this at all; its all view. Adding an action to a WidgetRepresenter means that the generator (Java file writer for example) will attach an handler to an event listener. In the case of a button press in Swing this means that a actionListener will be added to the button and the handling section will be called if the event comes in. The handling section will be a seperate method that can be overruled in the extening class.

In the case of a JButton this code is suppost to be created:

myButton.addActionListener( (ActionListener) EventHandler.create(ActionListener.class, this, "myButtonSlot") );

  public voic myButtonSlot() {
      // do something..
  } 
In this case the "addActionListener" methodRepresenter is the initAction argument and the 'myButtonSlot' method is the handlingSection argument.


getActions

public Vector getActions()


Copyright © 2002,2003 Thomas Zander Available under the Free Apache licence