Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

headless graphics environment #7691

Open
wants to merge 21 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
45712ab
ui calls don't occur with headless
gdicristofaro Sep 23, 2022
8a402d8
space fix
gdicristofaro Sep 23, 2022
9e63585
Merge branch 'develop' of github.com:sleuthkit/autopsy into graphicsE…
gdicristofaro Jan 17, 2023
54acb53
fix for headless to wait for command line option processor to finish
gdicristofaro Jan 19, 2023
d0950ff
Merge branch 'develop' of github.com:sleuthkit/autopsy into graphicsE…
gdicristofaro Jan 25, 2023
836eb53
merge from develop
gdicristofaro May 19, 2023
c2f0854
Merge branch 'develop' of github.com:sleuthkit/autopsy into graphicsE…
gdicristofaro May 30, 2023
8a83987
Merge branch 'develop' of github.com:sleuthkit/autopsy into graphicsE…
gdicristofaro Jun 6, 2023
6622f78
Merge branch 'develop' of github.com:sleuthkit/autopsy into graphicsE…
gdicristofaro Jun 16, 2023
fca37c5
Merge branch 'develop' of github.com:sleuthkit/autopsy into graphicsE…
gdicristofaro Jun 29, 2023
ef0affd
Merge branch 'develop' of github.com:sleuthkit/autopsy into graphicsE…
gdicristofaro Jul 13, 2023
cdf93d7
Merge branch 'develop' of github.com:sleuthkit/autopsy into graphicsE…
gdicristofaro Aug 23, 2023
905424d
Merge branch 'develop' of github.com:sleuthkit/autopsy into graphicsE…
gdicristofaro Aug 25, 2023
842d1fb
Merge branch 'release-4.21.0' of github.com:sleuthkit/autopsy into gr…
gdicristofaro Aug 30, 2023
abf041c
Merge branch 'develop' of github.com:sleuthkit/autopsy into graphicsE…
gdicristofaro Aug 30, 2023
feb5a17
Merge branch 'develop' of github.com:sleuthkit/autopsy into graphicsE…
gdicristofaro Aug 30, 2023
e561c4a
Merge branch 'develop' of github.com:sleuthkit/autopsy into graphicsE…
gdicristofaro Oct 23, 2023
2d221c6
Merge branch 'develop' of github.com:sleuthkit/autopsy into graphicsE…
gdicristofaro Nov 28, 2023
bc2db58
Merge branch 'develop' of github.com:sleuthkit/autopsy into graphicsE…
gdicristofaro Dec 12, 2023
0059103
Merge branch 'develop' of github.com:sleuthkit/autopsy into graphicsE…
gdicristofaro Apr 24, 2024
f6eb429
Merge branch 'develop' of github.com:sleuthkit/autopsy into graphicsE…
gdicristofaro May 10, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 6 additions & 3 deletions Core/src/org/sleuthkit/autopsy/casemodule/Case.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
});
}
}

/**
Expand Down
15 changes: 12 additions & 3 deletions Core/src/org/sleuthkit/autopsy/core/Installer.java
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,11 @@ public void restored() {
ensurePythonModulesFolderExists();
ensureClassifierFolderExists();
ensureOcrLanguagePacksFolderExists();
initJavaFx();

if (!GraphicsEnvironment.isHeadless()) {
initJavaFx();
}

initializeSevenZip();
for (ModuleInstall mi : packageInstallers) {
try {
Expand Down Expand Up @@ -543,7 +547,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<Void> future = new FutureTask<>(new Callable<Void>() {
@Override
public Void call() throws Exception {
Expand All @@ -561,7 +568,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 {
Expand Down
51 changes: 35 additions & 16 deletions Core/src/org/sleuthkit/autopsy/corecomponents/Installer.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;

Expand All @@ -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
Expand Down
21 changes: 12 additions & 9 deletions Core/src/org/sleuthkit/autopsy/ingest/IngestManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
}
}

Expand Down
5 changes: 4 additions & 1 deletion Core/src/org/sleuthkit/autopsy/ingest/Installer.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}

Expand Down