org.faceless.pdf2.viewer2
Class LongRunningTask

java.lang.Object
  extended by org.faceless.pdf2.viewer2.LongRunningTask
Direct Known Subclasses:
Exporter.ExporterTask, Importer.ImporterTask

public abstract class LongRunningTask
extends Object

The superclass for Importer and Exporter, this general class represents a task which takes some time to run, may optionally be cancelled and which displays some sort of progress dialog.

This code is copyright the Big Faceless Organization. You're welcome to use, modify and distribute it in any form in your own projects, provided those projects continue to make use of the Big Faceless PDF library.

Since:
2.10.2

Constructor Summary
LongRunningTask()
           
 
Method Summary
 void cancel()
          Cancel the current task.
abstract  float getProgress()
          Return the progress of this task - a value from 0 (just started) to 1 (complete).
abstract  boolean isCancellable()
          Return true if this task can be cancelled before completion by the user.
 boolean isCancelled()
          Return true if this task was cancelled before completion by the user.
 boolean isRunning()
          Return true if this task is currently running.
abstract  void run()
          Run the current task.
 Thread start(JComponent parent, String title)
          Start the task.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LongRunningTask

public LongRunningTask()
Method Detail

getProgress

public abstract float getProgress()
Return the progress of this task - a value from 0 (just started) to 1 (complete).


isCancellable

public abstract boolean isCancellable()
Return true if this task can be cancelled before completion by the user.


isCancelled

public boolean isCancelled()
Return true if this task was cancelled before completion by the user.


isRunning

public boolean isRunning()
Return true if this task is currently running.


cancel

public void cancel()
Cancel the current task.


run

public abstract void run()
                  throws Exception
Run the current task. Called by start(javax.swing.JComponent, java.lang.String), this method should typically not be called directly.

Throws:
Exception

start

public Thread start(JComponent parent,
                    String title)
Start the task. The run() method is called, and a dialog displayed which will show the tasks progress as determined by the getProgress() method. If the task is cancellable, a "Cancel" button is displayed as well, which will call the cancel() method when clicked on.

Parameters:
parent - the JComponent that the dialog should be displayed relative to
title - the title of the dialog window - typically something like "Loading".


Copyright © 2001-2008 Big Faceless Organization