mirror of
https://github.com/elisspace/autopsy.git
synced 2026-10-06 01:06:20 +00:00
Tidy up corecomponents.Installer
This commit is contained in:
@@ -554,11 +554,7 @@ public class Case implements SleuthkitCase.ErrorObserver {
|
||||
*
|
||||
* @throws CaseActionException
|
||||
*/
|
||||
/**
|
||||
* TODO: Deprecate this and throw a more general exception.
|
||||
*/
|
||||
public static void open(String caseMetadataFilePath) throws CaseActionException {
|
||||
|
||||
if (!caseMetadataFilePath.endsWith(CASE_DOT_EXTENSION)) {
|
||||
throw new CaseActionException(NbBundle.getMessage(Case.class, "Case.open.exception.checkFile.msg", CASE_DOT_EXTENSION));
|
||||
}
|
||||
@@ -590,8 +586,7 @@ public class Case implements SleuthkitCase.ErrorObserver {
|
||||
db = SleuthkitCase.openCase(metadata.getCaseDatabaseName(), UserPreferences.getDatabaseConnectionInfo(), caseDir);
|
||||
} catch (UserPreferencesException ex) {
|
||||
logger.log(Level.SEVERE, "Error accessing case database connection info", ex); //NON-NLS
|
||||
throw new CaseActionException(
|
||||
NbBundle.getMessage(Case.class, "Case.databaseConnectionInfo.error.msg"), ex);
|
||||
throw new CaseActionException(NbBundle.getMessage(Case.class, "Case.databaseConnectionInfo.error.msg"), ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -45,6 +45,7 @@ import org.sleuthkit.autopsy.ingest.IngestManager;
|
||||
@ServiceProvider(service = CaseOpenAction.class)
|
||||
public final class CaseOpenAction implements ActionListener {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(CaseOpenAction.class.getName());
|
||||
private static final String PROP_BASECASE = "LBL_BaseCase_PATH"; //NON-NLS
|
||||
private final JFileChooser fileChooser = new JFileChooser();
|
||||
private final FileFilter caseMetadataFileFilter;
|
||||
@@ -71,7 +72,6 @@ public final class CaseOpenAction implements ActionListener {
|
||||
*/
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
|
||||
/*
|
||||
* If ingest is running, do a dialog to warn the user and confirm
|
||||
* abandoning the ingest.
|
||||
@@ -87,7 +87,7 @@ public final class CaseOpenAction implements ActionListener {
|
||||
try {
|
||||
Case.getCurrentCase().closeCase();
|
||||
} catch (Exception ex) {
|
||||
Logger.getLogger(NewCaseWizardAction.class.getName()).log(Level.WARNING, "Error closing case", ex); //NON-NLS
|
||||
logger.log(Level.SEVERE, "Error closing case", ex); //NON-NLS
|
||||
}
|
||||
} else {
|
||||
return;
|
||||
@@ -121,10 +121,11 @@ public final class CaseOpenAction implements ActionListener {
|
||||
try {
|
||||
Case.open(path);
|
||||
} catch (CaseActionException ex) {
|
||||
logger.log(Level.SEVERE, String.format("Could not open case at %s", path), ex);
|
||||
SwingUtilities.invokeLater(() -> {
|
||||
WindowManager.getDefault().getMainWindow().setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
|
||||
JOptionPane.showMessageDialog(WindowManager.getDefault().getMainWindow(), ex.getMessage() + " "
|
||||
+ NbBundle.getMessage(this.getClass(), "CaseExceptionWarning.CheckMultiUserOptions"),
|
||||
JOptionPane.showMessageDialog(WindowManager.getDefault().getMainWindow(),
|
||||
ex.getMessage(),
|
||||
NbBundle.getMessage(this.getClass(), "CaseOpenAction.msgDlg.cantOpenCase.title"), JOptionPane.ERROR_MESSAGE); //NON-NLS
|
||||
if (!Case.isCaseOpen()) {
|
||||
StartupWindowProvider.getInstance().open();
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* Autopsy Forensic Browser
|
||||
*
|
||||
* Copyright 2011-2015 Basis Technology Corp.
|
||||
* Copyright 2011-2016 Basis Technology Corp.
|
||||
* Contact: carrier <at> sleuthkit <dot> org
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@@ -43,8 +43,9 @@ import org.sleuthkit.autopsy.coreutils.Logger;
|
||||
*/
|
||||
public class Installer extends ModuleInstall {
|
||||
|
||||
private static Installer instance;
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final Logger logger = Logger.getLogger(Installer.class.getName());
|
||||
private static Installer instance;
|
||||
|
||||
public synchronized static Installer getDefault() {
|
||||
if (instance == null) {
|
||||
@@ -61,13 +62,15 @@ public class Installer extends ModuleInstall {
|
||||
public void restored() {
|
||||
super.restored();
|
||||
|
||||
setupLAF();
|
||||
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));
|
||||
|
||||
/*
|
||||
* Open the passed in case, if an aut file was double clicked.
|
||||
* Open the case if a case metadata file was double-clicked. This only
|
||||
* works if the user has associated files with ".aut" extensions with
|
||||
* Autopsy.
|
||||
*/
|
||||
WindowManager.getDefault().invokeWhenUIReady(() -> {
|
||||
Collection<? extends OptionProcessor> processors = Lookup.getDefault().lookupAll(OptionProcessor.class);
|
||||
@@ -77,11 +80,10 @@ public class Installer extends ModuleInstall {
|
||||
final String caseFile = argsProcessor.getDefaultArg();
|
||||
if (caseFile != null && !caseFile.equals("") && caseFile.endsWith(".aut") && new File(caseFile).exists()) { //NON-NLS
|
||||
new Thread(() -> {
|
||||
// Create case.
|
||||
try {
|
||||
Case.open(caseFile);
|
||||
} catch (Exception ex) {
|
||||
logger.log(Level.SEVERE, "Error opening case: ", ex); //NON-NLS
|
||||
logger.log(Level.SEVERE, "Error opening case", ex); //NON-NLS
|
||||
}
|
||||
}).start();
|
||||
return;
|
||||
@@ -105,22 +107,16 @@ public class Installer extends ModuleInstall {
|
||||
if (Case.isCaseOpen()) {
|
||||
Case.getCurrentCase().closeCase();
|
||||
}
|
||||
} catch (CaseActionException | IllegalStateException unused) {
|
||||
} catch (CaseActionException | IllegalStateException ignored) {
|
||||
// Exception already logged. Shutting down, no need to do popup.
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
|
||||
private void setupLAF() {
|
||||
|
||||
//TODO apply custom skinning
|
||||
//UIManager.put("nimbusBase", new Color());
|
||||
//UIManager.put("nimbusBlueGrey", new Color());
|
||||
//UIManager.put("control", new Color());
|
||||
private void setLookAndFeel() {
|
||||
if (System.getProperty("os.name").toLowerCase().contains("mac")) { //NON-NLS
|
||||
setupMacOsXLAF();
|
||||
setOSXLookAndFeel();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -128,24 +124,21 @@ public class Installer extends ModuleInstall {
|
||||
* dependent elements that set the Menu Bar to be in the correct place on
|
||||
* Mac OS X.
|
||||
*/
|
||||
private void setupMacOsXLAF() {
|
||||
private void setOSXLookAndFeel() {
|
||||
try {
|
||||
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
|
||||
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException ex) {
|
||||
logger.log(Level.WARNING, "Unable to set theme. ", ex); //NON-NLS
|
||||
}
|
||||
|
||||
final String[] UI_MENU_ITEM_KEYS = new String[]{"MenuBarUI", //NON-NLS
|
||||
};
|
||||
|
||||
Map<Object, Object> uiEntries = new TreeMap<>();
|
||||
|
||||
// Store the keys that deal with menu items
|
||||
final String[] UI_MENU_ITEM_KEYS = new String[]{"MenuBarUI",}; //NON-NLS
|
||||
Map<Object, Object> uiEntries = new TreeMap<>();
|
||||
for (String key : UI_MENU_ITEM_KEYS) {
|
||||
uiEntries.put(key, UIManager.get(key));
|
||||
}
|
||||
|
||||
//use Metal if available
|
||||
// Use Metal if available
|
||||
for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
|
||||
if ("Nimbus".equals(info.getName())) { //NON-NLS
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user