Skip to content

Commit 80bf519

Browse files
committed
Improve drag-and-drop playlist implementation
1 parent 95058a4 commit 80bf519

File tree

1 file changed

+56
-108
lines changed

1 file changed

+56
-108
lines changed

src/main/java/listfix/view/GUIScreen.java

+56-108
Original file line numberDiff line numberDiff line change
@@ -255,12 +255,12 @@ public boolean postProcessKeyEvent(KeyEvent e)
255255

256256
private boolean ctrlShiftTabWasPressed(KeyEvent e)
257257
{
258-
return (e.getKeyCode() == KeyEvent.VK_TAB) && ((e.getModifiers() & KeyEvent.CTRL_MASK) != 0) && ((e.getModifiers() & KeyEvent.SHIFT_MASK) != 0) && _playlistTabbedPane.getDocumentCount() > 0 && e.getID() == KeyEvent.KEY_PRESSED;
258+
return (e.getKeyCode() == KeyEvent.VK_TAB) && ((e.getModifiersEx() & KeyEvent.CTRL_DOWN_MASK) != 0) && ((e.getModifiersEx() & KeyEvent.SHIFT_DOWN_MASK) != 0) && _playlistTabbedPane.getDocumentCount() > 0 && e.getID() == KeyEvent.KEY_PRESSED;
259259
}
260260

261261
private boolean ctrlTabWasPressed(KeyEvent e)
262262
{
263-
return (e.getKeyCode() == KeyEvent.VK_TAB) && ((e.getModifiers() & KeyEvent.CTRL_MASK) != 0) && ((e.getModifiers() & KeyEvent.SHIFT_MASK) == 0) && _playlistTabbedPane.getDocumentCount() > 0 && e.getID() == KeyEvent.KEY_PRESSED;
263+
return (e.getKeyCode() == KeyEvent.VK_TAB) && ((e.getModifiersEx() & KeyEvent.CTRL_DOWN_MASK) != 0) && ((e.getModifiersEx() & KeyEvent.SHIFT_DOWN_MASK) == 0) && _playlistTabbedPane.getDocumentCount() > 0 && e.getID() == KeyEvent.KEY_PRESSED;
264264
}
265265
};
266266

@@ -290,7 +290,7 @@ private void handleMouseEvent(MouseEvent e)
290290
{
291291
int rowIx = _playlistDirectoryTree.getRowForLocation(p.x, p.y);
292292
boolean isOverItem = rowIx >= 0;
293-
if (isOverItem && (e.getModifiers() & ActionEvent.CTRL_MASK) > 0)
293+
if (isOverItem && (e.getModifiersEx() & ActionEvent.CTRL_MASK) > 0)
294294
{
295295
_playlistDirectoryTree.addSelectionRow(rowIx);
296296
}
@@ -620,70 +620,70 @@ private void initComponents()
620620
_miRefreshDirectoryTree = new JMenuItem();
621621
_miRemovePlaylistDirectory = new JMenuItem();
622622
_miOpenSelectedPlaylists = new JMenuItem();
623-
_miOpenSelectedPlaylistLocation = new JMenuItem();
623+
JMenuItem _miOpenSelectedPlaylistLocation = new JMenuItem();
624624
_miExactMatchesSearch = new JMenuItem();
625625
_miClosestMatchesSearch = new JMenuItem();
626626
_miDeleteFile = new JMenuItem();
627627
_miRenameSelectedItem = new JMenuItem();
628-
_statusPanel = new JPanel();
628+
JPanel _statusPanel = new JPanel();
629629
statusLabel = new JLabel();
630-
_splitPane = new JSplitPane();
630+
JSplitPane _splitPane = new JSplitPane();
631631
_leftSplitPane = new JSplitPane();
632-
_mediaLibraryPanel = new JPanel();
633-
_mediaLibraryButtonPanel = new JPanel();
634-
_addMediaDirButton = new JButton();
632+
JPanel _mediaLibraryPanel = new JPanel();
633+
JPanel _mediaLibraryButtonPanel = new JPanel();
634+
JButton _addMediaDirButton = new JButton();
635635
_removeMediaDirButton = new JButton();
636636
_refreshMediaDirsButton = new JButton();
637-
_mediaLibraryScrollPane = new JScrollPane();
637+
JScrollPane _mediaLibraryScrollPane = new JScrollPane();
638638
_lstMediaLibraryDirs = new JList<String>(new String[]{"Please Add A Media Directory..."});
639-
_playlistDirectoryPanel = new JPanel();
640-
_treeScrollPane = new JScrollPane();
639+
JPanel _playlistDirectoryPanel = new JPanel();
640+
JScrollPane _treeScrollPane = new JScrollPane();
641641
_playlistDirectoryTree = new JTree();
642-
_playlistsDirectoryButtonPanel = new JPanel();
643-
_btnSetPlaylistsDir = new JButton();
644-
_btnRefresh = new JButton();
642+
JPanel _playlistsDirectoryButtonPanel = new JPanel();
643+
JButton _btnSetPlaylistsDir = new JButton();
644+
JButton _btnRefresh = new JButton();
645645
_btnOpenSelected = new JButton();
646646
_btnQuickRepair = new JButton();
647647
_btnDeepRepair = new JButton();
648648
_playlistPanel = new JPanel();
649-
_gettingStartedPanel = new JPanel();
650-
_verticalPanel = new JPanel();
651-
_openIconButton = new JButton();
652-
_spacerPanel = new JPanel();
653-
_newIconButton = new JButton();
654-
_docTabPanel = new JPanel();
655-
_playlistTabbedPane = new JDocumentTabbedPane();
656-
_mainMenuBar = new JMenuBar();
657-
_fileMenu = new JMenu();
658-
_newPlaylistMenuItem = new JMenuItem();
659-
_loadMenuItem = new JMenuItem();
660-
_openPlaylistLocationMenuItem = new JMenuItem();
661-
_closeMenuItem = new JMenuItem();
662-
_closeAllMenuItem = new JMenuItem();
663-
jSeparator1 = new Separator();
664-
_saveMenuItem = new JMenuItem();
665-
_saveAsMenuItem = new JMenuItem();
666-
_saveAllMenuItem = new JMenuItem();
667-
jSeparator2 = new Separator();
668-
_miReload = new JMenuItem();
669-
_miReloadAll = new JMenuItem();
670-
jSeparator3 = new Separator();
649+
JPanel _gettingStartedPanel = new JPanel();
650+
JPanel _verticalPanel = new JPanel();
651+
JButton _openIconButton = new JButton();
652+
JPanel _spacerPanel = new JPanel();
653+
JButton _newIconButton = new JButton();
654+
JPanel _docTabPanel = new JPanel();
655+
_playlistTabbedPane = new JDocumentTabbedPane<>();
656+
JMenuBar _mainMenuBar = new JMenuBar();
657+
JMenu _fileMenu = new JMenu();
658+
JMenuItem _newPlaylistMenuItem = new JMenuItem();
659+
JMenuItem _loadMenuItem = new JMenuItem();
660+
JMenuItem _openPlaylistLocationMenuItem = new JMenuItem();
661+
JMenuItem _closeMenuItem = new JMenuItem();
662+
JMenuItem _closeAllMenuItem = new JMenuItem();
663+
Separator jSeparator1 = new Separator();
664+
JMenuItem _saveMenuItem = new JMenuItem();
665+
JMenuItem _saveAsMenuItem = new JMenuItem();
666+
JMenuItem _saveAllMenuItem = new JMenuItem();
667+
Separator jSeparator2 = new Separator();
668+
JMenuItem _miReload = new JMenuItem();
669+
JMenuItem _miReloadAll = new JMenuItem();
670+
Separator jSeparator3 = new Separator();
671671
recentMenu = new JMenu();
672-
_clearHistoryMenuItem = new JMenuItem();
673-
jSeparator4 = new Separator();
674-
_appOptionsMenuItem = new JMenuItem();
675-
jSeparator5 = new Separator();
676-
_exitMenuItem = new JMenuItem();
677-
_repairMenu = new JMenu();
678-
_miBatchRepair = new JMenuItem();
679-
_miExactMatchRepairOpenPlaylists = new JMenuItem();
680-
_miClosestMatchRepairOpenPlaylists = new JMenuItem();
672+
JMenuItem _clearHistoryMenuItem = new JMenuItem();
673+
Separator jSeparator4 = new Separator();
674+
JMenuItem _appOptionsMenuItem = new JMenuItem();
675+
Separator jSeparator5 = new Separator();
676+
JMenuItem _exitMenuItem = new JMenuItem();
677+
JMenu _repairMenu = new JMenu();
678+
JMenuItem _miBatchRepair = new JMenuItem();
679+
JMenuItem _miExactMatchRepairOpenPlaylists = new JMenuItem();
680+
JMenuItem _miClosestMatchRepairOpenPlaylists = new JMenuItem();
681681
_batchRepairWinampMenuItem = new JMenuItem();
682682
_extractPlaylistsMenuItem = new JMenuItem();
683-
_helpMenu = new JMenu();
684-
_helpMenuItem = new JMenuItem();
685-
_updateCheckMenuItem = new JMenuItem();
686-
_aboutMenuItem = new JMenuItem();
683+
JMenu _helpMenu = new JMenu();
684+
JMenuItem _helpMenuItem = new JMenuItem();
685+
JMenuItem _updateCheckMenuItem = new JMenuItem();
686+
JMenuItem _aboutMenuItem = new JMenuItem();
687687

688688
_miRemovePlaylistDirectory.setText("Remove Playlist Directory");
689689
_miRemovePlaylistDirectory.setToolTipText("Remove playlist directory from configuration");
@@ -1164,7 +1164,7 @@ public void documentClosed(JDocumentComponent<PlaylistEditCtrl> document)
11641164
}
11651165

11661166
@Override
1167-
public void documentActivated(JDocumentComponent doc)
1167+
public void documentActivated(JDocumentComponent<PlaylistEditCtrl> doc)
11681168
{
11691169
GUIScreen.this.currentTabChanged(doc);
11701170
}
@@ -1718,7 +1718,7 @@ private void updateAllComponentTreeUIs()
17181718
SwingUtilities.updateComponentTreeUI(_playlistTabbedPane);
17191719
}
17201720

1721-
private Playlist getPlaylistFromDocumentComponent(JDocumentComponent ctrl)
1721+
private Playlist getPlaylistFromDocumentComponent(JDocumentComponent<PlaylistEditCtrl> ctrl)
17221722
{
17231723
return ((PlaylistEditCtrl) ctrl.getComponent()).getPlaylist();
17241724
}
@@ -1858,7 +1858,7 @@ private void currentTabChanged()
18581858
this.currentTabChanged(_playlistTabbedPane.getActiveTab());
18591859
}
18601860

1861-
private void currentTabChanged(JDocumentComponent documentComponent)
1861+
private void currentTabChanged(JDocumentComponent<PlaylistEditCtrl> documentComponent)
18621862
{
18631863
Playlist list = documentComponent != null ? ((PlaylistEditCtrl) documentComponent.getComponent()).getPlaylist() : null;
18641864
if (list == _currentPlaylist)
@@ -1913,7 +1913,7 @@ private void refreshStatusLabel(Playlist list)
19131913
}
19141914
}
19151915

1916-
private void updateTabTitleForPlaylist(Playlist list, JDocumentComponent comp)
1916+
private void updateTabTitleForPlaylist(Playlist list, JDocumentComponent<PlaylistEditCtrl> comp)
19171917
{
19181918
comp.setPath(list.getPath());
19191919
}
@@ -2392,7 +2392,7 @@ private void _newIconButtonActionPerformed()//GEN-FIRST:event__newIconButtonActi
23922392
Path path = _currentPlaylist.getPath();
23932393
PlaylistEditCtrl editor = new PlaylistEditCtrl(this);
23942394
editor.setPlaylist(_currentPlaylist);
2395-
final JDocumentComponent tempComp = _playlistTabbedPane.openDocument(editor, path);
2395+
final JDocumentComponent<PlaylistEditCtrl> tempComp = _playlistTabbedPane.openDocument(editor, path);
23962396
_playlistTabbedPane.setActiveDocument(path);
23972397

23982398
_openPlaylists.add(_currentPlaylist);
@@ -2788,9 +2788,7 @@ public static void main(String[] args) throws IOException, InterruptedException,
27882788
// EDT Exception
27892789
SwingUtilities.invokeAndWait(() -> {
27902790
// We are in the event dispatching thread
2791-
Thread.currentThread().setUncaughtExceptionHandler((thread, e) -> {
2792-
_logger.error("Uncaught Exception", e);
2793-
});
2791+
Thread.currentThread().setUncaughtExceptionHandler((thread, e) -> _logger.error("Uncaught Exception", e));
27942792
});
27952793

27962794
IAppOptions tempOptions = ApplicationOptionsConfiguration.load().getConfig();
@@ -2845,76 +2843,26 @@ private void addPlaylist(File playlistFile)
28452843
this.updatePlaylistDirectoryPanel();
28462844
}
28472845

2848-
// <editor-fold defaultstate="collapsed" desc="Generated Code">
2849-
// Variables declaration - do not modify//GEN-BEGIN:variables
2850-
private JMenuItem _aboutMenuItem;
2851-
private JButton _addMediaDirButton;
2852-
private JMenuItem _appOptionsMenuItem;
28532846
private JMenuItem _batchRepairWinampMenuItem;
28542847
private JButton _btnDeepRepair;
28552848
private JButton _btnOpenSelected;
28562849
private JButton _btnQuickRepair;
2857-
private JButton _btnRefresh;
2858-
private JButton _btnSetPlaylistsDir;
2859-
private JMenuItem _clearHistoryMenuItem;
2860-
private JMenuItem _closeAllMenuItem;
2861-
private JMenuItem _closeMenuItem;
2862-
private JPanel _docTabPanel;
28632850
private JDocumentTabbedPane<PlaylistEditCtrl> _playlistTabbedPane;
2864-
private JMenuItem _exitMenuItem;
28652851
private JMenuItem _extractPlaylistsMenuItem;
2866-
private JMenu _fileMenu;
2867-
private JPanel _gettingStartedPanel;
2868-
private JMenu _helpMenu;
2869-
private JMenuItem _helpMenuItem;
28702852
private JSplitPane _leftSplitPane;
2871-
private JMenuItem _loadMenuItem;
2872-
private JMenuItem _openPlaylistLocationMenuItem;
28732853
private JList<String> _lstMediaLibraryDirs;
2874-
private JMenuBar _mainMenuBar;
2875-
private JPanel _mediaLibraryButtonPanel;
2876-
private JPanel _mediaLibraryPanel;
2877-
private JScrollPane _mediaLibraryScrollPane;
2878-
private JMenuItem _miBatchRepair;
2879-
private JMenuItem _miClosestMatchRepairOpenPlaylists;
28802854
private JMenuItem _miClosestMatchesSearch;
28812855
private JMenuItem _miDeleteFile;
2882-
private JMenuItem _miExactMatchRepairOpenPlaylists;
28832856
private JMenuItem _miExactMatchesSearch;
28842857
private JMenuItem _miOpenSelectedPlaylists;
2885-
private JMenuItem _miOpenSelectedPlaylistLocation;
28862858
private JMenuItem _miRefreshDirectoryTree;
28872859
private JMenuItem _miRemovePlaylistDirectory;
2888-
private JMenuItem _miReload;
2889-
private JMenuItem _miReloadAll;
28902860
private JMenuItem _miRenameSelectedItem;
2891-
private JButton _newIconButton;
2892-
private JMenuItem _newPlaylistMenuItem;
2893-
private JButton _openIconButton;
2894-
private JPanel _playlistDirectoryPanel;
28952861
private JTree _playlistDirectoryTree;
28962862
private JPanel _playlistPanel;
28972863
private JPopupMenu _playlistTreeRightClickMenu;
2898-
private JPanel _playlistsDirectoryButtonPanel;
28992864
private JButton _refreshMediaDirsButton;
29002865
private JButton _removeMediaDirButton;
2901-
private JMenu _repairMenu;
2902-
private JMenuItem _saveAllMenuItem;
2903-
private JMenuItem _saveAsMenuItem;
2904-
private JMenuItem _saveMenuItem;
2905-
private JPanel _spacerPanel;
2906-
private JSplitPane _splitPane;
2907-
private JPanel _statusPanel;
2908-
private JScrollPane _treeScrollPane;
2909-
private JMenuItem _updateCheckMenuItem;
2910-
private JPanel _verticalPanel;
2911-
private Separator jSeparator1;
2912-
private Separator jSeparator2;
2913-
private Separator jSeparator3;
2914-
private Separator jSeparator4;
2915-
private Separator jSeparator5;
29162866
private JMenu recentMenu;
29172867
private JLabel statusLabel;
2918-
// End of variables declaration//GEN-END:variables
2919-
// </editor-fold>
29202868
}

0 commit comments

Comments
 (0)