Auto-update functionality. UI is prettier, too
This commit is contained in:
parent
c6e75c8183
commit
6ce417a2fb
2
pom.xml
2
pom.xml
@ -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.0.7</version>
|
<version>1.0.8</version>
|
||||||
<name>ripme</name>
|
<name>ripme</name>
|
||||||
<url>http://rip.rarchives.com</url>
|
<url>http://rip.rarchives.com</url>
|
||||||
<properties>
|
<properties>
|
||||||
|
@ -5,6 +5,7 @@ import java.awt.Color;
|
|||||||
import java.awt.Container;
|
import java.awt.Container;
|
||||||
import java.awt.Desktop;
|
import java.awt.Desktop;
|
||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
|
import java.awt.Font;
|
||||||
import java.awt.GridBagConstraints;
|
import java.awt.GridBagConstraints;
|
||||||
import java.awt.GridBagLayout;
|
import java.awt.GridBagLayout;
|
||||||
import java.awt.Image;
|
import java.awt.Image;
|
||||||
@ -93,7 +94,9 @@ public class MainWindow implements Runnable, RipStatusHandler {
|
|||||||
private static JLabel configSaveDirLabel;
|
private static JLabel configSaveDirLabel;
|
||||||
private static JButton configSaveDirButton;
|
private static JButton configSaveDirButton;
|
||||||
private static JTextField configRetriesText;
|
private static JTextField configRetriesText;
|
||||||
|
private static JCheckBox configAutoupdateCheckbox;
|
||||||
|
|
||||||
|
private static MenuItem trayMenuMain;
|
||||||
private static MenuItem trayMenuAbout;
|
private static MenuItem trayMenuAbout;
|
||||||
private static MenuItem trayMenuExit;
|
private static MenuItem trayMenuExit;
|
||||||
private static CheckboxMenuItem trayMenuAutorip;
|
private static CheckboxMenuItem trayMenuAutorip;
|
||||||
@ -117,10 +120,27 @@ public class MainWindow implements Runnable, RipStatusHandler {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
Runtime.getRuntime().addShutdownHook(shutdownThread);
|
Runtime.getRuntime().addShutdownHook(shutdownThread);
|
||||||
|
|
||||||
|
if (Utils.getConfigBoolean("auto.update", true)) {
|
||||||
|
upgradeProgram();
|
||||||
|
}
|
||||||
|
|
||||||
ClipboardUtils.setClipboardAutoRip(Utils.getConfigBoolean("clipboard.autorip", false));
|
ClipboardUtils.setClipboardAutoRip(Utils.getConfigBoolean("clipboard.autorip", false));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void upgradeProgram() {
|
||||||
|
if (!configurationPanel.isVisible()) {
|
||||||
|
optionConfiguration.doClick();
|
||||||
|
}
|
||||||
|
Runnable r = new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
UpdateUtils.updateProgram(configUpdateLabel);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
SwingUtilities.invokeLater(r);
|
||||||
|
}
|
||||||
|
|
||||||
public void run() {
|
public void run() {
|
||||||
mainFrame.pack();
|
mainFrame.pack();
|
||||||
mainFrame.setLocationRelativeTo(null);
|
mainFrame.setLocationRelativeTo(null);
|
||||||
@ -133,6 +153,7 @@ public class MainWindow implements Runnable, RipStatusHandler {
|
|||||||
Utils.setConfigInteger("download.retries", Integer.parseInt(configRetriesText.getText()));
|
Utils.setConfigInteger("download.retries", Integer.parseInt(configRetriesText.getText()));
|
||||||
Utils.setConfigInteger("download.timeout", Integer.parseInt(configTimeoutText.getText()));
|
Utils.setConfigInteger("download.timeout", Integer.parseInt(configTimeoutText.getText()));
|
||||||
Utils.setConfigBoolean("clipboard.autorip", ClipboardUtils.getClipboardAutoRip());
|
Utils.setConfigBoolean("clipboard.autorip", ClipboardUtils.getClipboardAutoRip());
|
||||||
|
Utils.setConfigBoolean("auto.update", configAutoupdateCheckbox.isSelected());
|
||||||
saveHistory();
|
saveHistory();
|
||||||
Utils.saveConfig();
|
Utils.saveConfig();
|
||||||
ClipboardUtils.setClipboardAutoRip(false);
|
ClipboardUtils.setClipboardAutoRip(false);
|
||||||
@ -155,6 +176,19 @@ public class MainWindow implements Runnable, RipStatusHandler {
|
|||||||
private void createUI(Container pane) {
|
private void createUI(Container pane) {
|
||||||
// System tray
|
// System tray
|
||||||
PopupMenu trayMenu = new PopupMenu();
|
PopupMenu trayMenu = new PopupMenu();
|
||||||
|
trayMenuMain = new MenuItem(mainFrame.getTitle());
|
||||||
|
trayMenuMain.addActionListener(new ActionListener() {
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent arg0) {
|
||||||
|
if (mainFrame.isVisible()) {
|
||||||
|
mainFrame.setVisible(false);
|
||||||
|
trayMenuMain.setLabel("Show");
|
||||||
|
} else {
|
||||||
|
mainFrame.setVisible(true);
|
||||||
|
trayMenuMain.setLabel("Hide");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
trayMenuAbout = new MenuItem("About " + mainFrame.getTitle());
|
trayMenuAbout = new MenuItem("About " + mainFrame.getTitle());
|
||||||
trayMenuAbout.addActionListener(new ActionListener() {
|
trayMenuAbout.addActionListener(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
@ -182,6 +216,7 @@ public class MainWindow implements Runnable, RipStatusHandler {
|
|||||||
ClipboardUtils.setClipboardAutoRip(trayMenuAutorip.getState());
|
ClipboardUtils.setClipboardAutoRip(trayMenuAutorip.getState());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
trayMenu.add(trayMenuMain);
|
||||||
trayMenu.add(trayMenuAbout);
|
trayMenu.add(trayMenuAbout);
|
||||||
trayMenu.addSeparator();
|
trayMenu.addSeparator();
|
||||||
trayMenu.add(trayMenuAutorip);
|
trayMenu.add(trayMenuAutorip);
|
||||||
@ -211,7 +246,7 @@ public class MainWindow implements Runnable, RipStatusHandler {
|
|||||||
|
|
||||||
ripTextfield = new JTextField("", 20);
|
ripTextfield = new JTextField("", 20);
|
||||||
ImageIcon ripIcon = new ImageIcon(mainIcon.getScaledInstance(20, 20, Image.SCALE_SMOOTH));
|
ImageIcon ripIcon = new ImageIcon(mainIcon.getScaledInstance(20, 20, Image.SCALE_SMOOTH));
|
||||||
ripButton = new JButton("<html><b>Rip</b></html>", ripIcon);
|
ripButton = new JButton("<html><font size=\"5\"><b>Rip</b></font></html>", ripIcon);
|
||||||
JPanel ripPanel = new JPanel(new GridBagLayout());
|
JPanel ripPanel = new JPanel(new GridBagLayout());
|
||||||
ripPanel.setBorder(emptyBorder);
|
ripPanel.setBorder(emptyBorder);
|
||||||
|
|
||||||
@ -296,6 +331,9 @@ public class MainWindow implements Runnable, RipStatusHandler {
|
|||||||
configOverwriteCheckbox = new JCheckBox("Overwrite existing files?", Utils.getConfigBoolean("file.overwrite", false));
|
configOverwriteCheckbox = new JCheckBox("Overwrite existing files?", Utils.getConfigBoolean("file.overwrite", false));
|
||||||
configOverwriteCheckbox.setHorizontalAlignment(JCheckBox.RIGHT);
|
configOverwriteCheckbox.setHorizontalAlignment(JCheckBox.RIGHT);
|
||||||
configOverwriteCheckbox.setHorizontalTextPosition(JCheckBox.LEFT);
|
configOverwriteCheckbox.setHorizontalTextPosition(JCheckBox.LEFT);
|
||||||
|
configAutoupdateCheckbox = new JCheckBox("Auto-update?", Utils.getConfigBoolean("auto.update", true));
|
||||||
|
configAutoupdateCheckbox.setHorizontalAlignment(JCheckBox.RIGHT);
|
||||||
|
configAutoupdateCheckbox.setHorizontalTextPosition(JCheckBox.LEFT);
|
||||||
configSaveDirLabel = new JLabel();
|
configSaveDirLabel = new JLabel();
|
||||||
try {
|
try {
|
||||||
String workingDir = (Utils.shortenPath(Utils.getWorkingDirectory()));
|
String workingDir = (Utils.shortenPath(Utils.getWorkingDirectory()));
|
||||||
@ -306,14 +344,15 @@ public class MainWindow implements Runnable, RipStatusHandler {
|
|||||||
configSaveDirButton = new JButton("Browse...");
|
configSaveDirButton = new JButton("Browse...");
|
||||||
gbc.gridy = 0; gbc.gridx = 0; configurationPanel.add(configUpdateLabel, gbc);
|
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(configThreadsLabel, gbc);
|
gbc.gridy = 1; gbc.gridx = 0; configurationPanel.add(configAutoupdateCheckbox, 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 = 2; gbc.gridx = 0; configurationPanel.add(configTimeoutLabel, 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 = 3; gbc.gridx = 0; configurationPanel.add(configRetriesLabel, 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 = 4; gbc.gridx = 0; configurationPanel.add(configOverwriteCheckbox, gbc);
|
gbc.gridy = 5; gbc.gridx = 0; configurationPanel.add(configOverwriteCheckbox, gbc);
|
||||||
gbc.gridy = 5; gbc.gridx = 0; configurationPanel.add(configSaveDirLabel, gbc);
|
gbc.gridy = 6; gbc.gridx = 0; configurationPanel.add(configSaveDirLabel, gbc);
|
||||||
gbc.gridx = 1; configurationPanel.add(configSaveDirButton, gbc);
|
gbc.gridx = 1; configurationPanel.add(configSaveDirButton, gbc);
|
||||||
|
|
||||||
gbc.gridy = 0; pane.add(ripPanel, gbc);
|
gbc.gridy = 0; pane.add(ripPanel, gbc);
|
||||||
@ -334,6 +373,13 @@ public class MainWindow implements Runnable, RipStatusHandler {
|
|||||||
logPanel.setVisible(!logPanel.isVisible());
|
logPanel.setVisible(!logPanel.isVisible());
|
||||||
historyPanel.setVisible(false);
|
historyPanel.setVisible(false);
|
||||||
configurationPanel.setVisible(false);
|
configurationPanel.setVisible(false);
|
||||||
|
if (logPanel.isVisible()) {
|
||||||
|
optionLog.setFont(optionLog.getFont().deriveFont(Font.BOLD));
|
||||||
|
} else {
|
||||||
|
optionLog.setFont(optionLog.getFont().deriveFont(Font.PLAIN));
|
||||||
|
}
|
||||||
|
optionHistory.setFont(optionLog.getFont().deriveFont(Font.PLAIN));
|
||||||
|
optionConfiguration.setFont(optionLog.getFont().deriveFont(Font.PLAIN));
|
||||||
mainFrame.pack();
|
mainFrame.pack();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -343,6 +389,13 @@ public class MainWindow implements Runnable, RipStatusHandler {
|
|||||||
logPanel.setVisible(false);
|
logPanel.setVisible(false);
|
||||||
historyPanel.setVisible(!historyPanel.isVisible());
|
historyPanel.setVisible(!historyPanel.isVisible());
|
||||||
configurationPanel.setVisible(false);
|
configurationPanel.setVisible(false);
|
||||||
|
optionLog.setFont(optionLog.getFont().deriveFont(Font.PLAIN));
|
||||||
|
if (historyPanel.isVisible()) {
|
||||||
|
optionHistory.setFont(optionLog.getFont().deriveFont(Font.BOLD));
|
||||||
|
} else {
|
||||||
|
optionHistory.setFont(optionLog.getFont().deriveFont(Font.PLAIN));
|
||||||
|
}
|
||||||
|
optionConfiguration.setFont(optionLog.getFont().deriveFont(Font.PLAIN));
|
||||||
mainFrame.pack();
|
mainFrame.pack();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -352,6 +405,13 @@ public class MainWindow implements Runnable, RipStatusHandler {
|
|||||||
logPanel.setVisible(false);
|
logPanel.setVisible(false);
|
||||||
historyPanel.setVisible(false);
|
historyPanel.setVisible(false);
|
||||||
configurationPanel.setVisible(!configurationPanel.isVisible());
|
configurationPanel.setVisible(!configurationPanel.isVisible());
|
||||||
|
optionLog.setFont(optionLog.getFont().deriveFont(Font.PLAIN));
|
||||||
|
optionHistory.setFont(optionLog.getFont().deriveFont(Font.PLAIN));
|
||||||
|
if (configurationPanel.isVisible()) {
|
||||||
|
optionConfiguration.setFont(optionLog.getFont().deriveFont(Font.BOLD));
|
||||||
|
} else {
|
||||||
|
optionConfiguration.setFont(optionLog.getFont().deriveFont(Font.PLAIN));
|
||||||
|
}
|
||||||
mainFrame.pack();
|
mainFrame.pack();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -17,7 +17,7 @@ import org.jsoup.nodes.Document;
|
|||||||
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.0.4";
|
private static final String DEFAULT_VERSION = "1.0.7";
|
||||||
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";
|
||||||
|
Loading…
Reference in New Issue
Block a user