From 981898dc2aa25be6c82b828f10e0a6a8ba6b06e1 Mon Sep 17 00:00:00 2001 From: Artyom Yurkov <32659793+Varinara@users.noreply.github.com> Date: Thu, 7 Dec 2017 18:30:52 +0300 Subject: [PATCH] Update MainWindow.java --- .../com/rarchives/ripme/ui/MainWindow.java | 291 +++++++++--------- 1 file changed, 152 insertions(+), 139 deletions(-) diff --git a/src/main/java/com/rarchives/ripme/ui/MainWindow.java b/src/main/java/com/rarchives/ripme/ui/MainWindow.java index 6bc00038..ac21e12b 100644 --- a/src/main/java/com/rarchives/ripme/ui/MainWindow.java +++ b/src/main/java/com/rarchives/ripme/ui/MainWindow.java @@ -74,7 +74,7 @@ public final class MainWindow implements Runnable, RipStatusHandler { private static JFrame mainFrame; private static JTextField ripTextfield; private static JButton ripButton, - stopButton; + stopButton; private static JLabel statusLabel; private static JButton openButton; @@ -96,8 +96,8 @@ public final class MainWindow implements Runnable, RipStatusHandler { private static JTable historyTable; private static AbstractTableModel historyTableModel; private static JButton historyButtonRemove, - historyButtonClear, - historyButtonRerip; + historyButtonClear, + historyButtonRerip; // Queue public static JButton optionQueue; @@ -388,15 +388,15 @@ public final class MainWindow implements Runnable, RipStatusHandler { for (int i = 0; i < historyTable.getColumnModel().getColumnCount(); i++) { int width = 130; // Default switch (i) { - case 0: // URL - width = 270; - break; - case 3: - width = 40; - break; - case 4: - width = 15; - break; + case 0: // URL + width = 270; + break; + case 3: + width = 40; + break; + case 4: + width = 15; + break; } historyTable.getColumnModel().getColumn(i).setPreferredWidth(width); } @@ -494,29 +494,29 @@ public final class MainWindow implements Runnable, RipStatusHandler { configSaveDirLabel.setHorizontalAlignment(JLabel.RIGHT); configSaveDirButton = new JButton("Select Save Directory..."); gbc.gridy = 0; gbc.gridx = 0; configurationPanel.add(configUpdateLabel, gbc); - gbc.gridx = 1; configurationPanel.add(configUpdateButton, gbc); + gbc.gridx = 1; configurationPanel.add(configUpdateButton, gbc); gbc.gridy = 1; gbc.gridx = 0; configurationPanel.add(configAutoupdateCheckbox, gbc); - gbc.gridx = 1; configurationPanel.add(configLogLevelCombobox, gbc); + gbc.gridx = 1; configurationPanel.add(configLogLevelCombobox, gbc); gbc.gridy = 2; gbc.gridx = 0; configurationPanel.add(configThreadsLabel, gbc); - gbc.gridx = 1; configurationPanel.add(configThreadsText, gbc); + gbc.gridx = 1; configurationPanel.add(configThreadsText, gbc); gbc.gridy = 3; gbc.gridx = 0; configurationPanel.add(configTimeoutLabel, gbc); - gbc.gridx = 1; configurationPanel.add(configTimeoutText, gbc); + gbc.gridx = 1; configurationPanel.add(configTimeoutText, gbc); gbc.gridy = 4; gbc.gridx = 0; configurationPanel.add(configRetriesLabel, gbc); - gbc.gridx = 1; configurationPanel.add(configRetriesText, gbc); + gbc.gridx = 1; configurationPanel.add(configRetriesText, gbc); gbc.gridy = 5; gbc.gridx = 0; configurationPanel.add(configOverwriteCheckbox, gbc); - gbc.gridx = 1; configurationPanel.add(configSaveOrderCheckbox, gbc); + gbc.gridx = 1; configurationPanel.add(configSaveOrderCheckbox, gbc); gbc.gridy = 6; gbc.gridx = 0; configurationPanel.add(configPlaySound, gbc); - gbc.gridx = 1; configurationPanel.add(configSaveLogs, gbc); + gbc.gridx = 1; configurationPanel.add(configSaveLogs, gbc); gbc.gridy = 7; gbc.gridx = 0; configurationPanel.add(configShowPopup, gbc); - gbc.gridx = 1; configurationPanel.add(configSaveURLsOnly, gbc); + gbc.gridx = 1; configurationPanel.add(configSaveURLsOnly, gbc); gbc.gridy = 8; gbc.gridx = 0; configurationPanel.add(configClipboardAutorip, gbc); - gbc.gridx = 1; configurationPanel.add(configSaveAlbumTitles, gbc); + gbc.gridx = 1; configurationPanel.add(configSaveAlbumTitles, gbc); gbc.gridy = 9; gbc.gridx = 0; configurationPanel.add(configSaveDescriptions, gbc); - gbc.gridx = 1; configurationPanel.add(configPreferMp4, gbc); + gbc.gridx = 1; configurationPanel.add(configPreferMp4, gbc); gbc.gridy = 10; gbc.gridx = 0; configurationPanel.add(configWindowPosition, gbc); - gbc.gridx = 1; configurationPanel.add(configURLHistoryCheckbox, gbc); + gbc.gridx = 1; configurationPanel.add(configURLHistoryCheckbox, gbc); gbc.gridy = 11; gbc.gridx = 0; configurationPanel.add(configSaveDirLabel, gbc); - gbc.gridx = 1; configurationPanel.add(configSaveDirButton, gbc); + gbc.gridx = 1; configurationPanel.add(configSaveDirButton, gbc); emptyPanel = new JPanel(); @@ -661,33 +661,46 @@ public final class MainWindow implements Runnable, RipStatusHandler { saveHistory(); }); historyButtonClear.addActionListener(event -> { - JPanel checkChoise = new JPanel(); - checkChoise.setLayout(new FlowLayout()); - JButton yesButton = new JButton("YES"); - 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); + if (Utils.getConfigBoolean("history.warn_before_delete", true)) { + + JPanel checkChoise = new JPanel(); + checkChoise.setLayout(new FlowLayout()); + JButton yesButton = new JButton("YES"); + 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) { } + } catch (Exception e) { + } saveHistory(); - }); + } }); // Re-rip all history @@ -760,7 +773,7 @@ public final class MainWindow implements Runnable, RipStatusHandler { addCheckboxListener(configSaveDescriptions, "descriptions.save"); addCheckboxListener(configPreferMp4, "prefer.mp4"); addCheckboxListener(configWindowPosition, "window.position"); - + configClipboardAutorip.addActionListener(arg0 -> { Utils.setConfigBoolean("clipboard.autorip", configClipboardAutorip.isSelected()); ClipboardUtils.setClipboardAutoRip(configClipboardAutorip.isSelected()); @@ -834,8 +847,8 @@ public final class MainWindow implements Runnable, RipStatusHandler { trayMenuAbout.addActionListener(arg0 -> { StringBuilder about = new StringBuilder(); about.append("