org.peace_tools.core
Class DeleteDialog

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by java.awt.Window
              extended by java.awt.Dialog
                  extended by javax.swing.JDialog
                      extended by org.peace_tools.core.DeleteDialog
All Implemented Interfaces:
java.awt.event.ActionListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.lang.Runnable, java.util.EventListener, javax.accessibility.Accessible, javax.swing.RootPaneContainer, javax.swing.WindowConstants

public class DeleteDialog
extends javax.swing.JDialog
implements java.awt.event.ActionListener, java.lang.Runnable

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JDialog
javax.swing.JDialog.AccessibleJDialog
 
Nested classes/interfaces inherited from class java.awt.Dialog
java.awt.Dialog.AccessibleAWTDialog, java.awt.Dialog.ModalExclusionType, java.awt.Dialog.ModalityType
 
Nested classes/interfaces inherited from class java.awt.Window
java.awt.Window.AccessibleAWTWindow
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
private  javax.swing.JPanel bottomPanel
          The bottom panel in the dialog box that contains both the OK/Cancel buttons and the progress bar.
private static java.lang.String CANT_FIND_SERVER
          A message that is formatted and displayed to the user when a server corresponding to a given job entry could not be located in the work space.
private static java.lang.String DATASET_ERROR
          Message to be displayed to the user (after formatting) to report error when deleting a workspace entry.
private  javax.swing.JCheckBox deleteFiles
          A check box to determine if the user wants the physical file to be deleted as well.
private  javax.swing.JLabel delPath
          This label is used to display the actual path being deleted when physical file deletion is requested.
private static java.lang.String FILE_DEL_ERROR
          A message that is formatted and displayed to the user when an error occurs when deleting files or directories corresponding to a given entry in the work space.
private  javax.swing.JLabel icon
          The icon that is displayed in this dialog box to the left.
private  MainFrame mainFrame
          A convenient reference to the main frame that logically owns this dialog.
private  javax.swing.JLabel mainMessage
          This label contains the main message displayed in this dialog.
private static java.lang.String[] Message
          A set of predefined static messages to be displayed to the user indicating the entry to be removed and the implications of removing the entry.
private  javax.swing.JProgressBar progressBar
          The progress bar that is placed in indeterminate mode when deleting remote entries and directories.
private static long serialVersionUID
          A generated serialization UID to keep compiler happy.
private  java.lang.Object wsEntry
          The actual work space entry to be removed by this dialog.
 
Fields inherited from class javax.swing.JDialog
accessibleContext, rootPane, rootPaneCheckingEnabled
 
Fields inherited from class java.awt.Dialog
DEFAULT_MODALITY_TYPE
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface javax.swing.WindowConstants
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, EXIT_ON_CLOSE, HIDE_ON_CLOSE
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
DeleteDialog(MainFrame mainFrame, java.lang.Object wsEntry)
          The constructor.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent event)
          Handle clicking of OK or Cancel buttons.
private  void deleteLocalFile(java.lang.String fileName)
          Helper method to delete a local file.
private  void deleteRemoteDir(Server server, java.lang.String directory)
          Helper method to recursively delete file on server.
private  void delJobFiles(Job job)
          Helper method to delete files for a given job.
private  void disposeDialog()
          Helper method to hide and dispose this dialog.
private  int getTypeCode(java.lang.Object wsObject)
          An internal method to returns a type code for a given work space entry.
private  void removeDataSet(DataSet dataSet)
          Helper method to delete a data set along with all underlying entries and files.
 void run()
          This method is called when the user clicks the OK button to delete entry(s).
 
Methods inherited from class javax.swing.JDialog
addImpl, createRootPane, dialogInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getGraphics, getJMenuBar, getLayeredPane, getRootPane, getTransferHandler, isDefaultLookAndFeelDecorated, isRootPaneCheckingEnabled, paramString, processWindowEvent, remove, repaint, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, setTransferHandler, update
 
Methods inherited from class java.awt.Dialog
addNotify, getModalityType, getTitle, hide, isModal, isResizable, isUndecorated, setModal, setModalityType, setResizable, setTitle, setUndecorated, setVisible, show, toBack
 
Methods inherited from class java.awt.Window
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getGraphicsConfiguration, getIconImages, getInputContext, getListeners, getLocale, getModalExclusionType, getMostRecentFocusOwner, getOwnedWindows, getOwner, getOwnerlessWindows, getToolkit, getWarningString, getWindowFocusListeners, getWindowListeners, getWindows, getWindowStateListeners, isActive, isAlwaysOnTop, isAlwaysOnTopSupported, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isShowing, pack, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeNotify, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, reshape, setAlwaysOnTop, setBounds, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setIconImage, setIconImages, setLocationByPlatform, setLocationRelativeTo, setMinimumSize, setModalExclusionType, setSize, setSize, 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, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, 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, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, 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, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resize, resize, setBackground, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setName, setPreferredSize, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

mainFrame

private final MainFrame mainFrame
A convenient reference to the main frame that logically owns this dialog.


wsEntry

private final java.lang.Object wsEntry
The actual work space entry to be removed by this dialog. This object is a valid work space entry such as: Job, Server, MSTClusterData, MSTData, or DataSet. However, different actions and messages are generated depending on the entry being deleted.


deleteFiles

private javax.swing.JCheckBox deleteFiles
A check box to determine if the user wants the physical file to be deleted as well. If this check box is checked, the physical files associated with the entry are deleted first before the entry is deleted.


icon

private javax.swing.JLabel icon
The icon that is displayed in this dialog box to the left. The icon is stored separately to provide the option of changing it at a later date.


progressBar

private javax.swing.JProgressBar progressBar
The progress bar that is placed in indeterminate mode when deleting remote entries and directories.


bottomPanel

private javax.swing.JPanel bottomPanel
The bottom panel in the dialog box that contains both the OK/Cancel buttons and the progress bar. Only one of them is shown as this panel is set to use a CardLayout manager.


delPath

private javax.swing.JLabel delPath
This label is used to display the actual path being deleted when physical file deletion is requested. Initially it is set to being empty.


mainMessage

private javax.swing.JLabel mainMessage
This label contains the main message displayed in this dialog. This label's message is updated when the deletion process starts to make it appear disabled.


Message

private static final java.lang.String[] Message
A set of predefined static messages to be displayed to the user indicating the entry to be removed and the implications of removing the entry. Begin and end HTML tags are added after the message is formatted in the constructor.


FILE_DEL_ERROR

private static final java.lang.String FILE_DEL_ERROR
A message that is formatted and displayed to the user when an error occurs when deleting files or directories corresponding to a given entry in the work space.

See Also:
Constant Field Values

CANT_FIND_SERVER

private static final java.lang.String CANT_FIND_SERVER
A message that is formatted and displayed to the user when a server corresponding to a given job entry could not be located in the work space.

See Also:
Constant Field Values

DATASET_ERROR

private static final java.lang.String DATASET_ERROR
Message to be displayed to the user (after formatting) to report error when deleting a workspace entry.

See Also:
Constant Field Values

serialVersionUID

private static final long serialVersionUID
A generated serialization UID to keep compiler happy.

See Also:
Constant Field Values
Constructor Detail

DeleteDialog

public DeleteDialog(MainFrame mainFrame,
                    java.lang.Object wsEntry)
The constructor. The constructor merely passes the parameters to the base class and sets up the various components to be displayed in this dialog.

Parameters:
mainFrame - The main frame that ultimately owns all views and this dialog box. This information is required to correctly create a modal dialog that does not steal focus from other applications.
wsEntry - The work space entry to be deleted. This object must be a valid work space entry such as: Job, Server, MSTClusterData, MSTData, or DataSet.
Method Detail

getTypeCode

private int getTypeCode(java.lang.Object wsObject)
An internal method to returns a type code for a given work space entry. This is a helper method that is used to determine a type code for a work space entry object. The type code is simply an integer value for a given work space object. Integer values ease performing various tasks in this dialog. The integer values are assigned as per the following table:
Object Type Code
Job 0
Server 1
MSTClusterData 2
MSTData 3
DataSet 4

Parameters:
wsObject - The wsObject whose type code is to be returned.
Returns:
The type code for the given wsObject. If the object is not a valid work space entry, then this method returns -1.

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent event)
Handle clicking of OK or Cancel buttons. This method intercepts the click from OK or Cancel button and appropriately performs the necessary operation.

Specified by:
actionPerformed in interface java.awt.event.ActionListener
Parameters:
event - The action event to be processed by this method.

run

public void run()
This method is called when the user clicks the OK button to delete entry(s). This method is invoked from a separate thread so that the GUI does not appear to hang (while files are being deleted on remote machines which could be a time consuming operation).

Specified by:
run in interface java.lang.Runnable

disposeDialog

private void disposeDialog()
Helper method to hide and dispose this dialog. This method simply hides and disposes the dialog from the main swing thread.


removeDataSet

private void removeDataSet(DataSet dataSet)
Helper method to delete a data set along with all underlying entries and files. This is a helper method that is invoked from the run() method to delete a complete data set. This method first deletes all the cluster entries (deleting files if indicated) followed by all MST entries (deleting MST files if indicated). If all the sub-entries were deleted successfully then this method also removes the data set entry.

Parameters:
dataSet - The data set to be removed from the work space.

delJobFiles

private void delJobFiles(Job job)
                  throws java.lang.Exception
Helper method to delete files for a given job. This helper method was introduced to streamline the code in the run method. Several operations need to be performed to remove a job entry which includes locating a suitable server entry.

Parameters:
job - The job entry to be removed.
Throws:
java.lang.Exception

deleteLocalFile

private void deleteLocalFile(java.lang.String fileName)
                      throws java.lang.Exception
Helper method to delete a local file. This is a simple method that deletes a local file on the local machine.

Parameters:
fileName - The full path to the file to be deleted.
Throws:
java.lang.Exception - This method throws an exception on errors.

deleteRemoteDir

private void deleteRemoteDir(Server server,
                             java.lang.String directory)
                      throws java.lang.Exception
Helper method to recursively delete file on server. This is a helper method that is used to recursively delete directories on a local or remote server. This method executes different commands (depending on server OS type) to recursively delete directories.

Parameters:
server - The server entry which the file is to be deleted.
directory - The path to the directory to be deleted.
Throws:
java.lang.Exception - This method throws an exception on errors.