SOA
© 2004 SoS Group
All Rights Reserved

sos.koa
Class Task

java.lang.Object
  extended bysos.koa.Task
All Implemented Interfaces:
java.awt.event.ActionListener, java.util.EventListener, KOAConstants
Direct Known Subclasses:
ClearAdapter, CountAdapter, DecryptAdapter, ExitAdapter, ImportCandidatesAdapter, ImportKeyAdapter, ImportVotesAdapter, ReportAdapter, RestartAdapter

public abstract class Task
extends java.lang.Object
implements KOAConstants, java.awt.event.ActionListener

Class which reacts to buttons in the menu.

Version:
$Id: Task.java,v 1.34 2004/05/21 20:39:37 hubbers Exp $
Author:
Martijn Oostdijk (martijno@cs.kun.nl)

Class Specifications
invariant 0 <= subTaskCount&&subTaskCount <= maxSubTasks;

Nested Class Summary
(package private)  class Task.ActionThread
          Inner class that runs this task's doAction method.
(package private)  class Task.MonitoredThread
          Inner class to monitor the ActionThread.
 
Field Summary
[spec_public] (package private)  int maxSubTasks
          The (estimated) maximum number of sub-tasks.
(package private)  javax.swing.ProgressMonitor monitor
          Progress monitor.
(package private)  boolean stillWorking
          Whether doAction is still running.
[spec_public] (package private)  int subTaskCount
          The current sub-task.
(package private)  boolean success
          Success status of this task.
 
Fields inherited from interface sos.koa.KOAConstants
ADDITIONAL_INFO_EXTRA, ADDITIONAL_INFO_MAX_HEIGHT, ADDITIONAL_INFO_MAX_WIDTH, AUDITLOG, AUDITLOG_PDF, AUDITLOG_XML, AUDITLOG_XSL, BASEDIR, CANDIDATES_IMPORTED_STATE, CLEAR_BUT_TXT, CLEAR_FAILURE_MSG, CLEAR_SUCCESS_MSG, CLEAR_TASK_MSG, CLEAR_WARNING_MSG, CLEAR_WARNING_MSG_1, CLEAR_WARNING_MSG_2, CLEARED_STATE, COUNT_BUT_TXT, COUNT_FAILURE_MSG, COUNT_SUCCESS_MSG, COUNT_TASK_MSG, COUNT_WARNING_MSG, DECRYPT_BUT_TXT, DECRYPT_ERROR_MSG, DECRYPT_ERROR_TAG, DECRYPT_FAILURE_MSG, DECRYPT_SUCCESS_MSG, DECRYPT_TASK_MSG, DECRYPT_WARNING_MSG, DECRYPTEDFILE, DEFAULT_VOTING_INTERVAL, EXIT_BUT_TXT, EXIT_FAILURE_MSG, EXIT_SUCCESS_MSG, EXIT_TASK_MSG, EXIT_WARNING_MSG, FORWARD_BACK_OPTIONS, FORWARD_MOREINFO_BACK_OPTIONS, HELP_BUT_TXT, HELP_TASK_MSG, IMPORT_CANDIDATES_BUT_TXT, IMPORT_CANDIDATES_FAILURE_MSG, IMPORT_CANDIDATES_SUCCESS_MSG, IMPORT_CANDIDATES_TASK_MSG, IMPORT_CANDIDATES_WARNING_MSG, IMPORT_KEY_FAILURE_MSG, IMPORT_KEY_SUCCESS_MSG, IMPORT_KEY_WARNING_MSG, IMPORT_PRIVATE_KEY_BUT_TXT, IMPORT_PRIVATE_KEY_TASK_MSG, IMPORT_PUBLIC_KEY_BUT_TXT, IMPORT_PUBLIC_KEY_TASK_MSG, IMPORT_VOTES_BUT_TXT, IMPORT_VOTES_FAILURE_MSG, IMPORT_VOTES_SUCCESS_MSG, IMPORT_VOTES_TASK_MSG, IMPORT_VOTES_WARNING_MSG, INIT_STATE, LESSINFO_OPTION, MAX_ENCRYPTED_VOTE_LENGTH, MAX_KEY_LENGTH, MOREINFO_OPTION, NO_ERRORS_MSG, NUMBER_OF_REDUNDANT_FIELDS, OK_CANCEL_OPTIONS, OK_LESSINFO_CANCEL_OPTIONS, OK_LESSINFO_OPTIONS, OK_MOREINFO_CANCEL_OPTIONS, OK_MOREINFO_OPTIONS, OK_OPTIONS, OUTDIR, PRIVATE_KEY_IMPORTED_STATE, PRIVATE_KEYTYPE, PUBLIC_KEY_IMPORTED_STATE, PUBLIC_KEYTYPE, RECOUNT, RECOUNT_PDF, RECOUNT_XML, RECOUNT_XSL, RELEASE, REPORT_BUT_TXT, REPORT_FAILURE_MSG, REPORT_GENERATED_STATE, REPORT_OPTIONS, REPORT_SUCCESS_MSG, REPORT_TASK_MSG, REPORT_WARNING_MSG, RESTART_BUT_TXT, RESTART_FAILURE_MSG, RESTART_SUCCESS_MSG, RESTART_TASK_MSG, RESTART_WARNING_MSG, TASK_CANCELED_MSG, TITLE, VOTES_COUNTED_STATE, VOTES_DECRYPTED_STATE, VOTES_IGNORED_SEE_MORE_INFO_MSG, VOTES_IMPORTED_STATE, YES_CANCEL_OPTIONS, YES_NO_OPTIONS
 
Constructor Summary
(package private) Task()
          Constructs this task.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent ae)
          Gets called when the button associated to this task is pressed.
(package private)  void clear()
          Clears temporary memory used by this task.
(package private) abstract  void doAction()
          Performs the actual work of this task.
(package private)  java.lang.Object getAdditionalInfo()
          Gets even more information about this (completed) task.
(package private) abstract  java.lang.String getFailureMessage()
          What to print in failure dialog.
(package private)  java.lang.String getInfo()
          Gets information that should be displayed if this task completes successfully.
(package private) abstract  java.lang.String getSuccessMessage()
          What to print in success dialog.
(package private) abstract  int getSuccessState()
          The application state after successful termination of this task.
(package private) abstract  java.lang.String getTitle()
          The title of this task.
(package private)  java.lang.String getWarningMessage()
          What to print in warning dialog used to ask user if he/she is sure to perform this task.
(package private)  boolean isAdditionalInfoAvailable()
          Indicates whether even more information is available about this (completed) task.
(package private)  boolean isCancelableTask()
          Indicates whether the effect of this task can be undone (and whether the user should be given the option to undo the task).
(package private)  boolean isDangerousTask()
          Indicates whether the user should be warned that we're about to start this task.
(package private)  boolean isModalTask()
          Indicates whether this task influences the application's state and whether the GUI should be disabled until this task completes.
(package private) abstract  boolean isPreStateAllowed(int state)
           
(package private)  boolean isProgressMonitoredTask()
          Indicates whether a progress monitor should be popped up.
(package private)  void logCanceled()
          Writes a 'task canceled' entry in the log.
(package private)  void logCompleted()
          Writes a 'task completed' entry in the log.
(package private)  void logFailed(java.lang.String reason)
          Writes a 'task failed' entry in the log.
(package private)  void logOpenedFile(java.io.File file)
          Writes a 'task opened file' entry in the log.
(package private)  void logStarted()
          Writes a 'task started' entry in the log.
(package private)  void popupAdditionalInfo()
          Pops up a dialog.
(package private)  int popupAdditionalInfo(java.lang.Object[] options)
          Pops up a dialog.
(package private)  void popupFailure(java.lang.String info)
          Pops up a dialog.
(package private)  java.io.File popupGetFile(java.lang.String extension, java.lang.String description)
          Pops up a dialog.
(package private)  java.lang.String popupGetPassword()
          Pops up a dialog.
(package private)  boolean popupNext()
          Pops up a dialog.
(package private)  boolean popupNextOrBack()
          Pops up a dialog.
(package private)  void popupSuccess()
          Pops up a dialog.
(package private)  boolean popupWarning()
          Pops up a dialog.
(package private)  void setMaxSubTasks(int maxSubTasks)
          Sets the (estimated) maximum number of sub-tasks.
(package private)  void setSubTaskCount(int subTaskCount)
          Sets the number of already completed subtasks.
(package private)  void stopAction()
          What to do to halt the execution of the doAction method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

subTaskCount

int subTaskCount
The current sub-task.

Specifications: spec_public

maxSubTasks

int maxSubTasks
The (estimated) maximum number of sub-tasks.

Specifications: spec_public

success

boolean success
Success status of this task.


stillWorking

boolean stillWorking
Whether doAction is still running.


monitor

javax.swing.ProgressMonitor monitor
Progress monitor.

Constructor Detail

Task

Task()
Constructs this task.

Method Detail

isDangerousTask

boolean isDangerousTask()
Indicates whether the user should be warned that we're about to start this task. Default is false.

Returns:
By default false.
Specifications: pure

isProgressMonitoredTask

boolean isProgressMonitoredTask()
Indicates whether a progress monitor should be popped up. Default is false.

Returns:
By default false.
Specifications: pure

isModalTask

boolean isModalTask()
Indicates whether this task influences the application's state and whether the GUI should be disabled until this task completes. Default is true.

Returns:
By default true.
Specifications: pure

isCancelableTask

boolean isCancelableTask()
Indicates whether the effect of this task can be undone (and whether the user should be given the option to undo the task). Default is false.

Returns:
By default false.
Specifications: pure

setSubTaskCount

void setSubTaskCount(int subTaskCount)
Sets the number of already completed subtasks.

Parameters:
subTaskCount - the number of already completed subtasks.
Specifications:
assignable objectState;

getInfo

java.lang.String getInfo()
Gets information that should be displayed if this task completes successfully.

Returns:
information that should be displayed if this task completes successfully.
Specifications:
assignable AuditLog.*;

isAdditionalInfoAvailable

boolean isAdditionalInfoAvailable()
Indicates whether even more information is available about this (completed) task.

Returns:
A boolean indicating whether even more information is available about this (completed) task.
Specifications: pure

getAdditionalInfo

java.lang.Object getAdditionalInfo()
Gets even more information about this (completed) task. The resulting Object can be used in a dialog message.

Returns:
Even more information about this (completed) task.
Specifications: pure

setMaxSubTasks

void setMaxSubTasks(int maxSubTasks)
Sets the (estimated) maximum number of sub-tasks.

Parameters:
maxSubTasks - the new (estimated) maximum number of sub-tasks.
Specifications:
requires maxSubTasks >= 0;
assignable objectState;
ensures this.maxSubTasks == maxSubTasks;

getTitle

abstract java.lang.String getTitle()
The title of this task. Is used in title-bar of dialogs.

Returns:
Title of this task.
Specifications: pure

getSuccessMessage

abstract java.lang.String getSuccessMessage()
What to print in success dialog.

Returns:
text to print in success dialog.
Specifications: pure

getFailureMessage

abstract java.lang.String getFailureMessage()
What to print in failure dialog.

Returns:
text to print in failure dialog.
Specifications: pure

getWarningMessage

java.lang.String getWarningMessage()
What to print in warning dialog used to ask user if he/she is sure to perform this task.

Returns:
text to print in warning dialog.
Specifications: pure

isPreStateAllowed

abstract boolean isPreStateAllowed(int state)
Specifications: pure

getSuccessState

abstract int getSuccessState()
The application state after successful termination of this task.

Returns:
the new state.
Specifications: pure

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent ae)
Gets called when the button associated to this task is pressed.

Specified by:
actionPerformed in interface java.awt.event.ActionListener
Parameters:
ae - Event indicating the button is pressed.

doAction

abstract void doAction()
                throws KOAException
Performs the actual work of this task.

Throws:
KOAException - if something goes wrong.
Specifications:
assignable objectState;

stopAction

void stopAction()
What to do to halt the execution of the doAction method.


clear

void clear()
Clears temporary memory used by this task.


logStarted

void logStarted()
Writes a 'task started' entry in the log.

Specifications:
assignable AuditLog.*;

logCanceled

void logCanceled()
Writes a 'task canceled' entry in the log.

Specifications:
assignable AuditLog.*;

logOpenedFile

void logOpenedFile(java.io.File file)
Writes a 'task opened file' entry in the log.

Specifications:
assignable AuditLog.*;

logFailed

void logFailed(java.lang.String reason)
Writes a 'task failed' entry in the log.

Specifications:
assignable AuditLog.*;

logCompleted

void logCompleted()
Writes a 'task completed' entry in the log.


popupGetFile

java.io.File popupGetFile(java.lang.String extension,
                          java.lang.String description)
                    throws KOAException
Pops up a dialog.

Throws:
KOAException
Specifications:
assignable AuditLog.*;

popupGetPassword

java.lang.String popupGetPassword()
Pops up a dialog.

Specifications: pure

popupSuccess

void popupSuccess()
Pops up a dialog.

Specifications:
assignable AuditLog.*;

popupWarning

boolean popupWarning()
Pops up a dialog.

Specifications: pure

popupNextOrBack

boolean popupNextOrBack()
Pops up a dialog.

Specifications:
assignable AuditLog.*;

popupNext

boolean popupNext()
Pops up a dialog.

Specifications:
assignable AuditLog.*;

popupFailure

void popupFailure(java.lang.String info)
Pops up a dialog.

Specifications: pure

popupAdditionalInfo

void popupAdditionalInfo()
Pops up a dialog.

Specifications: pure

popupAdditionalInfo

int popupAdditionalInfo(java.lang.Object[] options)
Pops up a dialog.

Specifications: pure

SOA
© 2004 SoS Group
All Rights Reserved