org.tentackle.appworx
Class Hook

java.lang.Object
  extended by org.tentackle.appworx.Hook

public class Hook
extends Object

Delegates certain (mostly interactive) functionality to the concrete implementation.

For example, applications should not instantiate AppDbObjectDialog directly, but use Hook.edit() instead. By using this technique it is fairly easy to change the implementation at runtime. Poolkeepers replication framework relies on that, for example.

Author:
harald

Field Summary
protected static String CLASSNAME
          The classname of the hook.
protected  AppDbObjectDialogPool dialogPool
           
protected static Hook hook
          global hook (singleton)
 
Constructor Summary
protected Hook()
          Creates a hook.
 
Method Summary
 boolean delete(AppDbObject object)
          Deletes an AppDbObject.
The user will be prompted for confirmation.
 void edit(AppDbObject object)
          Edits an AppDbObject in a non-modal dialog.
 void edit(AppDbObject object, boolean disposeOnDeleteOrSave)
          Edits an AppDbObject in a non-modal dialog.
 void edit(AppDbObject object, Component comp, boolean disposeOnDeleteOrSave)
          Edits an AppDbObject in a non-modal dialog.
 AppDbObject editModal(AppDbObject object)
          Edits an AppDbObject in a modal dialog.
 AppDbObject editModal(AppDbObject object, Component comp)
          Edits an AppDbObject in a modal dialog.
 AppDbObjectDialogPool getDialogPool()
          Gets the dialog pool.
static Hook hook()
          Gets the global hook.
static void install(String className)
          Installs the hook (overriding any existing hook) for the given public CLASSNAME.
protected  void shutdown()
          Shuts the hook down (for being replaced)
protected  void startup()
          Initializes a new hook.
 void view(AppDbObject object)
          Shows an AppDbObject in a non-modal dialog.
 void view(AppDbObject object, Component comp)
          Shows an AppDbObject in a non-modal dialog.
 void viewModal(AppDbObject object)
          Shows an AppDbObject in a modal dialog.
 void viewModal(AppDbObject object, Component comp)
          Shows an AppDbObject in a modal dialog.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CLASSNAME

protected static String CLASSNAME
The classname of the hook. Applications *must* change this via install() if the hook's implementation needs to be changed.


hook

protected static Hook hook
global hook (singleton)


dialogPool

protected AppDbObjectDialogPool dialogPool
Constructor Detail

Hook

protected Hook()
Creates a hook.

Method Detail

hook

public static Hook hook()
Gets the global hook. This is a factory method and refers to CLASSNAME.

Returns:
the hook, never null

install

public static void install(String className)
Installs the hook (overriding any existing hook) for the given public CLASSNAME.

Parameters:
className - the classname of the hook

startup

protected void startup()
Initializes a new hook. The default implementation creates an empty AppDbObjectDialogPool.


shutdown

protected void shutdown()
Shuts the hook down (for being replaced)


getDialogPool

public AppDbObjectDialogPool getDialogPool()
Gets the dialog pool.

Returns:
the dialog pool, never null

view

public void view(AppDbObject object,
                 Component comp)
Shows an AppDbObject in a non-modal dialog.

Parameters:
object - the AppDbObject to view-only
comp - optional component to determine the window owner, null = no owner

view

public void view(AppDbObject object)
Shows an AppDbObject in a non-modal dialog.

Parameters:
object - the AppDbObject to view-only

viewModal

public void viewModal(AppDbObject object,
                      Component comp)
Shows an AppDbObject in a modal dialog.

Parameters:
object - the AppDbObject to view-only
comp - optional component to determine the window owner, null = no owner

viewModal

public void viewModal(AppDbObject object)
Shows an AppDbObject in a modal dialog.

Parameters:
object - the AppDbObject to view-only

edit

public void edit(AppDbObject object,
                 Component comp,
                 boolean disposeOnDeleteOrSave)
Edits an AppDbObject in a non-modal dialog.

Parameters:
object - the AppDbObject to edit
comp - optional component to determine the window owner, null = no owner
disposeOnDeleteOrSave - true if dispose dialog after delete or save

edit

public void edit(AppDbObject object,
                 boolean disposeOnDeleteOrSave)
Edits an AppDbObject in a non-modal dialog.

Parameters:
object - the AppDbObject to edit
disposeOnDeleteOrSave - true if dispose dialog after delete or save

edit

public void edit(AppDbObject object)
Edits an AppDbObject in a non-modal dialog.

Parameters:
object - the AppDbObject to edit

editModal

public AppDbObject editModal(AppDbObject object,
                             Component comp)
Edits an AppDbObject in a modal dialog.

Parameters:
object - the AppDbObject to edit
comp - optional component to determine the window owner, null = no owner
Returns:
the (possibly reloaded) object, null if cancel.

editModal

public AppDbObject editModal(AppDbObject object)
Edits an AppDbObject in a modal dialog.

Parameters:
object - the AppDbObject to edit
Returns:
the (possibly reloaded) object, null if cancel.

delete

public boolean delete(AppDbObject object)
Deletes an AppDbObject.
The user will be prompted for confirmation. If the delete fails, an error message will be displayed.

Parameters:
object - the AppDbObject to delete
Returns:
true if deleted, false if user aborted or delete error.


Copyright © 2001-2008 Harald Krake, Bergstr. 48, 78098 Triberg, Germany, harald@krake.de