1.1.2 - Popup menu to check/uncheck history in bulk

Fixes #156
This commit is contained in:
4pr0n 2015-01-13 01:23:16 -08:00
parent 3c096add20
commit 56254ab6bc
4 changed files with 88 additions and 3 deletions

View File

@ -4,7 +4,7 @@
<groupId>com.rarchives.ripme</groupId> <groupId>com.rarchives.ripme</groupId>
<artifactId>ripme</artifactId> <artifactId>ripme</artifactId>
<packaging>jar</packaging> <packaging>jar</packaging>
<version>1.1.1</version> <version>1.1.2</version>
<name>ripme</name> <name>ripme</name>
<url>http://rip.rarchives.com</url> <url>http://rip.rarchives.com</url>
<properties> <properties>

View File

@ -0,0 +1,84 @@
package com.rarchives.ripme.ui;
import java.awt.event.ActionEvent;
import java.awt.event.InputEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.JPopupMenu;
import javax.swing.JTable;
public class HistoryMenuMouseListener extends MouseAdapter {
private JPopupMenu popup = new JPopupMenu();
private Action checkAllAction,
uncheckAllAction,
checkSelected,
uncheckSelected;
private JTable tableComponent;
@SuppressWarnings("serial")
public HistoryMenuMouseListener() {
checkAllAction = new AbstractAction("Check All") {
@Override
public void actionPerformed(ActionEvent ae) {
for (int row = 0; row < tableComponent.getRowCount(); row++) {
tableComponent.setValueAt(new Boolean(true), row, 4);
}
}
};
popup.add(checkAllAction);
uncheckAllAction = new AbstractAction("Check None") {
@Override
public void actionPerformed(ActionEvent ae) {
for (int row = 0; row < tableComponent.getRowCount(); row++) {
tableComponent.setValueAt(new Boolean(false), row, 4);
}
}
};
popup.add(uncheckAllAction);
popup.addSeparator();
checkSelected = new AbstractAction("Check Selected") {
@Override
public void actionPerformed(ActionEvent ae) {
for (int row : tableComponent.getSelectedRows()) {
tableComponent.setValueAt(new Boolean(false), row, 4);
}
}
};
popup.add(checkSelected);
uncheckSelected = new AbstractAction("Uncheck Selected") {
@Override
public void actionPerformed(ActionEvent ae) {
for (int row : tableComponent.getSelectedRows()) {
tableComponent.setValueAt(new Boolean(false), row, 4);
}
}
};
popup.add(uncheckSelected);
}
@Override
public void mouseClicked(MouseEvent e) {
if (e.getModifiers() == InputEvent.BUTTON3_MASK) {
if (!(e.getSource() instanceof JTable)) {
return;
}
tableComponent = (JTable) e.getSource();
tableComponent.requestFocus();
int nx = e.getX();
if (nx > 500) {
nx = nx - popup.getSize().width;
}
popup.show(e.getComponent(), nx, e.getY() - popup.getSize().height);
}
}
}

View File

@ -344,6 +344,7 @@ public class MainWindow implements Runnable, RipStatusHandler {
} }
}; };
historyTable = new JTable(historyTableModel); historyTable = new JTable(historyTableModel);
historyTable.addMouseListener(new HistoryMenuMouseListener());
historyTable.setAutoCreateRowSorter(true); historyTable.setAutoCreateRowSorter(true);
for (int i = 0; i < historyTable.getColumnModel().getColumnCount(); i++) { for (int i = 0; i < historyTable.getColumnModel().getColumnCount(); i++) {
int width = 130; // Default int width = 130; // Default
@ -625,7 +626,7 @@ public class MainWindow implements Runnable, RipStatusHandler {
if (added == 0) { if (added == 0) {
JOptionPane.showMessageDialog(null, JOptionPane.showMessageDialog(null,
"No history entries have been 'Checked'\n" + "No history entries have been 'Checked'\n" +
"Check an entry by clicking the checkbox to the right of the URL", "Check an entry by clicking the checkbox to the right of the URL or Right-click a URL to check/uncheck all items",
"RipMe Error", "RipMe Error",
JOptionPane.ERROR_MESSAGE); JOptionPane.ERROR_MESSAGE);
return; return;

View File

@ -21,7 +21,7 @@ import com.rarchives.ripme.utils.Utils;
public class UpdateUtils { public class UpdateUtils {
private static final Logger logger = Logger.getLogger(UpdateUtils.class); private static final Logger logger = Logger.getLogger(UpdateUtils.class);
private static final String DEFAULT_VERSION = "1.1.1"; private static final String DEFAULT_VERSION = "1.1.2";
private static final String updateJsonURL = "http://rarchives.com/ripme.json"; private static final String updateJsonURL = "http://rarchives.com/ripme.json";
private static final String updateJarURL = "http://rarchives.com/ripme.jar"; private static final String updateJarURL = "http://rarchives.com/ripme.jar";
private static final String mainFileName = "ripme.jar"; private static final String mainFileName = "ripme.jar";