This commit is contained in:
Sean-M 2013-05-10 16:04:51 -04:00
commit fb14384e71
12 changed files with 162 additions and 34 deletions

View File

@ -816,7 +816,7 @@ public class Case {
* Invoke the creation of startup dialog window. * Invoke the creation of startup dialog window.
*/ */
static public void invokeStartupDialog() { static public void invokeStartupDialog() {
StartupWindow.getInstance().open(); StartupWindowProvider.getInstance().open();
} }
/** /**

View File

@ -86,7 +86,7 @@ public final class CaseCloseAction extends CallableSystemAction implements Prese
EventQueue.invokeLater(new Runnable() { EventQueue.invokeLater(new Runnable() {
@Override @Override
public void run() { public void run() {
StartupWindow.getInstance().open(); StartupWindowProvider.getInstance().open();
} }
}); });
} catch (Exception ex) { } catch (Exception ex) {

View File

@ -85,7 +85,7 @@ public final class CaseOpenAction implements ActionListener {
} else { } else {
// try to close Startup window if there's one // try to close Startup window if there's one
try { try {
StartupWindow.getInstance().close(); StartupWindowProvider.getInstance().close();
} catch (Exception ex) { } catch (Exception ex) {
// no need to show the error message to the user. // no need to show the error message to the user.
logger.log(Level.WARNING, "Error closing startup window.", ex); logger.log(Level.WARNING, "Error closing startup window.", ex);
@ -97,7 +97,7 @@ public final class CaseOpenAction implements ActionListener {
+ ": " + ex.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); + ": " + ex.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
logger.log(Level.WARNING, "Error opening case in folder " + path, ex); logger.log(Level.WARNING, "Error opening case in folder " + path, ex);
StartupWindow.getInstance().open(); StartupWindowProvider.getInstance().open();
} }
} }
} }

View File

@ -291,7 +291,7 @@ class NewCaseWizardPanel1 implements WizardDescriptor.ValidatingPanel<WizardDesc
createdDirectory = caseDirPath; createdDirectory = caseDirPath;
// try to close Startup window if there's one // try to close Startup window if there's one
try { try {
StartupWindow.getInstance().close(); StartupWindowProvider.getInstance().close();
} catch (Exception ex) { } catch (Exception ex) {
logger.log(Level.WARNING, "Startup window didn't close as expected.", ex); logger.log(Level.WARNING, "Startup window didn't close as expected.", ex);

View File

@ -187,7 +187,7 @@ class OpenRecentCasePanel extends javax.swing.JPanel {
if (!casePath.equals("")) { if (!casePath.equals("")) {
// Close the startup menu // Close the startup menu
try { try {
StartupWindow.getInstance().close(); StartupWindowProvider.getInstance().close();
CueBannerPanel.closeOpenRecentCasesWindow(); CueBannerPanel.closeOpenRecentCasesWindow();
} catch (Exception ex) { } catch (Exception ex) {
logger.log(Level.WARNING, "Error: couldn't open case: " + caseName, ex); logger.log(Level.WARNING, "Error: couldn't open case: " + caseName, ex);
@ -200,7 +200,7 @@ class OpenRecentCasePanel extends javax.swing.JPanel {
//if case is not opened, open the start window //if case is not opened, open the start window
if (Case.isCaseOpen() == false) { if (Case.isCaseOpen() == false) {
StartupWindow.getInstance().open(); StartupWindowProvider.getInstance().open();
} }
} else { } else {

View File

@ -65,7 +65,7 @@ class RecentItems implements ActionListener {
@Override @Override
public void run() { public void run() {
StartupWindow.getInstance().open(); StartupWindowProvider.getInstance().open();
} }
}); });

View File

@ -26,40 +26,28 @@ import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import javax.swing.JDialog; import javax.swing.JDialog;
import javax.swing.JFrame; import javax.swing.JFrame;
import org.openide.util.lookup.ServiceProvider;
/** /**
* Displays * The default implementation of the Autopsy startup window
*/ */
public final class StartupWindow extends JDialog { @ServiceProvider(service=StartupWindowInterface.class)
public final class StartupWindow extends JDialog implements StartupWindowInterface {
private static StartupWindow instance; private static StartupWindow instance;
private static final String TITLE = "Welcome"; private static final String TITLE = "Welcome";
private static Dimension DIMENSIONS = new Dimension(750, 400); private static Dimension DIMENSIONS = new Dimension(750, 400);
private StartupWindow(JFrame frame, String title, boolean isModal) { public StartupWindow() {
super(frame, title, isModal); super(new JFrame(TITLE), TITLE, true);
init(); init();
} }
/**
* Get the startup window
* @return the startup window singleton
*/
public static synchronized StartupWindow getInstance() {
if (StartupWindow.instance == null) {
JFrame frame = new JFrame(TITLE);
boolean isModal = true;
StartupWindow.instance = new StartupWindow(frame, TITLE, isModal);
}
return instance;
}
/** /**
* Shows the startup window. * Shows the startup window.
*/ */
public void init() { private void init() {
Dimension screenDimension = Toolkit.getDefaultToolkit().getScreenSize(); Dimension screenDimension = Toolkit.getDefaultToolkit().getScreenSize();
@ -88,6 +76,7 @@ public final class StartupWindow extends JDialog {
} }
@Override
public void open() { public void open() {
setVisible(true); setVisible(true);
} }
@ -95,6 +84,7 @@ public final class StartupWindow extends JDialog {
/** /**
* Closes the startup window. * Closes the startup window.
*/ */
@Override
public void close() { public void close() {
this.setVisible(false); this.setVisible(false);
} }

View File

@ -0,0 +1,35 @@
/*
* Autopsy Forensic Browser
*
* Copyright 2013 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.sleuthkit.autopsy.casemodule;
/**
* Interface for startup window implementations
*/
public interface StartupWindowInterface {
/**
* Shows and makes active the startup window
*/
public void open();
/**
* Closes the startup window
*/
public void close();
}

View File

@ -0,0 +1,103 @@
/*
* Autopsy Forensic Browser
*
* Copyright 2013 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.sleuthkit.autopsy.casemodule;
import java.util.Collection;
import java.util.Iterator;
import java.util.logging.Level;
import org.openide.util.Lookup;
import org.sleuthkit.autopsy.coreutils.Logger;
/**
* Provides the start up window to rest of the application. It may return the
* main / default startup window, or a custom one if it has been discovered.
*
* All that is required to create a custom startup window in a module and active it,
* is to implement StartupWindowInterface and register it with lookup as a ServiceProvider.
* The custom startup window is automatically chosen over the default one, given it is the only external module custom startup window.
*/
public class StartupWindowProvider implements StartupWindowInterface {
private static volatile StartupWindowProvider instance;
private static final Logger logger = Logger.getLogger(StartupWindowProvider.class.getName());
private volatile StartupWindowInterface startupWindowToUse;
public static StartupWindowProvider getInstance() {
if (instance == null) {
synchronized (StartupWindowProvider.class) {
if (instance == null) {
instance = new StartupWindowProvider();
instance.init();
}
}
}
return instance;
}
private void init() {
if (startupWindowToUse == null) {
//discover the registered windows
Collection<? extends StartupWindowInterface> startupWindows =
Lookup.getDefault().lookupAll(StartupWindowInterface.class);
int windowsCount = startupWindows.size();
if (windowsCount > 2) {
logger.log(Level.WARNING, "More than 2 (" + windowsCount + ") start up windows discovered, will use the first custom one");
} else if (windowsCount == 1) {
startupWindowToUse = startupWindows.iterator().next();
logger.log(Level.INFO, "Will use the default startup window: " + startupWindowToUse.toString());
} else {
//pick the non default one
Iterator<? extends StartupWindowInterface> it = startupWindows.iterator();
while (it.hasNext()) {
StartupWindowInterface window = it.next();
if (!org.sleuthkit.autopsy.casemodule.StartupWindow.class.isInstance(window)) {
startupWindowToUse = window;
logger.log(Level.INFO, "Will use the custom startup window: " + startupWindowToUse.toString());
break;
}
}
if (startupWindowToUse == null) {
logger.log(Level.SEVERE, "Unexpected error, no custom startup window found, using the default");
startupWindowToUse = new org.sleuthkit.autopsy.casemodule.StartupWindow();
}
}
}
}
@Override
public void open() {
if (startupWindowToUse != null) {
startupWindowToUse.open();
}
}
@Override
public void close() {
if (startupWindowToUse != null) {
startupWindowToUse.close();
}
}
}

View File

@ -124,7 +124,7 @@ public class Installer extends ModuleInstall {
javaFxInit = false; javaFxInit = false;
final String msg = "Error initializing JavaFX. "; final String msg = "Error initializing JavaFX. ";
final String details = " Some features will not be available. " final String details = " Some features will not be available. "
+ " Check that you have the right JRE installed (Sun JRE > 1.7.10). "; + " Check that you have the right JRE installed (Oracle JRE > 1.7.10). ";
logger.log(Level.SEVERE, msg logger.log(Level.SEVERE, msg
+ details, e); + details, e);

View File

@ -578,22 +578,21 @@ class IngestScheduler {
* of skipped * of skipped
* @return true if should be enqueued, false otherwise * @return true if should be enqueued, false otherwise
*/ */
private static boolean shouldEnqueueTask(ProcessTask processTask) { private static boolean shouldEnqueueTask(final ProcessTask processTask) {
final AbstractFile aFile = processTask.file; final AbstractFile aFile = processTask.file;
//if it's unalloc file, skip if so scheduled //if it's unalloc file, skip if so scheduled
if (processTask.context.isProcessUnalloc() == false) { if (processTask.context.isProcessUnalloc() == false
if (aFile.isVirtual() == true) { && aFile.getType().equals(TSK_DB_FILES_TYPE_ENUM.UNALLOC_BLOCKS //unalloc files
) ) {
return false; return false;
} }
}
String fileName = aFile.getName(); String fileName = aFile.getName();
if (fileName.equals(".") || fileName.equals("..")) { if (fileName.equals(".") || fileName.equals("..")) {
return false; return false;
} }
if (aFile.isVirtual() == false && aFile.isFile() == true else if (aFile instanceof org.sleuthkit.datamodel.File ) {
&& aFile.getType() == TSK_DB_FILES_TYPE_ENUM.FS) {
final org.sleuthkit.datamodel.File f = (File) aFile; final org.sleuthkit.datamodel.File f = (File) aFile;
//skip files in root dir, starting with $, containing : (not default attributes) //skip files in root dir, starting with $, containing : (not default attributes)

View File

@ -7,6 +7,7 @@ Improvements:
Bugfixes: Bugfixes:
- Keyword Search: fix when Solr does not cleanly shutdown - Keyword Search: fix when Solr does not cleanly shutdown
- fix for "Process Unallocated Space" option doesn't do anything