aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/DownloadConfigPane.java
diff options
context:
space:
mode:
authorPinapelz <yukais@pinapelz.com>2024-10-01 22:37:57 -0700
committerPinapelz <yukais@pinapelz.com>2024-10-01 22:37:57 -0700
commit110ad8f7746aca49a91fe4048e2b0f4329944a74 (patch)
tree7f45c7f968c2798c600b9f3f6d79dc625f8140a2 /src/main/java/DownloadConfigPane.java
parentdf370fd1d3d3d84fe8693be94c94b76f0747b095 (diff)
code cleanup and refactor
Diffstat (limited to 'src/main/java/DownloadConfigPane.java')
-rw-r--r--src/main/java/DownloadConfigPane.java90
1 files changed, 39 insertions, 51 deletions
diff --git a/src/main/java/DownloadConfigPane.java b/src/main/java/DownloadConfigPane.java
index ba2f6dd..7206d7e 100644
--- a/src/main/java/DownloadConfigPane.java
+++ b/src/main/java/DownloadConfigPane.java
@@ -22,6 +22,7 @@ public class DownloadConfigPane extends JFrame{
private JButton saveButton;
private JButton removeButton;
private JScrollPane tableScrollPane;
+ private JCheckBox fullVideoCheckBox;
private String loadedPath;
@@ -32,57 +33,50 @@ public class DownloadConfigPane extends JFrame{
initializeTable();
this.add(mainPanel);
this.setVisible(true);
- loadFromFileButton.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- loadConfigFromFile();
+ loadFromFileButton.addActionListener(e -> loadConfigFromFile());
+ addButton.addActionListener(e -> {
+ String url = urlField.getText();
+ String from = fromField.getText();
+ String to = toField.getText();
+ if (url.isEmpty()){
+ return;
}
- });
- saveButton.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
-
+ if (from.length() != 8){
+ from = "00:00:00";
+ }
+ if (to.length() != 8){
+ to = "00:00:00";
}
+ Object[] song = new Object[]{url, from, to};
+ DefaultTableModel model = (DefaultTableModel) outputTable.getModel();
+ model.addRow(song);
});
- addButton.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- String url = urlField.getText();
- String from = fromField.getText();
- String to = toField.getText();
- if (url.length() == 0){
- return;
- }
- if (from.length() != 8){
- from = "00:00:00";
- }
- if (to.length() != 8){
- to = "00:00:00";
- }
- Object[] song = new Object[]{url, from, to};
- DefaultTableModel model = (DefaultTableModel) outputTable.getModel();
- model.addRow(song);
+ removeButton.addActionListener(e -> {
+ int row = outputTable.getSelectedRow();
+ if (row == -1){
+ return;
}
+ DefaultTableModel model = (DefaultTableModel) outputTable.getModel();
+ model.removeRow(row);
});
- removeButton.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- int row = outputTable.getSelectedRow();
- if (row == -1){
- return;
- }
- DefaultTableModel model = (DefaultTableModel) outputTable.getModel();
- model.removeRow(row);
+
+ saveButton.addActionListener(e -> {
+ try {
+ saveConfigToFile();
+ } catch (IOException ex) {
+ throw new RuntimeException(ex);
}
});
- saveButton.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- try {
- saveConfigToFile();
- } catch (IOException ex) {
- throw new RuntimeException(ex);
- }
+ fullVideoCheckBox.addActionListener(e -> {
+ if (fullVideoCheckBox.isSelected()){
+ fromField.setEnabled(false);
+ fromField.setText("BEGINNING_OF_VIDEO");
+ toField.setEnabled(false);
+ toField.setText("END_OF_VIDEO");
+ }
+ else{
+ fromField.setEnabled(true);
+ toField.setEnabled(true);
}
});
}
@@ -90,7 +84,6 @@ public class DownloadConfigPane extends JFrame{
private void initializeTable() {
DefaultTableModel model = new DefaultTableModel();
// center align the text in the table
-
DefaultTableCellRenderer centerRenderer = new DefaultTableCellRenderer();
centerRenderer.setHorizontalAlignment( JLabel.CENTER );
outputTable.setDefaultRenderer(String.class, centerRenderer);
@@ -162,14 +155,10 @@ public class DownloadConfigPane extends JFrame{
DefaultTableModel model = (DefaultTableModel) outputTable.getModel();
model.addRow(song);
// add headers to the table
-
-
-
}
loadedPath = file.getAbsolutePath();
}
catch (Exception e){
- e.printStackTrace();
JOptionPane.showMessageDialog(null, "Please choose a file with the download config format");
System.out.println("Invalid file selected");
loadedPath = null;
@@ -205,8 +194,7 @@ public class DownloadConfigPane extends JFrame{
try{
writer.write(line + System.lineSeparator());
}
- catch (Exception e){
- e.printStackTrace();
+ catch (Exception ignored){
}
System.out.println(line);
}
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage