Autopsy  4.5.0
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.util.Map;
23 import java.util.TreeMap;
24 import java.util.logging.Level;
25 import javax.swing.BorderFactory;
26 import javax.swing.UIManager;
27 import javax.swing.UIManager.LookAndFeelInfo;
28 import javax.swing.UnsupportedLookAndFeelException;
29 import org.netbeans.swing.tabcontrol.plaf.DefaultTabbedContainerUI;
30 import org.openide.modules.ModuleInstall;
31 import org.openide.windows.WindowManager;
35 
39 public class Installer extends ModuleInstall {
40 
41  private static final long serialVersionUID = 1L;
42  private static final Logger logger = Logger.getLogger(Installer.class.getName());
43  private static Installer instance;
44 
45  public synchronized static Installer getDefault() {
46  if (null == instance) {
47  instance = new Installer();
48  }
49  return instance;
50  }
51 
52  private Installer() {
53  super();
54  }
55 
56  @Override
57  public void restored() {
58  super.restored();
60  UIManager.put("ViewTabDisplayerUI", "org.sleuthkit.autopsy.corecomponents.NoTabsTabDisplayerUI");
61  UIManager.put(DefaultTabbedContainerUI.KEY_VIEW_CONTENT_BORDER, BorderFactory.createEmptyBorder());
62  UIManager.put("TabbedPane.contentBorderInsets", new Insets(0, 0, 0, 0));
63  WindowManager.getDefault().invokeWhenUIReady(() -> {
65  });
66  }
67 
68  @Override
69  public void uninstalled() {
70  super.uninstalled();
71  }
72 
73  private void setLookAndFeel() {
74  if (System.getProperty("os.name").toLowerCase().contains("mac")) { //NON-NLS
76  }else if (System.getProperty("os.name").toLowerCase().contains("nux")){
78  }
79  }
80 
86  private void setOSXLookAndFeel() {
87  try {
88  UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
89  } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException ex) {
90  logger.log(Level.WARNING, "Error setting OS-X look-and-feel", ex); //NON-NLS
91  }
92 
93  // Store the keys that deal with menu items
94  final String[] UI_MENU_ITEM_KEYS = new String[]{"MenuBarUI",}; //NON-NLS
95  Map<Object, Object> uiEntries = new TreeMap<>();
96  for (String key : UI_MENU_ITEM_KEYS) {
97  uiEntries.put(key, UIManager.get(key));
98  }
99 
100  // Use Metal if available.
101  for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
102  if ("Nimbus".equals(info.getName())) { //NON-NLS
103  try {
104  UIManager.setLookAndFeel(info.getClassName());
105  } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException ex) {
106  logger.log(Level.WARNING, "Error setting OS-X look-and-feel", ex); //NON-NLS
107  }
108  break;
109  }
110  }
111 
112  // Overwrite the Metal menu item keys to use the Aqua versions.
113  uiEntries.entrySet().stream().forEach((entry) -> {
114  UIManager.put(entry.getKey(), entry.getValue());
115  });
116  }
117 
118  private void setModuleSettings(String value) {
119  if (ModuleSettings.configExists("timeline")) {
120  ModuleSettings.setConfigSetting("timeline", "enable_timeline", value);
121  } else {
122  ModuleSettings.makeConfigFile("timeline");
123  ModuleSettings.setConfigSetting("timeline", "enable_timeline", value);
124  }
125  }
126 
127  private void setUnixLookAndFeel(){
128  try {
129  UIManager.put("swing.boldMetal", Boolean.FALSE);
130  UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
131  setModuleSettings("true");
132  } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException ex) {
133  logger.log(Level.WARNING, "Error setting crossplatform look-and-feel, setting default look-and-feel",ex);
134  setModuleSettings("false");
135  }
136  }
137 }
static synchronized Installer getDefault()
Definition: Installer.java:45
static boolean makeConfigFile(String moduleName)
static synchronized void setConfigSetting(String moduleName, String settingName, String settingVal)
static boolean configExists(String moduleName)
synchronized static Logger getLogger(String name)
Definition: Logger.java:124

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