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
Issues and returns the issues, which in turn may haveSolutions.Subclasses should be registered as plugin in
META-INF/plugin.xmlto become functional.- Author:
- Hendrik Schreiber
- See Also:
PluginManager
-
-
Field Summary
Fields Modifier and Type Field Description protected PropertyChangeSupportpropertyChangeSupport
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected voidaddIssue(Issue<?> issue)To be used by subclasses to add a single issue.protected voidaddIssues(Collection<Issue<?>> issues)To be used by subclasses to add multiple issues.voidaddPropertyChangeListener(String propertyName, PropertyChangeListener listener)voidcancel()Called by the UI.protected static voidcheckInterruption()Check whether the interrupt flag has been set.protected voidclearIssues()To be used by subclasses.protected IconcreateDisabledIcon()protected IconcreateIcon()BeaTunesgetApplication()Returns the main application component.StringgetCategory()Indicates the inspection's category or grouping.JComponentgetComponent()The actual visual component for this view.abstract StringgetDescription()Inspector description.JComponentgetFocusRoot()The component that should be focused by default, when view is shown.IcongetIcon()StringgetId()Unique idea for a configured instance of this class.InspectiongetInspection()floatgetInspectionProgress()InspectorCategorygetInspectorCategory()Returns the InspectorCategory for this InspectorInspectorViewgetInspectorView()ListModel<Issue<? extends Inspector>>getIssueModel()List<Issue<?>>getIssues()List<Issue<?>>getIssues(Long songId)abstract StringgetName()Inspector name.abstract StringgetPropertyName()Indicates which property is inspected by this inspector.SolutiongetSolution(String solutionId)StringgetStatusLabel()Status label to show in the status bar when this component becomes visible.voidinit()Initializes this component and its sub-components.protected abstract voidinspect(InspectionProgressListener inspectionProgressListener)Inspects the given songs for problems of a specific kind.booleanisAvailable()Indicates whether this Inspector is available at all.booleanisBeforeFirstInspection()Indicates whether this this inspector has been used before.booleanisCancelled()Lets the Inspector check whether an ongoing inspection was cancelled by the user.booleanisEnabled()Is this inspector enabled?booleanisIndeterminateProgress()Indicates that the current status is an operation with indeterminate progress which should be reflected in the rendering of the status bar.booleanisInspecting()booleanisPartiallyEnabled()Indicates that someInspectors are enabled while others aren't.intissueCount()Number of issues.voidperformInspection()Inspects the given songs for problems of a specific kind.voidperformInspection(InspectionProgressListener progressListener)Inspects the given songs for problems of a specific kind.protected voidrefreshLocations(List<Track> trackList)Deprecated.AudioSongobjects update their location automaticallyvoidremoveIssue(Issue<?> issue)voidremoveIssues(Collection<Issue<?>> issues)voidremovePropertyChangeListener(String propertyName, PropertyChangeListener listener)voidsetApplication(BeaTunes beaTunes)Sets the main application component.voidsetAvailable(boolean available)Sets availability.voidsetEnabled(boolean enabled)Enables/disables this inspector.voidsetInspectionProgress(float inspectionProgress)voidshutdown()Shuts down this component and its sub-components.StringtoString()
-
-
-
Field Detail
-
propertyChangeSupport
protected PropertyChangeSupport propertyChangeSupport
-
-
Constructor Detail
-
Inspector
protected Inspector(BeaTunes application)
-
-
Method Detail
-
checkInterruption
protected static void checkInterruption() throws InterruptedExceptionCheck 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:ApplicationComponentInitializes this component and its sub-components.- Specified by:
initin interfaceApplicationComponent<BeaTunes>
-
shutdown
public void shutdown()
Description copied from interface:ApplicationComponentShuts down this component and its sub-components.- Specified by:
shutdownin interfaceApplicationComponent<BeaTunes>
-
getApplication
public BeaTunes getApplication()
Description copied from interface:ApplicationComponentReturns the main application component.- Specified by:
getApplicationin interfaceApplicationComponent<BeaTunes>- Returns:
- application object
-
setApplication
public void setApplication(BeaTunes beaTunes)
Description copied from interface:ApplicationComponentSets the main application component.- Specified by:
setApplicationin interfaceApplicationComponent<BeaTunes>- Parameters:
beaTunes- main application component
-
getComponent
public JComponent getComponent()
Description copied from interface:ViewThe actual visual component for this view.- Specified by:
getComponentin interfaceView- Returns:
- detail component
-
getFocusRoot
public JComponent getFocusRoot()
Description copied from interface:ViewThe component that should be focused by default, when view is shown.- Specified by:
getFocusRootin interfaceView- Returns:
- component
-
getInspectorView
public InspectorView getInspectorView()
-
isIndeterminateProgress
public boolean isIndeterminateProgress()
Description copied from interface:DetailViewIndicates that the current status is an operation with indeterminate progress which should be reflected in the rendering of the status bar.- Specified by:
isIndeterminateProgressin interfaceDetailView- Returns:
- true if an indeterminate progress indicator is supposed to be rendered
-
getStatusLabel
public String getStatusLabel()
Description copied from interface:DetailViewStatus label to show in the status bar when this component becomes visible.- Specified by:
getStatusLabelin interfaceDetailView- Returns:
- label
- See Also:
MainWindow.getStatusLabel()
-
getInspection
public Inspection getInspection()
-
isPartiallyEnabled
public boolean isPartiallyEnabled()
Indicates that someInspectors 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:
getIdin 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.AudioSongobjects update their location automaticallyRefreshes the location of aSongobject. 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()
-
-