GUI improvements
This commit is contained in:
2
pom.xml
2
pom.xml
@@ -4,7 +4,7 @@
|
|||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>BelegScanner</groupId>
|
<groupId>BelegScanner</groupId>
|
||||||
<artifactId>BelegScanner</artifactId>
|
<artifactId>BelegScanner</artifactId>
|
||||||
<version>0.0.7</version>
|
<version>0.0.8</version>
|
||||||
|
|
||||||
<name>BelegScanner</name>
|
<name>BelegScanner</name>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|||||||
@@ -29,7 +29,8 @@ public class DocTable extends JPanel{
|
|||||||
private static final Logger LOG = LoggerFactory.getLogger(DocTable.class);
|
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 PAGES = (dir,name) -> name.toLowerCase().endsWith("pdf") && name.toLowerCase().startsWith("page");
|
||||||
private static FilenameFilter PDFS = (dir,name) -> name.toLowerCase().endsWith("pdf");
|
private static FilenameFilter PDFS = (dir,name) -> name.toLowerCase().endsWith("pdf");
|
||||||
|
private static int rowCounter = 0;
|
||||||
|
|
||||||
public interface PreviewListener{
|
public interface PreviewListener{
|
||||||
public void show(String filename);
|
public void show(String filename);
|
||||||
}
|
}
|
||||||
@@ -37,16 +38,20 @@ public class DocTable extends JPanel{
|
|||||||
private class Row{
|
private class Row{
|
||||||
|
|
||||||
private JLabel status;
|
private JLabel status;
|
||||||
|
private JLabel pathLabel;
|
||||||
|
private JPanel buttons;
|
||||||
|
private String path;
|
||||||
|
|
||||||
public Row(String path) {
|
public Row(String path) {
|
||||||
|
this.path = path;
|
||||||
rows.put(path, this);
|
rows.put(path, this);
|
||||||
constraints.gridy = rows.size();
|
constraints.gridy = ++rowCounter;
|
||||||
constraints.gridx = 0;
|
constraints.gridx = 0;
|
||||||
add(new JLabel(path), constraints);
|
add(pathLabel = new JLabel(path), constraints);
|
||||||
constraints.gridx = 1;
|
constraints.gridx = 1;
|
||||||
add(status = new JLabel("neu"),constraints);
|
add(status = new JLabel("neu"),constraints);
|
||||||
|
|
||||||
JPanel buttons = new JPanel();
|
buttons = new JPanel();
|
||||||
buttons.setLayout(new FlowLayout());
|
buttons.setLayout(new FlowLayout());
|
||||||
|
|
||||||
JButton folderButton = new JButton("Ordner öffnen");
|
JButton folderButton = new JButton("Ordner öffnen");
|
||||||
@@ -61,10 +66,23 @@ public class DocTable extends JPanel{
|
|||||||
preview.addActionListener(ev -> preview(path));
|
preview.addActionListener(ev -> preview(path));
|
||||||
buttons.add(preview);
|
buttons.add(preview);
|
||||||
|
|
||||||
|
JButton drop = new JButton("Erledigt");
|
||||||
|
drop.addActionListener(ev -> drop(this));
|
||||||
|
buttons.add(drop);
|
||||||
|
|
||||||
constraints.gridx = 2;
|
constraints.gridx = 2;
|
||||||
add(buttons,constraints);
|
add(buttons,constraints);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void drop(Row row) {
|
||||||
|
remove(pathLabel);
|
||||||
|
remove(status);
|
||||||
|
remove(buttons);
|
||||||
|
invalidate();
|
||||||
|
repaint();
|
||||||
|
rows.remove(path);
|
||||||
|
}
|
||||||
|
|
||||||
public Row status(String status) {
|
public Row status(String status) {
|
||||||
this.status.setText(status);
|
this.status.setText(status);
|
||||||
return this;
|
return this;
|
||||||
@@ -92,7 +110,7 @@ public class DocTable extends JPanel{
|
|||||||
add(new JLabel("Aktionen"),constraints);
|
add(new JLabel("Aktionen"),constraints);
|
||||||
previewListeners = new HashSet<>();
|
previewListeners = new HashSet<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void add(String path) {
|
public void add(String path) {
|
||||||
if (!rows.containsKey(path)) new Row(path).status("neu");
|
if (!rows.containsKey(path)) new Row(path).status("neu");
|
||||||
}
|
}
|
||||||
@@ -102,15 +120,6 @@ public class DocTable extends JPanel{
|
|||||||
return this;
|
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) {
|
public void joinDocs(String path) {
|
||||||
|
|
||||||
LOG.debug("joinFiles({})",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) {
|
public void setState(String path, String state) {
|
||||||
Row row = rows.get(path);
|
Row row = rows.get(path);
|
||||||
|
|||||||
@@ -147,7 +147,10 @@ public class MainFrame extends JFrame {
|
|||||||
int errorCode = process.waitFor();
|
int errorCode = process.waitFor();
|
||||||
if (errorCode != 0) {
|
if (errorCode != 0) {
|
||||||
LOG.error("error code: {} for {}",errorCode,cmd);
|
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) {
|
} catch (InterruptedException | IOException e) {
|
||||||
LOG.error("{} terminated: ",builder,e);
|
LOG.error("{} terminated: ",builder,e);
|
||||||
@@ -167,7 +170,10 @@ public class MainFrame extends JFrame {
|
|||||||
int errorCode = process.waitFor();
|
int errorCode = process.waitFor();
|
||||||
if (errorCode != 0) {
|
if (errorCode != 0) {
|
||||||
LOG.error("error code: {} for {}",errorCode,cmd);
|
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) {
|
} catch (InterruptedException | IOException e) {
|
||||||
LOG.error("{} terminated: ",builder,e);
|
LOG.error("{} terminated: ",builder,e);
|
||||||
@@ -196,7 +202,9 @@ public class MainFrame extends JFrame {
|
|||||||
int errorCode = process.waitFor();
|
int errorCode = process.waitFor();
|
||||||
if (errorCode != 0) {
|
if (errorCode != 0) {
|
||||||
LOG.error("error code: {} for {}",errorCode,cmd);
|
LOG.error("error code: {} for {}",errorCode,cmd);
|
||||||
} else LOG.debug("error code: {}",errorCode);
|
docTable.setState(path, "OCR fehlgeschlagen.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
} catch (InterruptedException | IOException e) {
|
} catch (InterruptedException | IOException e) {
|
||||||
LOG.error("{} terminated: ",builder,e);
|
LOG.error("{} terminated: ",builder,e);
|
||||||
|
|||||||
Reference in New Issue
Block a user