de.kleopatra.forms.view.builder
Class AbstractForm

java.lang.Object
  extended byde.kleopatra.forms.view.builder.AbstractForm
All Implemented Interfaces:
Form

public abstract class AbstractForm
extends java.lang.Object
implements Form

Convenience implementation of Form.

The component is created lazily in getFormComponent(). On first call this method will internally call

Subclasses minimally have to provide a resource != null and implement bind(..) to wire any binding/listeners/logic. See the examples for code with/without using JGoodies Binding.

Version:
$Revision: 1.5 $ - $Date: 2004/09/29 14:40:19 $
Author:
(C) 2004 Jeanette Winzenburg, Berlin

Field Summary
protected  javax.swing.JComponent form
           
protected  java.lang.Class formClass
           
protected  java.lang.String formResource
           
 
Constructor Summary
protected AbstractForm()
           
  AbstractForm(java.lang.String formResource, java.lang.Class formClass)
           
 
Method Summary
protected abstract  void bind(javax.swing.JComponent form)
          called after the form is loaded.
protected  javax.swing.JComponent buildForm(java.lang.String resource)
           
 void commit()
          does nothing...
protected  void configure(javax.swing.JComponent form)
          called after the form is loaded and the widgets are bound.
 void flush()
          does nothing...
protected  java.lang.String getButtonResource()
          resource for registering actions.
 javax.swing.JComponent getFormComponent()
          returns the JComponent associated with the resource.
 java.lang.String getResource()
          return the resource to load from.
protected  java.lang.Class getResourceClass()
          returns an appropriate class to search the resource.
 java.lang.Object getTarget()
          do nothing
 void registerActionAsHandler(java.lang.Object actionID, javax.swing.Action action)
          convenience to register a single action.
 void registerActionsAsHandlers(java.util.List actionIDs, java.util.List actions)
          a hook to register actions to buttons loaded by this form.
 void registerHandler(java.util.List actionIDs, java.lang.Object handler)
          a hook to register callback methods in an external handler to buttons loaded by this form.
protected  void setResource(java.lang.String resource, java.lang.Class targetClass)
           
 void setTarget(java.lang.Object data)
          do nothing
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

form

protected javax.swing.JComponent form

formResource

protected java.lang.String formResource

formClass

protected java.lang.Class formClass
Constructor Detail

AbstractForm

protected AbstractForm()

AbstractForm

public AbstractForm(java.lang.String formResource,
                    java.lang.Class formClass)
Method Detail

getFormComponent

public javax.swing.JComponent getFormComponent()
returns the JComponent associated with the resource. PRE: getResource() != null.

Specified by:
getFormComponent in interface Form
Returns:
a component built from a layout resource.

getResource

public java.lang.String getResource()
Description copied from interface: Form
return the resource to load from.

PENDING: really needed to expose publicly? Used only in FormUtils as default title ...

Specified by:
getResource in interface Form
Returns:

getTarget

public java.lang.Object getTarget()
do nothing

Specified by:
getTarget in interface Form
Returns:

setTarget

public void setTarget(java.lang.Object data)
do nothing

Specified by:
setTarget in interface Form
Parameters:
data -

commit

public void commit()
does nothing...

Specified by:
commit in interface Form

flush

public void flush()
does nothing...

Specified by:
flush in interface Form

registerHandler

public void registerHandler(java.util.List actionIDs,
                            java.lang.Object handler)
Description copied from interface: Form
a hook to register callback methods in an external handler to buttons loaded by this form.

Specified by:
registerHandler in interface Form
Parameters:
actionIDs - a list of methods names
handler - the object implementing the methods

registerActionsAsHandlers

public void registerActionsAsHandlers(java.util.List actionIDs,
                                      java.util.List actions)
Description copied from interface: Form
a hook to register actions to buttons loaded by this form.

NOTE: it's the responsibility of the calling code to keep the two parameter lists in synch.

Specified by:
registerActionsAsHandlers in interface Form
Parameters:
actionIDs - a list of actions
actions - a list of corresponding button ids

registerActionAsHandler

public void registerActionAsHandler(java.lang.Object actionID,
                                    javax.swing.Action action)
convenience to register a single action.

Parameters:
actionID -
action -

bind

protected abstract void bind(javax.swing.JComponent form)
called after the form is loaded.

Parameters:
form -

configure

protected void configure(javax.swing.JComponent form)
called after the form is loaded and the widgets are bound.

Parameters:
form -

setResource

protected void setResource(java.lang.String resource,
                           java.lang.Class targetClass)

getResourceClass

protected java.lang.Class getResourceClass()
returns an appropriate class to search the resource. here: returns formClass if explicitly set or getClass()

Returns:

getButtonResource

protected java.lang.String getButtonResource()
resource for registering actions. Here: same as getResource()


buildForm

protected javax.swing.JComponent buildForm(java.lang.String resource)


Copyright © 2003, 2004 SwingEmpire Jeanette Winzenburg. All Rights Reserved.