org.geotoolkit.gui.swing
Class ProgressWindow

Object
  extended by ProgressController
      extended by ProgressWindow
All Implemented Interfaces:
EventListener, ProcessListener, Disposable, Localized

@ThreadSafe
public class ProgressWindow
extends ProgressController
implements Disposable

Reports progress of a lengthly operation in a window. This implementation can also formats warnings. Its method can be invoked from any thread (it doesn't need to be the Swing thread), which make it easier to use it from some background thread. Such background thread should have a low priority in order to avoid delaying Swing repaint events.

 

 

Since:
1.0
Version:
3.19
Author:
Martin Desruisseaux (MPO, IRD, Geomatys)
Module:
display/geotk-widgets-swing (download)    View source code for this class

Constructor Summary
ProgressWindow(Component parent)
          Creates a window for reporting progress.
 
Method Summary
 void completed()
          Notifies that the operation has finished.
 void dispose()
          Releases any resource holds by this window.
 void exceptionOccurred(Throwable exception)
          Displays an exception stack trace.
 String getTitle()
          Returns the window title.
 void setProgress(float percent)
          Notifies this controller of progress in the lengthly operation.
 void setTask(CharSequence task)
          Sets the description of the current task being performed.
 void setTitle(String name)
          Sets the window title.
 void started()
          Notifies that the operation begins.
 void warningOccurred(String source, String location, String warning)
          Displays a warning message under the progress bar.
 
Methods inherited from class ProgressController
cancel, completed, failed, getLocale, getProgress, getTask, isCanceled, progressing, started
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ProgressWindow

public ProgressWindow(Component parent)
Creates a window for reporting progress. The window will not appears immediately. It will appears only when the started() method will be invoked.

Parameters:
parent - The parent component, or null if none.
Method Detail

setTitle

public void setTitle(String name)
Sets the window title. A null value resets the default title.

Parameters:
name - The new window title.

getTitle

public String getTitle()
Returns the window title. The default title is "Progress" localized in current locale.

Returns:
The current window title.

setTask

public void setTask(CharSequence task)
Sets the description of the current task being performed. This method is usually invoked before any progress begins. However, it is legal to invoke this method at any time during the operation, in which case the task label is updated without any change to the percentage accomplished.

Overrides:
setTask in class ProgressController
Parameters:
task - Description of the task being performed as a String or InternationalString, or null if none.
Since:
2.3

started

public void started()
Notifies that the operation begins. This method display the windows if it was not already visible.

Specified by:
started in class ProgressController

setProgress

public void setProgress(float percent)
Notifies this controller of progress in the lengthly operation. Progresses are reported as a value between 0 and 100 inclusive. Values out of bounds will be clamped.

Overrides:
setProgress in class ProgressController
Parameters:
percent - The progress as a value between 0 and 100 inclusive.

warningOccurred

public void warningOccurred(String source,
                            String location,
                            String warning)
Displays a warning message under the progress bar. The text area for warning messages will appears only the first time this method is invoked.

Specified by:
warningOccurred in class ProgressController
Parameters:
source - Name of the warning source, or null if none. This is typically the filename in process of being parsed or the URL of the data being processed.
location - Text to write on the left side of the warning message, or null if none. This is typically the line number where the error occurred in the source file or the feature ID of the feature that produced the message.
warning - The warning message.

exceptionOccurred

public void exceptionOccurred(Throwable exception)
Displays an exception stack trace.

Specified by:
exceptionOccurred in class ProgressController
Parameters:
exception - The exception to report.

completed

public void completed()
Notifies that the operation has finished. The window will disappears, except if it contains warning or exception stack traces.

Specified by:
completed in class ProgressController

dispose

public void dispose()
Releases any resource holds by this window. Invoking this method destroy the window.

Specified by:
dispose in interface Disposable


Copyright © 2009-2012 Geotoolkit.org. All Rights Reserved.