diff --git a/Core/src/org/sleuthkit/autopsy/contentviewers/PDFViewer.java b/Core/src/org/sleuthkit/autopsy/contentviewers/PDFViewer.java index b21a48a1937af96fc171f5b7cbbda0d9106c6f07..59e276ce435472c7e1c67bd4389c9ce65609b2c1 100755 --- a/Core/src/org/sleuthkit/autopsy/contentviewers/PDFViewer.java +++ b/Core/src/org/sleuthkit/autopsy/contentviewers/PDFViewer.java @@ -20,6 +20,7 @@ import java.awt.BorderLayout; import java.awt.Component; +import java.awt.Container; import java.io.IOException; import java.lang.reflect.InvocationTargetException; import java.util.Arrays; @@ -97,6 +98,9 @@ public void setFile(AbstractFile file) { // Add the IcePDF view to the center of our container. this.container.add(icePdfPanel, BorderLayout.CENTER); + + // Disable all components until the document is ready to view. + enableComponents(container, false); // Document is the 'M' in IcePDFs MVC set up. Read the data needed to // populate the model in the background. @@ -122,12 +126,13 @@ protected void done() { // will cause UI widgets to be updated. try { Document doc = get(); - controller.openDocument(doc, null); + controller.openDocument(doc, file.getName()); // This makes the PDF viewer appear as one continuous // document, which is the default for most popular PDF viewers. controller.setPageViewMode(DocumentViewControllerImpl.ONE_COLUMN_VIEW, true); // This makes it possible to select text by left clicking and dragging. controller.setDisplayTool(DocumentViewModelImpl.DISPLAY_TOOL_TEXT_SELECTION); + enableComponents(container, true); } catch (InterruptedException ex) { // Do nothing. } catch (ExecutionException ex) { @@ -140,10 +145,28 @@ protected void done() { file.getId(), file.getName()), ex); showErrorDialog(); } + } catch (Throwable ex) { + logger.log(Level.WARNING, String.format("PDF content viewer " + + "was unable to open document with id %d and name %s", + file.getId(), file.getName()), ex); } } }.execute(); } + + /** + * Recursively enable/disable all components in this content viewer. + * This will disable/enable all internal IcePDF Swing components too. + */ + private void enableComponents(Container container, boolean enabled) { + Component[] components = container.getComponents(); + for(Component component : components) { + component.setEnabled(enabled); + if (component instanceof Container) { + enableComponents((Container)component, enabled); + } + } + } @Override public Component getComponent() {