* delete items from both lists as to delete the whole row
This commit is contained in:
parent
bdc09a7055
commit
6110d6f73c
|
@ -47,10 +47,10 @@ public class FileBotList<E> 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<E> 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<E> 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);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue