diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/Case.java b/Core/src/org/sleuthkit/autopsy/casemodule/Case.java index 0923666a87e..b5818afb42c 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/Case.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/Case.java @@ -26,6 +26,7 @@ import java.awt.Cursor; import org.sleuthkit.autopsy.casemodule.multiusercases.CaseNodeData; import java.awt.Frame; +import java.awt.GraphicsEnvironment; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.beans.PropertyChangeListener; @@ -207,9 +208,11 @@ public class Case { * changing the main window title. */ static { - WindowManager.getDefault().invokeWhenUIReady(() -> { - mainFrame = WindowManager.getDefault().getMainWindow(); - }); + if (!GraphicsEnvironment.isHeadless()) { + WindowManager.getDefault().invokeWhenUIReady(() -> { + mainFrame = WindowManager.getDefault().getMainWindow(); + }); + } } /** diff --git a/Core/src/org/sleuthkit/autopsy/core/Installer.java b/Core/src/org/sleuthkit/autopsy/core/Installer.java index 374d5b8ccb3..a2fe9c99543 100644 --- a/Core/src/org/sleuthkit/autopsy/core/Installer.java +++ b/Core/src/org/sleuthkit/autopsy/core/Installer.java @@ -406,7 +406,11 @@ public void restored() { ensurePythonModulesFolderExists(); ensureClassifierFolderExists(); ensureOcrLanguagePacksFolderExists(); - initJavaFx(); + + if (!GraphicsEnvironment.isHeadless()) { + initJavaFx(); + } + initializeSevenZip(); for (ModuleInstall mi : packageInstallers) { try { @@ -544,7 +548,10 @@ public void uninstalled() { @Override public boolean closing() { if (IngestRunningCheck.checkAndConfirmProceed(Bundle.Installer_closing_confirmationDialog_title(), Bundle.Installer_closing_confirmationDialog_message())) { - WindowManager.getDefault().getMainWindow().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); + if (!GraphicsEnvironment.isHeadless() && RuntimeProperties.runningWithGUI()) { + WindowManager.getDefault().getMainWindow().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); + } + FutureTask future = new FutureTask<>(new Callable() { @Override public Void call() throws Exception { @@ -562,7 +569,9 @@ public Void call() throws Exception { logger.log(Level.SEVERE, "Error closing the current case", ex); MessageNotifyUtil.Message.error(Bundle.Installer_closing_messageBox_caseCloseExceptionMessage(ex.getMessage())); } finally { - WindowManager.getDefault().getMainWindow().setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); + if (!GraphicsEnvironment.isHeadless() && RuntimeProperties.runningWithGUI()) { + WindowManager.getDefault().getMainWindow().setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); + } } return true; } else { diff --git a/Core/src/org/sleuthkit/autopsy/corecomponents/Installer.java b/Core/src/org/sleuthkit/autopsy/corecomponents/Installer.java index 74412e9c621..fc12e31064f 100644 --- a/Core/src/org/sleuthkit/autopsy/corecomponents/Installer.java +++ b/Core/src/org/sleuthkit/autopsy/corecomponents/Installer.java @@ -19,6 +19,7 @@ package org.sleuthkit.autopsy.corecomponents; import java.awt.Font; +import java.awt.GraphicsEnvironment; import java.awt.Insets; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; @@ -39,10 +40,10 @@ import org.netbeans.spi.sendopts.OptionProcessor; import org.netbeans.swing.tabcontrol.plaf.DefaultTabbedContainerUI; import org.openide.modules.ModuleInstall; -import org.openide.util.Exceptions; import org.openide.util.Lookup; import org.openide.windows.WindowManager; import org.sleuthkit.autopsy.casemodule.StartupWindowProvider; +import org.sleuthkit.autopsy.commandlineingest.CommandLineIngestManager; import org.sleuthkit.autopsy.commandlineingest.CommandLineOptionProcessor; import org.sleuthkit.autopsy.coreutils.Logger; import org.sleuthkit.autopsy.coreutils.ModuleSettings; @@ -80,12 +81,15 @@ public void restored() { } - SwingUtilities.invokeLater(() -> { - setLookAndFeel(); - }); - UIManager.put("ViewTabDisplayerUI", "org.sleuthkit.autopsy.corecomponents.NoTabsTabDisplayerUI"); - UIManager.put(DefaultTabbedContainerUI.KEY_VIEW_CONTENT_BORDER, BorderFactory.createEmptyBorder()); - UIManager.put("TabbedPane.contentBorderInsets", new Insets(0, 0, 0, 0)); + if (!GraphicsEnvironment.isHeadless()) { + SwingUtilities.invokeLater(() -> { + setLookAndFeel(); + }); + + UIManager.put("ViewTabDisplayerUI", "org.sleuthkit.autopsy.corecomponents.NoTabsTabDisplayerUI"); + UIManager.put(DefaultTabbedContainerUI.KEY_VIEW_CONTENT_BORDER, BorderFactory.createEmptyBorder()); + UIManager.put("TabbedPane.contentBorderInsets", new Insets(0, 0, 0, 0)); + } final CommandLineOptionProcessor finalprocessor = processor; @@ -100,20 +104,35 @@ public void restored() { // Why not just listen to the command processor instead of using the invokeWhen? // If there were no command line options supplied then the process method will never // be called. - WindowManager.getDefault().invokeWhenUIReady(() -> { - if(WindowManager.getDefault().getMainWindow().isVisible() || finalprocessor == null || finalprocessor.getState() == CommandLineOptionProcessor.ProcessState.COMPLETED) { - StartupWindowProvider.getInstance().open(); + if (GraphicsEnvironment.isHeadless()) { + if (finalprocessor.getState() == CommandLineOptionProcessor.ProcessState.COMPLETED) { + new CommandLineIngestManager().start(); } else { - finalprocessor.addPropertyChangeListener(new PropertyChangeListener(){ + finalprocessor.addPropertyChangeListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { - if(evt.getPropertyName().equals(CommandLineOptionProcessor.PROCESSING_COMPLETED)) { - StartupWindowProvider.getInstance().open(); + if (evt.getPropertyName().equals(CommandLineOptionProcessor.PROCESSING_COMPLETED)) { + new CommandLineIngestManager().start(); } - } + } }); - } - }); + } + } else { + WindowManager.getDefault().invokeWhenUIReady(() -> { + if(WindowManager.getDefault().getMainWindow().isVisible() || finalprocessor == null || finalprocessor.getState() == CommandLineOptionProcessor.ProcessState.COMPLETED) { + StartupWindowProvider.getInstance().open(); + } else { + finalprocessor.addPropertyChangeListener(new PropertyChangeListener(){ + @Override + public void propertyChange(PropertyChangeEvent evt) { + if(evt.getPropertyName().equals(CommandLineOptionProcessor.PROCESSING_COMPLETED)) { + StartupWindowProvider.getInstance().open(); + } + } + }); + } + }); + } } @Override diff --git a/Core/src/org/sleuthkit/autopsy/ingest/IngestManager.java b/Core/src/org/sleuthkit/autopsy/ingest/IngestManager.java index 01938c326c0..90de8a188fb 100644 --- a/Core/src/org/sleuthkit/autopsy/ingest/IngestManager.java +++ b/Core/src/org/sleuthkit/autopsy/ingest/IngestManager.java @@ -21,6 +21,7 @@ import com.google.common.eventbus.Subscribe; import com.google.common.util.concurrent.ThreadFactoryBuilder; import java.awt.EventQueue; +import java.awt.GraphicsEnvironment; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.io.Serializable; @@ -574,15 +575,17 @@ IngestJobStartResult startIngestJob(IngestJob job) { // initialize IngestMessageInbox, if it hasn't been initialized yet. This can't be done in // the constructor because that ends up freezing the UI on startup (JIRA-7345). - if (SwingUtilities.isEventDispatchThread()) { - initIngestMessageInbox(); - } else { - try { - SwingUtilities.invokeAndWait(() -> initIngestMessageInbox()); - } catch (InterruptedException ex) { - // ignore interruptions - } catch (InvocationTargetException ex) { - logger.log(Level.WARNING, "There was an error starting ingest message inbox", ex); + if (!GraphicsEnvironment.isHeadless()) { + if (SwingUtilities.isEventDispatchThread()) { + initIngestMessageInbox(); + } else { + try { + SwingUtilities.invokeAndWait(() -> initIngestMessageInbox()); + } catch (InterruptedException ex) { + // ignore interruptions + } catch (InvocationTargetException ex) { + logger.log(Level.WARNING, "There was an error starting ingest message inbox", ex); + } } } diff --git a/Core/src/org/sleuthkit/autopsy/ingest/Installer.java b/Core/src/org/sleuthkit/autopsy/ingest/Installer.java index 19fa852b205..91aaa2c534b 100644 --- a/Core/src/org/sleuthkit/autopsy/ingest/Installer.java +++ b/Core/src/org/sleuthkit/autopsy/ingest/Installer.java @@ -18,6 +18,7 @@ */ package org.sleuthkit.autopsy.ingest; +import java.awt.GraphicsEnvironment; import java.io.File; import java.io.FileInputStream; import java.io.IOException; @@ -68,7 +69,9 @@ public void restored() { @Override public boolean closing() { //force ingest inbox closed on exit and save state as such - IngestMessageTopComponent.findInstance().close(); + if (!GraphicsEnvironment.isHeadless()) { + IngestMessageTopComponent.findInstance().close(); + } return true; }