|
|
|
@ -8,17 +8,16 @@ import java.awt.event.ActionEvent;
@@ -8,17 +8,16 @@ import java.awt.event.ActionEvent;
|
|
|
|
|
import java.io.File; |
|
|
|
|
import java.io.IOException; |
|
|
|
|
import java.nio.file.Path; |
|
|
|
|
import java.util.Date; |
|
|
|
|
import java.util.HashMap; |
|
|
|
|
import java.util.HashSet; |
|
|
|
|
import java.util.*; |
|
|
|
|
import java.util.Map.Entry; |
|
|
|
|
import java.util.Vector; |
|
|
|
|
import java.util.regex.Matcher; |
|
|
|
|
import java.util.regex.Pattern; |
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
|
import javax.swing.BorderFactory; |
|
|
|
|
import javax.swing.JFrame; |
|
|
|
|
import javax.swing.JLabel; |
|
|
|
|
import javax.swing.JOptionPane; |
|
|
|
|
import javax.swing.JPanel; |
|
|
|
|
import javax.swing.SwingConstants; |
|
|
|
|
|
|
|
|
@ -32,6 +31,7 @@ import org.slf4j.LoggerFactory;
@@ -32,6 +31,7 @@ import org.slf4j.LoggerFactory;
|
|
|
|
|
|
|
|
|
|
import static de.srsoftware.belegscanner.Application.*; |
|
|
|
|
import de.srsoftware.belegscanner.Configuration; |
|
|
|
|
import de.srsoftware.belegscanner.Constants; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -136,7 +136,25 @@ public class MainFrame extends JFrame {
@@ -136,7 +136,25 @@ public class MainFrame extends JFrame {
|
|
|
|
|
while (matches.find()) marks.add(matches.group(1)); |
|
|
|
|
toolbar.addFieldsFor(marks); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void checkDependencies() { |
|
|
|
|
List<String> missing = List.of("convert --version", "killall --version", "pdfsandwich -version", "pdftk --version", "scanimage --version",Constants.FILE_BROWSER+" --version").stream().map(this::appMissing).filter(app -> app != null).collect(Collectors.toList()); |
|
|
|
|
if (!missing.isEmpty()) notifyAppsMissing(missing); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public String appMissing(String appTest){ |
|
|
|
|
List<String> cmd = Arrays.asList(appTest.split(" ")); |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
Process process = new ProcessBuilder(cmd).start(); |
|
|
|
|
int errorCode = process.waitFor(); |
|
|
|
|
if (errorCode == 0) return null; |
|
|
|
|
} catch (InterruptedException | IOException e) { |
|
|
|
|
LOG.error(t("{} terminated: "),appTest,e); |
|
|
|
|
} |
|
|
|
|
return cmd.get(0); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* checks, whether the scan button may be enabled. |
|
|
|
|
*/ |
|
|
|
@ -144,6 +162,22 @@ public class MainFrame extends JFrame {
@@ -144,6 +162,22 @@ public class MainFrame extends JFrame {
|
|
|
|
|
toolbar.readyToScan(!(isScanning || patchedPath==null || patchedPath.isBlank() || patchedPath.contains("$"))); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void notifyAppsMissing(List<String> missingApps) { |
|
|
|
|
StringBuilder message = new StringBuilder(); |
|
|
|
|
message.append("<html>"); |
|
|
|
|
message.append(t("This application requires the following helper commands to be installed:")); |
|
|
|
|
message.append("<ul>"); |
|
|
|
|
missingApps.forEach(app -> message.append("<li>").append(app).append("</li>")); |
|
|
|
|
message.append("</ul>"); |
|
|
|
|
|
|
|
|
|
JOptionPane.showMessageDialog(this, |
|
|
|
|
message, |
|
|
|
|
t("Apps missing"), |
|
|
|
|
JOptionPane.WARNING_MESSAGE); |
|
|
|
|
System.exit(-1); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* scan a new document, convert it to pdf and perform text recognition |
|
|
|
|
* @param path |
|
|
|
|