Package com.tagtraum.beatunes.inspection
Class Inspector
- java.lang.Object
-
- com.tagtraum.beatunes.inspection.Inspector
-
- All Implemented Interfaces:
DetailView
,View
,ApplicationComponent<BeaTunes>
- Direct Known Subclasses:
AlbumInTitleInspector
,AlbumOrArtistInTitleInspector
,AmazonAlbumVersionInspector
,ArtistInTitleInspector
,ArtworkNotEmbeddedInspector
,CapitalizationInspector
,CompilationInspector
,DifferentAlbumArtistInspector
,DifferentArtworkCountInspector
,DifferentGenreInspector
,DifferentLanguageInspector
,DifferentRatingInspector
,DifferentYearInspector
,DiscNumberInspector
,DuplicatesInspector
,InspectorCategory
,MediaKindInspector
,MissingAlbumArtistInspector
,MissingFileInspector
,MissingTrackCountInspector
,RarelyUsedGenreInspector
,ReadOnlyFileInspector
,SortInspector
,SortnameUsedAsInspector
,TitleStartsWithTrackNumberInspector
,TypoInspector
public abstract class Inspector extends Object implements DetailView, ApplicationComponent<BeaTunes>
Abstract superclass for all inspectors, an object that analyzes a list of songs for specific
Issue
s and returns the issues, which in turn may haveSolution
s.Subclasses should be registered as plugin in
META-INF/plugin.xml
to become functional.- Author:
- Hendrik Schreiber
- See Also:
PluginManager
-
-
Field Summary
Fields Modifier and Type Field Description protected PropertyChangeSupport
propertyChangeSupport
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected void
addIssue(Issue<?> issue)
To be used by subclasses to add a single issue.protected void
addIssues(Collection<Issue<?>> issues)
To be used by subclasses to add multiple issues.void
addPropertyChangeListener(String propertyName, PropertyChangeListener listener)
void
cancel()
Called by the UI.protected static void
checkInterruption()
Check whether the interrupt flag has been set.protected void
clearIssues()
To be used by subclasses.protected Icon
createDisabledIcon()
protected Icon
createIcon()
BeaTunes
getApplication()
Returns the main application component.String
getCategory()
Indicates the inspection's category or grouping.JComponent
getComponent()
The actual visual component for this view.abstract String
getDescription()
Inspector description.JComponent
getFocusRoot()
The component that should be focused by default, when view is shown.Icon
getIcon()
String
getId()
Unique idea for a configured instance of this class.Inspection
getInspection()
float
getInspectionProgress()
InspectorCategory
getInspectorCategory()
Returns the InspectorCategory for this InspectorInspectorView
getInspectorView()
ListModel<Issue<? extends Inspector>>
getIssueModel()
List<Issue<?>>
getIssues()
List<Issue<?>>
getIssues(Long songId)
abstract String
getName()
Inspector name.abstract String
getPropertyName()
Indicates which property is inspected by this inspector.Solution
getSolution(String solutionId)
String
getStatusLabel()
Status label to show in the status bar when this component becomes visible.void
init()
Initializes this component and its sub-components.protected abstract void
inspect(InspectionProgressListener inspectionProgressListener)
Inspects the given songs for problems of a specific kind.boolean
isAvailable()
Indicates whether this Inspector is available at all.boolean
isBeforeFirstInspection()
Indicates whether this this inspector has been used before.boolean
isCancelled()
Lets the Inspector check whether an ongoing inspection was cancelled by the user.boolean
isEnabled()
Is this inspector enabled?boolean
isIndeterminateProgress()
Indicates that the current status is an operation with indeterminate progress which should be reflected in the rendering of the status bar.boolean
isInspecting()
boolean
isPartiallyEnabled()
Indicates that someInspector
s are enabled while others aren't.int
issueCount()
Number of issues.void
performInspection()
Inspects the given songs for problems of a specific kind.void
performInspection(InspectionProgressListener progressListener)
Inspects the given songs for problems of a specific kind.protected void
refreshLocations(List<Track> trackList)
Deprecated.AudioSong
objects update their location automaticallyvoid
removeIssue(Issue<?> issue)
void
removeIssues(Collection<Issue<?>> issues)
void
removePropertyChangeListener(String propertyName, PropertyChangeListener listener)
void
setApplication(BeaTunes beaTunes)
Sets the main application component.void
setAvailable(boolean available)
Sets availability.void
setEnabled(boolean enabled)
Enables/disables this inspector.void
setInspectionProgress(float inspectionProgress)
void
shutdown()
Shuts down this component and its sub-components.String
toString()
-
-
-
Field Detail
-
propertyChangeSupport
protected PropertyChangeSupport propertyChangeSupport
-
-
Constructor Detail
-
Inspector
protected Inspector(BeaTunes application)
-
-
Method Detail
-
checkInterruption
protected static void checkInterruption() throws InterruptedException
Check whether the interrupt flag has been set.- Throws:
InterruptedException
-
createIcon
protected Icon createIcon()
-
createDisabledIcon
protected Icon createDisabledIcon()
-
getIcon
public Icon getIcon()
-
init
public void init()
Description copied from interface:ApplicationComponent
Initializes this component and its sub-components.- Specified by:
init
in interfaceApplicationComponent<BeaTunes>
-
shutdown
public void shutdown()
Description copied from interface:ApplicationComponent
Shuts down this component and its sub-components.- Specified by:
shutdown
in interfaceApplicationComponent<BeaTunes>
-
getApplication
public BeaTunes getApplication()
Description copied from interface:ApplicationComponent
Returns the main application component.- Specified by:
getApplication
in interfaceApplicationComponent<BeaTunes>
- Returns:
- application object
-
setApplication
public void setApplication(BeaTunes beaTunes)
Description copied from interface:ApplicationComponent
Sets the main application component.- Specified by:
setApplication
in interfaceApplicationComponent<BeaTunes>
- Parameters:
beaTunes
- main application component
-
getComponent
public JComponent getComponent()
Description copied from interface:View
The actual visual component for this view.- Specified by:
getComponent
in interfaceView
- Returns:
- detail component
-
getFocusRoot
public JComponent getFocusRoot()
Description copied from interface:View
The component that should be focused by default, when view is shown.- Specified by:
getFocusRoot
in interfaceView
- Returns:
- component
-
getInspectorView
public InspectorView getInspectorView()
-
isIndeterminateProgress
public boolean isIndeterminateProgress()
Description copied from interface:DetailView
Indicates that the current status is an operation with indeterminate progress which should be reflected in the rendering of the status bar.- Specified by:
isIndeterminateProgress
in interfaceDetailView
- Returns:
- true if an indeterminate progress indicator is supposed to be rendered
-
getStatusLabel
public String getStatusLabel()
Description copied from interface:DetailView
Status label to show in the status bar when this component becomes visible.- Specified by:
getStatusLabel
in interfaceDetailView
- Returns:
- label
- See Also:
MainWindow.getStatusLabel()
-
getInspection
public Inspection getInspection()
-
isPartiallyEnabled
public boolean isPartiallyEnabled()
Indicates that someInspector
s are enabled while others aren't. Only meaningful forInspectorCategory
. Default returnsfalse
.- Returns:
- true or false
-
isEnabled
public boolean isEnabled()
Is this inspector enabled?- Returns:
- true or false
-
setEnabled
public void setEnabled(boolean enabled)
Enables/disables this inspector.- Parameters:
enabled
- true or false
-
isAvailable
public boolean isAvailable()
Indicates whether this Inspector is available at all. E.g. an Inspector could be unavailable for libraries specified byFileSystemLibraryDescriptor
, but available for iTunes specific libraries (ITunesLibraryDescriptor
). Or available for macOS, but not for Windows....- Returns:
- true or false
-
setAvailable
public void setAvailable(boolean available)
Sets availability.- Parameters:
available
- true or false- See Also:
isAvailable()
-
getCategory
public String getCategory()
Indicates the inspection's category or grouping. By default this returnsGENERAL
.- Returns:
- category, by default General
-
getInspectorCategory
public InspectorCategory getInspectorCategory()
Returns the InspectorCategory for this Inspector- Returns:
- the InspectorCategory or null of none can be found.
-
getId
public String getId()
Unique idea for a configured instance of this class. The id has to be the same, if the configuration is the same. I.e. it has to be persistent. The default implementation assumes a stateless Inspector, so the class name is used as id.- Specified by:
getId
in interfaceApplicationComponent<BeaTunes>
- Returns:
- id of this inspector instance
-
getName
public abstract String getName()
Inspector name.- Returns:
- descriptive name for this inspector meant for the UI
-
getDescription
public abstract String getDescription()
Inspector description.- Returns:
- long description about this inspector meant for the UI
-
getPropertyName
public abstract String getPropertyName()
Indicates which property is inspected by this inspector. This will be used when highlighting said property in views of a song that has issues.- Returns:
- property name
-
inspect
protected abstract void inspect(InspectionProgressListener inspectionProgressListener)
Inspects the given songs for problems of a specific kind. Found issues are accessible through the issues property. Implementations need to add issues usingaddIssue(Issue)
. If this is a long running inspection, you might want to checkisCancelled()
every now and then and abort the inspection should the method returntrue
. Note that this method is called in a separate thread, i.e. not the event dispatch thread. You can report progress throughInspectionProgressListener.progress(Inspector, String, float)
.- Parameters:
inspectionProgressListener
- progress listener- See Also:
getIssues()
,addIssue(Issue)
,isCancelled()
-
performInspection
public void performInspection()
Inspects the given songs for problems of a specific kind. Found issues are accessible through the issues property. This method is asynchronous and returns immediately. Progress (start/stop) can be tracked through the propertyinspecting
.- See Also:
getIssues()
,addIssue(Issue)
-
performInspection
public void performInspection(InspectionProgressListener progressListener)
Inspects the given songs for problems of a specific kind. Found issues are accessible through the issues property.- See Also:
getIssues()
,addIssue(Issue)
,performInspection()
-
getInspectionProgress
public float getInspectionProgress()
-
setInspectionProgress
public void setInspectionProgress(float inspectionProgress)
-
isInspecting
public boolean isInspecting()
-
isBeforeFirstInspection
public boolean isBeforeFirstInspection()
Indicates whether this this inspector has been used before.- Returns:
- true or false
-
issueCount
public int issueCount()
Number of issues. This property can be followed by adding a property change listener.- Returns:
- number of current issues
-
addIssue
protected void addIssue(Issue<?> issue)
To be used by subclasses to add a single issue. Issues may be ignore, ifInspection.ignore(Issue)
returns true.- Parameters:
issue
- issue- See Also:
addIssues(java.util.Collection)
-
addIssues
protected void addIssues(Collection<Issue<?>> issues)
To be used by subclasses to add multiple issues. This method is a lot more efficient thanaddIssue(Issue)
when adding a lot of issues, because the UI is only updated once and not for every single issue individually. Issues may be ignore, ifInspection.ignore(Issue)
returns true.- Parameters:
issues
- issues
-
removeIssue
public void removeIssue(Issue<?> issue)
-
removeIssues
public void removeIssues(Collection<Issue<?>> issues)
-
clearIssues
protected void clearIssues()
To be used by subclasses. Should be called before rebuilding the issue list. This also resets the cancel flag tofalse
.- See Also:
isCancelled()
-
addPropertyChangeListener
public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener)
-
removePropertyChangeListener
public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener)
-
refreshLocations
protected void refreshLocations(List<Track> trackList)
Deprecated.AudioSong
objects update their location automaticallyRefreshes the location of aSong
object. Necessary, after manipulating name or artist.- Parameters:
trackList
- list of tracks that may now have a different location.
-
cancel
public void cancel()
Called by the UI. Do not call this yourself.
-
isCancelled
public boolean isCancelled()
Lets the Inspector check whether an ongoing inspection was cancelled by the user.- Returns:
- true, of the user cancelled the inspection
- See Also:
clearIssues()
-
-