Class NewPlayListAction
- java.lang.Object
-
- javax.swing.AbstractAction
-
- com.tagtraum.core.app.ApplicationAction
-
- com.tagtraum.beatunes.action.BaseAction
-
- com.tagtraum.beatunes.action.standard.NewPlayListAction
-
- All Implemented Interfaces:
ApplicationComponent<BeaTunes>
,ActionListener
,Serializable
,Cloneable
,EventListener
,Action
- Direct Known Subclasses:
NewEmptyPlayListAction
,NewFolderAction
,NewPlayListFromSelectionAction
public abstract class NewPlayListAction extends BaseAction
Abstract superclass for actions that create playlists. SeefillPlayList(PlayList, long[])
for implementation details.- Author:
- Hendrik Schreiber
- See Also:
ReArrangePlayListAction
, Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.tagtraum.beatunes.action.BaseAction
BaseAction.EnabledView, BaseAction.Location, BaseAction.SelectionCount
-
Nested classes/interfaces inherited from class com.tagtraum.core.app.ApplicationAction
ApplicationAction.ApplicationActionFacade
-
-
Field Summary
-
Fields inherited from class com.tagtraum.beatunes.action.BaseAction
ITEMS_EDITABLE
-
Fields inherited from class com.tagtraum.core.app.ApplicationAction
BUTTON_MODEL, DISABLED_ICON, DISABLED_SELECTED_ICON, PRESSED_ICON, ROLLOVER_ICON, SELECTED_ICON, SHORT_NAME
-
Fields inherited from class javax.swing.AbstractAction
changeSupport, enabled
-
Fields inherited from interface javax.swing.Action
ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, DISPLAYED_MNEMONIC_INDEX_KEY, LARGE_ICON_KEY, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SELECTED_KEY, SHORT_DESCRIPTION, SMALL_ICON
-
-
Constructor Summary
Constructors Constructor Description NewPlayListAction(BeaTunes application)
NewPlayListAction(BeaTunes application, boolean requiresSelectedSongs)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
actionPerformed(ActionEvent e)
protected PlayList
createEmptyPlayList()
Create the empty (but persistent)PlayList
object.abstract boolean
fillPlayList(PlayList newPlayList, long[] selectedSongIds)
This method is called by the action as part of itsactionPerformed(ActionEvent)
method.ActionLocation[]
getActionLocations()
By default installs this action in the File menu below the New Folder action and—ifisRequiresSelectedSongs()
returnstrue
also in the context menu.boolean
isRequiresSelectedSongs()
Indicates whether beaTunes should provide the ids of the selected songs infillPlayList(PlayList, long[])
.protected void
loadResources()
Installs enabled/disabled listeners that turn the action on and off, depending on whether any songs are selected.void
setRequiresSelectedSongs(boolean requiresSelectedSongs)
Call this from the constructor to determine, whetherfillPlayList(PlayList, long[])
should be called with the ids of selected songs.-
Methods inherited from class com.tagtraum.beatunes.action.BaseAction
bindListeners, bindListeners, getApplication, getFocusedPlayList, getFocusOwner, getMostRecentlyFocused, getPlayListTreeNode, getSelectedPlayList, getSelectedPlayListTreeNode, getSelectedSong, getSelectedSongCount, getSelectedSongIds, getSelectedSongs, getSelectedSongs, init, isAnalysisQueueFocused, isMatchTableFocused, isPlayListTreeFocused, isSimpleSongTableFocused, isSongTableFocused, numberOfSelectedSongs, numberOfSelectedSongs, setApplication, shutdown
-
Methods inherited from class com.tagtraum.core.app.ApplicationAction
getButtonModel, getIconButtonFacade, getId, getMenuFacade, getToolbarButtonFacade, isVisible, register, setButtonModel, setVisible
-
Methods inherited from class javax.swing.AbstractAction
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
-
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.tagtraum.core.app.ApplicationComponent
getId
-
-
-
-
Method Detail
-
getActionLocations
public ActionLocation[] getActionLocations()
By default installs this action in the File menu below the New Folder action and—ifisRequiresSelectedSongs()
returnstrue
also in the context menu. If you require different locations, override this method.- Overrides:
getActionLocations
in classApplicationAction
- Returns:
- action locations
-
loadResources
protected void loadResources()
Installs enabled/disabled listeners that turn the action on and off, depending on whether any songs are selected. The listeners are only installed, ifisRequiresSelectedSongs()
returnstrue
. This method is called fromBaseAction.init()
, so you should callsetRequiresSelectedSongs(boolean)
from the constructor (or useNewPlayListAction(BeaTunes, boolean)
). Override this method, if you desire a different enable/disable behavior.- Overrides:
loadResources
in classBaseAction
-
isRequiresSelectedSongs
public boolean isRequiresSelectedSongs()
Indicates whether beaTunes should provide the ids of the selected songs infillPlayList(PlayList, long[])
.- Returns:
true
(default) orfalse
-
setRequiresSelectedSongs
public void setRequiresSelectedSongs(boolean requiresSelectedSongs)
Call this from the constructor to determine, whetherfillPlayList(PlayList, long[])
should be called with the ids of selected songs.- Parameters:
requiresSelectedSongs
-true
orfalse
-
fillPlayList
public abstract boolean fillPlayList(PlayList newPlayList, long[] selectedSongIds)
This method is called by the action as part of its
actionPerformed(ActionEvent)
method. You are given an empty, new playlist and the ids of the currently selected songs, ifisRequiresSelectedSongs()
istrue
. The idea is to add songs to the playlist using thePlayList.addSongIds(java.util.List)
method. If you don't just want to add any of the selected songs, useMediaLibrary
to find other songs you want to add to this playlist.You may also modify the playlist object itself, e.g. change the default name programmatically.
Note that you are not called from either the EDT or the default database thread, but an independent thread. This means, that you may block this thread indefinitely (of course you shouldn't though!). It also means, that from this thread you should invoke UI code using
SwingUtilities.invokeAndWait(Runnable)
.After this method returns, beaTunes adds the playlist to the
PlayListTree
, selects it, and allows the user to edit its name.- Parameters:
newPlayList
- new, empty playlistselectedSongIds
- selected song ids or an empty array, ifisRequiresSelectedSongs()
isfalse
- Returns:
true
on success,false
on cancel
-
actionPerformed
public void actionPerformed(ActionEvent e)
-
-