org.mycore.frontend.fileupload
Class MCRUploadProgressMonitor
java.lang.Object
java.awt.Component
java.awt.Container
java.awt.Window
java.awt.Dialog
javax.swing.JDialog
org.mycore.frontend.fileupload.MCRUploadProgressMonitor
- All Implemented Interfaces:
- ImageObserver, MenuContainer, Serializable, Accessible, RootPaneContainer, WindowConstants
public class MCRUploadProgressMonitor
- extends JDialog
This class implements a Dialog that shows messages and a progress bar while
creating, updating or deleting the derivates of a document. This class is a
singleton, there is only one instance at a time that you get with
getDialog(). The MCRUploadProgressMonitor provides methods to set the next
message that should be displayed and to start, update and finish the progress
bar.
- Version:
- $Revision: 13085 $ $Date: 2008-02-06 18:27:24 +0100 (Mi, 06 Feb 2008) $
- Author:
- Frank Lützenkirchen, Jens Kupferschmidt
- See Also:
- Serialized Form
|
Method Summary |
protected void |
cancel()
|
void |
cancel(Exception ex)
Informs the monitor that uploading is canceled because some error
occured. |
protected void |
close()
|
protected void |
end()
|
void |
endFile()
Informs the monitor that the upload of the current file is finished. |
void |
finish()
Informs the monitor that uploading of all files is finished. |
protected String |
formatSize(long bytes)
|
protected String |
formatTime(int sec)
|
boolean |
isCanceled()
|
static void |
main(String[] args)
A small test that reads all files in a given directory. |
void |
progressFile(long bytesToAdd)
Informs the monitor that a number of bytes was read for the current file. |
static void |
reportException(Exception ex)
Shows a message dialog that displays an exception that occured. |
void |
startFile(String name,
long size)
Informs the monitor that the next file is being uploaded. |
protected void |
update()
|
| Methods inherited from class javax.swing.JDialog |
addImpl, createRootPane, dialogInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getJMenuBar, getLayeredPane, getRootPane, isDefaultLookAndFeelDecorated, isRootPaneCheckingEnabled, paramString, processWindowEvent, remove, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, update |
| Methods inherited from class java.awt.Dialog |
addNotify, getTitle, hide, isModal, isResizable, isUndecorated, setModal, setResizable, setTitle, setUndecorated, show |
| Methods inherited from class java.awt.Window |
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, finalize, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getGraphicsConfiguration, getInputContext, getListeners, getLocale, getMostRecentFocusOwner, getOwnedWindows, getOwner, getToolkit, getWarningString, getWindowFocusListeners, getWindowListeners, getWindowStateListeners, isActive, isAlwaysOnTop, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isShowing, pack, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, setAlwaysOnTop, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setLocationByPlatform, setLocationRelativeTo, toBack, toFront |
| Methods inherited from class java.awt.Container |
add, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, removeNotify, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, transferFocusBackward, transferFocusDownCycle, validate, validateTree |
| Methods inherited from class java.awt.Component |
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, setVisible, show, size, toString, transferFocus, transferFocusUpCycle |
applet
protected MCRUploadApplet applet
canceled
protected boolean canceled
finished
protected boolean finished
filename
protected String filename
lbFilename
protected JLabel lbFilename
sizeFile
protected long sizeFile
bytesFile
protected long bytesFile
fileTrans
protected String fileTrans
lbBytesFile
protected JLabel lbBytesFile
fileProg
protected int fileProg
pbFile
protected JProgressBar pbFile
numFiles
protected int numFiles
fileCount
protected int fileCount
lbNumFiles
protected JLabel lbNumFiles
sizeTotal
protected long sizeTotal
bytesTotal
protected long bytesTotal
lbBytesTotal
protected JLabel lbBytesTotal
pbTotal
protected JProgressBar pbTotal
startTime
protected long startTime
endTime
protected long endTime
lastUpdate
protected long lastUpdate
lbThroughput
protected JLabel lbThroughput
lbTime
protected JLabel lbTime
button
protected JButton button
df
protected DecimalFormat df
MCRUploadProgressMonitor
protected MCRUploadProgressMonitor(int numFiles,
long sizeTotal,
MCRUploadApplet applet)
- Creates a new upload progress monitor and makes it visible.
- Parameters:
numFiles - total number of files to be uploadedsizeTotal - total byte size of all filesapplet - the UploadApplet this monitor belongs to
cancel
protected void cancel()
close
protected void close()
formatTime
protected String formatTime(int sec)
formatSize
protected String formatSize(long bytes)
update
protected void update()
startFile
public void startFile(String name,
long size)
- Informs the monitor that the next file is being uploaded.
- Parameters:
name - the name of the file without pathsize - the byte size of the file
progressFile
public void progressFile(long bytesToAdd)
- Informs the monitor that a number of bytes was read for the current file.
This is the single number of bytes read in this iteration, not the total
number of files read from this file.
- Parameters:
bytesToAdd - the single number of bytes transferred in this step
endFile
public void endFile()
- Informs the monitor that the upload of the current file is finished.
finish
public void finish()
- Informs the monitor that uploading of all files is finished.
cancel
public void cancel(Exception ex)
- Informs the monitor that uploading is canceled because some error
occured.
reportException
public static void reportException(Exception ex)
- Shows a message dialog that displays an exception that occured.
- Parameters:
ex - the Exception to be shown
end
protected void end()
isCanceled
public boolean isCanceled()
main
public static void main(String[] args)
throws Exception
- A small test that reads all files in a given directory.
- Parameters:
args - first arg is the path of the directory to read from
- Throws:
Exception - if anything goes wrong