GUI improvements
This commit is contained in:
2
pom.xml
2
pom.xml
@@ -4,7 +4,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>BelegScanner</groupId>
|
||||
<artifactId>BelegScanner</artifactId>
|
||||
<version>0.0.7</version>
|
||||
<version>0.0.8</version>
|
||||
|
||||
<name>BelegScanner</name>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
@@ -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{
|
||||
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{
|
||||
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{
|
||||
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{
|
||||
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{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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);
|
||||
|
||||
@@ -147,7 +147,10 @@ public class MainFrame extends JFrame {
|
||||
int errorCode = process.waitFor();
|
||||
if (errorCode != 0) {
|
||||
LOG.error("error code: {} for {}",errorCode,cmd);
|
||||
} else LOG.debug("error code: {}",errorCode);
|
||||
docTable.setState(path, "Scannen fehlgeschlagen.");
|
||||
toolbar.readyToScan(true);
|
||||
return;
|
||||
}
|
||||
|
||||
} catch (InterruptedException | IOException e) {
|
||||
LOG.error("{} terminated: ",builder,e);
|
||||
@@ -167,7 +170,10 @@ public class MainFrame extends JFrame {
|
||||
int errorCode = process.waitFor();
|
||||
if (errorCode != 0) {
|
||||
LOG.error("error code: {} for {}",errorCode,cmd);
|
||||
} else LOG.debug("error code: {}",errorCode);
|
||||
docTable.setState(path, "Konvertierung fehlgeschlagen.");
|
||||
toolbar.readyToScan(true);
|
||||
return;
|
||||
}
|
||||
|
||||
} catch (InterruptedException | IOException e) {
|
||||
LOG.error("{} terminated: ",builder,e);
|
||||
@@ -196,7 +202,9 @@ public class MainFrame extends JFrame {
|
||||
int errorCode = process.waitFor();
|
||||
if (errorCode != 0) {
|
||||
LOG.error("error code: {} for {}",errorCode,cmd);
|
||||
} else LOG.debug("error code: {}",errorCode);
|
||||
docTable.setState(path, "OCR fehlgeschlagen.");
|
||||
return;
|
||||
}
|
||||
|
||||
} catch (InterruptedException | IOException e) {
|
||||
LOG.error("{} terminated: ",builder,e);
|
||||
|
||||
Reference in New Issue
Block a user