Merge pull request #322 from Varinara/feature

added additional button for clearing history
This commit is contained in:
cyian-1756 2017-12-16 16:12:50 -05:00 committed by GitHub
commit 7363efed6a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -662,12 +662,46 @@ public final class MainWindow implements Runnable, RipStatusHandler {
saveHistory(); saveHistory();
}); });
historyButtonClear.addActionListener(event -> { historyButtonClear.addActionListener(event -> {
Utils.clearURLHistory(); if (Utils.getConfigBoolean("history.warn_before_delete", true)) {
HISTORY.clear();
try { JPanel checkChoise = new JPanel();
historyTableModel.fireTableDataChanged(); checkChoise.setLayout(new FlowLayout());
} catch (Exception e) { } JButton yesButton = new JButton("YES");
saveHistory(); JButton noButton = new JButton("NO");
yesButton.setPreferredSize(new Dimension(70, 30));
noButton.setPreferredSize(new Dimension(70, 30));
checkChoise.add(yesButton);
checkChoise.add(noButton);
JFrame.setDefaultLookAndFeelDecorated(true);
JFrame frame = new JFrame("Are you sure?");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.add(checkChoise);
frame.setSize(405, 70);
frame.setVisible(true);
frame.setLocationRelativeTo(null);
noButton.addActionListener(e -> {
frame.setVisible(false);
});
yesButton.addActionListener(ed -> {
frame.setVisible(false);
Utils.clearURLHistory();
HISTORY.clear();
try {
historyTableModel.fireTableDataChanged();
} catch (Exception e) {
}
saveHistory();
});
}
else {
Utils.clearURLHistory();
HISTORY.clear();
try {
historyTableModel.fireTableDataChanged();
} catch (Exception e) {
}
saveHistory();
}
}); });
// Re-rip all history // Re-rip all history