|
|
|
@ -29,7 +29,8 @@ public class DocTable extends JPanel{
@@ -29,7 +29,8 @@ public class DocTable extends JPanel{
|
|
|
|
|
private static final Logger LOG = LoggerFactory.getLogger(DocTable.class); |
|
|
|
|
private static FilenameFilter PAGES = (dir,name) -> name.toLowerCase().endsWith("pdf") && name.toLowerCase().startsWith("page"); |
|
|
|
|
private static FilenameFilter PDFS = (dir,name) -> name.toLowerCase().endsWith("pdf"); |
|
|
|
|
|
|
|
|
|
private static int rowCounter = 0; |
|
|
|
|
|
|
|
|
|
public interface PreviewListener{ |
|
|
|
|
public void show(String filename); |
|
|
|
|
} |
|
|
|
@ -37,16 +38,20 @@ public class DocTable extends JPanel{
@@ -37,16 +38,20 @@ public class DocTable extends JPanel{
|
|
|
|
|
private class Row{ |
|
|
|
|
|
|
|
|
|
private JLabel status; |
|
|
|
|
private JLabel pathLabel; |
|
|
|
|
private JPanel buttons; |
|
|
|
|
private String path; |
|
|
|
|
|
|
|
|
|
public Row(String path) { |
|
|
|
|
this.path = path; |
|
|
|
|
rows.put(path, this); |
|
|
|
|
constraints.gridy = rows.size(); |
|
|
|
|
constraints.gridy = ++rowCounter; |
|
|
|
|
constraints.gridx = 0; |
|
|
|
|
add(new JLabel(path), constraints); |
|
|
|
|
add(pathLabel = new JLabel(path), constraints); |
|
|
|
|
constraints.gridx = 1; |
|
|
|
|
add(status = new JLabel("neu"),constraints); |
|
|
|
|
|
|
|
|
|
JPanel buttons = new JPanel(); |
|
|
|
|
buttons = new JPanel(); |
|
|
|
|
buttons.setLayout(new FlowLayout()); |
|
|
|
|
|
|
|
|
|
JButton folderButton = new JButton("Ordner öffnen"); |
|
|
|
@ -61,10 +66,23 @@ public class DocTable extends JPanel{
@@ -61,10 +66,23 @@ public class DocTable extends JPanel{
|
|
|
|
|
preview.addActionListener(ev -> preview(path)); |
|
|
|
|
buttons.add(preview); |
|
|
|
|
|
|
|
|
|
JButton drop = new JButton("Erledigt"); |
|
|
|
|
drop.addActionListener(ev -> drop(this)); |
|
|
|
|
buttons.add(drop); |
|
|
|
|
|
|
|
|
|
constraints.gridx = 2; |
|
|
|
|
add(buttons,constraints); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void drop(Row row) { |
|
|
|
|
remove(pathLabel); |
|
|
|
|
remove(status); |
|
|
|
|
remove(buttons); |
|
|
|
|
invalidate(); |
|
|
|
|
repaint(); |
|
|
|
|
rows.remove(path); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public Row status(String status) { |
|
|
|
|
this.status.setText(status); |
|
|
|
|
return this; |
|
|
|
@ -92,7 +110,7 @@ public class DocTable extends JPanel{
@@ -92,7 +110,7 @@ public class DocTable extends JPanel{
|
|
|
|
|
add(new JLabel("Aktionen"),constraints); |
|
|
|
|
previewListeners = new HashSet<>(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void add(String path) { |
|
|
|
|
if (!rows.containsKey(path)) new Row(path).status("neu"); |
|
|
|
|
} |
|
|
|
@ -102,15 +120,6 @@ public class DocTable extends JPanel{
@@ -102,15 +120,6 @@ public class DocTable extends JPanel{
|
|
|
|
|
return this; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void preview(String path) { |
|
|
|
|
LOG.debug("preview({})",path); |
|
|
|
|
File folder = new File(path); |
|
|
|
|
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())); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void joinDocs(String path) { |
|
|
|
|
|
|
|
|
|
LOG.debug("joinFiles({})",path); |
|
|
|
@ -160,7 +169,14 @@ public class DocTable extends JPanel{
@@ -160,7 +169,14 @@ public class DocTable extends JPanel{
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void preview(String path) { |
|
|
|
|
LOG.debug("preview({})",path); |
|
|
|
|
File folder = new File(path); |
|
|
|
|
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())); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void setState(String path, String state) { |
|
|
|
|
Row row = rows.get(path); |
|
|
|
|