diff --git a/source/net/sourceforge/filebot/ui/FileBotList.java b/source/net/sourceforge/filebot/ui/FileBotList.java index 75df6c99..15847290 100644 --- a/source/net/sourceforge/filebot/ui/FileBotList.java +++ b/source/net/sourceforge/filebot/ui/FileBotList.java @@ -47,10 +47,10 @@ public class FileBotList extends JComponent { add(listScrollPane, BorderLayout.CENTER); // Shortcut DELETE, disabled by default - removeAction.setEnabled(false); + getRemoveAction().setEnabled(false); - TunedUtilities.installAction(this, KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0), removeAction); - TunedUtilities.installAction(this, KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SPACE, 0), removeAction); + TunedUtilities.installAction(this, KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0), removeHook); + TunedUtilities.installAction(this, KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SPACE, 0), removeHook); } @@ -120,12 +120,7 @@ public class FileBotList extends JComponent { } } - - public Action getRemoveAction() { - return removeAction; - } - - private final AbstractAction removeAction = new AbstractAction("Remove") { + private final AbstractAction defaultRemoveAction = new AbstractAction("Remove") { @Override public void actionPerformed(ActionEvent e) { @@ -144,4 +139,26 @@ public class FileBotList extends JComponent { } }; + private Action removeAction = defaultRemoveAction; + + + public Action getRemoveAction() { + return removeAction; + } + + + public void setRemoveAction(Action action) { + this.removeAction = action; + } + + private final AbstractAction removeHook = new AbstractAction("Remove") { + + @Override + public void actionPerformed(ActionEvent e) { + if (getRemoveAction() != null && getRemoveAction().isEnabled()) { + getRemoveAction().actionPerformed(e); + } + } + }; + } diff --git a/source/net/sourceforge/filebot/ui/rename/RenamePanel.java b/source/net/sourceforge/filebot/ui/rename/RenamePanel.java index a7ab36e7..a35b0820 100644 --- a/source/net/sourceforge/filebot/ui/rename/RenamePanel.java +++ b/source/net/sourceforge/filebot/ui/rename/RenamePanel.java @@ -132,6 +132,30 @@ public class RenamePanel extends JComponent { // synchronize viewports new ScrollPaneSynchronizer(namesList, filesList); + // delete items from both lists + Action removeAction = new AbstractAction("Remove") { + + @Override + public void actionPerformed(ActionEvent e) { + JList list = ((RenameList) e.getSource()).getListComponent(); + int index = list.getSelectedIndex(); + if (index >= 0) { + if (isShiftDown(e)) { + ((RenameList) e.getSource()).remove(index); + } else { + renameModel.matches().remove(index); + } + int maxIndex = list.getModel().getSize() - 1; + if (index > maxIndex) { + index = maxIndex; + } + list.setSelectedIndex(index); + } + } + }; + namesList.setRemoveAction(removeAction); + filesList.setRemoveAction(removeAction); + // create Match button JButton matchButton = new JButton(matchAction); matchButton.setVerticalTextPosition(SwingConstants.BOTTOM);