org.fuin.utils4swing.progress
Class FileCopyProgressMonitor

java.lang.Object
  extended by org.fuin.utils4swing.progress.FileCopyProgressMonitor
All Implemented Interfaces:
FileCopyProgressListener

public final class FileCopyProgressMonitor
extends java.lang.Object
implements FileCopyProgressListener

A class to monitor the progress of a copying a list of files using frame.


Constructor Summary
FileCopyProgressMonitor(org.fuin.utils4j.Cancelable cancelable, java.lang.String title, int fileMax)
          Constructor with basic arguments.
FileCopyProgressMonitor(org.fuin.utils4j.Cancelable cancelable, java.lang.String title, java.lang.String transferText, java.lang.String srcLabelText, java.lang.String destLabelText, int fileMax)
          Constructor with basic arguments.
 
Method Summary
 void close()
          Close the frame and free all resources.
 org.fuin.utils4j.Cancelable getCancelable()
          The unit that gets notified when the user presses the "cancel" button - If null the "cancel" button is disabled.
 int getCurrentByte()
          Returns the byte counter.
 int getCurrentFile()
          Returns the file counter.
 java.lang.String getDestLabelText()
          Returns the text for the "destination" label.
 int getFileMax()
          Return the total number of files to be copied.
 java.lang.String getSrcLabelText()
          Returns the text for the "source" label.
 java.lang.String getTitle()
          Returns the title for the panel and frame.
 java.lang.String getTransferText()
          Returns the text for the "file transfer" (Example: "Transferring file $N of $M...").
 boolean isCanceled()
          Returns if the monitor was canceled.
static void main(java.lang.String[] args)
          Main method to test the monitor.
 void open()
          Show the monitor dialog.If called outside the EDT this method will switch to the UI thread using SwingUtilities.invokeAndWait(Runnable).
 void updateByte(int n)
          Updates the current byte number of the file transferred.If called outside the EDT this method will switch to the UI thread using SwingUtilities.invokeLater(Runnable).
 void updateFile(java.lang.String sourceFile, java.lang.String destFile, int currentFile, int fileSize)
          Starts a new file being transferred.If called outside the EDT this method will switch to the UI thread using SwingUtilities.invokeLater(Runnable).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileCopyProgressMonitor

public FileCopyProgressMonitor(org.fuin.utils4j.Cancelable cancelable,
                               java.lang.String title,
                               int fileMax)
Constructor with basic arguments.

Parameters:
cancelable - Someone to notify if the user pressed the "cancel" button - If null the "cancel" button will be disabled.
title - Title for the panel and frame - If null a default title will be used.
fileMax - Number of files to be copied.

FileCopyProgressMonitor

public FileCopyProgressMonitor(org.fuin.utils4j.Cancelable cancelable,
                               java.lang.String title,
                               java.lang.String transferText,
                               java.lang.String srcLabelText,
                               java.lang.String destLabelText,
                               int fileMax)
Constructor with basic arguments.

Parameters:
cancelable - Someone to notify if the user pressed the "cancel" button - If null the "cancel" button will be disabled.
title - Title for the panel and frame - If null a default title will be used.
transferText - Text for the "file transfer" (Example: "Transferring file $N of $M..."). Can contain two possible variables: $N = Current file number, $M = Max file count. ) - If null a default text will be used.
srcLabelText - Text for the "source" label -If null a default text will be used.
destLabelText - Text for the "destination" label -If null a default text will be used.
fileMax - Number of files to be copied.
Method Detail

getFileMax

public final int getFileMax()
Return the total number of files to be copied.

Returns:
File count.

getTransferText

public final java.lang.String getTransferText()
Returns the text for the "file transfer" (Example: "Transferring file $N of $M..."). Can contain two possible variables: $N = Current file number, $M = Max file count. )

Returns:
Text - Always non-null.

getTitle

public final java.lang.String getTitle()
Returns the title for the panel and frame.

Returns:
Title - Always non-null.

getCancelable

public final org.fuin.utils4j.Cancelable getCancelable()
The unit that gets notified when the user presses the "cancel" button - If null the "cancel" button is disabled.

Returns:
Listener or null

getSrcLabelText

public final java.lang.String getSrcLabelText()
Returns the text for the "source" label.

Returns:
Text.

getDestLabelText

public final java.lang.String getDestLabelText()
Returns the text for the "destination" label.

Returns:
Text.

getCurrentByte

public final int getCurrentByte()
Returns the byte counter.

Returns:
Byte number.

getCurrentFile

public final int getCurrentFile()
Returns the file counter.

Returns:
File number.

open

public final void open()
Show the monitor dialog.If called outside the EDT this method will switch to the UI thread using SwingUtilities.invokeAndWait(Runnable).


close

public final void close()
Close the frame and free all resources. After calling "close" the monitor object cannot be used again!If called outside the EDT this method will switch to the UI thread using SwingUtilities.invokeAndWait(Runnable).


updateFile

public final void updateFile(java.lang.String sourceFile,
                             java.lang.String destFile,
                             int currentFile,
                             int fileSize)
Starts a new file being transferred.If called outside the EDT this method will switch to the UI thread using SwingUtilities.invokeLater(Runnable).

Specified by:
updateFile in interface FileCopyProgressListener
Parameters:
sourceFile - Name and path of the source file.
destFile - Name and path of the destination file.
currentFile - Number of the current file.
fileSize - Size of the file.

updateByte

public final void updateByte(int n)
Updates the current byte number of the file transferred.If called outside the EDT this method will switch to the UI thread using SwingUtilities.invokeLater(Runnable).

Specified by:
updateByte in interface FileCopyProgressListener
Parameters:
n - Byte number.

isCanceled

public final boolean isCanceled()
Returns if the monitor was canceled.

Returns:
If it was canceled true else false.

main

public static void main(java.lang.String[] args)
Main method to test the monitor. Only for testing purposes.

Parameters:
args - Not used.


Copyright © 2009 Future Invent Informationsmanagement GmbH. All Rights Reserved.