mirror of
https://github.com/RipMeApp/ripme.git
synced 2025-08-27 07:44:20 +02:00
Fix queue after changes in #1406
This commit is contained in:
@@ -71,8 +71,8 @@ public final class MainWindow implements Runnable, RipStatusHandler {
|
|||||||
|
|
||||||
private static JFrame mainFrame;
|
private static JFrame mainFrame;
|
||||||
private static JTextField ripTextfield;
|
private static JTextField ripTextfield;
|
||||||
private static JButton ripButton,
|
private static JButton ripButton, stopButton;
|
||||||
stopButton;
|
|
||||||
|
|
||||||
private static JLabel statusLabel;
|
private static JLabel statusLabel;
|
||||||
private static JButton openButton;
|
private static JButton openButton;
|
||||||
@@ -93,14 +93,15 @@ public final class MainWindow implements Runnable, RipStatusHandler {
|
|||||||
private static JPanel historyPanel;
|
private static JPanel historyPanel;
|
||||||
private static JTable historyTable;
|
private static JTable historyTable;
|
||||||
private static AbstractTableModel historyTableModel;
|
private static AbstractTableModel historyTableModel;
|
||||||
private static JButton historyButtonRemove,
|
private static JButton historyButtonRemove, historyButtonClear, historyButtonRerip;
|
||||||
historyButtonClear,
|
|
||||||
historyButtonRerip;
|
|
||||||
|
|
||||||
// Queue
|
// Queue
|
||||||
public static JButton optionQueue;
|
public static JButton optionQueue;
|
||||||
private static JPanel queuePanel;
|
private static JPanel queuePanel;
|
||||||
private static DefaultListModel queueListModel;
|
private static DefaultListModel<Object> queueListModel;
|
||||||
|
private static QueueMenuMouseListener queueMenuMouseListener;
|
||||||
|
|
||||||
// Configuration
|
// Configuration
|
||||||
private static JButton optionConfiguration;
|
private static JButton optionConfiguration;
|
||||||
@@ -141,34 +142,40 @@ public final class MainWindow implements Runnable, RipStatusHandler {
|
|||||||
|
|
||||||
private static AbstractRipper ripper;
|
private static AbstractRipper ripper;
|
||||||
|
|
||||||
public static ResourceBundle rb = Utils.getResourceBundle(null);
|
|
||||||
|
|
||||||
// All the langs ripme has been translated into
|
|
||||||
private static String[] supportedLanges = new String[] {
|
|
||||||
"de_DE",
|
|
||||||
"ar_AR",
|
|
||||||
"en_US",
|
|
||||||
"es_ES",
|
|
||||||
"fi_FI",
|
|
||||||
"fr_CH",
|
|
||||||
"in_ID",
|
|
||||||
"it_IT",
|
|
||||||
"kr_KR",
|
|
||||||
"nl_NL",
|
|
||||||
"pl_PL",
|
|
||||||
"porrisavvo_FI",
|
|
||||||
"pt_BR",
|
|
||||||
"pt_PT",
|
|
||||||
"ru_RU"};
|
|
||||||
|
|
||||||
private void updateQueueLabel() {
|
private void updateQueue(DefaultListModel<Object> model) {
|
||||||
if (queueListModel.size() > 0) {
|
if (model == null)
|
||||||
optionQueue.setText(rb.getString("Queue") + " (" + queueListModel.size() + ")");
|
model = queueListModel;
|
||||||
} else {
|
|
||||||
optionQueue.setText(rb.getString("Queue"));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (model.size() > 0){
|
||||||
|
Utils.setConfigList("queue", (Enumeration<Object>) model.elements());
|
||||||
|
Utils.saveConfig();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MainWindow.optionQueue.setText(String.format("%s%s", Utils.getLocalizedString("queue"),
|
||||||
|
model.size() == 0 ? "" : "(" + model.size() + ")"));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateQueue() {
|
||||||
|
updateQueue(null);
|
||||||
|
}
|
||||||
|
|
||||||
private static void addCheckboxListener(JCheckBox checkBox, String configString) {
|
private static void addCheckboxListener(JCheckBox checkBox, String configString) {
|
||||||
checkBox.addActionListener(arg0 -> {
|
checkBox.addActionListener(arg0 -> {
|
||||||
@@ -276,29 +283,35 @@ public final class MainWindow implements Runnable, RipStatusHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean isCollapsed() {
|
private boolean isCollapsed() {
|
||||||
return (!logPanel.isVisible() &&
|
return (!logPanel.isVisible() && !historyPanel.isVisible() && !queuePanel.isVisible()
|
||||||
!historyPanel.isVisible() &&
|
|
||||||
!queuePanel.isVisible() &&
|
|
||||||
!configurationPanel.isVisible()
|
&& !configurationPanel.isVisible());
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createUI(Container pane) {
|
private void createUI(Container pane) {
|
||||||
//If creating the tray icon fails, ignore it.
|
// If creating the tray icon fails, ignore it.
|
||||||
try {
|
try {
|
||||||
setupTrayIcon();
|
setupTrayIcon();
|
||||||
} catch (Exception e) { }
|
} catch (Exception e) {
|
||||||
|
}
|
||||||
|
|
||||||
EmptyBorder emptyBorder = new EmptyBorder(5, 5, 5, 5);
|
EmptyBorder emptyBorder = new EmptyBorder(5, 5, 5, 5);
|
||||||
GridBagConstraints gbc = new GridBagConstraints();
|
GridBagConstraints gbc = new GridBagConstraints();
|
||||||
gbc.fill = GridBagConstraints.HORIZONTAL;
|
gbc.fill = GridBagConstraints.HORIZONTAL;
|
||||||
gbc.weightx = 1; gbc.ipadx = 2; gbc.gridx = 0;
|
gbc.weightx = 1;
|
||||||
gbc.weighty = 0; gbc.ipady = 2; gbc.gridy = 0;
|
gbc.ipadx = 2;
|
||||||
|
gbc.gridx = 0;
|
||||||
|
gbc.weighty = 0;
|
||||||
|
gbc.ipady = 2;
|
||||||
|
gbc.gridy = 0;
|
||||||
gbc.anchor = GridBagConstraints.PAGE_START;
|
gbc.anchor = GridBagConstraints.PAGE_START;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
|
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
|
||||||
} catch (ClassNotFoundException | InstantiationException | UnsupportedLookAndFeelException | IllegalAccessException e) {
|
} catch (ClassNotFoundException | InstantiationException | UnsupportedLookAndFeelException
|
||||||
|
| IllegalAccessException e) {
|
||||||
LOGGER.error("[!] Exception setting system theme:", e);
|
LOGGER.error("[!] Exception setting system theme:", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -311,31 +324,38 @@ public final class MainWindow implements Runnable, RipStatusHandler {
|
|||||||
try {
|
try {
|
||||||
Image stopIcon = ImageIO.read(getClass().getClassLoader().getResource("stop.png"));
|
Image stopIcon = ImageIO.read(getClass().getClassLoader().getResource("stop.png"));
|
||||||
stopButton.setIcon(new ImageIcon(stopIcon));
|
stopButton.setIcon(new ImageIcon(stopIcon));
|
||||||
} catch (Exception ignored) { }
|
} catch (Exception ignored) {
|
||||||
|
}
|
||||||
JPanel ripPanel = new JPanel(new GridBagLayout());
|
JPanel ripPanel = new JPanel(new GridBagLayout());
|
||||||
ripPanel.setBorder(emptyBorder);
|
ripPanel.setBorder(emptyBorder);
|
||||||
|
|
||||||
gbc.fill = GridBagConstraints.BOTH;
|
gbc.fill = GridBagConstraints.BOTH;
|
||||||
gbc.weightx = 0;
|
gbc.weightx = 0;
|
||||||
gbc.gridx = 0; ripPanel.add(new JLabel("URL:", JLabel.RIGHT), gbc);
|
gbc.gridx = 0;
|
||||||
|
ripPanel.add(new JLabel("URL:", JLabel.RIGHT), gbc);
|
||||||
gbc.weightx = 1;
|
gbc.weightx = 1;
|
||||||
gbc.weighty = 1;
|
gbc.weighty = 1;
|
||||||
gbc.gridx = 1; ripPanel.add(ripTextfield, gbc);
|
gbc.gridx = 1;
|
||||||
|
ripPanel.add(ripTextfield, gbc);
|
||||||
gbc.weighty = 0;
|
gbc.weighty = 0;
|
||||||
gbc.weightx = 0;
|
gbc.weightx = 0;
|
||||||
gbc.gridx = 2; ripPanel.add(ripButton, gbc);
|
gbc.gridx = 2;
|
||||||
gbc.gridx = 3; ripPanel.add(stopButton, gbc);
|
ripPanel.add(ripButton, gbc);
|
||||||
|
gbc.gridx = 3;
|
||||||
|
ripPanel.add(stopButton, gbc);
|
||||||
gbc.weightx = 1;
|
gbc.weightx = 1;
|
||||||
|
|
||||||
statusLabel = new JLabel(rb.getString("inactive"));
|
statusLabel = new JLabel(Utils.getLocalizedString("inactive"));
|
||||||
statusLabel.setHorizontalAlignment(JLabel.CENTER);
|
statusLabel.setHorizontalAlignment(JLabel.CENTER);
|
||||||
openButton = new JButton();
|
openButton = new JButton();
|
||||||
openButton.setVisible(false);
|
openButton.setVisible(false);
|
||||||
JPanel statusPanel = new JPanel(new GridBagLayout());
|
JPanel statusPanel = new JPanel(new GridBagLayout());
|
||||||
statusPanel.setBorder(emptyBorder);
|
statusPanel.setBorder(emptyBorder);
|
||||||
|
|
||||||
gbc.gridx = 0; statusPanel.add(statusLabel, gbc);
|
gbc.gridx = 0;
|
||||||
gbc.gridy = 1; statusPanel.add(openButton, gbc);
|
statusPanel.add(statusLabel, gbc);
|
||||||
|
gbc.gridy = 1;
|
||||||
|
statusPanel.add(openButton, gbc);
|
||||||
gbc.gridy = 0;
|
gbc.gridy = 0;
|
||||||
|
|
||||||
JPanel progressPanel = new JPanel(new GridBagLayout());
|
JPanel progressPanel = new JPanel(new GridBagLayout());
|
||||||
@@ -345,10 +365,10 @@ public final class MainWindow implements Runnable, RipStatusHandler {
|
|||||||
|
|
||||||
JPanel optionsPanel = new JPanel(new GridBagLayout());
|
JPanel optionsPanel = new JPanel(new GridBagLayout());
|
||||||
optionsPanel.setBorder(emptyBorder);
|
optionsPanel.setBorder(emptyBorder);
|
||||||
optionLog = new JButton(rb.getString("Log"));
|
optionLog = new JButton(Utils.getLocalizedString("Log"));
|
||||||
optionHistory = new JButton(rb.getString("History"));
|
optionHistory = new JButton(Utils.getLocalizedString("History"));
|
||||||
optionQueue = new JButton(rb.getString("Queue"));
|
optionQueue = new JButton(Utils.getLocalizedString("queue"));
|
||||||
optionConfiguration = new JButton(rb.getString("Configuration"));
|
optionConfiguration = new JButton(Utils.getLocalizedString("Configuration"));
|
||||||
optionLog.setFont(optionLog.getFont().deriveFont(Font.PLAIN));
|
optionLog.setFont(optionLog.getFont().deriveFont(Font.PLAIN));
|
||||||
optionHistory.setFont(optionLog.getFont().deriveFont(Font.PLAIN));
|
optionHistory.setFont(optionLog.getFont().deriveFont(Font.PLAIN));
|
||||||
optionQueue.setFont(optionLog.getFont().deriveFont(Font.PLAIN));
|
optionQueue.setFont(optionLog.getFont().deriveFont(Font.PLAIN));
|
||||||
@@ -363,11 +383,16 @@ public final class MainWindow implements Runnable, RipStatusHandler {
|
|||||||
optionQueue.setIcon(new ImageIcon(icon));
|
optionQueue.setIcon(new ImageIcon(icon));
|
||||||
icon = ImageIO.read(getClass().getClassLoader().getResource("gear.png"));
|
icon = ImageIO.read(getClass().getClassLoader().getResource("gear.png"));
|
||||||
optionConfiguration.setIcon(new ImageIcon(icon));
|
optionConfiguration.setIcon(new ImageIcon(icon));
|
||||||
} catch (Exception e) { }
|
} catch (Exception e) {
|
||||||
gbc.gridx = 0; optionsPanel.add(optionLog, gbc);
|
}
|
||||||
gbc.gridx = 1; optionsPanel.add(optionHistory, gbc);
|
gbc.gridx = 0;
|
||||||
gbc.gridx = 2; optionsPanel.add(optionQueue, gbc);
|
optionsPanel.add(optionLog, gbc);
|
||||||
gbc.gridx = 3; optionsPanel.add(optionConfiguration, gbc);
|
gbc.gridx = 1;
|
||||||
|
optionsPanel.add(optionHistory, gbc);
|
||||||
|
gbc.gridx = 2;
|
||||||
|
optionsPanel.add(optionQueue, gbc);
|
||||||
|
gbc.gridx = 3;
|
||||||
|
optionsPanel.add(optionConfiguration, gbc);
|
||||||
|
|
||||||
logPanel = new JPanel(new GridBagLayout());
|
logPanel = new JPanel(new GridBagLayout());
|
||||||
logPanel.setBorder(emptyBorder);
|
logPanel.setBorder(emptyBorder);
|
||||||
@@ -389,30 +414,37 @@ public final class MainWindow implements Runnable, RipStatusHandler {
|
|||||||
historyPanel.setPreferredSize(new Dimension(300, 250));
|
historyPanel.setPreferredSize(new Dimension(300, 250));
|
||||||
historyTableModel = new AbstractTableModel() {
|
historyTableModel = new AbstractTableModel() {
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getColumnName(int col) {
|
public String getColumnName(int col) {
|
||||||
return HISTORY.getColumnName(col);
|
return HISTORY.getColumnName(col);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Class<?> getColumnClass(int c) {
|
public Class<?> getColumnClass(int c) {
|
||||||
return getValueAt(0, c).getClass();
|
return getValueAt(0, c).getClass();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getValueAt(int row, int col) {
|
public Object getValueAt(int row, int col) {
|
||||||
return HISTORY.getValueAt(row, col);
|
return HISTORY.getValueAt(row, col);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getRowCount() {
|
public int getRowCount() {
|
||||||
return HISTORY.toList().size();
|
return HISTORY.toList().size();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getColumnCount() {
|
public int getColumnCount() {
|
||||||
return HISTORY.getColumnCount();
|
return HISTORY.getColumnCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isCellEditable(int row, int col) {
|
public boolean isCellEditable(int row, int col) {
|
||||||
return (col == 0 || col == 4);
|
return (col == 0 || col == 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setValueAt(Object value, int row, int col) {
|
public void setValueAt(Object value, int row, int col) {
|
||||||
if (col == 4) {
|
if (col == 4) {
|
||||||
@@ -440,9 +472,9 @@ public final class MainWindow implements Runnable, RipStatusHandler {
|
|||||||
historyTable.getColumnModel().getColumn(i).setPreferredWidth(width);
|
historyTable.getColumnModel().getColumn(i).setPreferredWidth(width);
|
||||||
}
|
}
|
||||||
JScrollPane historyTableScrollPane = new JScrollPane(historyTable);
|
JScrollPane historyTableScrollPane = new JScrollPane(historyTable);
|
||||||
historyButtonRemove = new JButton(rb.getString("remove"));
|
historyButtonRemove = new JButton(Utils.getLocalizedString("remove"));
|
||||||
historyButtonClear = new JButton(rb.getString("clear"));
|
historyButtonClear = new JButton(Utils.getLocalizedString("clear"));
|
||||||
historyButtonRerip = new JButton(rb.getString("re-rip.checked"));
|
historyButtonRerip = new JButton(Utils.getLocalizedString("re-rip.checked"));
|
||||||
gbc.gridx = 0;
|
gbc.gridx = 0;
|
||||||
// History List Panel
|
// History List Panel
|
||||||
JPanel historyTablePanel = new JPanel(new GridBagLayout());
|
JPanel historyTablePanel = new JPanel(new GridBagLayout());
|
||||||
@@ -456,10 +488,14 @@ public final class MainWindow implements Runnable, RipStatusHandler {
|
|||||||
JPanel historyButtonPanel = new JPanel(new GridBagLayout());
|
JPanel historyButtonPanel = new JPanel(new GridBagLayout());
|
||||||
historyButtonPanel.setPreferredSize(new Dimension(300, 10));
|
historyButtonPanel.setPreferredSize(new Dimension(300, 10));
|
||||||
historyButtonPanel.setBorder(emptyBorder);
|
historyButtonPanel.setBorder(emptyBorder);
|
||||||
gbc.gridx = 0; historyButtonPanel.add(historyButtonRemove, gbc);
|
gbc.gridx = 0;
|
||||||
gbc.gridx = 1; historyButtonPanel.add(historyButtonClear, gbc);
|
historyButtonPanel.add(historyButtonRemove, gbc);
|
||||||
gbc.gridx = 2; historyButtonPanel.add(historyButtonRerip, gbc);
|
gbc.gridx = 1;
|
||||||
gbc.gridy = 1; gbc.gridx = 0;
|
historyButtonPanel.add(historyButtonClear, gbc);
|
||||||
|
gbc.gridx = 2;
|
||||||
|
historyButtonPanel.add(historyButtonRerip, gbc);
|
||||||
|
gbc.gridy = 1;
|
||||||
|
gbc.gridx = 0;
|
||||||
gbc.weighty = 0;
|
gbc.weighty = 0;
|
||||||
gbc.fill = GridBagConstraints.HORIZONTAL;
|
gbc.fill = GridBagConstraints.HORIZONTAL;
|
||||||
historyPanel.add(historyButtonPanel, gbc);
|
historyPanel.add(historyButtonPanel, gbc);
|
||||||
@@ -471,14 +507,16 @@ 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(new QueueMenuMouseListener());
|
queueList.addMouseListener(
|
||||||
JScrollPane queueListScroll = new JScrollPane(queueList,
|
queueMenuMouseListener = new QueueMenuMouseListener(d -> updateQueue(queueListModel)));
|
||||||
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);
|
||||||
}
|
}
|
||||||
updateQueueLabel();
|
updateQueue();
|
||||||
|
|
||||||
gbc.gridx = 0;
|
gbc.gridx = 0;
|
||||||
JPanel queueListPanel = new JPanel(new GridBagLayout());
|
JPanel queueListPanel = new JPanel(new GridBagLayout());
|
||||||
gbc.fill = GridBagConstraints.BOTH;
|
gbc.fill = GridBagConstraints.BOTH;
|
||||||
@@ -493,32 +531,42 @@ public final class MainWindow implements Runnable, RipStatusHandler {
|
|||||||
configurationPanel.setBorder(emptyBorder);
|
configurationPanel.setBorder(emptyBorder);
|
||||||
configurationPanel.setVisible(false);
|
configurationPanel.setVisible(false);
|
||||||
// TODO Configuration components
|
// TODO Configuration components
|
||||||
configUpdateButton = new JButton(rb.getString("check.for.updates"));
|
configUpdateButton = new JButton(Utils.getLocalizedString("check.for.updates"));
|
||||||
configUpdateLabel = new JLabel( rb.getString("current.version") + ": " + UpdateUtils.getThisJarVersion(), JLabel.RIGHT);
|
configUpdateLabel = new JLabel(
|
||||||
configThreadsLabel = new JLabel(rb.getString("max.download.threads") + ":", JLabel.RIGHT);
|
Utils.getLocalizedString("current.version") + ": " + UpdateUtils.getThisJarVersion(), JLabel.RIGHT);
|
||||||
configTimeoutLabel = new JLabel(rb.getString("timeout.mill"), JLabel.RIGHT);
|
configThreadsLabel = new JLabel(Utils.getLocalizedString("max.download.threads") + ":", JLabel.RIGHT);
|
||||||
configRetriesLabel = new JLabel(rb.getString("retry.download.count"), JLabel.RIGHT);
|
configTimeoutLabel = new JLabel(Utils.getLocalizedString("timeout.mill"), JLabel.RIGHT);
|
||||||
|
configRetriesLabel = new JLabel(Utils.getLocalizedString("retry.download.count"), JLabel.RIGHT);
|
||||||
configThreadsText = new JTextField(Integer.toString(Utils.getConfigInteger("threads.size", 3)));
|
configThreadsText = new JTextField(Integer.toString(Utils.getConfigInteger("threads.size", 3)));
|
||||||
configTimeoutText = new JTextField(Integer.toString(Utils.getConfigInteger("download.timeout", 60000)));
|
configTimeoutText = new JTextField(Integer.toString(Utils.getConfigInteger("download.timeout", 60000)));
|
||||||
configRetriesText = new JTextField(Integer.toString(Utils.getConfigInteger("download.retries", 3)));
|
configRetriesText = new JTextField(Integer.toString(Utils.getConfigInteger("download.retries", 3)));
|
||||||
configOverwriteCheckbox = addNewCheckbox(rb.getString("overwrite.existing.files"), "file.overwrite", false);
|
configOverwriteCheckbox = addNewCheckbox(Utils.getLocalizedString("overwrite.existing.files"), "file.overwrite",
|
||||||
configAutoupdateCheckbox = addNewCheckbox(rb.getString("auto.update"), "auto.update", true);
|
false);
|
||||||
configPlaySound = addNewCheckbox(rb.getString("sound.when.rip.completes"), "play.sound", false);
|
configAutoupdateCheckbox = addNewCheckbox(Utils.getLocalizedString("auto.update"), "auto.update", true);
|
||||||
configShowPopup = addNewCheckbox(rb.getString("notification.when.rip.starts"), "download.show_popup", false);
|
configPlaySound = addNewCheckbox(Utils.getLocalizedString("sound.when.rip.completes"), "play.sound", false);
|
||||||
configSaveOrderCheckbox = addNewCheckbox(rb.getString("preserve.order"), "download.save_order", true);
|
configShowPopup = addNewCheckbox(Utils.getLocalizedString("notification.when.rip.starts"),
|
||||||
configSaveLogs = addNewCheckbox(rb.getString("save.logs"), "log.save", false);
|
"download.show_popup", false);
|
||||||
configSaveURLsOnly = addNewCheckbox(rb.getString("save.urls.only"), "urls_only.save", false);
|
configSaveOrderCheckbox = addNewCheckbox(Utils.getLocalizedString("preserve.order"), "download.save_order",
|
||||||
configSaveAlbumTitles = addNewCheckbox(rb.getString("save.album.titles"), "album_titles.save", true);
|
true);
|
||||||
configClipboardAutorip = addNewCheckbox(rb.getString("autorip.from.clipboard"), "clipboard.autorip", false);
|
configSaveLogs = addNewCheckbox(Utils.getLocalizedString("save.logs"), "log.save", false);
|
||||||
configSaveDescriptions = addNewCheckbox(rb.getString("save.descriptions"), "descriptions.save", true);
|
configSaveURLsOnly = addNewCheckbox(Utils.getLocalizedString("save.urls.only"), "urls_only.save", false);
|
||||||
configPreferMp4 = addNewCheckbox(rb.getString("prefer.mp4.over.gif"),"prefer.mp4", false);
|
configSaveAlbumTitles = addNewCheckbox(Utils.getLocalizedString("save.album.titles"), "album_titles.save",
|
||||||
configWindowPosition = addNewCheckbox(rb.getString("restore.window.position"), "window.position", true);
|
true);
|
||||||
configURLHistoryCheckbox = addNewCheckbox(rb.getString("remember.url.history"), "remember.url_history", true);
|
configClipboardAutorip = addNewCheckbox(Utils.getLocalizedString("autorip.from.clipboard"), "clipboard.autorip",
|
||||||
configUrlFileChooserButton = new JButton(rb.getString("download.url.list"));
|
false);
|
||||||
|
configSaveDescriptions = addNewCheckbox(Utils.getLocalizedString("save.descriptions"), "descriptions.save",
|
||||||
|
true);
|
||||||
|
configPreferMp4 = addNewCheckbox(Utils.getLocalizedString("prefer.mp4.over.gif"), "prefer.mp4", false);
|
||||||
|
configWindowPosition = addNewCheckbox(Utils.getLocalizedString("restore.window.position"), "window.position",
|
||||||
|
true);
|
||||||
|
configURLHistoryCheckbox = addNewCheckbox(Utils.getLocalizedString("remember.url.history"),
|
||||||
|
"remember.url_history", true);
|
||||||
|
configUrlFileChooserButton = new JButton(Utils.getLocalizedString("download.url.list"));
|
||||||
|
|
||||||
configLogLevelCombobox = new JComboBox<>(new String[] {"Log level: Error", "Log level: Warn", "Log level: Info", "Log level: Debug"});
|
configLogLevelCombobox = new JComboBox<>(
|
||||||
configSelectLangComboBox = new JComboBox<>(supportedLanges);
|
new String[] { "Log level: Error", "Log level: Warn", "Log level: Info", "Log level: Debug" });
|
||||||
configSelectLangComboBox.setSelectedItem(rb.getLocale().toString());
|
configSelectLangComboBox = new JComboBox<>(Utils.getSupportedLanguages());
|
||||||
|
configSelectLangComboBox.setSelectedItem(Utils.getSelectedLanguage());
|
||||||
configLogLevelCombobox.setSelectedItem(Utils.getConfigString("log.level", "Log level: Debug"));
|
configLogLevelCombobox.setSelectedItem(Utils.getConfigString("log.level", "Log level: Debug"));
|
||||||
setLogLevel(configLogLevelCombobox.getSelectedItem().toString());
|
setLogLevel(configLogLevelCombobox.getSelectedItem().toString());
|
||||||
configSaveDirLabel = new JLabel();
|
configSaveDirLabel = new JLabel();
|
||||||
@@ -527,10 +575,11 @@ public final class MainWindow implements Runnable, RipStatusHandler {
|
|||||||
configSaveDirLabel.setText(workingDir);
|
configSaveDirLabel.setText(workingDir);
|
||||||
configSaveDirLabel.setForeground(Color.BLUE);
|
configSaveDirLabel.setForeground(Color.BLUE);
|
||||||
configSaveDirLabel.setCursor(new Cursor(Cursor.HAND_CURSOR));
|
configSaveDirLabel.setCursor(new Cursor(Cursor.HAND_CURSOR));
|
||||||
} catch (Exception e) { }
|
} catch (Exception e) {
|
||||||
|
}
|
||||||
configSaveDirLabel.setToolTipText(configSaveDirLabel.getText());
|
configSaveDirLabel.setToolTipText(configSaveDirLabel.getText());
|
||||||
configSaveDirLabel.setHorizontalAlignment(JLabel.RIGHT);
|
configSaveDirLabel.setHorizontalAlignment(JLabel.RIGHT);
|
||||||
configSaveDirButton = new JButton(rb.getString("select.save.dir") + "...");
|
configSaveDirButton = new JButton(Utils.getLocalizedString("select.save.dir") + "...");
|
||||||
|
|
||||||
addItemToConfigGridBagConstraints(gbc, 0, configUpdateLabel, configUpdateButton);
|
addItemToConfigGridBagConstraints(gbc, 0, configUpdateLabel, configUpdateButton);
|
||||||
addItemToConfigGridBagConstraints(gbc, 1, configAutoupdateCheckbox, configLogLevelCombobox);
|
addItemToConfigGridBagConstraints(gbc, 1, configAutoupdateCheckbox, configLogLevelCombobox);
|
||||||
@@ -554,76 +603,107 @@ public final class MainWindow implements Runnable, RipStatusHandler {
|
|||||||
emptyPanel.setSize(0, 0);
|
emptyPanel.setSize(0, 0);
|
||||||
|
|
||||||
gbc.anchor = GridBagConstraints.PAGE_START;
|
gbc.anchor = GridBagConstraints.PAGE_START;
|
||||||
gbc.gridy = 0; pane.add(ripPanel, gbc);
|
gbc.gridy = 0;
|
||||||
gbc.gridy = 1; pane.add(statusPanel, gbc);
|
pane.add(ripPanel, gbc);
|
||||||
gbc.gridy = 2; pane.add(progressPanel, gbc);
|
gbc.gridy = 1;
|
||||||
gbc.gridy = 3; pane.add(optionsPanel, gbc);
|
pane.add(statusPanel, gbc);
|
||||||
|
gbc.gridy = 2;
|
||||||
|
pane.add(progressPanel, gbc);
|
||||||
|
gbc.gridy = 3;
|
||||||
|
pane.add(optionsPanel, gbc);
|
||||||
gbc.weighty = 1;
|
gbc.weighty = 1;
|
||||||
gbc.fill = GridBagConstraints.BOTH;
|
gbc.fill = GridBagConstraints.BOTH;
|
||||||
gbc.gridy = 4; pane.add(logPanel, gbc);
|
gbc.gridy = 4;
|
||||||
gbc.gridy = 5; pane.add(historyPanel, gbc);
|
pane.add(logPanel, gbc);
|
||||||
gbc.gridy = 5; pane.add(queuePanel, gbc);
|
gbc.gridy = 5;
|
||||||
gbc.gridy = 5; pane.add(configurationPanel, gbc);
|
pane.add(historyPanel, gbc);
|
||||||
gbc.gridy = 5; pane.add(emptyPanel, gbc);
|
gbc.gridy = 5;
|
||||||
|
pane.add(queuePanel, gbc);
|
||||||
|
gbc.gridy = 5;
|
||||||
|
pane.add(configurationPanel, gbc);
|
||||||
|
gbc.gridy = 5;
|
||||||
|
pane.add(emptyPanel, gbc);
|
||||||
gbc.weighty = 0;
|
gbc.weighty = 0;
|
||||||
gbc.fill = GridBagConstraints.HORIZONTAL;
|
gbc.fill = GridBagConstraints.HORIZONTAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addItemToConfigGridBagConstraints(GridBagConstraints gbc, int gbcYValue, JLabel thing1ToAdd, JButton thing2ToAdd ) {
|
private void addItemToConfigGridBagConstraints(GridBagConstraints gbc, int gbcYValue, JLabel thing1ToAdd,
|
||||||
gbc.gridy = gbcYValue; gbc.gridx = 0; configurationPanel.add(thing1ToAdd, gbc);
|
JButton thing2ToAdd) {
|
||||||
gbc.gridx = 1; configurationPanel.add(thing2ToAdd, gbc);
|
gbc.gridy = gbcYValue;
|
||||||
|
gbc.gridx = 0;
|
||||||
|
configurationPanel.add(thing1ToAdd, gbc);
|
||||||
|
gbc.gridx = 1;
|
||||||
|
configurationPanel.add(thing2ToAdd, gbc);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addItemToConfigGridBagConstraints(GridBagConstraints gbc, int gbcYValue, JLabel thing1ToAdd, JTextField thing2ToAdd ) {
|
private void addItemToConfigGridBagConstraints(GridBagConstraints gbc, int gbcYValue, JLabel thing1ToAdd,
|
||||||
gbc.gridy = gbcYValue; gbc.gridx = 0; configurationPanel.add(thing1ToAdd, gbc);
|
JTextField thing2ToAdd) {
|
||||||
gbc.gridx = 1; configurationPanel.add(thing2ToAdd, gbc);
|
gbc.gridy = gbcYValue;
|
||||||
|
gbc.gridx = 0;
|
||||||
|
configurationPanel.add(thing1ToAdd, gbc);
|
||||||
|
gbc.gridx = 1;
|
||||||
|
configurationPanel.add(thing2ToAdd, gbc);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addItemToConfigGridBagConstraints(GridBagConstraints gbc, int gbcYValue, JCheckBox thing1ToAdd, JCheckBox thing2ToAdd ) {
|
private void addItemToConfigGridBagConstraints(GridBagConstraints gbc, int gbcYValue, JCheckBox thing1ToAdd,
|
||||||
gbc.gridy = gbcYValue; gbc.gridx = 0; configurationPanel.add(thing1ToAdd, gbc);
|
JCheckBox thing2ToAdd) {
|
||||||
gbc.gridx = 1; configurationPanel.add(thing2ToAdd, gbc);
|
gbc.gridy = gbcYValue;
|
||||||
|
gbc.gridx = 0;
|
||||||
|
configurationPanel.add(thing1ToAdd, gbc);
|
||||||
|
gbc.gridx = 1;
|
||||||
|
configurationPanel.add(thing2ToAdd, gbc);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addItemToConfigGridBagConstraints(GridBagConstraints gbc, int gbcYValue, JCheckBox thing1ToAdd, JComboBox thing2ToAdd ) {
|
private void addItemToConfigGridBagConstraints(GridBagConstraints gbc, int gbcYValue, JCheckBox thing1ToAdd,
|
||||||
gbc.gridy = gbcYValue; gbc.gridx = 0; configurationPanel.add(thing1ToAdd, gbc);
|
JComboBox thing2ToAdd) {
|
||||||
gbc.gridx = 1; configurationPanel.add(thing2ToAdd, gbc);
|
gbc.gridy = gbcYValue;
|
||||||
|
gbc.gridx = 0;
|
||||||
|
configurationPanel.add(thing1ToAdd, gbc);
|
||||||
|
gbc.gridx = 1;
|
||||||
|
configurationPanel.add(thing2ToAdd, gbc);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addItemToConfigGridBagConstraints(GridBagConstraints gbc, int gbcYValue, JComboBox thing1ToAdd, JButton thing2ToAdd ) {
|
private void addItemToConfigGridBagConstraints(GridBagConstraints gbc, int gbcYValue, JComboBox thing1ToAdd,
|
||||||
gbc.gridy = gbcYValue; gbc.gridx = 0; configurationPanel.add(thing1ToAdd, gbc);
|
JButton thing2ToAdd) {
|
||||||
gbc.gridx = 1; configurationPanel.add(thing2ToAdd, gbc);
|
gbc.gridy = gbcYValue;
|
||||||
|
gbc.gridx = 0;
|
||||||
|
configurationPanel.add(thing1ToAdd, gbc);
|
||||||
|
gbc.gridx = 1;
|
||||||
|
configurationPanel.add(thing2ToAdd, gbc);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addItemToConfigGridBagConstraints(GridBagConstraints gbc, int gbcYValue, JComboBox thing1ToAdd ) {
|
private void addItemToConfigGridBagConstraints(GridBagConstraints gbc, int gbcYValue, JComboBox thing1ToAdd) {
|
||||||
gbc.gridy = gbcYValue; gbc.gridx = 0; configurationPanel.add(thing1ToAdd, gbc);
|
gbc.gridy = gbcYValue;
|
||||||
|
gbc.gridx = 0;
|
||||||
|
configurationPanel.add(thing1ToAdd, gbc);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void changeLocale() {
|
private void changeLocale() {
|
||||||
statusLabel.setText(rb.getString("inactive"));
|
statusLabel.setText(Utils.getLocalizedString("inactive"));
|
||||||
configUpdateButton.setText(rb.getString("check.for.updates"));
|
configUpdateButton.setText(Utils.getLocalizedString("check.for.updates"));
|
||||||
configUpdateLabel.setText(rb.getString("current.version") + ": " + UpdateUtils.getThisJarVersion());
|
configUpdateLabel.setText(Utils.getLocalizedString("current.version") + ": " + UpdateUtils.getThisJarVersion());
|
||||||
configThreadsLabel.setText(rb.getString("max.download.threads"));
|
configThreadsLabel.setText(Utils.getLocalizedString("max.download.threads"));
|
||||||
configTimeoutLabel.setText(rb.getString("timeout.mill"));
|
configTimeoutLabel.setText(Utils.getLocalizedString("timeout.mill"));
|
||||||
configRetriesLabel.setText(rb.getString("retry.download.count"));
|
configRetriesLabel.setText(Utils.getLocalizedString("retry.download.count"));
|
||||||
configOverwriteCheckbox.setText(rb.getString("overwrite.existing.files"));
|
configOverwriteCheckbox.setText(Utils.getLocalizedString("overwrite.existing.files"));
|
||||||
configAutoupdateCheckbox.setText(rb.getString("auto.update"));
|
configAutoupdateCheckbox.setText(Utils.getLocalizedString("auto.update"));
|
||||||
configPlaySound.setText(rb.getString("sound.when.rip.completes"));
|
configPlaySound.setText(Utils.getLocalizedString("sound.when.rip.completes"));
|
||||||
configShowPopup.setText(rb.getString("notification.when.rip.starts"));
|
configShowPopup.setText(Utils.getLocalizedString("notification.when.rip.starts"));
|
||||||
configSaveOrderCheckbox.setText(rb.getString("preserve.order"));
|
configSaveOrderCheckbox.setText(Utils.getLocalizedString("preserve.order"));
|
||||||
configSaveLogs.setText(rb.getString("save.logs"));
|
configSaveLogs.setText(Utils.getLocalizedString("save.logs"));
|
||||||
configSaveURLsOnly.setText(rb.getString("save.urls.only"));
|
configSaveURLsOnly.setText(Utils.getLocalizedString("save.urls.only"));
|
||||||
configSaveAlbumTitles.setText(rb.getString("save.album.titles"));
|
configSaveAlbumTitles.setText(Utils.getLocalizedString("save.album.titles"));
|
||||||
configClipboardAutorip.setText(rb.getString("autorip.from.clipboard"));
|
configClipboardAutorip.setText(Utils.getLocalizedString("autorip.from.clipboard"));
|
||||||
configSaveDescriptions.setText(rb.getString("save.descriptions"));
|
configSaveDescriptions.setText(Utils.getLocalizedString("save.descriptions"));
|
||||||
configUrlFileChooserButton.setText(rb.getString("download.url.list"));
|
configUrlFileChooserButton.setText(Utils.getLocalizedString("download.url.list"));
|
||||||
configSaveDirButton.setText(rb.getString("select.save.dir") + "...");
|
configSaveDirButton.setText(Utils.getLocalizedString("select.save.dir") + "...");
|
||||||
configPreferMp4.setText(rb.getString("prefer.mp4.over.gif"));
|
configPreferMp4.setText(Utils.getLocalizedString("prefer.mp4.over.gif"));
|
||||||
configWindowPosition.setText(rb.getString("restore.window.position"));
|
configWindowPosition.setText(Utils.getLocalizedString("restore.window.position"));
|
||||||
configURLHistoryCheckbox.setText(rb.getString("remember.url.history"));
|
configURLHistoryCheckbox.setText(Utils.getLocalizedString("remember.url.history"));
|
||||||
optionLog.setText(rb.getString("Log"));
|
optionLog.setText(Utils.getLocalizedString("Log"));
|
||||||
optionHistory.setText(rb.getString("History"));
|
optionHistory.setText(Utils.getLocalizedString("History"));
|
||||||
optionQueue.setText(rb.getString("Queue"));
|
optionQueue.setText(Utils.getLocalizedString("queue"));
|
||||||
optionConfiguration.setText(rb.getString("Configuration"));
|
optionConfiguration.setText(Utils.getLocalizedString("Configuration"));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setupHandlers() {
|
private void setupHandlers() {
|
||||||
@@ -634,14 +714,17 @@ public final class MainWindow implements Runnable, RipStatusHandler {
|
|||||||
public void removeUpdate(DocumentEvent e) {
|
public void removeUpdate(DocumentEvent e) {
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void insertUpdate(DocumentEvent e) {
|
public void insertUpdate(DocumentEvent e) {
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void changedUpdate(DocumentEvent e) {
|
public void changedUpdate(DocumentEvent e) {
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void update() {
|
private void update() {
|
||||||
try {
|
try {
|
||||||
String urlText = ripTextfield.getText().trim();
|
String urlText = ripTextfield.getText().trim();
|
||||||
@@ -668,7 +751,7 @@ public final class MainWindow implements Runnable, RipStatusHandler {
|
|||||||
statusProgress.setVisible(false);
|
statusProgress.setVisible(false);
|
||||||
pack();
|
pack();
|
||||||
statusProgress.setValue(0);
|
statusProgress.setValue(0);
|
||||||
status("Ripping interrupted");
|
status(Utils.getLocalizedString("ripping.interrupted"));
|
||||||
appendLog("Ripper interrupted", Color.RED);
|
appendLog("Ripper interrupted", Color.RED);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -744,7 +827,8 @@ public final class MainWindow implements Runnable, RipStatusHandler {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
historyTableModel.fireTableDataChanged();
|
historyTableModel.fireTableDataChanged();
|
||||||
} catch (Exception e) { }
|
} catch (Exception e) {
|
||||||
|
}
|
||||||
saveHistory();
|
saveHistory();
|
||||||
});
|
});
|
||||||
historyButtonClear.addActionListener(event -> {
|
historyButtonClear.addActionListener(event -> {
|
||||||
@@ -778,8 +862,8 @@ public final class MainWindow implements Runnable, RipStatusHandler {
|
|||||||
}
|
}
|
||||||
saveHistory();
|
saveHistory();
|
||||||
});
|
});
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
Utils.clearURLHistory();
|
Utils.clearURLHistory();
|
||||||
HISTORY.clear();
|
HISTORY.clear();
|
||||||
try {
|
try {
|
||||||
@@ -793,9 +877,9 @@ public final class MainWindow implements Runnable, RipStatusHandler {
|
|||||||
// Re-rip all history
|
// Re-rip all history
|
||||||
historyButtonRerip.addActionListener(event -> {
|
historyButtonRerip.addActionListener(event -> {
|
||||||
if (HISTORY.isEmpty()) {
|
if (HISTORY.isEmpty()) {
|
||||||
JOptionPane.showMessageDialog(null,
|
JOptionPane.showMessageDialog(null, Utils.getLocalizedString("history.load.none"), "RipMe Error",
|
||||||
"There are no history entries to re-rip. Rip some albums first",
|
|
||||||
"RipMe Error",
|
|
||||||
JOptionPane.ERROR_MESSAGE);
|
JOptionPane.ERROR_MESSAGE);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -807,11 +891,11 @@ public final class MainWindow implements Runnable, RipStatusHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (added == 0) {
|
if (added == 0) {
|
||||||
JOptionPane.showMessageDialog(null,
|
JOptionPane.showMessageDialog(null, Utils.getLocalizedString("history.load.none.checked"),
|
||||||
"No history entries have been 'Checked'\n" +
|
|
||||||
"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",
|
|
||||||
JOptionPane.ERROR_MESSAGE);
|
"RipMe Error", JOptionPane.ERROR_MESSAGE);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
configUpdateButton.addActionListener(arg0 -> {
|
configUpdateButton.addActionListener(arg0 -> {
|
||||||
@@ -824,7 +908,7 @@ public final class MainWindow implements Runnable, RipStatusHandler {
|
|||||||
});
|
});
|
||||||
configSelectLangComboBox.addActionListener(arg0 -> {
|
configSelectLangComboBox.addActionListener(arg0 -> {
|
||||||
String level = ((JComboBox) arg0.getSource()).getSelectedItem().toString();
|
String level = ((JComboBox) arg0.getSource()).getSelectedItem().toString();
|
||||||
rb = Utils.getResourceBundle(level);
|
Utils.setLanguage(level);
|
||||||
changeLocale();
|
changeLocale();
|
||||||
});
|
});
|
||||||
configSaveDirLabel.addMouseListener(new MouseAdapter() {
|
configSaveDirLabel.addMouseListener(new MouseAdapter() {
|
||||||
@@ -834,7 +918,8 @@ public final class MainWindow implements Runnable, RipStatusHandler {
|
|||||||
Desktop desktop = Desktop.getDesktop();
|
Desktop desktop = Desktop.getDesktop();
|
||||||
try {
|
try {
|
||||||
desktop.open(file);
|
desktop.open(file);
|
||||||
} catch (Exception e1) { }
|
} catch (Exception e1) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
configSaveDirButton.addActionListener(arg0 -> {
|
configSaveDirButton.addActionListener(arg0 -> {
|
||||||
@@ -883,7 +968,7 @@ public final class MainWindow implements Runnable, RipStatusHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} catch(IOException e) {
|
} catch (IOException e) {
|
||||||
LOGGER.error("Error reading file " + e.getMessage());
|
LOGGER.error("Error reading file " + e.getMessage());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -907,15 +992,20 @@ public final class MainWindow implements Runnable, RipStatusHandler {
|
|||||||
queueListModel.addListDataListener(new ListDataListener() {
|
queueListModel.addListDataListener(new ListDataListener() {
|
||||||
@Override
|
@Override
|
||||||
public void intervalAdded(ListDataEvent arg0) {
|
public void intervalAdded(ListDataEvent arg0) {
|
||||||
updateQueueLabel();
|
updateQueue();
|
||||||
|
|
||||||
if (!isRipping) {
|
if (!isRipping) {
|
||||||
ripNextAlbum();
|
ripNextAlbum();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void contentsChanged(ListDataEvent arg0) { }
|
public void contentsChanged(ListDataEvent arg0) {
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void intervalRemoved(ListDataEvent arg0) { }
|
public void intervalRemoved(ListDataEvent arg0) {
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -938,11 +1028,11 @@ public final class MainWindow implements Runnable, RipStatusHandler {
|
|||||||
}
|
}
|
||||||
Logger.getRootLogger().setLevel(newLevel);
|
Logger.getRootLogger().setLevel(newLevel);
|
||||||
LOGGER.setLevel(newLevel);
|
LOGGER.setLevel(newLevel);
|
||||||
ConsoleAppender ca = (ConsoleAppender)Logger.getRootLogger().getAppender("stdout");
|
ConsoleAppender ca = (ConsoleAppender) Logger.getRootLogger().getAppender("stdout");
|
||||||
if (ca != null) {
|
if (ca != null) {
|
||||||
ca.setThreshold(newLevel);
|
ca.setThreshold(newLevel);
|
||||||
}
|
}
|
||||||
FileAppender fa = (FileAppender)Logger.getRootLogger().getAppender("FILE");
|
FileAppender fa = (FileAppender) Logger.getRootLogger().getAppender("FILE");
|
||||||
if (fa != null) {
|
if (fa != null) {
|
||||||
fa.setThreshold(newLevel);
|
fa.setThreshold(newLevel);
|
||||||
}
|
}
|
||||||
@@ -951,23 +1041,34 @@ public final class MainWindow implements Runnable, RipStatusHandler {
|
|||||||
private void setupTrayIcon() {
|
private void setupTrayIcon() {
|
||||||
mainFrame.addWindowListener(new WindowAdapter() {
|
mainFrame.addWindowListener(new WindowAdapter() {
|
||||||
@Override
|
@Override
|
||||||
public void windowActivated(WindowEvent e) { trayMenuMain.setLabel("Hide"); }
|
public void windowActivated(WindowEvent e) {
|
||||||
|
trayMenuMain.setLabel(Utils.getLocalizedString("tray.hide"));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void windowDeactivated(WindowEvent e) { trayMenuMain.setLabel("Show"); }
|
public void windowDeactivated(WindowEvent e) {
|
||||||
|
trayMenuMain.setLabel(Utils.getLocalizedString("tray.show"));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void windowDeiconified(WindowEvent e) { trayMenuMain.setLabel("Hide"); }
|
public void windowDeiconified(WindowEvent e) {
|
||||||
|
trayMenuMain.setLabel(Utils.getLocalizedString("tray.hide"));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void windowIconified(WindowEvent e) { trayMenuMain.setLabel("Show"); }
|
public void windowIconified(WindowEvent e) {
|
||||||
|
trayMenuMain.setLabel(Utils.getLocalizedString("tray.show"));
|
||||||
|
}
|
||||||
});
|
});
|
||||||
PopupMenu trayMenu = new PopupMenu();
|
PopupMenu trayMenu = new PopupMenu();
|
||||||
trayMenuMain = new MenuItem("Hide");
|
trayMenuMain = new MenuItem(Utils.getLocalizedString("tray.hide"));
|
||||||
trayMenuMain.addActionListener(arg0 -> toggleTrayClick());
|
trayMenuMain.addActionListener(arg0 -> toggleTrayClick());
|
||||||
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())
|
about.append("<html><h1>").append(mainFrame.getTitle()).append("</h1>");
|
||||||
.append("</h1>");
|
|
||||||
about.append("Download albums from various websites:");
|
about.append("Download albums from various websites:");
|
||||||
try {
|
try {
|
||||||
List<String> rippers = Utils.getListOfAlbumRippers();
|
List<String> rippers = Utils.getListOfAlbumRippers();
|
||||||
@@ -982,7 +1083,8 @@ public final class MainWindow implements Runnable, RipStatusHandler {
|
|||||||
about.append("</li>");
|
about.append("</li>");
|
||||||
}
|
}
|
||||||
about.append("</ul>");
|
about.append("</ul>");
|
||||||
} catch (Exception e) { }
|
} catch (Exception e) {
|
||||||
|
}
|
||||||
about.append("<br>And download videos from video sites:");
|
about.append("<br>And download videos from video sites:");
|
||||||
try {
|
try {
|
||||||
List<String> rippers = Utils.getListOfVideoRippers();
|
List<String> rippers = Utils.getListOfVideoRippers();
|
||||||
@@ -997,16 +1099,17 @@ public final class MainWindow implements Runnable, RipStatusHandler {
|
|||||||
about.append("</li>");
|
about.append("</li>");
|
||||||
}
|
}
|
||||||
about.append("</ul>");
|
about.append("</ul>");
|
||||||
} catch (Exception e) { }
|
} catch (Exception e) {
|
||||||
|
}
|
||||||
|
|
||||||
about.append("Do you want to visit the project homepage on Github?");
|
about.append("Do you want to visit the project homepage on Github?");
|
||||||
about.append("</html>");
|
about.append("</html>");
|
||||||
int response = JOptionPane.showConfirmDialog(null,
|
int response = JOptionPane.showConfirmDialog(null, about.toString(), mainFrame.getTitle(),
|
||||||
about.toString(),
|
JOptionPane.YES_NO_OPTION, JOptionPane.PLAIN_MESSAGE, new ImageIcon(mainIcon));
|
||||||
mainFrame.getTitle(),
|
|
||||||
JOptionPane.YES_NO_OPTION,
|
|
||||||
JOptionPane.PLAIN_MESSAGE,
|
|
||||||
new ImageIcon(mainIcon));
|
|
||||||
if (response == JOptionPane.YES_OPTION) {
|
if (response == JOptionPane.YES_OPTION) {
|
||||||
try {
|
try {
|
||||||
Desktop.getDesktop().browse(URI.create("http://github.com/ripmeapp/ripme"));
|
Desktop.getDesktop().browse(URI.create("http://github.com/ripmeapp/ripme"));
|
||||||
@@ -1015,9 +1118,9 @@ public final class MainWindow implements Runnable, RipStatusHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
MenuItem trayMenuExit = new MenuItem("Exit");
|
MenuItem trayMenuExit = new MenuItem(Utils.getLocalizedString("tray.exit"));
|
||||||
trayMenuExit.addActionListener(arg0 -> System.exit(0));
|
trayMenuExit.addActionListener(arg0 -> System.exit(0));
|
||||||
trayMenuAutorip = new CheckboxMenuItem("Clipboard Autorip");
|
trayMenuAutorip = new CheckboxMenuItem(Utils.getLocalizedString("tray.autorip"));
|
||||||
trayMenuAutorip.addItemListener(arg0 -> {
|
trayMenuAutorip.addItemListener(arg0 -> {
|
||||||
ClipboardUtils.setClipboardAutoRip(trayMenuAutorip.getState());
|
ClipboardUtils.setClipboardAutoRip(trayMenuAutorip.getState());
|
||||||
configClipboardAutorip.setSelected(trayMenuAutorip.getState());
|
configClipboardAutorip.setSelected(trayMenuAutorip.getState());
|
||||||
@@ -1047,22 +1150,23 @@ public final class MainWindow implements Runnable, RipStatusHandler {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
} catch (IOException | AWTException e) {
|
} catch (IOException | AWTException e) {
|
||||||
//TODO implement proper stack trace handling this is really just intented as a placeholder until you implement proper error handling
|
// TODO implement proper stack trace handling this is really just intented as a
|
||||||
|
// placeholder until you implement proper error handling
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void toggleTrayClick() {
|
private void toggleTrayClick() {
|
||||||
if (mainFrame.getExtendedState() == JFrame.ICONIFIED
|
if (mainFrame.getExtendedState() == JFrame.ICONIFIED || !mainFrame.isActive() || !mainFrame.isVisible()) {
|
||||||
|| !mainFrame.isActive()
|
|
||||||
|| !mainFrame.isVisible()) {
|
|
||||||
mainFrame.setVisible(true);
|
mainFrame.setVisible(true);
|
||||||
mainFrame.setAlwaysOnTop(true);
|
mainFrame.setAlwaysOnTop(true);
|
||||||
mainFrame.setAlwaysOnTop(false);
|
mainFrame.setAlwaysOnTop(false);
|
||||||
trayMenuMain.setLabel("Hide");
|
trayMenuMain.setLabel(Utils.getLocalizedString("tray.hide"));
|
||||||
} else {
|
} else {
|
||||||
mainFrame.setVisible(false);
|
mainFrame.setVisible(false);
|
||||||
trayMenuMain.setLabel("Show");
|
trayMenuMain.setLabel(Utils.getLocalizedString("tray.show"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1080,7 +1184,8 @@ public final class MainWindow implements Runnable, RipStatusHandler {
|
|||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
sd.insertString(sd.getLength(), text + "\n", sas);
|
sd.insertString(sd.getLength(), text + "\n", sas);
|
||||||
}
|
}
|
||||||
} catch (BadLocationException e) { }
|
} catch (BadLocationException e) {
|
||||||
|
}
|
||||||
|
|
||||||
logText.setCaretPosition(sd.getLength());
|
logText.setCaretPosition(sd.getLength());
|
||||||
}
|
}
|
||||||
@@ -1101,25 +1206,26 @@ public final class MainWindow implements Runnable, RipStatusHandler {
|
|||||||
HISTORY.clear();
|
HISTORY.clear();
|
||||||
if (historyFile.exists()) {
|
if (historyFile.exists()) {
|
||||||
try {
|
try {
|
||||||
LOGGER.info(rb.getString("loading.history.from") + " " + historyFile.getCanonicalPath());
|
LOGGER.info(Utils.getLocalizedString("loading.history.from") + " " + historyFile.getCanonicalPath());
|
||||||
HISTORY.fromFile(historyFile.getCanonicalPath());
|
HISTORY.fromFile(historyFile.getCanonicalPath());
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
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,
|
||||||
"RipMe failed to load the history file at " + historyFile.getAbsolutePath() + "\n\n" +
|
String.format(Utils.getLocalizedString("history.load.failed.warning"), e.getMessage()),
|
||||||
"Error: " + e.getMessage() + "\n\n" +
|
|
||||||
"Closing RipMe will automatically overwrite the contents of this file,\n" +
|
|
||||||
"so you may want to back the file up before closing RipMe!",
|
|
||||||
"RipMe - history load failure",
|
|
||||||
JOptionPane.ERROR_MESSAGE);
|
"RipMe - history load failure", JOptionPane.ERROR_MESSAGE);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
LOGGER.info(rb.getString("loading.history.from.configuration"));
|
LOGGER.info(Utils.getLocalizedString("loading.history.from.configuration"));
|
||||||
HISTORY.fromList(Utils.getConfigList("download.history"));
|
HISTORY.fromList(Utils.getConfigList("download.history"));
|
||||||
if (HISTORY.toList().isEmpty()) {
|
if (HISTORY.toList().isEmpty()) {
|
||||||
// Loaded from config, still no entries.
|
// Loaded from config, still no entries.
|
||||||
// Guess rip history based on rip folder
|
// Guess rip history based on rip folder
|
||||||
String[] dirs = Utils.getWorkingDirectory().list((dir, file) -> new File(dir.getAbsolutePath() + File.separator + file).isDirectory());
|
String[] dirs = Utils.getWorkingDirectory()
|
||||||
|
.list((dir, file) -> new File(dir.getAbsolutePath() + File.separator + file).isDirectory());
|
||||||
for (String dir : dirs) {
|
for (String dir : dirs) {
|
||||||
String url = RipUtils.urlFromDirectoryName(dir);
|
String url = RipUtils.urlFromDirectoryName(dir);
|
||||||
if (url != null) {
|
if (url != null) {
|
||||||
@@ -1148,7 +1254,7 @@ 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.
|
||||||
@@ -1160,13 +1266,15 @@ public final class MainWindow implements Runnable, RipStatusHandler {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
String nextAlbum = (String) queueListModel.remove(0);
|
String nextAlbum = (String) queueListModel.remove(0);
|
||||||
updateQueueLabel();
|
|
||||||
|
updateQueue();
|
||||||
|
|
||||||
Thread t = ripAlbum(nextAlbum);
|
Thread t = ripAlbum(nextAlbum);
|
||||||
if (t == null) {
|
if (t == null) {
|
||||||
try {
|
try {
|
||||||
Thread.sleep(500);
|
Thread.sleep(500);
|
||||||
} catch (InterruptedException ie) {
|
} catch (InterruptedException ie) {
|
||||||
LOGGER.error(rb.getString("interrupted.while.waiting.to.rip.next.album"), ie);
|
LOGGER.error(Utils.getLocalizedString("interrupted.while.waiting.to.rip.next.album"), ie);
|
||||||
}
|
}
|
||||||
ripNextAlbum();
|
ripNextAlbum();
|
||||||
} else {
|
} else {
|
||||||
@@ -1175,7 +1283,7 @@ public final class MainWindow implements Runnable, RipStatusHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Thread ripAlbum(String urlString) {
|
private Thread ripAlbum(String urlString) {
|
||||||
//shutdownCleanup();
|
// shutdownCleanup();
|
||||||
if (!logPanel.isVisible()) {
|
if (!logPanel.isVisible()) {
|
||||||
optionLog.doClick();
|
optionLog.doClick();
|
||||||
}
|
}
|
||||||
@@ -1214,11 +1322,12 @@ public final class MainWindow implements Runnable, RipStatusHandler {
|
|||||||
status("Starting rip...");
|
status("Starting rip...");
|
||||||
ripper.setObserver(this);
|
ripper.setObserver(this);
|
||||||
Thread t = new Thread(ripper);
|
Thread t = new Thread(ripper);
|
||||||
if (configShowPopup.isSelected() &&
|
if (configShowPopup.isSelected() && (!mainFrame.isVisible() || !mainFrame.isActive())) {
|
||||||
(!mainFrame.isVisible() || !mainFrame.isActive())) {
|
|
||||||
mainFrame.toFront();
|
mainFrame.toFront();
|
||||||
mainFrame.setAlwaysOnTop(true);
|
mainFrame.setAlwaysOnTop(true);
|
||||||
trayIcon.displayMessage(mainFrame.getTitle(), "Started ripping " + ripper.getURL().toExternalForm(), MessageType.INFO);
|
trayIcon.displayMessage(mainFrame.getTitle(), "Started ripping " + ripper.getURL().toExternalForm(),
|
||||||
|
MessageType.INFO);
|
||||||
mainFrame.setAlwaysOnTop(false);
|
mainFrame.setAlwaysOnTop(false);
|
||||||
}
|
}
|
||||||
return t;
|
return t;
|
||||||
@@ -1262,7 +1371,7 @@ public final class MainWindow implements Runnable, RipStatusHandler {
|
|||||||
String rangeToParse = url.substring(url.indexOf("{") + 1, url.indexOf("}"));
|
String rangeToParse = url.substring(url.indexOf("{") + 1, url.indexOf("}"));
|
||||||
int rangeStart = Integer.parseInt(rangeToParse.split("-")[0]);
|
int rangeStart = Integer.parseInt(rangeToParse.split("-")[0]);
|
||||||
int rangeEnd = Integer.parseInt(rangeToParse.split("-")[1]);
|
int rangeEnd = Integer.parseInt(rangeToParse.split("-")[1]);
|
||||||
for (int i = rangeStart; i < rangeEnd +1; i++) {
|
for (int i = rangeStart; i < rangeEnd + 1; i++) {
|
||||||
String realURL = url.replaceAll("\\{\\S*\\}", Integer.toString(i));
|
String realURL = url.replaceAll("\\{\\S*\\}", Integer.toString(i));
|
||||||
if (canRip(realURL)) {
|
if (canRip(realURL)) {
|
||||||
queueListModel.add(queueListModel.size(), realURL);
|
queueListModel.add(queueListModel.size(), realURL);
|
||||||
@@ -1307,9 +1416,9 @@ public final class MainWindow implements Runnable, RipStatusHandler {
|
|||||||
int completedPercent = evt.ripper.getCompletionPercentage();
|
int completedPercent = evt.ripper.getCompletionPercentage();
|
||||||
statusProgress.setValue(completedPercent);
|
statusProgress.setValue(completedPercent);
|
||||||
statusProgress.setVisible(true);
|
statusProgress.setVisible(true);
|
||||||
status( evt.ripper.getStatusText() );
|
status(evt.ripper.getStatusText());
|
||||||
|
|
||||||
switch(msg.getStatus()) {
|
switch (msg.getStatus()) {
|
||||||
case LOADING_RESOURCE:
|
case LOADING_RESOURCE:
|
||||||
case DOWNLOAD_STARTED:
|
case DOWNLOAD_STARTED:
|
||||||
if (LOGGER.isEnabledFor(Level.INFO)) {
|
if (LOGGER.isEnabledFor(Level.INFO)) {
|
||||||
@@ -1365,7 +1474,8 @@ public final class MainWindow implements Runnable, RipStatusHandler {
|
|||||||
entry.count = rsc.count;
|
entry.count = rsc.count;
|
||||||
try {
|
try {
|
||||||
entry.title = ripper.getAlbumTitle(ripper.getURL());
|
entry.title = ripper.getAlbumTitle(ripper.getURL());
|
||||||
} catch (MalformedURLException e) { }
|
} catch (MalformedURLException e) {
|
||||||
|
}
|
||||||
HISTORY.add(entry);
|
HISTORY.add(entry);
|
||||||
historyTableModel.fireTableDataChanged();
|
historyTableModel.fireTableDataChanged();
|
||||||
}
|
}
|
||||||
@@ -1379,15 +1489,17 @@ public final class MainWindow implements Runnable, RipStatusHandler {
|
|||||||
openButton.setVisible(true);
|
openButton.setVisible(true);
|
||||||
File f = rsc.dir;
|
File f = rsc.dir;
|
||||||
String prettyFile = Utils.shortenPath(f);
|
String prettyFile = Utils.shortenPath(f);
|
||||||
openButton.setText("Open " + prettyFile);
|
openButton.setText(Utils.getLocalizedString("open") + prettyFile);
|
||||||
mainFrame.setTitle("RipMe v" + UpdateUtils.getThisJarVersion());
|
mainFrame.setTitle("RipMe v" + UpdateUtils.getThisJarVersion());
|
||||||
try {
|
try {
|
||||||
Image folderIcon = ImageIO.read(getClass().getClassLoader().getResource("folder.png"));
|
Image folderIcon = ImageIO.read(getClass().getClassLoader().getResource("folder.png"));
|
||||||
openButton.setIcon(new ImageIcon(folderIcon));
|
openButton.setIcon(new ImageIcon(folderIcon));
|
||||||
} catch (Exception e) { }
|
} catch (Exception e) {
|
||||||
/* 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 {
|
||||||
@@ -1395,13 +1507,14 @@ public final class MainWindow implements Runnable, RipStatusHandler {
|
|||||||
commandToRun = commandToRun.replaceAll("%url%", url);
|
commandToRun = commandToRun.replaceAll("%url%", url);
|
||||||
commandToRun = commandToRun.replaceAll("%path%", f.getAbsolutePath());
|
commandToRun = commandToRun.replaceAll("%path%", f.getAbsolutePath());
|
||||||
LOGGER.info("RUnning command " + commandToRun);
|
LOGGER.info("RUnning command " + commandToRun);
|
||||||
// code from: https://stackoverflow.com/questions/5711084/java-runtime-getruntime-getting-output-from-executing-a-command-line-program
|
// code from:
|
||||||
|
// https://stackoverflow.com/questions/5711084/java-runtime-getruntime-getting-output-from-executing-a-command-line-program
|
||||||
Process proc = Runtime.getRuntime().exec(commandToRun);
|
Process proc = Runtime.getRuntime().exec(commandToRun);
|
||||||
BufferedReader stdInput = new BufferedReader(new
|
BufferedReader stdInput = new BufferedReader(new InputStreamReader(proc.getInputStream()));
|
||||||
InputStreamReader(proc.getInputStream()));
|
|
||||||
|
|
||||||
|
BufferedReader stdError = new BufferedReader(new InputStreamReader(proc.getErrorStream()));
|
||||||
|
|
||||||
BufferedReader stdError = new BufferedReader(new
|
|
||||||
InputStreamReader(proc.getErrorStream()));
|
|
||||||
|
|
||||||
// read the output from the command
|
// read the output from the command
|
||||||
LOGGER.info("Command output:\n");
|
LOGGER.info("Command output:\n");
|
||||||
@@ -1472,9 +1585,11 @@ public final class MainWindow implements Runnable, RipStatusHandler {
|
|||||||
|
|
||||||
private static boolean hasWindowPositionBug() {
|
private static boolean hasWindowPositionBug() {
|
||||||
String osName = System.getProperty("os.name");
|
String osName = System.getProperty("os.name");
|
||||||
// Java on Windows has a bug where if we try to manually set the position of the Window,
|
// Java on Windows has a bug where if we try to manually set the position of the
|
||||||
|
// Window,
|
||||||
// javaw.exe will not close itself down when the application is closed.
|
// javaw.exe will not close itself down when the application is closed.
|
||||||
// Therefore, even if isWindowPositioningEnabled, if we are on Windows, we ignore it.
|
// Therefore, even if isWindowPositioningEnabled, if we are on Windows, we
|
||||||
|
// ignore it.
|
||||||
return osName == null || osName.startsWith("Windows");
|
return osName == null || osName.startsWith("Windows");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1500,8 +1615,8 @@ public final class MainWindow implements Runnable, RipStatusHandler {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
int x = (int)point.getX();
|
int x = (int) point.getX();
|
||||||
int y = (int)point.getY();
|
int y = (int) point.getY();
|
||||||
int w = frame.getWidth();
|
int w = frame.getWidth();
|
||||||
int h = frame.getHeight();
|
int h = frame.getHeight();
|
||||||
Utils.setConfigInteger("window.x", x);
|
Utils.setConfigInteger("window.x", x);
|
||||||
|
Reference in New Issue
Block a user