diff options
Diffstat (limited to 'hierarchyviewer2/app')
-rw-r--r-- | hierarchyviewer2/app/.classpath | 1 | ||||
-rw-r--r-- | hierarchyviewer2/app/Android.mk | 27 | ||||
-rw-r--r-- | hierarchyviewer2/app/NOTICE | 190 | ||||
-rwxr-xr-x | hierarchyviewer2/app/README | 69 | ||||
-rwxr-xr-x | hierarchyviewer2/app/etc/hierarchyviewer | 8 | ||||
-rwxr-xr-x | hierarchyviewer2/app/etc/hierarchyviewer.bat | 2 | ||||
-rw-r--r-- | hierarchyviewer2/app/src/Android.mk | 33 | ||||
-rw-r--r-- | hierarchyviewer2/app/src/com/android/hierarchyviewer/AboutDialog.java | 4 | ||||
-rw-r--r-- | hierarchyviewer2/app/src/com/android/hierarchyviewer/HierarchyViewerApplication.java | 98 | ||||
-rw-r--r-- | hierarchyviewer2/app/src/com/android/hierarchyviewer/actions/AboutAction.java | 2 | ||||
-rw-r--r-- | hierarchyviewer2/app/src/com/android/hierarchyviewer/util/ActionButton.java | 4 |
11 files changed, 360 insertions, 78 deletions
diff --git a/hierarchyviewer2/app/.classpath b/hierarchyviewer2/app/.classpath index d75889a..c5a657c 100644 --- a/hierarchyviewer2/app/.classpath +++ b/hierarchyviewer2/app/.classpath @@ -7,5 +7,6 @@ <classpathentry combineaccessrules="false" kind="src" path="/ddmlib"/> <classpathentry combineaccessrules="false" kind="src" path="/ddmuilib"/> <classpathentry combineaccessrules="false" kind="src" path="/SdkLib"/> + <classpathentry kind="var" path="ANDROID_OUT_FRAMEWORK/swtmenubar.jar" sourcepath="/ANDROID_SRC/sdk/swtmenubar/src"/> <classpathentry kind="output" path="bin"/> </classpath> diff --git a/hierarchyviewer2/app/Android.mk b/hierarchyviewer2/app/Android.mk index 2927f1d..0e00273 100644 --- a/hierarchyviewer2/app/Android.mk +++ b/hierarchyviewer2/app/Android.mk @@ -12,6 +12,27 @@ # See the License for the specific language governing permissions and # limitations under the License. -HIERARCHYVIEWERAPP_LOCAL_DIR := $(call my-dir) -include $(HIERARCHYVIEWERAPP_LOCAL_DIR)/etc/Android.mk -include $(HIERARCHYVIEWERAPP_LOCAL_DIR)/src/Android.mk +LOCAL_PATH := $(call my-dir) +include $(CLEAR_VARS) + +LOCAL_SRC_FILES := $(call all-java-files-under, src) +LOCAL_JAVA_RESOURCE_DIRS := src + +LOCAL_JAR_MANIFEST := etc/manifest.txt + +LOCAL_JAVA_LIBRARIES := \ + ddmlib \ + ddmuilib \ + hierarchyviewerlib \ + swt \ + org.eclipse.jface_3.4.2.M20090107-0800 \ + org.eclipse.core.commands_3.4.0.I20080509-2000 \ + sdklib \ + swtmenubar + +LOCAL_MODULE := hierarchyviewer2 + +include $(BUILD_HOST_JAVA_LIBRARY) + +# Build all sub-directories +include $(call all-makefiles-under,$(LOCAL_PATH)) diff --git a/hierarchyviewer2/app/NOTICE b/hierarchyviewer2/app/NOTICE new file mode 100644 index 0000000..c5b1efa --- /dev/null +++ b/hierarchyviewer2/app/NOTICE @@ -0,0 +1,190 @@ + + Copyright (c) 2005-2008, The Android Open Source Project + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + diff --git a/hierarchyviewer2/app/README b/hierarchyviewer2/app/README new file mode 100755 index 0000000..c00ef99 --- /dev/null +++ b/hierarchyviewer2/app/README @@ -0,0 +1,69 @@ +Using the Eclipse project HierarchyViewer +----------------------------------------- + +HierarchyViewer requires some external libraries to compile. +If you build HierarchyViewer using the makefile, you have nothing +to configure. However if you want to develop on HierarchyViewer +using Eclipse, you need to perform the following configuration. + + +------- +1- Projects required in Eclipse +------- + +To run HierarchyViewer from Eclipse, you need to import the following 5 projects: + + - sdk/hierarchyviewer2/app + - sdk/hierarchyviewer2/libs/hierarchyviewerlib/ + - sdk/ddms/libs/ddmlib + - sdk/ddms/libs/ddmuilib + - sdk/sdkmanager/libs/sdklib + + +------- +2- HierarchyViewer requires some SWT JARs to compile. +------- + +SWT is available in the tree under prebuild/<platform>/swt + +Because the build path cannot contain relative path that are not inside +the project directory, the .classpath file references a user library +called ANDROID_SWT. + +In order to compile the project: +- Open Preferences > Java > Build Path > User Libraries + +- Create a new user library named ANDROID_SWT +- Add the following 4 JAR files: + + - prebuilt/<platform>/swt/swt.jar + - prebuilt/common/eclipse/org.eclipse.core.commands_3.*.jar + - prebuilt/common/eclipse/org.eclipse.equinox.common_3.*.jar + - prebuilt/common/eclipse/org.eclipse.jface_3.*.jar + + +------- +3- HierarchyViewer also requires the compiled SwtMenuBar library. +------- + +Build the swtmenubar library: +$ cd $TOP (top of Android tree) +$ . build/envsetup.sh && lunch sdk-eng +$ sdk/eclipse/scripts/create_sdkman_symlinks.sh + +Define a classpath variable in Eclipse: +- Open Preferences > Java > Build Path > Classpath Variables +- Create a new classpath variable named ANDROID_OUT_FRAMEWORK +- Set its folder value to <Android tree>/out/host/<platform>/framework +- Create a new classpath variable named ANDROID_SRC +- Set its folder value to <Android tree> + +You might need to clean the ddms project (Project > Clean...) after +you add the new classpath variable, otherwise previous errors might not +go away automatically. + +The ANDROID_SRC part should be optional. It allows you to have access to +the SwtMenuBar generic parts from the Java editor. + +-- +EOF diff --git a/hierarchyviewer2/app/etc/hierarchyviewer b/hierarchyviewer2/app/etc/hierarchyviewer index 9f31701..82304dc 100755 --- a/hierarchyviewer2/app/etc/hierarchyviewer +++ b/hierarchyviewer2/app/etc/hierarchyviewer @@ -76,7 +76,7 @@ if [ `uname` = "Linux" ]; then export GDK_NATIVE_WINDOWS=true fi -jarpath="$frameworkdir/$jarfile" +jarpath="$frameworkdir/$jarfile:$frameworkdir/swtmenubar.jar" # Figure out the path to the swt.jar for the current architecture. # if ANDROID_SWT is defined, then just use this. @@ -103,4 +103,8 @@ fi # need to use "java.ext.dirs" because "-jar" causes classpath to be ignored # might need more memory, e.g. -Xmx128M -exec "$javaCmd" -Xmx512M $os_opts $java_debug -Dcom.android.hierarchyviewer.bindir="$progdir" -classpath "$jarpath:$swtpath/swt.jar" com.android.hierarchyviewer.HierarchyViewerApplication "$@" +exec "$javaCmd" \ + -Xmx512M $os_opts $java_debug \ + -Dcom.android.hierarchyviewer.bindir="$progdir" \ + -classpath "$jarpath:$swtpath/swt.jar" \ + com.android.hierarchyviewer.HierarchyViewerApplication "$@" diff --git a/hierarchyviewer2/app/etc/hierarchyviewer.bat b/hierarchyviewer2/app/etc/hierarchyviewer.bat index 0876d2f..8a14957 100755 --- a/hierarchyviewer2/app/etc/hierarchyviewer.bat +++ b/hierarchyviewer2/app/etc/hierarchyviewer.bat @@ -49,7 +49,7 @@ if debug NEQ "%1" goto NoDebug shift 1
:NoDebug
-set jarpath=%frameworkdir%%jarfile%;%frameworkdir%hierarchyviewerlib.jar
+set jarpath=%frameworkdir%%jarfile%;%frameworkdir%hierarchyviewerlib.jar;%frameworkdir%swtmenubar.jar
if not defined ANDROID_SWT goto QueryArch
set swt_path=%ANDROID_SWT%
diff --git a/hierarchyviewer2/app/src/Android.mk b/hierarchyviewer2/app/src/Android.mk deleted file mode 100644 index 1f15bee..0000000 --- a/hierarchyviewer2/app/src/Android.mk +++ /dev/null @@ -1,33 +0,0 @@ -# Copyright (C) 2010 The Android Open Source Project -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -LOCAL_PATH := $(call my-dir) -include $(CLEAR_VARS) - -LOCAL_SRC_FILES := $(call all-subdir-java-files) - -LOCAL_JAR_MANIFEST := ../etc/manifest.txt -LOCAL_JAVA_LIBRARIES := \ - ddmlib \ - ddmuilib \ - hierarchyviewerlib \ - swt \ - org.eclipse.jface_3.4.2.M20090107-0800 \ - org.eclipse.core.commands_3.4.0.I20080509-2000 \ - sdklib - -LOCAL_MODULE := hierarchyviewer2 - -include $(BUILD_HOST_JAVA_LIBRARY) - diff --git a/hierarchyviewer2/app/src/com/android/hierarchyviewer/AboutDialog.java b/hierarchyviewer2/app/src/com/android/hierarchyviewer/AboutDialog.java index 3f973e7..150c70a 100644 --- a/hierarchyviewer2/app/src/com/android/hierarchyviewer/AboutDialog.java +++ b/hierarchyviewer2/app/src/com/android/hierarchyviewer/AboutDialog.java @@ -41,8 +41,8 @@ public class AboutDialog extends Dialog { public AboutDialog(Shell shell) { super(shell); ImageLoader imageLoader = ImageLoader.getLoader(HierarchyViewerDirector.class); - mSmallImage = imageLoader.loadImage("load-view-hierarchy.png", Display.getDefault()); //$NON-NLS-1$ - mAboutImage = imageLoader.loadImage("about.jpg", Display.getDefault()); //$NON-NLS-1$ + mSmallImage = imageLoader.loadImage("sdk-hierarchyviewer-16.png", Display.getDefault()); //$NON-NLS-1$ + mAboutImage = imageLoader.loadImage("sdk-hierarchyviewer-128.png", Display.getDefault()); //$NON-NLS-1$ } @Override diff --git a/hierarchyviewer2/app/src/com/android/hierarchyviewer/HierarchyViewerApplication.java b/hierarchyviewer2/app/src/com/android/hierarchyviewer/HierarchyViewerApplication.java index 25943c4..bf18965 100644 --- a/hierarchyviewer2/app/src/com/android/hierarchyviewer/HierarchyViewerApplication.java +++ b/hierarchyviewer2/app/src/com/android/hierarchyviewer/HierarchyViewerApplication.java @@ -26,6 +26,7 @@ import com.android.hierarchyviewer.util.ActionButton; import com.android.hierarchyviewerlib.HierarchyViewerDirector; import com.android.hierarchyviewerlib.actions.CapturePSDAction; import com.android.hierarchyviewerlib.actions.DisplayViewAction; +import com.android.hierarchyviewerlib.actions.DumpDisplayListAction; import com.android.hierarchyviewerlib.actions.InspectScreenshotAction; import com.android.hierarchyviewerlib.actions.InvalidateAction; import com.android.hierarchyviewerlib.actions.LoadOverlayAction; @@ -38,6 +39,8 @@ import com.android.hierarchyviewerlib.actions.RefreshWindowsAction; import com.android.hierarchyviewerlib.actions.RequestLayoutAction; import com.android.hierarchyviewerlib.actions.SavePixelPerfectAction; import com.android.hierarchyviewerlib.actions.SaveTreeViewAction; +import com.android.hierarchyviewerlib.device.DeviceBridge.ViewServerInfo; +import com.android.hierarchyviewerlib.models.DeviceSelectionModel; import com.android.hierarchyviewerlib.models.PixelPerfectModel; import com.android.hierarchyviewerlib.models.TreeViewModel; import com.android.hierarchyviewerlib.models.PixelPerfectModel.IImageChangeListener; @@ -53,11 +56,15 @@ import com.android.hierarchyviewerlib.ui.PropertyViewer; import com.android.hierarchyviewerlib.ui.TreeView; import com.android.hierarchyviewerlib.ui.TreeViewControls; import com.android.hierarchyviewerlib.ui.TreeViewOverview; +import com.android.menubar.IMenuBarEnhancer; +import com.android.menubar.MenuBarEnhancer; +import com.android.menubar.IMenuBarEnhancer.MenuBarMode; import org.eclipse.jface.action.MenuManager; import org.eclipse.jface.action.Separator; import org.eclipse.jface.window.ApplicationWindow; import org.eclipse.swt.SWT; +import org.eclipse.swt.SWTException; import org.eclipse.swt.custom.SashForm; import org.eclipse.swt.custom.StackLayout; import org.eclipse.swt.events.SelectionEvent; @@ -81,8 +88,9 @@ import org.eclipse.swt.widgets.Shell; public class HierarchyViewerApplication extends ApplicationWindow { - private static final int INITIAL_WIDTH = 1024; - private static final int INITIAL_HEIGHT = 768; + private static final String APP_NAME = "Hierarchy Viewer"; + private static final int INITIAL_WIDTH = 1280; + private static final int INITIAL_HEIGHT = 800; private static HierarchyViewerApplication sMainWindow; @@ -119,6 +127,8 @@ public class HierarchyViewerApplication extends ApplicationWindow { private PixelPerfectLoupe mPixelPerfectLoupe; private Composite mTreeViewControls; + private ActionButton dumpDisplayList; + private HierarchyViewerDirector mDirector; /* @@ -148,9 +158,9 @@ public class HierarchyViewerApplication extends ApplicationWindow { @Override protected void configureShell(Shell shell) { super.configureShell(shell); - shell.setText("Hierarchy Viewer"); + shell.setText(APP_NAME); ImageLoader imageLoader = ImageLoader.getLoader(HierarchyViewerDirector.class); - Image image = imageLoader.loadImage("load-view-hierarchy.png", Display.getDefault()); //$NON-NLS-1$ + Image image = imageLoader.loadImage("sdk-hierarchyviewer-128.png", Display.getDefault()); //$NON-NLS-1$ shell.setImage(image); } @@ -162,7 +172,14 @@ public class HierarchyViewerApplication extends ApplicationWindow { public void run() { setBlockOnOpen(true); - open(); + try { + open(); + } catch (SWTException e) { + // Ignore "widget disposed" errors after we closed. + if (!getShell().isDisposed()) { + throw e; + } + } TreeViewModel.getModel().removeTreeChangeListener(mTreeChangeListener); PixelPerfectModel.getModel().removeImageChangeListener(mImageChangeListener); @@ -354,7 +371,7 @@ public class HierarchyViewerApplication extends ApplicationWindow { Composite innerButtonPanel = new Composite(buttonPanel, SWT.NONE); innerButtonPanel.setLayoutData(new GridData(GridData.FILL_VERTICAL)); - GridLayout innerButtonPanelLayout = new GridLayout(6, true); + GridLayout innerButtonPanelLayout = new GridLayout(7, true); innerButtonPanelLayout.marginWidth = innerButtonPanelLayout.marginHeight = 2; innerButtonPanelLayout.horizontalSpacing = innerButtonPanelLayout.verticalSpacing = 2; innerButtonPanel.setLayout(innerButtonPanelLayout); @@ -382,6 +399,10 @@ public class HierarchyViewerApplication extends ApplicationWindow { new ActionButton(innerButtonPanel, RequestLayoutAction.getAction()); requestLayout.setLayoutData(new GridData(GridData.FILL_BOTH)); + dumpDisplayList = + new ActionButton(innerButtonPanel, DumpDisplayListAction.getAction()); + dumpDisplayList.setLayoutData(new GridData(GridData.FILL_BOTH)); + SashForm mainSash = new SashForm(mTreeViewPanel, SWT.HORIZONTAL | SWT.SMOOTH); mainSash.setLayoutData(new GridData(GridData.FILL_BOTH)); Composite treeViewContainer = new Composite(mainSash, SWT.BORDER); @@ -581,12 +602,16 @@ public class HierarchyViewerApplication extends ApplicationWindow { MenuManager mm = getMenuBarManager(); mm.removeAll(); - String os = System.getProperty("os.name"); //$NON-NLS-1$ - if (os.startsWith("Mac OS") == false) { //$NON-NLS-1$ - MenuManager file = new MenuManager("&File"); + MenuManager file = new MenuManager("&File"); + IMenuBarEnhancer enhancer = MenuBarEnhancer.setupMenuManager( + APP_NAME, + getShell().getDisplay(), + file, + AboutAction.getAction(getShell()), + null /*preferencesAction*/, + QuitAction.getAction()); + if (enhancer.getMenuBarMode() == MenuBarMode.GENERIC) { mm.add(file); - - file.add(QuitAction.getAction()); } MenuManager device = new MenuManager("&Devices"); @@ -596,11 +621,6 @@ public class HierarchyViewerApplication extends ApplicationWindow { device.add(LoadViewHierarchyAction.getAction()); device.add(InspectScreenshotAction.getAction()); - MenuManager help = new MenuManager("&Help"); - mm.add(help); - - help.add(AboutAction.getAction(getShell())); - mm.updateAll(true); mDeviceViewButton.setSelection(true); @@ -626,12 +646,16 @@ public class HierarchyViewerApplication extends ApplicationWindow { MenuManager mm = getMenuBarManager(); mm.removeAll(); - String os = System.getProperty("os.name"); //$NON-NLS-1$ - if (os.startsWith("Mac OS") == false) { //$NON-NLS-1$ - MenuManager file = new MenuManager("&File"); + MenuManager file = new MenuManager("&File"); + IMenuBarEnhancer enhancer = MenuBarEnhancer.setupMenuManager( + APP_NAME, + getShell().getDisplay(), + file, + AboutAction.getAction(getShell()), + null /*preferencesAction*/, + QuitAction.getAction()); + if (enhancer.getMenuBarMode() == MenuBarMode.GENERIC) { mm.add(file); - - file.add(QuitAction.getAction()); } MenuManager treeViewMenu = new MenuManager("&Tree View"); @@ -642,15 +666,18 @@ public class HierarchyViewerApplication extends ApplicationWindow { treeViewMenu.add(new Separator()); treeViewMenu.add(RefreshViewAction.getAction()); treeViewMenu.add(DisplayViewAction.getAction(getShell())); + // Only make the DumpDisplayList action visible if the protocol supports it. + ViewServerInfo info = DeviceSelectionModel.getModel().getSelectedDeviceInfo(); + if (info != null && info.protocolVersion >= 4) { + treeViewMenu.add(DumpDisplayListAction.getAction()); + dumpDisplayList.setVisible(true); + } else { + dumpDisplayList.setVisible(false); + } treeViewMenu.add(new Separator()); treeViewMenu.add(InvalidateAction.getAction()); treeViewMenu.add(RequestLayoutAction.getAction()); - MenuManager help = new MenuManager("&Help"); - mm.add(help); - - help.add(AboutAction.getAction(getShell())); - mm.updateAll(true); mDeviceViewButton.setSelection(false); @@ -676,12 +703,16 @@ public class HierarchyViewerApplication extends ApplicationWindow { MenuManager mm = getMenuBarManager(); mm.removeAll(); - String os = System.getProperty("os.name"); //$NON-NLS-1$ - if (os.startsWith("Mac OS") == false) { //$NON-NLS-1$ - MenuManager file = new MenuManager("&File"); + MenuManager file = new MenuManager("&File"); + IMenuBarEnhancer enhancer = MenuBarEnhancer.setupMenuManager( + APP_NAME, + getShell().getDisplay(), + file, + AboutAction.getAction(getShell()), + null /*preferencesAction*/, + QuitAction.getAction()); + if (enhancer.getMenuBarMode() == MenuBarMode.GENERIC) { mm.add(file); - - file.add(QuitAction.getAction()); } MenuManager pixelPerfect = new MenuManager("&Pixel Perfect"); @@ -695,11 +726,6 @@ public class HierarchyViewerApplication extends ApplicationWindow { mm.add(pixelPerfect); - MenuManager help = new MenuManager("&Help"); - mm.add(help); - - help.add(AboutAction.getAction(getShell())); - mm.updateAll(true); mDeviceViewButton.setSelection(false); diff --git a/hierarchyviewer2/app/src/com/android/hierarchyviewer/actions/AboutAction.java b/hierarchyviewer2/app/src/com/android/hierarchyviewer/actions/AboutAction.java index 0c7c7b2..332b2dc 100644 --- a/hierarchyviewer2/app/src/com/android/hierarchyviewer/actions/AboutAction.java +++ b/hierarchyviewer2/app/src/com/android/hierarchyviewer/actions/AboutAction.java @@ -41,7 +41,7 @@ public class AboutAction extends Action implements ImageAction { this.mShell = shell; setAccelerator(SWT.MOD1 + 'A'); ImageLoader imageLoader = ImageLoader.getLoader(HierarchyViewerDirector.class); - mImage = imageLoader.loadImage("about-small.jpg", Display.getDefault()); //$NON-NLS-1$ + mImage = imageLoader.loadImage("sdk-hierarchyviewer-16.png", Display.getDefault()); //$NON-NLS-1$ setImageDescriptor(ImageDescriptor.createFromImage(mImage)); setToolTipText("Shows the about dialog"); } diff --git a/hierarchyviewer2/app/src/com/android/hierarchyviewer/util/ActionButton.java b/hierarchyviewer2/app/src/com/android/hierarchyviewer/util/ActionButton.java index 4681c40..ca3c689 100644 --- a/hierarchyviewer2/app/src/com/android/hierarchyviewer/util/ActionButton.java +++ b/hierarchyviewer2/app/src/com/android/hierarchyviewer/util/ActionButton.java @@ -73,4 +73,8 @@ public class ActionButton implements IPropertyChangeListener, SelectionListener public void addSelectionListener(SelectionListener listener) { mButton.addSelectionListener(listener); } + + public void setVisible(boolean visible) { + mButton.setVisible(visible); + } } |