context.arch.service
Class DisplayChoiceService

java.lang.Object
  |
  +--context.arch.service.Service
        |
        +--context.arch.service.DisplayChoiceService

public class DisplayChoiceService
extends Service
implements java.awt.event.ActionListener

This class implements the display choices service. It accepts a list of choices, a question to display and a title to display, displays them in a frame to the user and collects the user's choice.

See Also:
Service, ActionListener

Field Summary
static java.lang.String CHOICE
          Tag for a CHOICE
static java.lang.String DISPLAY
          Tag for the DISPLAY function
static java.lang.String DISPLAY_CHOICES
          Tag for the DISPLAY_CHOICES service
static java.lang.String QUESTION
          Tag for QUESTION to be asked
static java.lang.String TITLE
          Tag for TITLE of the frame
 
Fields inherited from class context.arch.service.Service
ASYNCHRONOUS, comm, EXECUTED, EXECUTING, FAILED, pending, SERVICE_REQUEST, SERVICE_REQUEST_REPLY, SERVICE_RESULT, SERVICE_RESULT_REPLY, STATUS, SYNCHRONOUS
 
Constructor Summary
DisplayChoiceService(CommunicationsHandler comm)
          Basic constructor that creates the service object.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent evt)
          This method is called when the user interacts with the frame that displays choices.
 DataObject execute(ServiceInput serviceInput)
          This method is called when a remote component requests that this service be executed.
 
Methods inherited from class context.arch.service.Service
getFunctionDescriptions, getName, getServiceDescription, sendServiceResult, setFunctionDescriptions, setName, toDataObject
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DISPLAY_CHOICES

public static final java.lang.String DISPLAY_CHOICES
Tag for the DISPLAY_CHOICES service

DISPLAY

public static final java.lang.String DISPLAY
Tag for the DISPLAY function

TITLE

public static final java.lang.String TITLE
Tag for TITLE of the frame

QUESTION

public static final java.lang.String QUESTION
Tag for QUESTION to be asked

CHOICE

public static final java.lang.String CHOICE
Tag for a CHOICE
Constructor Detail

DisplayChoiceService

public DisplayChoiceService(CommunicationsHandler comm)
Basic constructor that creates the service object. It defines the DISPLAY_CHOICES service and the DISPLAY function.
See Also:
Service.setFunctionDescriptions(FunctionDescriptions)
Method Detail

execute

public DataObject execute(ServiceInput serviceInput)
This method is called when a remote component requests that this service be executed. The input the service name, function name, frame title, question to ask the user, and list of potential choices. It creates a frame and displays it to the user and adds the input request to the pending queue. It returns the status of the service request.
Overrides:
execute in class Service
Parameters:
serviceInput - Object containing the necessary information to execute the service
Returns:
DataObject that indicates the status of the request

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent evt)
This method is called when the user interacts with the frame that displays choices. It gets the user choice, determines which pending request the result is for, removes the request from the pending queue returns the results to the requester, and removes the frame.
Specified by:
actionPerformed in interface java.awt.event.ActionListener
Parameters:
evt - ActionEvent from a user interacting with the frame
See Also:
Service.sendServiceResult(ServiceInput,AttributeNameValues)