GUI improvements

This commit is contained in:
2022-01-05 13:54:25 +01:00
parent 1c07196e27
commit 0c107f7964
4 changed files with 22 additions and 5 deletions

View File

@@ -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.8</version> <version>0.0.9</version>
<name>BelegScanner</name> <name>BelegScanner</name>
<packaging>jar</packaging> <packaging>jar</packaging>

View File

@@ -41,6 +41,7 @@ public class DocTable extends JPanel{
private JLabel pathLabel; private JLabel pathLabel;
private JPanel buttons; private JPanel buttons;
private String path; private String path;
private JButton joinButton;
public Row(String path) { public Row(String path) {
this.path = path; this.path = path;
@@ -58,7 +59,7 @@ public class DocTable extends JPanel{
folderButton.addActionListener(ev -> openFolder(path)); folderButton.addActionListener(ev -> openFolder(path));
buttons.add(folderButton); buttons.add(folderButton);
JButton joinButton = new JButton("Zusammenfügen"); joinButton = new JButton("Zusammenfügen");
joinButton.addActionListener(ev -> joinDocs(path)); joinButton.addActionListener(ev -> joinDocs(path));
buttons.add(joinButton); buttons.add(joinButton);
@@ -88,6 +89,10 @@ public class DocTable extends JPanel{
return this; return this;
} }
public void removeJoinButton() {
buttons.remove(joinButton);
}
} }
private static final long serialVersionUID = 1073955198529023744L; private static final long serialVersionUID = 1073955198529023744L;
@@ -121,8 +126,8 @@ public class DocTable extends JPanel{
} }
public void joinDocs(String path) { public void joinDocs(String path) {
LOG.debug("joinFiles({})",path); LOG.debug("joinFiles({})",path);
rows.get(path).removeJoinButton();
File folder = new File(path); File folder = new File(path);
if (!folder.exists()) return; if (!folder.exists()) return;
@@ -150,6 +155,7 @@ public class DocTable extends JPanel{
} }
for (String page : pdfs) Path.of(path,page).toFile().delete(); for (String page : pdfs) Path.of(path,page).toFile().delete();
setState(path,"Zusammengefügt."); setState(path,"Zusammengefügt.");
preview(path);
} }
public void openFolder(String path) { public void openFolder(String path) {

View File

@@ -180,7 +180,6 @@ public class MainFrame extends JFrame {
} }
Path.of(path, raw).toFile().delete(); Path.of(path, raw).toFile().delete();
docTable.preview(path);
String ocr = "page."+timestamp+".ocr.pdf"; String ocr = "page."+timestamp+".ocr.pdf";
@@ -232,6 +231,7 @@ public class MainFrame extends JFrame {
pdfViewer.openDocument(file); pdfViewer.openDocument(file);
//pdfViewer.setToolBarVisible(false); //pdfViewer.setToolBarVisible(false);
pdfViewer.setPageFitMode(DocumentViewController.PAGE_FIT_WINDOW_WIDTH, false); pdfViewer.setPageFitMode(DocumentViewController.PAGE_FIT_WINDOW_WIDTH, false);
statusBar.setFile(file);
} }
private void scan(ActionEvent ev) { private void scan(ActionEvent ev) {

View File

@@ -1,5 +1,7 @@
package de.srsoftware.belegscanner.gui; package de.srsoftware.belegscanner.gui;
import java.io.File;
import javax.swing.BoxLayout; import javax.swing.BoxLayout;
import javax.swing.JLabel; import javax.swing.JLabel;
import javax.swing.JPanel; import javax.swing.JPanel;
@@ -13,12 +15,14 @@ public class StatusBar extends JPanel {
private static final long serialVersionUID = 8102800846089594705L; private static final long serialVersionUID = 8102800846089594705L;
private JLabel path; private JLabel path;
private JLabel file;
//private JLabel action; //private JLabel action;
public StatusBar() { public StatusBar() {
setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
//add(action = new JLabel("Bereit.")); //add(action = new JLabel("Bereit."));
add(file = new JLabel());
add(path = new JLabel("Kein Pfad gewält.")); add(path = new JLabel("Kein Pfad gewält."));
} }
@@ -27,4 +31,11 @@ public class StatusBar extends JPanel {
this.path.setText(path); this.path.setText(path);
return this; return this;
} }
public StatusBar setFile(String path) {
File file = new File(path);
String dir = file.getParentFile().getName();
this.file.setText(dir + File.separator + file.getName());
return this;
}
} }