Autopsy  3.1
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 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.UIManager;
29 import javax.swing.UIManager.LookAndFeelInfo;
30 import javax.swing.UnsupportedLookAndFeelException;
31 import org.netbeans.spi.sendopts.OptionProcessor;
32 import org.netbeans.swing.tabcontrol.plaf.DefaultTabbedContainerUI;
33 import org.openide.modules.ModuleInstall;
34 import org.openide.util.Lookup;
35 import org.openide.windows.WindowManager;
40 
44 public class Installer extends ModuleInstall {
45 
46  private static Installer instance;
47  private static final Logger logger = Logger.getLogger(Installer.class.getName());
48 
49  public synchronized static Installer getDefault() {
50  if (instance == null) {
51  instance = new Installer();
52  }
53  return instance;
54  }
55 
56  private Installer() {
57  super();
58  }
59 
60  @Override
61  public void restored() {
62  super.restored();
63 
64  setupLAF();
65  UIManager.put("ViewTabDisplayerUI", "org.sleuthkit.autopsy.corecomponents.NoTabsTabDisplayerUI");
66  UIManager.put(DefaultTabbedContainerUI.KEY_VIEW_CONTENT_BORDER, BorderFactory.createEmptyBorder());
67  UIManager.put("TabbedPane.contentBorderInsets", new Insets(0, 0, 0, 0));
68 
69  /* Open the passed in case, if an aut file was double clicked. */
70  WindowManager.getDefault().invokeWhenUIReady(new Runnable() {
71  @Override
72  public void run() {
73  Collection<? extends OptionProcessor> processors = Lookup.getDefault().lookupAll(OptionProcessor.class);
74  for (OptionProcessor processor : processors) {
75  if (processor instanceof OpenFromArguments) {
76  OpenFromArguments argsProcessor = (OpenFromArguments) processor;
77  String caseFile = argsProcessor.getDefaultArg();
78  if (caseFile != null && !caseFile.equals("") && caseFile.endsWith(".aut") && new File(caseFile).exists()) { //NON-NLS
79  try {
80  Case.open(caseFile);
81  return;
82  } catch (Exception e) {
83  }
84  }
85  }
86  }
87  Case.invokeStartupDialog(); // bring up the startup dialog
88  }
89  });
90 
91 
92  }
93 
94  @Override
95  public void uninstalled() {
96  super.uninstalled();
97 
98  }
99 
100  @Override
101  public void close() {
102  try {
103  if (Case.isCaseOpen())
105  }
106  catch (CaseActionException ex) {
107  logger.log(Level.WARNING, "Error closing case. ", ex); //NON-NLS
108  }
109  }
110 
111  private void setupLAF() {
112 
113  //TODO apply custom skinning
114  //UIManager.put("nimbusBase", new Color());
115  //UIManager.put("nimbusBlueGrey", new Color());
116  //UIManager.put("control", new Color());
117 
118  if (System.getProperty("os.name").toLowerCase().contains("mac")) { //NON-NLS
119  setupMacOsXLAF();
120  }
121 
122  }
123 
129  private void setupMacOsXLAF() {
130  try {
131  UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
132  } catch (ClassNotFoundException | InstantiationException
133  | IllegalAccessException | UnsupportedLookAndFeelException ex) {
134  logger.log(Level.WARNING, "Unable to set theme. ", ex); //NON-NLS
135  }
136 
137  final String[] UI_MENU_ITEM_KEYS = new String[]{"MenuBarUI", //NON-NLS
138  };
139 
140  Map<Object, Object> uiEntries = new TreeMap<>();
141 
142  // Store the keys that deal with menu items
143  for(String key : UI_MENU_ITEM_KEYS) {
144  uiEntries.put(key, UIManager.get(key));
145  }
146 
147  //use Metal if available
148  for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
149  if ("Nimbus".equals(info.getName())) { //NON-NLS
150  try {
151  UIManager.setLookAndFeel(info.getClassName());
152  } catch (ClassNotFoundException | InstantiationException |
153  IllegalAccessException | UnsupportedLookAndFeelException ex) {
154  logger.log(Level.WARNING, "Unable to set theme. ", ex); //NON-NLS
155  }
156  break;
157  }
158  }
159 
160  // Overwrite the Metal menu item keys to use the Aqua versions
161  for (Map.Entry<Object,Object> entry : uiEntries.entrySet()) {
162  UIManager.put(entry.getKey(), entry.getValue());
163  }
164  }
165 }
static void open(String configFilePath)
Definition: Case.java:318
static synchronized Installer getDefault()
Definition: Installer.java:49
static Logger getLogger(String name)
Definition: Logger.java:131

Copyright © 2012-2015 Basis Technology. Generated on: Mon Oct 19 2015
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.