uic.output.builder
Class WidgetRepresenter
java.lang.Object
uic.output.builder.Representer
uic.output.builder.Callable
uic.output.builder.ObjectRepresenter
uic.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.
Methods inherited from class uic.output.builder.Callable |
addArgument, addArgument, addArgument, addArgument, addArgument, addArgument, addArgument, addArgument, addArgument, addArgument, addNullArgument, getArguments |
methods
protected Vector methods
dependencies
protected Vector dependencies
events
protected Vector events
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.JPanelexport
- 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.
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