Autopsy  4.4
Graphical digital forensics platform for The Sleuth Kit and other tools.
Installer.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2011-2017 Basis Technology Corp.
5  * Contact: carrier <at> sleuthkit <dot> org
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19 package org.sleuthkit.autopsy.corecomponents;
20 
21 import java.awt.Insets;
22 import java.io.File;
23 import java.util.Collection;
24 import java.util.Map;
25 import java.util.TreeMap;
26 import java.util.logging.Level;
27 import javax.swing.BorderFactory;
28 import javax.swing.SwingUtilities;
29 import javax.swing.UIManager;
30 import javax.swing.UIManager.LookAndFeelInfo;
31 import javax.swing.UnsupportedLookAndFeelException;
32 import org.netbeans.spi.sendopts.OptionProcessor;
33 import org.netbeans.swing.tabcontrol.plaf.DefaultTabbedContainerUI;
34 import org.openide.modules.ModuleInstall;
35 import org.openide.util.Lookup;
36 import org.openide.util.NbBundle;
37 import org.openide.windows.WindowManager;
45 
49 public class Installer extends ModuleInstall {
50 
51  private static final long serialVersionUID = 1L;
52  private static final Logger logger = Logger.getLogger(Installer.class.getName());
53  private static Installer instance;
54 
55  public synchronized static Installer getDefault() {
56  if (null == instance) {
57  instance = new Installer();
58  }
59  return instance;
60  }
61 
62  private Installer() {
63  super();
64  }
65 
66  @Override
67  public void restored() {
68  super.restored();
69 
71  UIManager.put("ViewTabDisplayerUI", "org.sleuthkit.autopsy.corecomponents.NoTabsTabDisplayerUI");
72  UIManager.put(DefaultTabbedContainerUI.KEY_VIEW_CONTENT_BORDER, BorderFactory.createEmptyBorder());
73  UIManager.put("TabbedPane.contentBorderInsets", new Insets(0, 0, 0, 0));
74 
75  /*
76  * Open the case if a case metadata file was double-clicked. This only
77  * works if the user has associated files with ".aut" extensions with
78  * Autopsy.
79  */
80  WindowManager.getDefault().invokeWhenUIReady(() -> {
81  Collection<? extends OptionProcessor> processors = Lookup.getDefault().lookupAll(OptionProcessor.class);
82  for (OptionProcessor processor : processors) {
83  if (processor instanceof OpenFromArguments) {
84  OpenFromArguments argsProcessor = (OpenFromArguments) processor;
85  final String caseFile = argsProcessor.getDefaultArg();
86  if (caseFile != null && !caseFile.isEmpty() && caseFile.endsWith(CaseMetadata.getFileExtension()) && new File(caseFile).exists()) { //NON-NLS
87  try {
88  Case.openAsCurrentCase(caseFile);
89  } catch (CaseActionException ex) {
90  logger.log(Level.SEVERE, String.format("Error opening case with metadata file path %s", caseFile), ex); //NON-NLS
91  }
92  return;
93  }
94  }
95  }
97  });
98  }
99 
100  @Override
101  public void uninstalled() {
102  super.uninstalled();
103  }
104 
105  private void setLookAndFeel() {
106  if (System.getProperty("os.name").toLowerCase().contains("mac")) { //NON-NLS
108  }
109  }
110 
116  private void setOSXLookAndFeel() {
117  try {
118  UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
119  } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException ex) {
120  logger.log(Level.WARNING, "Error setting OS-X look-and-feel", ex); //NON-NLS
121  }
122 
123  // Store the keys that deal with menu items
124  final String[] UI_MENU_ITEM_KEYS = new String[]{"MenuBarUI",}; //NON-NLS
125  Map<Object, Object> uiEntries = new TreeMap<>();
126  for (String key : UI_MENU_ITEM_KEYS) {
127  uiEntries.put(key, UIManager.get(key));
128  }
129 
130  // Use Metal if available.
131  for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
132  if ("Nimbus".equals(info.getName())) { //NON-NLS
133  try {
134  UIManager.setLookAndFeel(info.getClassName());
135  } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException ex) {
136  logger.log(Level.WARNING, "Error setting OS-X look-and-feel", ex); //NON-NLS
137  }
138  break;
139  }
140  }
141 
142  // Overwrite the Metal menu item keys to use the Aqua versions.
143  uiEntries.entrySet().stream().forEach((entry) -> {
144  UIManager.put(entry.getKey(), entry.getValue());
145  });
146  }
147 }
static synchronized Installer getDefault()
Definition: Installer.java:55
static void openAsCurrentCase(String caseMetadataFilePath)
Definition: Case.java:481
synchronized static Logger getLogger(String name)
Definition: Logger.java:161

Copyright © 2012-2016 Basis Technology. Generated on: Tue Jun 13 2017
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.