task
Class CleanMusicDir

java.lang.Object
  extended by javax.swing.SwingWorker<java.lang.Void,java.lang.Void>
      extended by task.CleanMusicDir
All Implemented Interfaces:
java.lang.Runnable, java.util.concurrent.Future<java.lang.Void>, java.util.concurrent.RunnableFuture<java.lang.Void>

public class CleanMusicDir
extends javax.swing.SwingWorker<java.lang.Void,java.lang.Void>

This class provides functionality for backing up, deleting, and starting an orphaned file removal task. Once duplicate files have been found the user selects files to be operated on, and then this class will process them.


Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.SwingWorker
javax.swing.SwingWorker.StateValue
 
Constructor Summary
CleanMusicDir(java.util.ArrayList<java.io.File> selectedFiles, java.util.ArrayList<java.io.File> allDupFiles, java.io.File backupDir, SongTable table, boolean backup, boolean del)
          Creates a new CleanDirectory SwingWorker background task.
 
Method Summary
 void backupFiles(java.util.ArrayList<java.io.File> filesToBackup, java.io.File backupDir)
          Copies the selected files to a destination directory using the CopyFile class.
 boolean[] deleteFiles(java.util.ArrayList<java.io.File> filesToDelete)
          Deletes the user selected files.
 java.lang.Void doInBackground()
          Runs the main task of backing up and or deleting selected files.
 void done()
          The method called after the doInBackground method is finished by the SwingWorker task.
 
Methods inherited from class javax.swing.SwingWorker
addPropertyChangeListener, cancel, execute, firePropertyChange, get, get, getProgress, getPropertyChangeSupport, getState, isCancelled, isDone, process, publish, removePropertyChangeListener, run, setProgress
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CleanMusicDir

public CleanMusicDir(java.util.ArrayList<java.io.File> selectedFiles,
                     java.util.ArrayList<java.io.File> allDupFiles,
                     java.io.File backupDir,
                     SongTable table,
                     boolean backup,
                     boolean del)
Creates a new CleanDirectory SwingWorker background task.

Parameters:
selectedFiles - the files the user has selected to be operated on.
allDupFiles - all of the found duplicate files. This is necessary to help remove the lock that placed on a file during processing. If the file is being deleted it must be removed from both the filesToProcess/selectedFiles as well as AllDuplicateFiles/allDupFiles array lists.
backupDir - The directory to backup filesToProcess to.
table - the table displaying a list of all found duplicate files
backup - Whether or not the user has decided to backup the list of duplicated files to process.
del - Whether or not the user has decided to delete the files to process
Method Detail

doInBackground

public java.lang.Void doInBackground()
Runs the main task of backing up and or deleting selected files.

Specified by:
doInBackground in class javax.swing.SwingWorker<java.lang.Void,java.lang.Void>
Returns:
Void The object returned by the SwingWorker task.

done

public void done()
The method called after the doInBackground method is finished by the SwingWorker task.

Overrides:
done in class javax.swing.SwingWorker<java.lang.Void,java.lang.Void>

backupFiles

public void backupFiles(java.util.ArrayList<java.io.File> filesToBackup,
                        java.io.File backupDir)
Copies the selected files to a destination directory using the CopyFile class.

Parameters:
filesToBackup - The files to copy to the given backup directory.
backupDir - The directory to send the files to copy to.

deleteFiles

public boolean[] deleteFiles(java.util.ArrayList<java.io.File> filesToDelete)
Deletes the user selected files.

Parameters:
filesToDelete - The files to delete.
Returns:
The array of boolean values containing the results of the deleting files.