wt.clients.util
Class TaskDelegate

java.lang.Object
  extended bywt.clients.util.TaskDelegate
Direct Known Subclasses:
BusinessEntityTaskDelegate, ConfigurationItemTaskDelegate, EPMDocumentMasterTaskDelegate, EPMDocumentTaskDelegate, FolderTaskDelegate, LifeCycleTemplateTaskDelegate, ManagedBaselineTaskDelegate, ProjectTaskDelegate, ReportTemplateTaskDelegate, ShortcutTaskDelegate, TeamTemplateTaskDelegate, WfProcessTaskDelegate, WfProcessTemplateTaskDelegate, WTChangeIssueTaskDelegate, WTChangeOrder2TaskDelegate, WTChangeRequest2TaskDelegate, WTDocumentMasterTaskDelegate, WTDocumentTaskDelegate, WTPartMasterTaskDelegate, WTPartTaskDelegate, WTProductConfigurationTaskDelegate, WTProductInstance2TaskDelegate, WTProductTaskDelegate, WTRNRequestTaskDelegate, WTSerialNumberedPartTaskDelegate, WTUnitTaskDelegate

public class TaskDelegate
extends Object

Class TaskDelegate is a utility which supports launching create, update, view and delete tasks associated with a particular business object. The TaskDelegate class is intended to be subclassed to provide TaskDelegates for various business objects. By having subclasses of this class follow a naming convention, a user of the task delegates can launch the tasks associated with a particular business object without knowing the specific type of the business object.

For example, the WindchillExplorerFrame uses the TaskDelegate to launch the create, view and update tasks of objects that live in a folder.

The TaskDelegateFactory is used in conjunction with this class to generate an instance of a TaskDelegate on which the various tasks can be launched:

    public class MyDisplay extends Frame {
       ...
       public void handleViewEvent( Event evt ) {
          Object obj_to_view = evt.getSource();
          TaskDelegate delegate =
                 TaskDelegateFactory.instantiateTaskDelegate( obj_to_view );
            if( delegate != null ) {
               delegate.setParentApplet( getParentApplet() );
               delegate.setParentFrame( this );
               delegate.setObject( obj_to_view );

           try {
                delegate.launchViewTask();
             } catch (TaskDelegateException tde) {
             // Handle Exception
         }
       }
       ...
    }
  

See Also:


Supported API: true

Extendable: false

Field Summary
static String ACTION_KEY
           
static String OBJ_PROPS_ACTION
           
protected  Object object
           
protected  WTReference objReference
           
static String OID_KEY
           
protected  Applet parentApplet
           
protected  Folder parentFolder
           
protected  Frame parentFrame
           
private static String RESOURCES
           
static String URL_TEMPLATE_ACTION
           
static String URLPROCESSOR_CLASS
           
 
Constructor Summary
TaskDelegate()
           
 
Method Summary
protected  boolean confirmAction(String message)
          Launches a dialog prompting the user to confirm an action.
protected  void deleteObject()
           
 void displayPropertiesPage()
          Displays the HTML object properties page for the context object.
 Object getObject()
          Returns the Object which is used as the target of the view, update, and delete tasks.
 Applet getParentApplet()
          Returns the parent Applet.
 Folder getParentFolder()
          Returns the parent Folder of this delegate.
 Frame getParentFrame()
          Returns the parent Frame of this delegate.
 void launchCreateTask()
          Method launchCreateTask is invoked to launch the task to create a particular business object.
 void launchDeleteTask()
          Method launchDeleteTask is invoked to launch the task to delete a particular business object.
 void launchSaveAsTask()
          Method launchSaveAsTask is invoked to launch the task to create a particular business object from an existing one.
 void launchUpdateTask()
          Method launchUpdateTask is invoked to launch the task to update a particular business object.
 void launchViewDistributionListTask()
          Method launchViewDistributionListTask is invoked to launch the task to view a particular business object.
 void launchViewTask()
          Method launchViewTask is invoked to launch the task to view a particular business object.
 void setObject(Object obj)
          Sets the object to be used as the target of the view, update, and delete tasks.
 void setObjectReference(WTReference reference)
          Sets the WTReference which corresponds to the object to be used as the target of the view, update and delete tasks.
 void setParentApplet(Applet applet)
          Sets the parent Applet of this delegate.
 void setParentFolder(Folder folder)
          Sets the parent Folder.
 void setParentFrame(Frame frame)
          Sets the parent Frame of this delegate.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

parentApplet

protected Applet parentApplet

parentFrame

protected Frame parentFrame

parentFolder

protected Folder parentFolder

object

protected Object object

objReference

protected WTReference objReference

RESOURCES

private static final String RESOURCES
See Also:
Constant Field Values

OID_KEY

public static String OID_KEY

ACTION_KEY

public static String ACTION_KEY

OBJ_PROPS_ACTION

public static String OBJ_PROPS_ACTION

URLPROCESSOR_CLASS

public static String URLPROCESSOR_CLASS

URL_TEMPLATE_ACTION

public static String URL_TEMPLATE_ACTION
Constructor Detail

TaskDelegate

public TaskDelegate()
Method Detail

setParentApplet

public void setParentApplet(Applet applet)
Sets the parent Applet of this delegate. The applet instance is often used by client applications to retrieve the appropriate WTContext for that client.

Parameters:
applet - the Applet to set as the parent Applet
See Also:
getParentApplet(), WTContext

getParentApplet

public Applet getParentApplet()
Returns the parent Applet.

Returns:
the parent Applet of this delegate
See Also:
setParentApplet(java.applet.Applet)

setParentFrame

public void setParentFrame(Frame frame)
Sets the parent Frame of this delegate. The parent frame is provided to support tasks which involve launching dialogs. The parent frame can be used to parent those dialogs.

Parameters:
frame - the parent Frame of this delegate
See Also:
getParentFrame()

getParentFrame

public Frame getParentFrame()
Returns the parent Frame of this delegate. If no parent frame has been explicitly set, this method attempts to retrieve a Frame from the parent Applet if that has been set.

Returns:
the parent Frame of this delegate
See Also:
setParentApplet(java.applet.Applet), setParentFrame(java.awt.Frame)

setParentFolder

public void setParentFolder(Folder folder)
Sets the parent Folder. Setting the parent folder is useful when the business object associated with this delegate is Foldered. For example, by invoking setParentFolder, the Folder in which to create a new Foldered object can be initialized:
       Folder folder = getSelectedFolder();
       if( folder != null ) {
          delegate.setParentFolder( folder );
       }
       try {
          delegate.launchCreateTask();
       } catch (TaskDelegateException tde ) {
          ...
       }
  

Parameters:
folder - the Folder to be set as the parent folder
See Also:
getParentFolder(), Folder

getParentFolder

public Folder getParentFolder()
Returns the parent Folder of this delegate.

Returns:
the parent Folder of this delegate
See Also:
setParentFolder(wt.folder.Folder), Folder

setObject

public void setObject(Object obj)
Sets the object to be used as the target of the view, update, and delete tasks.

Parameters:
obj - the Object which is used in launching the view, update, and delete tasks
See Also:
getObject(), launchViewTask(), launchUpdateTask(), launchDeleteTask()

getObject

public Object getObject()
Returns the Object which is used as the target of the view, update, and delete tasks. If the object associated with this task has not been explicitly set, but has been set by an object reference, this method will retrieve the object from the object reference and return that object.

Returns:
the Object which is used in launching the view, update, and delete tasks
See Also:
getObject(), launchViewTask(), launchUpdateTask(), launchDeleteTask(), WTReference

setObjectReference

public void setObjectReference(WTReference reference)
Sets the WTReference which corresponds to the object to be used as the target of the view, update and delete tasks.

Parameters:
reference - the WTReference which is a reference to the object
See Also:
WTReference

launchCreateTask

public void launchCreateTask()
                      throws TaskDelegateException
Method launchCreateTask is invoked to launch the task to create a particular business object. Subclasses of this TaskDelegate class should implement the create task to support creating instances of the business object they represent. Since this TaskDelegate class is intented to be subclassed, this method provides no implementation. It method should be implemented to throw an exception when invoked, but simply does nothing.

Throws:
TaskDelegateException - if an error occurs launching a create task

launchSaveAsTask

public void launchSaveAsTask()
                      throws TaskDelegateException
Method launchSaveAsTask is invoked to launch the task to create a particular business object from an existing one. Subclasses of this TaskDelegate class should implement the saveas task to support creating instances of the business object they represent. Since this TaskDelegate class is intented to be subclassed, this method provides no implementation. It method should be implemented to throw an exception when invoked, but simply does nothing.

Throws:
TaskDelegateException - if an error occurs launching a create task

launchViewTask

public void launchViewTask()
                    throws ObjectNoLongerExistsException,
                           NotAuthorizedException,
                           TaskDelegateException,
                           WTException
Method launchViewTask is invoked to launch the task to view a particular business object. Subclasses of this TaskDelegate class should implement the view task to support viewing instances of the business object they represent. The particular object to be viewed is specified via setObject. This method currently only contains the code to refresh the object to be viewed.

Throws:
ObjectNoLongerExistsException - if the object no longer exists in the database
NotAuthorizedException - if the current user does not have permission to view the object
TaskDelegateException - if an error occurs launching a view task
WTException - if an error occurs preparing the object for viewing
See Also:
setObject(java.lang.Object)

launchUpdateTask

public void launchUpdateTask()
                      throws ModificationNotAllowedException,
                             ObjectNoLongerExistsException,
                             NotAuthorizedException,
                             TaskDelegateException,
                             WTException
Method launchUpdateTask is invoked to launch the task to update a particular business object. Subclasses of this TaskDelegate class should implement the update task to support updating instances of the business object they represent. The particular business object to be updated is specified via setObject. The implementation of this method prepares the given object for modification. Subclasses of this delegate class can invoke super.launchUpdateTask() in their implementations of this method to prepare the given object for modification.

Throws:
ModificationNotAllowedException - if the current user has permission to view but not modify the object
ObjectNoLongerExistsException - if the object no longer exists in the database
NotAuthorizedException - if the current user does not have permission to modify nor view the object
TaskDelegateException - if an error occurs launching a update task
WTException - if an error occurs preparing the object for modification

launchDeleteTask

public void launchDeleteTask()
                      throws TaskDelegateException,
                             WTException
Method launchDeleteTask is invoked to launch the task to delete a particular business object. Subclasses of this TaskDelegate class should implement the delete task to support deleting instances of the business object they represent. The particular object to be deleted is specified via setObject. This method will delete the object and then dispatch a RefreshEvent which broadcasts to RefreshListeners that the object was deleted.

Throws:
TaskDelegateException - if an error occurs deleting the object
WTException
See Also:
RefreshEvent, RefreshListener

launchViewDistributionListTask

public void launchViewDistributionListTask()
                                    throws ObjectNoLongerExistsException,
                                           NotAuthorizedException,
                                           TaskDelegateException,
                                           WTException
Method launchViewDistributionListTask is invoked to launch the task to view a particular business object. Subclasses of this TaskDelegate class should implement the view task to support viewing instances of the business object they represent. The particular object to be viewed is specified via setObject. This method currently only contains the code to refresh the object to be viewed.

Throws:
ObjectNoLongerExistsException - if the object no longer exists in the database
NotAuthorizedException - if the current user does not have permission to view the object
TaskDelegateException - if an error occurs launching a view task
WTException - if an error occurs preparing the object for viewing
See Also:
setObject(java.lang.Object)

confirmAction

protected boolean confirmAction(String message)
                         throws TaskDelegateException
Launches a dialog prompting the user to confirm an action. The displayed dialog allows the user to either Ok or Cancel the pending action.

Parameters:
message - the String message asking the user to confirm some action
Throws:
TaskDelegateException - thrown if no Frame is found to support the dialog

deleteObject

protected void deleteObject()
                     throws WTException
Throws:
WTException

displayPropertiesPage

public void displayPropertiesPage()
                           throws ObjectNoLongerExistsException,
                                  NotAuthorizedException,
                                  TaskDelegateException,
                                  WTException
Displays the HTML object properties page for the context object. Note that in release 5.0, this method will be called directly by 'launchViewTask'

Throws:
ObjectNoLongerExistsException - if the context object has been deleted
NotAuthorizedException - if the current user is not authorized to view the object
TaskDelegateException - if an error occurs displaying the properties page for the object
WTException - if an error occurs displaying the properties page for the object