Package com.tagtraum.beatunes.inspection
Class CallableSolution
- java.lang.Object
-
- com.tagtraum.beatunes.inspection.CallableSolution
-
public abstract class CallableSolution extends Object implements Callable<Void>
Code that should be executed, when aSolutionis actually applied/commited.- Author:
- Hendrik Schreiber
- See Also:
Solution.createCallable(java.util.Collection, boolean)
-
-
Field Summary
Fields Modifier and Type Field Description protected PropertyChangeSupportpropertyChangeSupport
-
Constructor Summary
Constructors Modifier Constructor Description protectedCallableSolution(Solution solution, String description, String progressMessage)Steps is set to -1, i.e.protectedCallableSolution(Solution solution, Collection<AudioSong> songs, String description, String progressMessage, int steps)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(CallableSolution otherCallableSolution)Adds another solution to this one, basically combining them.voidaddProgressListener(ProgressListener progressListener)voidaddPropertyChangeListener(PropertyChangeListener listener)voidaddPropertyChangeListener(String propertyName, PropertyChangeListener listener)booleancanAdd(CallableSolution otherCallableSolution)Offers a way to check whether you can combine two tasks into one (this).voidfireProgress(float progress)Fires progress for visual indicator.ThrowablegetCommitError()Non-null, if a commitment attempt was unsuccessful.StringgetDescription()Static description of the solution.StringgetProgressMessage()Message that can be shown while the solution is executed.SolutiongetSolution()List<Long>getSongIds()Ids of the songs that are going to be modified by this solution.intgetSteps()Approximate number of distinct steps in this solution.protected List<Track>getTracks(BeaTunes application, Collection<Long> songIds)Retrieves a list ofTrackobjects from the music player.voidsetCommitError(Throwable commitError)protected voidsetDescription(String description)protected voidsetProgressMessage(String progressMessage)protected voidsetSolution(Solution solution)voidsetSongIds(Collection<Long> songIds)Sets the ids of the songs that are going to be modified by this solution.voidsetSongs(Collection<AudioSong> songs)Extracts the ids from the given songs and sets them usingsetSongIds(java.util.Collection).protected voidsetSteps(int steps)intsongCount()Number of songs affected by this solution.StringtoString()
-
-
-
Field Detail
-
propertyChangeSupport
protected final PropertyChangeSupport propertyChangeSupport
-
-
Constructor Detail
-
CallableSolution
protected CallableSolution(Solution solution, String description, String progressMessage)
Steps is set to -1, i.e. it will be computed fromsongCount().- Parameters:
solution- actual solution this belongs todescription- static description of the solutionprogressMessage- message that may be shown while the solution is applied.
-
CallableSolution
protected CallableSolution(Solution solution, Collection<AudioSong> songs, String description, String progressMessage, int steps)
- Parameters:
solution- actual solution this belongs tosongs- songs, most likely selected by the user, seeSolution.createCallable(Collection, boolean)description- static description of the solutionprogressMessage- message that may be shown while the solution is applied.steps- number of steps it will take in total - this will be available throughgetSteps(). If set to -1, it will be computed automatically fromsongCount().
-
-
Method Detail
-
getCommitError
public Throwable getCommitError()
Non-null, if a commitment attempt was unsuccessful.- Returns:
- commit error
-
setCommitError
public void setCommitError(Throwable commitError)
-
getSolution
public Solution getSolution()
-
setSolution
protected void setSolution(Solution solution)
-
getProgressMessage
public String getProgressMessage()
Message that can be shown while the solution is executed.- Returns:
- progress message
-
setProgressMessage
protected void setProgressMessage(String progressMessage)
-
getDescription
public String getDescription()
Static description of the solution.- Returns:
- description
-
setDescription
protected void setDescription(String description)
-
getSteps
public int getSteps()
Approximate number of distinct steps in this solution.- Returns:
- steps
-
setSteps
protected void setSteps(int steps)
-
getSongIds
public List<Long> getSongIds()
Ids of the songs that are going to be modified by this solution.- Returns:
- list of song ids or empty list
- See Also:
setSongIds(Collection)
-
setSongIds
public void setSongIds(Collection<Long> songIds)
Sets the ids of the songs that are going to be modified by this solution.- Parameters:
songIds- list of song ids- See Also:
getSongIds(),setSongs(Collection)
-
setSongs
public void setSongs(Collection<AudioSong> songs)
Extracts the ids from the given songs and sets them usingsetSongIds(java.util.Collection).- Parameters:
songs- songs- See Also:
setSongIds(Collection)
-
songCount
public int songCount()
Number of songs affected by this solution.- Returns:
- song count
-
canAdd
public boolean canAdd(CallableSolution otherCallableSolution)
Offers a way to check whether you can combine two tasks into one (this).- Parameters:
otherCallableSolution- another asynchronous solution- Returns:
- true, if the given task can be added to this task.
-
add
public void add(CallableSolution otherCallableSolution)
Adds another solution to this one, basically combining them.- Parameters:
otherCallableSolution- another asynchronous solution- Throws:
IllegalArgumentException- if the solution cannot be added.
-
addProgressListener
public void addProgressListener(ProgressListener progressListener)
-
fireProgress
public void fireProgress(float progress)
Fires progress for visual indicator.- Parameters:
progress- percent done between 0.0f and 1.0f
-
getTracks
protected List<Track> getTracks(BeaTunes application, Collection<Long> songIds)
Retrieves a list of
Trackobjects from the music player. While doing so callsfireProgress(float)withi/getSteps(),ibeing the number of the track in question.Must be called from
TunesUtilitiesthread.- Parameters:
application- applicationsongIds- collection of songs ids- Returns:
- list of tracks
- See Also:
TunesUtilities.getTrack(Playlist, Long)
-
addPropertyChangeListener
public void addPropertyChangeListener(PropertyChangeListener listener)
-
addPropertyChangeListener
public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener)
-
-