-
Notifications
You must be signed in to change notification settings - Fork 202
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added same imgur and stuff album downloaders characteristics to ChanRipper #185
Changes from all commits
28af2ea
63432a5
cbf5eae
f846e36
b23ce03
8f0eaf5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,6 +47,7 @@ public JSONObject toJSON() { | |
return json; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return this.url; | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -75,11 +75,13 @@ | |
import com.rarchives.ripme.ripper.AbstractRipper; | ||
import com.rarchives.ripme.utils.RipUtils; | ||
import com.rarchives.ripme.utils.Utils; | ||
import java.awt.AWTException; | ||
import javax.swing.UnsupportedLookAndFeelException; | ||
|
||
/** | ||
* Everything UI-related starts and ends here. | ||
*/ | ||
public class MainWindow implements Runnable, RipStatusHandler { | ||
public final class MainWindow implements Runnable, RipStatusHandler { | ||
|
||
private static final Logger logger = Logger.getLogger(MainWindow.class); | ||
|
||
|
@@ -255,7 +257,13 @@ private void createUI(Container pane) { | |
|
||
try { | ||
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); | ||
} catch (Exception e) { | ||
} catch (ClassNotFoundException e) { | ||
logger.error("[!] Exception setting system theme:", e); | ||
} catch (InstantiationException e) { | ||
logger.error("[!] Exception setting system theme:", e); | ||
} catch (IllegalAccessException e) { | ||
logger.error("[!] Exception setting system theme:", e); | ||
} catch (UnsupportedLookAndFeelException e) { | ||
logger.error("[!] Exception setting system theme:", e); | ||
} | ||
|
||
|
@@ -271,12 +279,13 @@ private void createUI(Container pane) { | |
} catch (Exception e) { } | ||
JPanel ripPanel = new JPanel(new GridBagLayout()); | ||
ripPanel.setBorder(emptyBorder); | ||
|
||
gbc.gridx = 0; ripPanel.add(new JLabel("URL:", JLabel.RIGHT), gbc); | ||
gbc.gridx = 1; ripPanel.add(ripTextfield, gbc); | ||
gbc.gridx = 2; ripPanel.add(ripButton, gbc); | ||
gbc.gridx = 3; ripPanel.add(stopButton, gbc); | ||
|
||
|
||
gbc.gridx = 0; gbc.fill = GridBagConstraints.HORIZONTAL; ripPanel.add(new JLabel("URL:", JLabel.RIGHT), gbc); | ||
gbc.gridx = 1; gbc.fill = GridBagConstraints.HORIZONTAL; ripPanel.add(ripTextfield, gbc); | ||
gbc.gridx = 2; gbc.fill = GridBagConstraints.HORIZONTAL; ripPanel.add(ripButton, gbc); | ||
gbc.gridx = 3; gbc.fill = GridBagConstraints.HORIZONTAL; ripPanel.add(stopButton, gbc); | ||
gbc.fill = GridBagConstraints.BOTH; | ||
|
||
statusLabel = new JLabel("Inactive"); | ||
statusLabel.setHorizontalAlignment(JLabel.CENTER); | ||
openButton = new JButton(); | ||
|
@@ -333,6 +342,7 @@ private void createUI(Container pane) { | |
public String getColumnName(int col) { | ||
return HISTORY.getColumnName(col); | ||
} | ||
@Override | ||
public Class<? extends Object> getColumnClass(int c) { | ||
return getValueAt(0, c).getClass(); | ||
} | ||
|
@@ -653,7 +663,7 @@ public void actionPerformed(ActionEvent event) { | |
historyButtonRerip.addActionListener(new ActionListener() { | ||
@Override | ||
public void actionPerformed(ActionEvent event) { | ||
if (HISTORY.toList().size() == 0) { | ||
if (HISTORY.isEmpty()) { | ||
JOptionPane.showMessageDialog(null, | ||
"There are no history entries to re-rip. Rip some albums first", | ||
"RipMe Error", | ||
|
@@ -673,7 +683,6 @@ public void actionPerformed(ActionEvent event) { | |
"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); | ||
return; | ||
} | ||
} | ||
}); | ||
|
@@ -838,9 +847,13 @@ else if (level.equals("Error")) { | |
|
||
private void setupTrayIcon() { | ||
mainFrame.addWindowListener(new WindowAdapter() { | ||
@Override | ||
public void windowActivated(WindowEvent e) { trayMenuMain.setLabel("Hide"); } | ||
@Override | ||
public void windowDeactivated(WindowEvent e) { trayMenuMain.setLabel("Show"); } | ||
@Override | ||
public void windowDeiconified(WindowEvent e) { trayMenuMain.setLabel("Hide"); } | ||
@Override | ||
public void windowIconified(WindowEvent e) { trayMenuMain.setLabel("Show"); } | ||
}); | ||
PopupMenu trayMenu = new PopupMenu(); | ||
|
@@ -946,7 +959,11 @@ public void mouseClicked(MouseEvent e) { | |
mainFrame.setAlwaysOnTop(false); | ||
} | ||
}); | ||
} catch (Exception e) { | ||
} catch (IOException e) { | ||
//TODO implement proper stack trace handling this is really just intented as a placeholder until you implement proper error handling | ||
e.printStackTrace(); | ||
} catch (AWTException e) { | ||
//TODO implement proper stack trace handling this is really just intented as a placeholder until you implement proper error handling | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, that's true, but I think this code pattern is fair though. The point is to catch the exception, print it out so that someone can investigate it from the log, and not actually crash the program. (It is possible to continue the program and just not finish the operation that excepted.) |
||
e.printStackTrace(); | ||
} | ||
} | ||
|
@@ -1034,7 +1051,6 @@ private void saveHistory() { | |
@SuppressWarnings("unchecked") | ||
private void ripNextAlbum() { | ||
isRipping = true; | ||
|
||
// Save current state of queue to configuration. | ||
Utils.setConfigList("queue", (Enumeration<Object>) queueListModel.elements()); | ||
|
||
|
@@ -1044,7 +1060,7 @@ private void ripNextAlbum() { | |
return; | ||
} | ||
String nextAlbum = (String) queueListModel.remove(0); | ||
if (queueListModel.size() == 0) { | ||
if (queueListModel.isEmpty()) { | ||
optionQueue.setText("Queue"); | ||
} | ||
else { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe put these on the same line as the definition to keep the one-line method consistent?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not my code. But in the same style as C style pragma this should probably be above the method.
EDIT: In other spots in the code it is also done as a method decorator (above the method declaration, with the same indent)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have no strong opinion on this. Function over style, IMO. It's fiine as-is.