task
Class AddTracksTask

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

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

The AddTracksTask provides functionality for adding new tracks to iTunes. This is a accomplished by using the ITunesWin class for communication to and from iTunes, the Options class for reading user options, and the Exclusions class for files that may have been previously added to iTunes. The class itself extends the SwingWorker class to provide funcationality for gui based user interactions in the background.


Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.SwingWorker
javax.swing.SwingWorker.StateValue
 
Field Summary
static int AWAITING_ITUNES
          The progress integer for when the task is awaiting iTunes to finish processing files.
static int READING_XML
          The progress integer for when the task is reading the XML file.
 
Constructor Summary
AddTracksTask(boolean monitorProgress)
          Creates a new AddTracksTask that simply reads the Options object from the SysTrayMain object.
AddTracksTask(Options options, SongTable songTable, boolean monitorProgress)
          Creates a new AddTracksTask with the given set of options.
AddTracksTask(SongTable table, boolean monitorProgress)
          Creates a new AddTracksTask object responsible for adding tracks not currently in the iTunes library or previously added to iTunes.
 
Method Summary
 java.lang.Integer doInBackground()
          This method first reads the options from the options file, if all of the necessary options have been set as determined by the isReady() method in the Options class, the method proceeds.
 void done()
          Called when the SwingWorker method doInBackground is completed.
 java.util.ArrayList<java.io.File> findNewFiles(java.util.ArrayList<java.io.File> allPotentialNewFiles, java.util.ArrayList<java.io.File> iTunesFiles, OutputStringArrayList exclusions)
          Identifies new files to be added to iTunes by examining all new potential files against the files in iTunes, and the exclusions list.
 void getITunesLibraryFilePaths()
          Communicates with iTunes through the ITunesWin class to find the locations of all the files in the iTunes library.
static void main(java.lang.String[] args)
           
 
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
 

Field Detail

READING_XML

public static final int READING_XML
The progress integer for when the task is reading the XML file.

See Also:
Constant Field Values

AWAITING_ITUNES

public static final int AWAITING_ITUNES
The progress integer for when the task is awaiting iTunes to finish processing files.

See Also:
Constant Field Values
Constructor Detail

AddTracksTask

public AddTracksTask(SongTable table,
                     boolean monitorProgress)
Creates a new AddTracksTask object responsible for adding tracks not currently in the iTunes library or previously added to iTunes.

Parameters:
table - The table that displays to the user the new tracks that have been added to iTunes.
monitorProgress - The boolean value for whether or not a progress dialog should be shown to the user, while the AddTracksTask is running.

AddTracksTask

public AddTracksTask(Options options,
                     SongTable songTable,
                     boolean monitorProgress)
Creates a new AddTracksTask with the given set of options. This constructor is used for folder watching.

Parameters:
monitorProgress - The boolean value for whether or not a progress dialog should be shown to the user, while the AddTracksTask is running.
songTable - The song table object to display new tracks that have been added.
options - The given set of options.

AddTracksTask

public AddTracksTask(boolean monitorProgress)
Creates a new AddTracksTask that simply reads the Options object from the SysTrayMain object. A progress monitor will not be displayed using this constructor.

Parameters:
monitorProgress - The boolean value for whether or not a progress dialog should be shown to the user, while the AddTracksTask is running.
Method Detail

doInBackground

public java.lang.Integer doInBackground()
This method first reads the options from the options file, if all of the necessary options have been set as determined by the isReady() method in the Options class, the method proceeds. Otherwise it is returned. Once the options are loaded, exclusions are read from the exclusions data file. Then information about the current iTunes tracks are loaded and a new user playlist is created. Finally, the directories are processed for new tracks that have not been added previously.

Specified by:
doInBackground in class javax.swing.SwingWorker<java.lang.Integer,java.lang.Void>
Returns:
Integer The number of tracks added to iTunes.

done

public void done()
Called when the SwingWorker method doInBackground is completed.

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

getITunesLibraryFilePaths

public void getITunesLibraryFilePaths()
Communicates with iTunes through the ITunesWin class to find the locations of all the files in the iTunes library.


findNewFiles

public java.util.ArrayList<java.io.File> findNewFiles(java.util.ArrayList<java.io.File> allPotentialNewFiles,
                                                      java.util.ArrayList<java.io.File> iTunesFiles,
                                                      OutputStringArrayList exclusions)
Identifies new files to be added to iTunes by examining all new potential files against the files in iTunes, and the exclusions list. The returned array list is an array of all the files that should be added to iTunes.

Parameters:
allPotentialNewFiles - All files to check against iTunes and the exclusions list for new files.
iTunesFiles - All of the files in the iTunes library.
exclusions - The exclusions, or previously added files to the iTunes library by iTunesDSM.
Returns:
The files that are not yet in the iTunes database and should be added to iTunes.

main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
Throws:
java.lang.Exception