Merge pull request #625 from cyian-1756/refactoring
Some UI refactoring
This commit is contained in:
commit
ed30482123
@ -115,7 +115,7 @@ public final class MainWindow implements Runnable, RipStatusHandler {
|
|||||||
private static JButton configSaveDirButton;
|
private static JButton configSaveDirButton;
|
||||||
private static JTextField configRetriesText;
|
private static JTextField configRetriesText;
|
||||||
private static JCheckBox configAutoupdateCheckbox;
|
private static JCheckBox configAutoupdateCheckbox;
|
||||||
private static JComboBox configLogLevelCombobox;
|
private static JComboBox<String> configLogLevelCombobox;
|
||||||
private static JCheckBox configURLHistoryCheckbox;
|
private static JCheckBox configURLHistoryCheckbox;
|
||||||
private static JCheckBox configPlaySound;
|
private static JCheckBox configPlaySound;
|
||||||
private static JCheckBox configSaveOrderCheckbox;
|
private static JCheckBox configSaveOrderCheckbox;
|
||||||
@ -127,6 +127,10 @@ public final class MainWindow implements Runnable, RipStatusHandler {
|
|||||||
private static JCheckBox configSaveDescriptions;
|
private static JCheckBox configSaveDescriptions;
|
||||||
private static JCheckBox configPreferMp4;
|
private static JCheckBox configPreferMp4;
|
||||||
private static JCheckBox configWindowPosition;
|
private static JCheckBox configWindowPosition;
|
||||||
|
private static JComboBox<String> configSelectLangComboBox;
|
||||||
|
private static JLabel configThreadsLabel;
|
||||||
|
private static JLabel configTimeoutLabel;
|
||||||
|
private static JLabel configRetriesLabel;
|
||||||
|
|
||||||
private static TrayIcon trayIcon;
|
private static TrayIcon trayIcon;
|
||||||
private static MenuItem trayMenuMain;
|
private static MenuItem trayMenuMain;
|
||||||
@ -136,7 +140,7 @@ public final class MainWindow implements Runnable, RipStatusHandler {
|
|||||||
|
|
||||||
private static AbstractRipper ripper;
|
private static AbstractRipper ripper;
|
||||||
|
|
||||||
private ResourceBundle rb = Utils.getResourceBundle();
|
private ResourceBundle rb = Utils.getResourceBundle(null);
|
||||||
|
|
||||||
private void updateQueueLabel() {
|
private void updateQueueLabel() {
|
||||||
if (queueListModel.size() > 0) {
|
if (queueListModel.size() > 0) {
|
||||||
@ -471,9 +475,9 @@ public final class MainWindow implements Runnable, RipStatusHandler {
|
|||||||
// TODO Configuration components
|
// TODO Configuration components
|
||||||
configUpdateButton = new JButton(rb.getString("check.for.updates"));
|
configUpdateButton = new JButton(rb.getString("check.for.updates"));
|
||||||
configUpdateLabel = new JLabel( rb.getString("current.version") + ": " + UpdateUtils.getThisJarVersion(), JLabel.RIGHT);
|
configUpdateLabel = new JLabel( rb.getString("current.version") + ": " + UpdateUtils.getThisJarVersion(), JLabel.RIGHT);
|
||||||
JLabel configThreadsLabel = new JLabel(rb.getString("max.download.threads") + ":", JLabel.RIGHT);
|
configThreadsLabel = new JLabel(rb.getString("max.download.threads") + ":", JLabel.RIGHT);
|
||||||
JLabel configTimeoutLabel = new JLabel(rb.getString("timeout.mill"), JLabel.RIGHT);
|
configTimeoutLabel = new JLabel(rb.getString("timeout.mill"), JLabel.RIGHT);
|
||||||
JLabel configRetriesLabel = new JLabel(rb.getString("retry.download.count"), JLabel.RIGHT);
|
configRetriesLabel = new JLabel(rb.getString("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)));
|
||||||
@ -491,7 +495,8 @@ public final class MainWindow implements Runnable, RipStatusHandler {
|
|||||||
configWindowPosition = addNewCheckbox(rb.getString("restore.window.position"), "window.position", true);
|
configWindowPosition = addNewCheckbox(rb.getString("restore.window.position"), "window.position", true);
|
||||||
configURLHistoryCheckbox = addNewCheckbox(rb.getString("remember.url.history"), "remember.url_history", true);
|
configURLHistoryCheckbox = addNewCheckbox(rb.getString("remember.url.history"), "remember.url_history", true);
|
||||||
|
|
||||||
configLogLevelCombobox = new JComboBox(new String[] {"Log level: Error", "Log level: Warn", "Log level: Info", "Log level: Debug"});
|
configLogLevelCombobox = new JComboBox<>(new String[] {"Log level: Error", "Log level: Warn", "Log level: Info", "Log level: Debug"});
|
||||||
|
configSelectLangComboBox = new JComboBox<>(new String[] {"en_US", "de_DE", "es_ES", "fr_CH", "kr_KR", "pt_PT", "fi_FI", "in_ID", "porrisavvo_FI"});
|
||||||
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();
|
||||||
@ -504,30 +509,22 @@ public final class MainWindow implements Runnable, RipStatusHandler {
|
|||||||
configSaveDirLabel.setToolTipText(configSaveDirLabel.getText());
|
configSaveDirLabel.setToolTipText(configSaveDirLabel.getText());
|
||||||
configSaveDirLabel.setHorizontalAlignment(JLabel.RIGHT);
|
configSaveDirLabel.setHorizontalAlignment(JLabel.RIGHT);
|
||||||
configSaveDirButton = new JButton("Select Save Directory...");
|
configSaveDirButton = new JButton("Select Save Directory...");
|
||||||
gbc.gridy = 0; gbc.gridx = 0; configurationPanel.add(configUpdateLabel, gbc);
|
|
||||||
gbc.gridx = 1; configurationPanel.add(configUpdateButton, gbc);
|
addItemToConfigGridBagConstraints(gbc, 0, configUpdateLabel, configUpdateButton);
|
||||||
gbc.gridy = 1; gbc.gridx = 0; configurationPanel.add(configAutoupdateCheckbox, gbc);
|
addItemToConfigGridBagConstraints(gbc, 1, configAutoupdateCheckbox, configLogLevelCombobox);
|
||||||
gbc.gridx = 1; configurationPanel.add(configLogLevelCombobox, gbc);
|
addItemToConfigGridBagConstraints(gbc, 2, configThreadsLabel, configThreadsText);
|
||||||
gbc.gridy = 2; gbc.gridx = 0; configurationPanel.add(configThreadsLabel, gbc);
|
addItemToConfigGridBagConstraints(gbc, 3, configTimeoutLabel, configTimeoutText);
|
||||||
gbc.gridx = 1; configurationPanel.add(configThreadsText, gbc);
|
addItemToConfigGridBagConstraints(gbc, 4, configRetriesLabel, configRetriesText);
|
||||||
gbc.gridy = 3; gbc.gridx = 0; configurationPanel.add(configTimeoutLabel, gbc);
|
addItemToConfigGridBagConstraints(gbc, 5, configOverwriteCheckbox, configSaveOrderCheckbox);
|
||||||
gbc.gridx = 1; configurationPanel.add(configTimeoutText, gbc);
|
addItemToConfigGridBagConstraints(gbc, 6, configPlaySound, configSaveLogs);
|
||||||
gbc.gridy = 4; gbc.gridx = 0; configurationPanel.add(configRetriesLabel, gbc);
|
addItemToConfigGridBagConstraints(gbc, 7, configShowPopup, configSaveURLsOnly);
|
||||||
gbc.gridx = 1; configurationPanel.add(configRetriesText, gbc);
|
addItemToConfigGridBagConstraints(gbc, 8, configClipboardAutorip, configSaveAlbumTitles);
|
||||||
gbc.gridy = 5; gbc.gridx = 0; configurationPanel.add(configOverwriteCheckbox, gbc);
|
addItemToConfigGridBagConstraints(gbc, 9, configSaveDescriptions, configPreferMp4);
|
||||||
gbc.gridx = 1; configurationPanel.add(configSaveOrderCheckbox, gbc);
|
addItemToConfigGridBagConstraints(gbc, 10, configWindowPosition, configURLHistoryCheckbox);
|
||||||
gbc.gridy = 6; gbc.gridx = 0; configurationPanel.add(configPlaySound, gbc);
|
addItemToConfigGridBagConstraints(gbc, 11, configSelectLangComboBox);
|
||||||
gbc.gridx = 1; configurationPanel.add(configSaveLogs, gbc);
|
addItemToConfigGridBagConstraints(gbc, 12, configSaveDirLabel, configSaveDirButton);
|
||||||
gbc.gridy = 7; gbc.gridx = 0; configurationPanel.add(configShowPopup, 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.gridy = 9; gbc.gridx = 0; configurationPanel.add(configSaveDescriptions, 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.gridy = 11; gbc.gridx = 0; configurationPanel.add(configSaveDirLabel, gbc);
|
|
||||||
gbc.gridx = 1; configurationPanel.add(configSaveDirButton, gbc);
|
|
||||||
|
|
||||||
|
|
||||||
emptyPanel = new JPanel();
|
emptyPanel = new JPanel();
|
||||||
@ -550,6 +547,56 @@ public final class MainWindow implements Runnable, RipStatusHandler {
|
|||||||
gbc.fill = GridBagConstraints.HORIZONTAL;
|
gbc.fill = GridBagConstraints.HORIZONTAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void addItemToConfigGridBagConstraints(GridBagConstraints gbc, int gbcYValue, JLabel thing1ToAdd, JButton thing2ToAdd ) {
|
||||||
|
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 ) {
|
||||||
|
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 ) {
|
||||||
|
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 ) {
|
||||||
|
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 ) {
|
||||||
|
gbc.gridy = gbcYValue; gbc.gridx = 0; configurationPanel.add(thing1ToAdd, gbc);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void changeLocale() {
|
||||||
|
statusLabel.setText(rb.getString("inactive"));
|
||||||
|
configUpdateButton.setText(rb.getString("check.for.updates"));
|
||||||
|
configUpdateLabel.setText(rb.getString("current.version") + ": " + UpdateUtils.getThisJarVersion());
|
||||||
|
configThreadsLabel.setText(rb.getString("max.download.threads"));
|
||||||
|
configTimeoutLabel.setText(rb.getString("timeout.mill"));
|
||||||
|
configRetriesLabel.setText(rb.getString("retry.download.count"));
|
||||||
|
configOverwriteCheckbox.setText(rb.getString("overwrite.existing.files"));
|
||||||
|
configAutoupdateCheckbox.setText(rb.getString("auto.update"));
|
||||||
|
configPlaySound.setText(rb.getString("sound.when.rip.completes"));
|
||||||
|
configShowPopup.setText(rb.getString("notification.when.rip.starts"));
|
||||||
|
configSaveOrderCheckbox.setText(rb.getString("preserve.order"));
|
||||||
|
configSaveLogs.setText(rb.getString("save.logs"));
|
||||||
|
configSaveURLsOnly.setText(rb.getString("save.urls.only"));
|
||||||
|
configSaveAlbumTitles.setText(rb.getString("save.album.titles"));
|
||||||
|
configClipboardAutorip.setText(rb.getString("autorip.from.clipboard"));
|
||||||
|
configSaveDescriptions.setText(rb.getString("save.descriptions"));
|
||||||
|
configPreferMp4.setText(rb.getString("prefer.mp4.over.gif"));
|
||||||
|
configWindowPosition.setText(rb.getString("restore.window.position"));
|
||||||
|
configURLHistoryCheckbox.setText(rb.getString("remember.url.history"));
|
||||||
|
optionLog.setText(rb.getString("Log"));
|
||||||
|
optionHistory.setText(rb.getString("History"));
|
||||||
|
optionQueue.setText(rb.getString("Queue"));
|
||||||
|
optionConfiguration.setText(rb.getString("Configuration"));
|
||||||
|
}
|
||||||
|
|
||||||
private void setupHandlers() {
|
private void setupHandlers() {
|
||||||
ripButton.addActionListener(new RipButtonHandler());
|
ripButton.addActionListener(new RipButtonHandler());
|
||||||
ripTextfield.addActionListener(new RipButtonHandler());
|
ripTextfield.addActionListener(new RipButtonHandler());
|
||||||
@ -746,6 +793,11 @@ public final class MainWindow implements Runnable, RipStatusHandler {
|
|||||||
String level = ((JComboBox) arg0.getSource()).getSelectedItem().toString();
|
String level = ((JComboBox) arg0.getSource()).getSelectedItem().toString();
|
||||||
setLogLevel(level);
|
setLogLevel(level);
|
||||||
});
|
});
|
||||||
|
configSelectLangComboBox.addActionListener(arg0 -> {
|
||||||
|
String level = ((JComboBox) arg0.getSource()).getSelectedItem().toString();
|
||||||
|
rb = Utils.getResourceBundle(level);
|
||||||
|
changeLocale();
|
||||||
|
});
|
||||||
configSaveDirLabel.addMouseListener(new MouseAdapter() {
|
configSaveDirLabel.addMouseListener(new MouseAdapter() {
|
||||||
@Override
|
@Override
|
||||||
public void mouseClicked(MouseEvent e) {
|
public void mouseClicked(MouseEvent e) {
|
||||||
@ -897,7 +949,7 @@ public final class MainWindow implements Runnable, RipStatusHandler {
|
|||||||
new ImageIcon(mainIcon));
|
new ImageIcon(mainIcon));
|
||||||
if (response == JOptionPane.YES_OPTION) {
|
if (response == JOptionPane.YES_OPTION) {
|
||||||
try {
|
try {
|
||||||
Desktop.getDesktop().browse(URI.create("http://github.com/4pr0n/ripme"));
|
Desktop.getDesktop().browse(URI.create("http://github.com/ripmeapp/ripme"));
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
logger.error("Exception while opening project home page", e);
|
logger.error("Exception while opening project home page", e);
|
||||||
}
|
}
|
||||||
|
@ -686,18 +686,24 @@ public class Utils {
|
|||||||
*
|
*
|
||||||
* @return Returns the default resource bundle using the language specified in the config file.
|
* @return Returns the default resource bundle using the language specified in the config file.
|
||||||
*/
|
*/
|
||||||
public static ResourceBundle getResourceBundle() {
|
public static ResourceBundle getResourceBundle(String langSelect) {
|
||||||
|
if (langSelect == null) {
|
||||||
if (!getConfigString("lang", "").equals("")) {
|
if (!getConfigString("lang", "").equals("")) {
|
||||||
String[] langCode = getConfigString("lang", "").split("_");
|
String[] langCode = getConfigString("lang", "").split("_");
|
||||||
logger.info("Setting locale to " + getConfigString("lang", ""));
|
logger.info("Setting locale to " + getConfigString("lang", ""));
|
||||||
return ResourceBundle.getBundle("LabelsBundle", new Locale(langCode[0], langCode[1]), new UTF8Control());
|
return ResourceBundle.getBundle("LabelsBundle", new Locale(langCode[0], langCode[1]), new UTF8Control());
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
String[] langCode = langSelect.split("_");
|
||||||
|
logger.info("Setting locale to " + langSelect);
|
||||||
|
return ResourceBundle.getBundle("LabelsBundle", new Locale(langCode[0], langCode[1]), new UTF8Control());
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
ResourceBundle rb = ResourceBundle.getBundle("LabelsBundle", Locale.getDefault(), new UTF8Control());
|
logger.info("Setting locale to default");
|
||||||
return rb;
|
return ResourceBundle.getBundle("LabelsBundle", Locale.getDefault(), new UTF8Control());
|
||||||
} catch (MissingResourceException e) {
|
} catch (MissingResourceException e) {
|
||||||
ResourceBundle rb = ResourceBundle.getBundle("LabelsBundle", Locale.ROOT);
|
logger.info("Setting locale to root");
|
||||||
return rb;
|
return ResourceBundle.getBundle("LabelsBundle", Locale.ROOT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@ Configuration = Configuration
|
|||||||
current.version = Current version
|
current.version = Current version
|
||||||
check.for.updates = Check for updates
|
check.for.updates = Check for updates
|
||||||
auto.update = Auto-update?
|
auto.update = Auto-update?
|
||||||
max.download.threads = Maximum download threads
|
max.download.threads = Maximum download threads:
|
||||||
timeout.mill = Timeout (in milliseconds):
|
timeout.mill = Timeout (in milliseconds):
|
||||||
retry.download.count = Retry download count
|
retry.download.count = Retry download count
|
||||||
overwrite.existing.files = Overwrite existing files?
|
overwrite.existing.files = Overwrite existing files?
|
||||||
|
37
src/main/resources/LabelsBundle_en_US.properties
Normal file
37
src/main/resources/LabelsBundle_en_US.properties
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
Log = Log
|
||||||
|
History = History
|
||||||
|
created = created
|
||||||
|
modified = modified
|
||||||
|
Queue = Queue
|
||||||
|
Configuration = Configuration
|
||||||
|
|
||||||
|
# Keys for the Configuration menu
|
||||||
|
|
||||||
|
current.version = Current version
|
||||||
|
check.for.updates = Check for updates
|
||||||
|
auto.update = Auto-update?
|
||||||
|
max.download.threads = Maximum download threads:
|
||||||
|
timeout.mill = Timeout (in milliseconds):
|
||||||
|
retry.download.count = Retry download count
|
||||||
|
overwrite.existing.files = Overwrite existing files?
|
||||||
|
sound.when.rip.completes = Sound when rip completes
|
||||||
|
preserve.order = Preserve order
|
||||||
|
save.logs = Save logs
|
||||||
|
notification.when.rip.starts = Notification when rip starts
|
||||||
|
save.urls.only = Save URLs only
|
||||||
|
save.album.titles = Save album titles
|
||||||
|
autorip.from.clipboard = Autorip from Clipboard
|
||||||
|
save.descriptions = Save descriptions
|
||||||
|
prefer.mp4.over.gif = Prefer MP4 over GIF
|
||||||
|
restore.window.position = Restore window position
|
||||||
|
remember.url.history = Remember URL history
|
||||||
|
loading.history.from = Loading history from
|
||||||
|
|
||||||
|
# Misc UI keys
|
||||||
|
|
||||||
|
loading.history.from.configuration = Loading history from configuration
|
||||||
|
interrupted.while.waiting.to.rip.next.album = Interrupted while waiting to rip next album
|
||||||
|
inactive = Inactive
|
||||||
|
re-rip.checked = Re-rip Checked
|
||||||
|
remove = Remove
|
||||||
|
clear = Clear
|
Loading…
Reference in New Issue
Block a user