mirror of
https://github.com/RipMeApp/ripme.git
synced 2025-08-17 19:26:34 +02:00
Merge pull request #1407 from Isaaku/issues/1402_confirm_clear
Issues/1402 confirm clear
This commit is contained in:
21
.github/workflows/maven.yml
vendored
Normal file
21
.github/workflows/maven.yml
vendored
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
name: Java CI
|
||||||
|
|
||||||
|
on: [push, pull_request]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
os: [ubuntu-latest, windows-latest, macOS-latest]
|
||||||
|
java: [1.8, 1.9]
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v1
|
||||||
|
- name: Set up JDK 1.8
|
||||||
|
uses: actions/setup-java@v1
|
||||||
|
with:
|
||||||
|
java-version: ${{ matrix.java }}
|
||||||
|
- name: Build with Maven
|
||||||
|
run: mvn package --file pom.xml
|
@@ -143,10 +143,13 @@ public final class MainWindow implements Runnable, RipStatusHandler {
|
|||||||
if (model == null)
|
if (model == null)
|
||||||
model = queueListModel;
|
model = queueListModel;
|
||||||
|
|
||||||
Utils.setConfigList("Queue", (Enumeration<Object>) model.elements());
|
if (model.size() > 0) {
|
||||||
|
Utils.setConfigList("queue", (Enumeration<Object>) model.elements());
|
||||||
|
Utils.saveConfig();
|
||||||
|
|
||||||
MainWindow.optionQueue.setText(String.format("%s%s", Utils.getLocalizedString("queue"),
|
MainWindow.optionQueue.setText(String.format("%s%s", Utils.getLocalizedString("queue"),
|
||||||
model.size() == 0 ? "" : "(" + model.size() + ")"));
|
model.size() == 0 ? "" : "(" + model.size() + ")"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateQueue() {
|
private void updateQueue() {
|
||||||
@@ -259,6 +262,7 @@ public final class MainWindow implements Runnable, RipStatusHandler {
|
|||||||
|
|
||||||
private boolean isCollapsed() {
|
private boolean isCollapsed() {
|
||||||
return (!logPanel.isVisible() && !historyPanel.isVisible() && !queuePanel.isVisible()
|
return (!logPanel.isVisible() && !historyPanel.isVisible() && !queuePanel.isVisible()
|
||||||
|
|
||||||
&& !configurationPanel.isVisible());
|
&& !configurationPanel.isVisible());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -479,8 +483,10 @@ public final class MainWindow implements Runnable, RipStatusHandler {
|
|||||||
queueListModel = new DefaultListModel();
|
queueListModel = new DefaultListModel();
|
||||||
JList queueList = new JList(queueListModel);
|
JList queueList = new JList(queueListModel);
|
||||||
queueList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
|
queueList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
|
||||||
queueList.addMouseListener(queueMenuMouseListener = new QueueMenuMouseListener());
|
queueList.addMouseListener(
|
||||||
|
queueMenuMouseListener = new QueueMenuMouseListener(d -> updateQueue(queueListModel)));
|
||||||
JScrollPane queueListScroll = new JScrollPane(queueList, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
|
JScrollPane queueListScroll = new JScrollPane(queueList, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
|
||||||
|
|
||||||
JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
|
JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
|
||||||
for (String item : Utils.getConfigList("queue")) {
|
for (String item : Utils.getConfigList("queue")) {
|
||||||
queueListModel.addElement(item);
|
queueListModel.addElement(item);
|
||||||
@@ -856,6 +862,7 @@ public final class MainWindow implements Runnable, RipStatusHandler {
|
|||||||
}
|
}
|
||||||
if (added == 0) {
|
if (added == 0) {
|
||||||
JOptionPane.showMessageDialog(null, Utils.getLocalizedString("history.load.none.checked"),
|
JOptionPane.showMessageDialog(null, Utils.getLocalizedString("history.load.none.checked"),
|
||||||
|
|
||||||
"RipMe Error", JOptionPane.ERROR_MESSAGE);
|
"RipMe Error", JOptionPane.ERROR_MESSAGE);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -1026,6 +1033,7 @@ public final class MainWindow implements Runnable, RipStatusHandler {
|
|||||||
MenuItem trayMenuAbout = new MenuItem("About " + mainFrame.getTitle());
|
MenuItem trayMenuAbout = new MenuItem("About " + mainFrame.getTitle());
|
||||||
trayMenuAbout.addActionListener(arg0 -> {
|
trayMenuAbout.addActionListener(arg0 -> {
|
||||||
StringBuilder about = new StringBuilder();
|
StringBuilder about = new StringBuilder();
|
||||||
|
|
||||||
about.append("<html><h1>").append(mainFrame.getTitle()).append("</h1>");
|
about.append("<html><h1>").append(mainFrame.getTitle()).append("</h1>");
|
||||||
about.append("Download albums from various websites:");
|
about.append("Download albums from various websites:");
|
||||||
try {
|
try {
|
||||||
@@ -1164,6 +1172,7 @@ public final class MainWindow implements Runnable, RipStatusHandler {
|
|||||||
LOGGER.error("Failed to load history from file " + historyFile, e);
|
LOGGER.error("Failed to load history from file " + historyFile, e);
|
||||||
JOptionPane.showMessageDialog(null,
|
JOptionPane.showMessageDialog(null,
|
||||||
String.format(Utils.getLocalizedString("history.load.failed.warning"), e.getMessage()),
|
String.format(Utils.getLocalizedString("history.load.failed.warning"), e.getMessage()),
|
||||||
|
|
||||||
"RipMe - history load failure", JOptionPane.ERROR_MESSAGE);
|
"RipMe - history load failure", JOptionPane.ERROR_MESSAGE);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -1202,7 +1211,6 @@ public final class MainWindow implements Runnable, RipStatusHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
private void ripNextAlbum() {
|
private void ripNextAlbum() {
|
||||||
isRipping = true;
|
isRipping = true;
|
||||||
// Save current state of queue to configuration.
|
// Save current state of queue to configuration.
|
||||||
@@ -1445,6 +1453,8 @@ public final class MainWindow implements Runnable, RipStatusHandler {
|
|||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
* content key %path% the path to the album folder %url% is the album url
|
* content key %path% the path to the album folder %url% is the album url
|
||||||
|
*
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
if (Utils.getConfigBoolean("enable.finish.command", false)) {
|
if (Utils.getConfigBoolean("enable.finish.command", false)) {
|
||||||
try {
|
try {
|
||||||
|
@@ -4,25 +4,33 @@ import java.awt.event.ActionEvent;
|
|||||||
import java.awt.event.InputEvent;
|
import java.awt.event.InputEvent;
|
||||||
import java.awt.event.MouseAdapter;
|
import java.awt.event.MouseAdapter;
|
||||||
import java.awt.event.MouseEvent;
|
import java.awt.event.MouseEvent;
|
||||||
import java.util.Enumeration;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
import javax.swing.AbstractAction;
|
import javax.swing.AbstractAction;
|
||||||
import javax.swing.Action;
|
import javax.swing.Action;
|
||||||
import javax.swing.DefaultListModel;
|
import javax.swing.DefaultListModel;
|
||||||
import javax.swing.JList;
|
import javax.swing.JList;
|
||||||
|
import javax.swing.JOptionPane;
|
||||||
import javax.swing.JPopupMenu;
|
import javax.swing.JPopupMenu;
|
||||||
|
|
||||||
import com.rarchives.ripme.utils.Utils;
|
import com.rarchives.ripme.utils.Utils;
|
||||||
|
|
||||||
class QueueMenuMouseListener extends MouseAdapter {
|
class QueueMenuMouseListener extends MouseAdapter {
|
||||||
private JPopupMenu popup = new JPopupMenu();
|
private JPopupMenu popup = new JPopupMenu();
|
||||||
private JList queueList;
|
private JList<Object> queueList;
|
||||||
private DefaultListModel queueListModel;
|
private DefaultListModel<Object> queueListModel;
|
||||||
|
private Consumer<DefaultListModel<Object>> updateQueue;
|
||||||
|
|
||||||
@SuppressWarnings("serial")
|
public QueueMenuMouseListener(Consumer<DefaultListModel<Object>> updateQueue) {
|
||||||
public QueueMenuMouseListener() {
|
this.updateQueue = updateQueue;
|
||||||
|
updateUI();
|
||||||
|
}
|
||||||
|
|
||||||
Action removeSelected = new AbstractAction("Remove Selected") {
|
@SuppressWarnings("serial")
|
||||||
|
public void updateUI() {
|
||||||
|
popup.removeAll();
|
||||||
|
|
||||||
|
Action removeSelected = new AbstractAction(Utils.getLocalizedString("queue.remove.selected")) {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent ae) {
|
public void actionPerformed(ActionEvent ae) {
|
||||||
Object o = queueList.getSelectedValue();
|
Object o = queueList.getSelectedValue();
|
||||||
@@ -35,27 +43,22 @@ class QueueMenuMouseListener extends MouseAdapter {
|
|||||||
};
|
};
|
||||||
popup.add(removeSelected);
|
popup.add(removeSelected);
|
||||||
|
|
||||||
Action clearQueue = new AbstractAction("Remove All") {
|
Action clearQueue = new AbstractAction(Utils.getLocalizedString("queue.remove.all")) {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent ae) {
|
public void actionPerformed(ActionEvent ae) {
|
||||||
queueListModel.removeAllElements();
|
if (JOptionPane.showConfirmDialog(null, Utils.getLocalizedString("queue.validation"), "RipMe",
|
||||||
updateUI();
|
JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
|
||||||
|
queueListModel.removeAllElements();
|
||||||
|
updateUI();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
popup.add(clearQueue);
|
popup.add(clearQueue);
|
||||||
|
|
||||||
|
updateQueue.accept(queueListModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateUI() {
|
@SuppressWarnings("unchecked")
|
||||||
Utils.setConfigList("queue", (Enumeration<Object>) queueListModel.elements());
|
|
||||||
|
|
||||||
if (queueListModel.size() == 0) {
|
|
||||||
MainWindow.optionQueue.setText("Queue");
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
MainWindow.optionQueue.setText("Queue (" + queueListModel.size() + ")");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@Override
|
@Override
|
||||||
public void mouseClicked(MouseEvent e) {
|
public void mouseClicked(MouseEvent e) {
|
||||||
if (e.getModifiers() == InputEvent.BUTTON3_MASK) {
|
if (e.getModifiers() == InputEvent.BUTTON3_MASK) {
|
||||||
@@ -63,8 +66,8 @@ class QueueMenuMouseListener extends MouseAdapter {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
queueList = (JList) e.getSource();
|
queueList = (JList<Object>) e.getSource();
|
||||||
queueListModel = (DefaultListModel) queueList.getModel();
|
queueListModel = (DefaultListModel<Object>) queueList.getModel();
|
||||||
queueList.requestFocus();
|
queueList.requestFocus();
|
||||||
|
|
||||||
int nx = e.getX();
|
int nx = e.getX();
|
||||||
|
Reference in New Issue
Block a user