Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,10 @@ dependencies {
}

shadowJar {
// Required for Shadow 9+ to allow multiple files with the same name to be processed
duplicatesStrategy = DuplicatesStrategy.INCLUDE

// This triggers the SPI merging logic
mergeServiceFiles()

// Specifically handle the Tika parser file as a resource
append('META-INF/services/org.apache.tika.parser.Parser')
append('META-INF/tika-config.xml')

Expand Down
3 changes: 1 addition & 2 deletions src/main/java/de/tjorven/MetadataListUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,9 @@ public static void main(String[] args) {
}

public MetadataListUI() {
this.setTitle("Media Metadata Explorer");
this.setTitle("File-Sorter");
this.setSize(800, 600);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setAlwaysOnTop(true);
this.setLayout(new BorderLayout(10, 10));

this.pageablePanel = new PageablePanel();
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/de/tjorven/page/HomePage.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,15 @@ public HomePage() {
this.scanBtn.setEnabled(false);
this.scanBtn.setAlignmentX(Component.CENTER_ALIGNMENT);

this.nextBtn = new JButton("3. Configure Sorting →");
this.nextBtn.setEnabled(false);
this.nextBtn.setAlignmentX(Component.CENTER_ALIGNMENT);

this.progressBar = new JProgressBar();
this.progressBar.setIndeterminate(true);
this.progressBar.setVisible(false);
this.progressBar.setMaximumSize(new Dimension(300, 20));

this.nextBtn = new JButton("3. Configure Sorting →");
this.nextBtn.setEnabled(false);
this.nextBtn.setAlignmentX(Component.CENTER_ALIGNMENT);

this.selectBtn.addActionListener(e -> this.selectFolder());
this.scanBtn.addActionListener(e -> this.startAnalysis());
this.nextBtn.addActionListener(e -> this.goToSortPage());
Expand All @@ -66,7 +66,7 @@ public HomePage() {
this.add(this.scanBtn);
this.add(Box.createRigidArea(new Dimension(0, 10)));
this.add(this.progressBar);
this.add(Box.createVerticalGlue()); // Push next button to bottom
this.add(Box.createVerticalGlue());
this.add(this.nextBtn);
}

Expand Down
42 changes: 32 additions & 10 deletions src/main/java/de/tjorven/page/SortOptionsPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public class SortOptionsPage extends JPanel {

private final String selectedFolderPath;
private final Map<String, Map<String, String>> fileMetadataMap;
private final JProgressBar progressBar = new JProgressBar();

private final DefaultListModel<String> selectedLevelsModel = new DefaultListModel<>();
private final JList<String> levelsList = new JList<>(this.selectedLevelsModel);
Expand Down Expand Up @@ -85,9 +86,19 @@ private JPanel createHierarchyBuilder(List<String> options) {
this.updatePreview();
});

JButton removeButton = new JButton("Remove Level");
removeButton.addActionListener(e -> {
int selectedIndex = this.levelsList.getSelectedIndex();
if (selectedIndex != -1) {
this.selectedLevelsModel.remove(selectedIndex);
this.updatePreview();
}
});

JPanel btnPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
btnPanel.add(combo);
btnPanel.add(addButton);
btnPanel.add(removeButton);
btnPanel.add(clearButton);

panel.add(new JScrollPane(this.levelsList), BorderLayout.CENTER);
Expand All @@ -112,17 +123,28 @@ private void updatePreview() {
}

private void startSorting() {
if (this.selectedFolderPath == null || this.selectedLevelsModel.isEmpty()) {
JOptionPane.showMessageDialog(this, "Please select a folder and at least one sorting level.");
return;
}
List<String> attributes = Collections.list(this.selectedLevelsModel.elements());
if (this.selectedFolderPath == null || attributes.isEmpty()) return;

try {
List<String> attributes = Collections.list(this.selectedLevelsModel.elements());
this.runFilter(Paths.get(this.selectedFolderPath), attributes);
} catch (IOException ex) {
JOptionPane.showMessageDialog(this, "Error: " + ex.getMessage());
}
this.progressBar.setVisible(true);
this.revertButton.setEnabled(false);

new Thread(() -> {
try {
this.runFilter(Paths.get(this.selectedFolderPath), attributes);

SwingUtilities.invokeLater(() -> {
this.progressBar.setVisible(false);
this.revertButton.setEnabled(true);
JOptionPane.showMessageDialog(this, "Sorting complete!");
});
} catch (IOException ex) {
SwingUtilities.invokeLater(() -> {
this.progressBar.setVisible(false);
JOptionPane.showMessageDialog(this, "Error: " + ex.getMessage());
});
}
}).start();
}

public void runFilter(Path rootPath, List<String> selectedAttributes) throws IOException {
Expand Down
Loading