diff --git a/greenfield-apps/src/test/java/org/verapdf/apps/test/TempFileClosingTest.java b/greenfield-apps/src/test/java/org/verapdf/apps/test/TempFileClosingTest.java index cf032852..6e1160ae 100644 --- a/greenfield-apps/src/test/java/org/verapdf/apps/test/TempFileClosingTest.java +++ b/greenfield-apps/src/test/java/org/verapdf/apps/test/TempFileClosingTest.java @@ -21,10 +21,10 @@ public class TempFileClosingTest { private int initialFileAmount; public void test() throws VeraPDFException { - File testFile = new File(TEST_FILE); switchTempDir(); initialFileAmount = getAmountOfFiles(currentTempDir); try { + File testFile = new File(TEST_FILE); GreenfieldCliWrapper.main(new String[] {testFile.getAbsolutePath(), FORMAT_OPTION, TEXT_VARIANT}); } catch (VeraPDFException e) { System.setProperty(TEMP_DIR_PROPERTY, initialTempDir.getAbsolutePath()); diff --git a/gui/src/main/java/org/verapdf/apps/SoftwareUpdaterImpl.java b/gui/src/main/java/org/verapdf/apps/SoftwareUpdaterImpl.java index 59e7cc91..82d6f961 100644 --- a/gui/src/main/java/org/verapdf/apps/SoftwareUpdaterImpl.java +++ b/gui/src/main/java/org/verapdf/apps/SoftwareUpdaterImpl.java @@ -110,9 +110,9 @@ public String getLatestVersion(final ReleaseDetails details) { private static SemanticVersionNumber getLatestVersionFromUrl(final String endpoint) { try { - URL url = new URL(endpoint); DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); builder.setErrorHandler(null); + URL url = new URL(endpoint); Document doc = builder.parse(new InputSource(url.openStream())); XPath path = XPathFactory.newInstance().newXPath(); NodeList versions = ((NodeList) path.evaluate("//str[@name='v']", doc, XPathConstants.NODESET)); diff --git a/gui/src/main/java/org/verapdf/cli/VeraPdfCliProcessor.java b/gui/src/main/java/org/verapdf/cli/VeraPdfCliProcessor.java index cc7e2a0d..57cb6f37 100644 --- a/gui/src/main/java/org/verapdf/cli/VeraPdfCliProcessor.java +++ b/gui/src/main/java/org/verapdf/cli/VeraPdfCliProcessor.java @@ -79,7 +79,6 @@ ProcessorConfig getProcessorConfig() { } ExitCodes processPaths(final List pdfPaths, boolean nonPdfExt) throws VeraPDFException { - ExitCodes retStatus = ExitCodes.VALID; if (isServerMode) { try { this.tempFile = Files.createTempFile("tempReport", ".xml").toFile(); @@ -91,6 +90,7 @@ ExitCodes processPaths(final List pdfPaths, boolean nonPdfExt) throws Ve this.os = System.out; } // If the path list is empty then process the STDIN stream + ExitCodes retStatus = ExitCodes.VALID; if (pdfPaths.isEmpty() && !isServerMode) { retStatus = processStdIn(); } else { diff --git a/gui/src/main/java/org/verapdf/gui/MiniLogoPanel.java b/gui/src/main/java/org/verapdf/gui/MiniLogoPanel.java index 8ab03507..9c0240b5 100644 --- a/gui/src/main/java/org/verapdf/gui/MiniLogoPanel.java +++ b/gui/src/main/java/org/verapdf/gui/MiniLogoPanel.java @@ -46,30 +46,37 @@ class MiniLogoPanel extends JPanel { label.setToolTipText(GUIConstants.LABEL_TOOL_TIP); try (InputStream is = getClass().getClassLoader().getResourceAsStream(logoPath)) { final BufferedImage image = ImageIO.read(is); - Icon icon = new Icon() { - - private static final double SCALE = 0.3; - - @Override - public void paintIcon(Component c, Graphics g, int x, int y) { - g.drawImage(image, 0, 0, getIconWidth(), getIconHeight(), 0, 0, image.getWidth(), image.getHeight(), - null); - } - - @Override - public int getIconWidth() { - return (int) (image.getWidth() * SCALE); - } - - @Override - public int getIconHeight() { - return (int) (image.getHeight() * SCALE); - } - }; + Icon icon = new VeraPDFIcon(image); label.setIcon(icon); } add(label); } + + private static class VeraPDFIcon implements Icon { + + private static final double SCALE = 0.3; + private final BufferedImage image; + + public VeraPDFIcon(BufferedImage image) { + this.image = image; + } + + @Override + public void paintIcon(Component c, Graphics g, int x, int y) { + g.drawImage(image, 0, 0, getIconWidth(), getIconHeight(), 0, 0, image.getWidth(), image.getHeight(), + null); + } + + @Override + public int getIconWidth() { + return (int) (image.getWidth() * SCALE); + } + + @Override + public int getIconHeight() { + return (int) (image.getHeight() * SCALE); + } + } } diff --git a/gui/src/main/java/org/verapdf/gui/SettingsPanel.java b/gui/src/main/java/org/verapdf/gui/SettingsPanel.java index 43c2fd17..9e7c9931 100644 --- a/gui/src/main/java/org/verapdf/gui/SettingsPanel.java +++ b/gui/src/main/java/org/verapdf/gui/SettingsPanel.java @@ -133,10 +133,9 @@ class SettingsPanel extends JPanel { panel.add(new JLabel(GUIConstants.SELECTED_PATH_FOR_FIXER_LABEL_TEXT)); - File currentDir = new File(new File(GUIConstants.DOT).getCanonicalPath()); - JButton choose2 = new JButton(GUIConstants.FIX_METADATA_FOLDER_CHOOSE_BUTTON); this.folderChooser = new JFileChooser(); + File currentDir = new File(new File(GUIConstants.DOT).getCanonicalPath()); this.folderChooser.setCurrentDirectory(currentDir); this.folderChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); choose2.addActionListener(new ActionListener() { diff --git a/gui/src/main/java/org/verapdf/gui/ValidateWorker.java b/gui/src/main/java/org/verapdf/gui/ValidateWorker.java index 1d8f63b0..145901cf 100644 --- a/gui/src/main/java/org/verapdf/gui/ValidateWorker.java +++ b/gui/src/main/java/org/verapdf/gui/ValidateWorker.java @@ -162,8 +162,8 @@ protected void done() { private void writeHtmlReport() { final String extension = "html"; - final String ext = '.' + extension; try { + final String ext = '.' + extension; this.htmlReport = File.createTempFile("veraPDF-tempHTMLReport", ext); //$NON-NLS-1$ this.htmlReport.deleteOnExit(); try (InputStream xmlStream = new FileInputStream(this.xmlReport); @@ -173,10 +173,10 @@ private void writeHtmlReport() { this.configManager.getApplicationConfig().getWikiPath(), true); } catch (IOException | TransformerException excep) { - final String message = String.format(GUIConstants.IOEXCEP_SAVING_REPORT, extension); JOptionPane.showMessageDialog(this.parent, String.format(GUIConstants.IOEXCEP_SAVING_REPORT, extension), GUIConstants.ERROR, JOptionPane.ERROR_MESSAGE); + final String message = String.format(GUIConstants.IOEXCEP_SAVING_REPORT, extension); logger.log(Level.SEVERE, message, excep); this.htmlReport = null; }