OSDN Git Service

original
[gb-231r1-is01/Gingerbread_2.3.3_r1_IS01.git] / sdk / hierarchyviewer / src / com / android / hierarchyviewer / HierarchyViewer.java
1 /*
2  * Copyright (C) 2008 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 package com.android.hierarchyviewer;
18
19 import com.android.hierarchyviewer.ui.Workspace;
20 import com.android.hierarchyviewer.device.DeviceBridge;
21
22 import javax.swing.SwingUtilities;
23 import javax.swing.UIManager;
24 import javax.swing.UnsupportedLookAndFeelException;
25
26 public class HierarchyViewer {
27     private static final CharSequence OS_WINDOWS = "Windows";
28     private static final CharSequence OS_MACOSX = "Mac OS X";
29
30     private static void initUserInterface() {
31         System.setProperty("apple.laf.useScreenMenuBar", "true");
32         System.setProperty("apple.awt.brushMetalLook", "true");
33         System.setProperty("com.apple.mrj.application.apple.menu.about.name", "HierarchyViewer");
34
35         final String os = System.getProperty("os.name");
36
37         try {
38             if (os.contains(OS_WINDOWS) || os.contains(OS_MACOSX)) {
39                 UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
40             } else {
41                 UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());                
42             }
43         } catch (ClassNotFoundException e) {
44             e.printStackTrace();
45         } catch (InstantiationException e) {
46             e.printStackTrace();
47         } catch (IllegalAccessException e) {
48             e.printStackTrace();
49         } catch (UnsupportedLookAndFeelException e) {
50             e.printStackTrace();
51         }
52     }
53
54     public static void main(String[] args) {
55         initUserInterface();
56         DeviceBridge.initDebugBridge();
57
58         SwingUtilities.invokeLater(new Runnable() {
59             public void run() {
60                 Workspace workspace = new Workspace();
61                 workspace.setDefaultCloseOperation(Workspace.EXIT_ON_CLOSE);
62                 workspace.setLocationRelativeTo(null);
63                 workspace.setVisible(true);
64             }
65         });
66     }
67 }