Autopsy  4.4.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-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;
34 
38 public class Installer extends ModuleInstall {
39 
40  private static final long serialVersionUID = 1L;
41  private static final Logger logger = Logger.getLogger(Installer.class.getName());
42  private static Installer instance;
43 
44  public synchronized static Installer getDefault() {
45  if (null == instance) {
46  instance = new Installer();
47  }
48  return instance;
49  }
50 
51  private Installer() {
52  super();
53  }
54 
55  @Override
56  public void restored() {
57  super.restored();
59  UIManager.put("ViewTabDisplayerUI", "org.sleuthkit.autopsy.corecomponents.NoTabsTabDisplayerUI");
60  UIManager.put(DefaultTabbedContainerUI.KEY_VIEW_CONTENT_BORDER, BorderFactory.createEmptyBorder());
61  UIManager.put("TabbedPane.contentBorderInsets", new Insets(0, 0, 0, 0));
62  WindowManager.getDefault().invokeWhenUIReady(() -> {
64  });
65  }
66 
67  @Override
68  public void uninstalled() {
69  super.uninstalled();
70  }
71 
72  private void setLookAndFeel() {
73  if (System.getProperty("os.name").toLowerCase().contains("mac")) { //NON-NLS
75  }
76  }
77 
83  private void setOSXLookAndFeel() {
84  try {
85  UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
86  } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException ex) {
87  logger.log(Level.WARNING, "Error setting OS-X look-and-feel", ex); //NON-NLS
88  }
89 
90  // Store the keys that deal with menu items
91  final String[] UI_MENU_ITEM_KEYS = new String[]{"MenuBarUI",}; //NON-NLS
92  Map<Object, Object> uiEntries = new TreeMap<>();
93  for (String key : UI_MENU_ITEM_KEYS) {
94  uiEntries.put(key, UIManager.get(key));
95  }
96 
97  // Use Metal if available.
98  for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
99  if ("Nimbus".equals(info.getName())) { //NON-NLS
100  try {
101  UIManager.setLookAndFeel(info.getClassName());
102  } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException ex) {
103  logger.log(Level.WARNING, "Error setting OS-X look-and-feel", ex); //NON-NLS
104  }
105  break;
106  }
107  }
108 
109  // Overwrite the Metal menu item keys to use the Aqua versions.
110  uiEntries.entrySet().stream().forEach((entry) -> {
111  UIManager.put(entry.getKey(), entry.getValue());
112  });
113  }
114 }
static synchronized Installer getDefault()
Definition: Installer.java:44
synchronized static Logger getLogger(String name)
Definition: Logger.java:161

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