improving GUI
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.5</version>
|
||||
<version>0.0.6</version>
|
||||
|
||||
<name>BelegScanner</name>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
@@ -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{
|
||||
|
||||
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{
|
||||
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{
|
||||
|
||||
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{
|
||||
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{
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
@@ -108,12 +108,12 @@ public class MainFrame extends JFrame {
|
||||
|
||||
pdfViewer = new SwingController();
|
||||
SwingViewBuilder factory = new SwingViewBuilder(pdfViewer);
|
||||
|
||||
JPanel viewerComponentPanel = factory.buildViewerPanel();
|
||||
|
||||
ComponentKeyBinding.install(pdfViewer, viewerComponentPanel);
|
||||
// add interactive mouse link annotation support via callback
|
||||
pdfViewer.getDocumentViewController().setAnnotationCallback(new org.icepdf.ri.common.MyAnnotationCallback(pdfViewer.getDocumentViewController()));
|
||||
|
||||
return viewerComponentPanel;
|
||||
}
|
||||
|
||||
@@ -124,7 +124,7 @@ public class MainFrame extends JFrame {
|
||||
toolbar.addFieldsFor(marks);
|
||||
};
|
||||
|
||||
private void performScan(String path) {
|
||||
private void performScan(String path, Dimension dimension) {
|
||||
LOG.debug("performScan({})",path);
|
||||
toolbar.readyToScan(false);
|
||||
File folder = new File(path);
|
||||
@@ -187,6 +187,8 @@ public class MainFrame extends JFrame {
|
||||
}
|
||||
|
||||
Path.of(path, raw).toFile().delete();
|
||||
docTable.preview(path);
|
||||
|
||||
String ocr = "page."+timestamp+".ocr.pdf";
|
||||
|
||||
cmd = new Vector<>();
|
||||
@@ -214,11 +216,12 @@ public class MainFrame extends JFrame {
|
||||
}
|
||||
Path.of(path, pdf).toFile().delete();
|
||||
docTable.setState(path,"Texterkennung beendet.");
|
||||
docTable.preview(path);
|
||||
}
|
||||
|
||||
private void scan(ActionEvent ev) {
|
||||
updateConfig();
|
||||
new Thread(() -> performScan(patchedPath)).start();
|
||||
new Thread(() -> performScan(patchedPath,dimension)).start();
|
||||
}
|
||||
|
||||
private void setCategory(String category) {
|
||||
|
||||
@@ -123,6 +123,7 @@ public class Toolbar extends JPanel {
|
||||
|
||||
|
||||
protected void updateDimensions() {
|
||||
LOG.debug("updateDimensions()");
|
||||
try {
|
||||
int w = Integer.parseInt(width.getText().trim());
|
||||
int h = Integer.parseInt(height.getText().trim());
|
||||
@@ -279,6 +280,7 @@ public class Toolbar extends JPanel {
|
||||
Integer h = config.get(prefix+"size.h");
|
||||
LOG.debug("h: {}",h);
|
||||
height.setText(h == null ? Constants.DEFAULT_HEIGHT : h+"");
|
||||
updateDimensions();
|
||||
} else LOG.debug("newCat is empty!");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user