19 package org.sleuthkit.autopsy.casemodule;
21 import java.awt.Frame;
23 import java.io.IOException;
24 import java.nio.charset.Charset;
25 import java.util.Collection;
26 import java.util.Iterator;
27 import java.util.logging.Level;
28 import javax.swing.SwingUtilities;
29 import org.apache.commons.io.FileUtils;
30 import org.apache.commons.lang3.StringUtils;
31 import org.openide.util.Lookup;
32 import org.openide.util.NbBundle;
33 import org.openide.windows.WindowManager;
60 if (instance == null) {
62 if (instance == null) {
73 "# {0} - autFilePath",
74 "StartupWindowProvider.openCase.noFile=Unable to open previously open case because metadata file not found at: {0}",
75 "# {0} - reOpenFilePath",
76 "StartupWindowProvider.openCase.deleteOpenFailure=Unable to open or delete file containing path {0} to previously open case. The previous case will not be opened.",
77 "# {0} - autFilePath",
78 "StartupWindowProvider.openCase.cantOpen=Unable to open previously open case with metadata file: {0}"})
80 if (startupWindowToUse == null) {
84 boolean headless = !WindowManager.getDefault().getMainWindow().isVisible();
88 if (defaultArg != null) {
93 logger.log(Level.INFO,
"Running from command line");
107 Collection<? extends StartupWindowInterface> startupWindows
110 int windowsCount = startupWindows.size();
111 switch (windowsCount) {
113 startupWindowToUse = startupWindows.iterator().next();
114 logger.log(Level.INFO,
"Will use the default startup window: {0}", startupWindowToUse.toString());
118 Iterator<? extends StartupWindowInterface> it = startupWindows.iterator();
119 while (it.hasNext()) {
122 startupWindowToUse = window;
123 logger.log(Level.INFO,
"Will use the custom startup window: {0}", startupWindowToUse.toString());
131 Iterator<? extends StartupWindowInterface> it = startupWindows.iterator();
132 while (it.hasNext()) {
134 if (!window.getClass().getCanonicalName().startsWith(
"org.sleuthkit.autopsy")) {
135 startupWindowToUse = window;
136 logger.log(Level.INFO,
"Will use the custom startup window: {0}", startupWindowToUse.toString());
144 if (startupWindowToUse == null) {
145 logger.log(Level.SEVERE,
"Unexpected error, no startup window chosen, using the default");
151 if (openPreviousCaseFile.exists()) {
154 String caseFilePath =
"";
155 String unableToOpenMessage = null;
158 Charset encoding = null;
159 caseFilePath = FileUtils.readFileToString(openPreviousCaseFile, encoding);
160 if (
new File(caseFilePath).exists()) {
161 FileUtils.forceDelete(openPreviousCaseFile);
167 unableToOpenMessage = Bundle.StartupWindowProvider_openCase_noFile(caseFilePath);
168 logger.log(Level.WARNING, unableToOpenMessage);
170 }
catch (IOException ex) {
172 logger.log(Level.WARNING, unableToOpenMessage, ex);
174 unableToOpenMessage = Bundle.StartupWindowProvider_openCase_cantOpen(caseFilePath);
175 logger.log(Level.WARNING, unableToOpenMessage, ex);
179 final String message = unableToOpenMessage;
180 SwingUtilities.invokeLater(() -> {
198 NbBundle.getMessage(SolrNotConfiguredDialog.class,
"SolrNotConfiguredDialog.EmptyKeywordSearchHostName"));
200 SolrNotConfiguredDialog dialog =
new SolrNotConfiguredDialog();
201 dialog.setVisible(
true);
216 if (processor != null) {
229 if (processor != null) {
237 if (startupWindowToUse != null) {
238 startupWindowToUse.
open();
244 if (startupWindowToUse != null) {
245 startupWindowToUse.
close();
static boolean runningWithGUI
static void warn(String message)
StartupWindowInterface getStartupWindow()
static volatile StartupWindowProvider instance
synchronized boolean isRunFromCommandLine()
static boolean getIsMultiUserModeEnabled()
String getDefaultArgument()
static String getCaseToReopenFilePath()
boolean isRunningFromCommandLine()
String getDefaultArgument()
volatile StartupWindowInterface startupWindowToUse
static void openAsCurrentCase(String caseMetadataFilePath)
static void error(String title, String message)
synchronized static Logger getLogger(String name)
static StartupWindowProvider getInstance()
static String getIndexingServerHost()
static final Logger logger