|
|
|
@ -1,7 +1,9 @@
@@ -1,7 +1,9 @@
|
|
|
|
|
package de.srsoftware.belegscanner.gui; |
|
|
|
|
|
|
|
|
|
import java.awt.FlowLayout; |
|
|
|
|
import java.awt.GridLayout; |
|
|
|
|
import java.awt.GridBagConstraints; |
|
|
|
|
import java.awt.GridBagLayout; |
|
|
|
|
import java.awt.Insets; |
|
|
|
|
import java.io.File; |
|
|
|
|
import java.io.FilenameFilter; |
|
|
|
|
import java.io.IOException; |
|
|
|
@ -38,8 +40,11 @@ public class DocTable extends JPanel{
@@ -38,8 +40,11 @@ public class DocTable extends JPanel{
|
|
|
|
|
|
|
|
|
|
public Row(String path) { |
|
|
|
|
rows.put(path, this); |
|
|
|
|
add(new JLabel(path)); |
|
|
|
|
add(status = new JLabel("neu")); |
|
|
|
|
constraints.gridy = rows.size(); |
|
|
|
|
constraints.gridx = 0; |
|
|
|
|
add(new JLabel(path), constraints); |
|
|
|
|
constraints.gridx = 1; |
|
|
|
|
add(status = new JLabel("neu"),constraints); |
|
|
|
|
|
|
|
|
|
JPanel buttons = new JPanel(); |
|
|
|
|
buttons.setLayout(new FlowLayout()); |
|
|
|
@ -56,7 +61,8 @@ public class DocTable extends JPanel{
@@ -56,7 +61,8 @@ public class DocTable extends JPanel{
|
|
|
|
|
preview.addActionListener(ev -> preview(path)); |
|
|
|
|
buttons.add(preview); |
|
|
|
|
|
|
|
|
|
add(buttons); |
|
|
|
|
constraints.gridx = 2; |
|
|
|
|
add(buttons,constraints); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public Row status(String status) { |
|
|
|
@ -70,15 +76,27 @@ public class DocTable extends JPanel{
@@ -70,15 +76,27 @@ public class DocTable extends JPanel{
|
|
|
|
|
|
|
|
|
|
private final HashMap<String,Row> rows = new HashMap<>(); |
|
|
|
|
private HashSet<PreviewListener> previewListeners; |
|
|
|
|
private GridBagConstraints constraints; |
|
|
|
|
|
|
|
|
|
public DocTable() { |
|
|
|
|
setLayout(new GridLayout(0, 3)); |
|
|
|
|
add(new JLabel("Ordner")); |
|
|
|
|
add(new JLabel("Status")); |
|
|
|
|
add(new JLabel("Aktionen")); |
|
|
|
|
setLayout(new GridBagLayout()); |
|
|
|
|
constraints = new GridBagConstraints(); |
|
|
|
|
constraints.fill = GridBagConstraints.HORIZONTAL; |
|
|
|
|
constraints.insets = new Insets(3, 10, 3, 10); |
|
|
|
|
constraints.gridy = 0; |
|
|
|
|
constraints.gridx = 0; |
|
|
|
|
add(new JLabel("Ordner"),constraints); |
|
|
|
|
constraints.gridx = 1; |
|
|
|
|
add(new JLabel("Status"),constraints); |
|
|
|
|
constraints.gridx = 2; |
|
|
|
|
add(new JLabel("Aktionen"),constraints); |
|
|
|
|
previewListeners = new HashSet<>(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void add(String path) { |
|
|
|
|
if (!rows.containsKey(path)) new Row(path).status("neu"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public DocTable addPreviewListener(PreviewListener listener) { |
|
|
|
|
previewListeners.add(listener); |
|
|
|
|
return this; |
|
|
|
@ -90,7 +108,7 @@ public class DocTable extends JPanel{
@@ -90,7 +108,7 @@ public class DocTable extends JPanel{
|
|
|
|
|
if (!folder.exists()) return; |
|
|
|
|
List<String> pdfs = Arrays.asList(folder.list(PDFS)); |
|
|
|
|
LOG.debug("PDFs: {}",pdfs); |
|
|
|
|
if (!pdfs.isEmpty()) previewListeners.forEach(l -> l.show(Path.of(path,pdfs.get(0)).toString())); |
|
|
|
|
if (!pdfs.isEmpty()) previewListeners.forEach(l -> l.show(Path.of(path,pdfs.get(0)).toString())); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void joinDocs(String path) { |
|
|
|
@ -142,9 +160,7 @@ public class DocTable extends JPanel{
@@ -142,9 +160,7 @@ public class DocTable extends JPanel{
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void add(String path) { |
|
|
|
|
if (!rows.containsKey(path)) new Row(path).status("neu"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void setState(String path, String state) { |
|
|
|
|
Row row = rows.get(path); |
|
|
|
|