aboutsummaryrefslogtreecommitdiffstats
path: root/ddms/app
diff options
context:
space:
mode:
Diffstat (limited to 'ddms/app')
-rw-r--r--ddms/app/.classpath16
-rw-r--r--ddms/app/.project17
-rw-r--r--ddms/app/.settings/org.eclipse.jdt.core.prefs98
-rw-r--r--ddms/app/Android.mk32
-rw-r--r--ddms/app/NOTICE190
-rw-r--r--ddms/app/README75
-rw-r--r--ddms/app/etc/Android.mk8
-rwxr-xr-xddms/app/etc/ddms111
-rwxr-xr-xddms/app/etc/ddms.bat74
-rw-r--r--ddms/app/etc/manifest.txt3
-rw-r--r--ddms/app/src/com/android/ddms/AboutDialog.java158
-rw-r--r--ddms/app/src/com/android/ddms/DebugPortProvider.java164
-rw-r--r--ddms/app/src/com/android/ddms/DeviceCommandDialog.java441
-rw-r--r--ddms/app/src/com/android/ddms/DropdownSelectionListener.java80
-rw-r--r--ddms/app/src/com/android/ddms/Main.java171
-rw-r--r--ddms/app/src/com/android/ddms/PrefsDialog.java610
-rw-r--r--ddms/app/src/com/android/ddms/StaticPortConfigDialog.java395
-rw-r--r--ddms/app/src/com/android/ddms/StaticPortEditDialog.java334
-rw-r--r--ddms/app/src/com/android/ddms/UIThread.java1803
-rw-r--r--ddms/app/src/images/ddms-128.pngbin17692 -> 0 bytes
20 files changed, 0 insertions, 4780 deletions
diff --git a/ddms/app/.classpath b/ddms/app/.classpath
deleted file mode 100644
index 54b9743..0000000
--- a/ddms/app/.classpath
+++ /dev/null
@@ -1,16 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry combineaccessrules="false" kind="src" path="/ddmlib"/>
- <classpathentry combineaccessrules="false" kind="src" path="/ddmuilib"/>
- <classpathentry combineaccessrules="false" kind="src" path="/sdkstats"/>
- <classpathentry kind="var" path="ANDROID_OUT_FRAMEWORK/swt.jar"/>
- <classpathentry kind="var" path="ANDROID_SRC/prebuilts/tools/common/eclipse/org.eclipse.core.commands_3.6.0.I20100512-1500.jar"/>
- <classpathentry kind="var" path="ANDROID_SRC/prebuilts/tools/common/eclipse/org.eclipse.equinox.common_3.6.0.v20100503.jar"/>
- <classpathentry kind="var" path="ANDROID_SRC/prebuilts/tools/common/eclipse/org.eclipse.jface_3.6.2.M20110210-1200.jar"/>
- <classpathentry kind="var" path="ANDROID_OUT_FRAMEWORK/swtmenubar.jar" sourcepath="/ANDROID_SRC/sdk/swtmenubar/src"/>
- <classpathentry kind="var" path="ANDROID_SRC/prebuilts/tools/common/osgi/osgi.jar"/>
- <classpathentry combineaccessrules="false" kind="src" path="/common"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/ddms/app/.project b/ddms/app/.project
deleted file mode 100644
index ffb19d7..0000000
--- a/ddms/app/.project
+++ /dev/null
@@ -1,17 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>ddms</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
-</projectDescription>
diff --git a/ddms/app/.settings/org.eclipse.jdt.core.prefs b/ddms/app/.settings/org.eclipse.jdt.core.prefs
deleted file mode 100644
index 9dbff07..0000000
--- a/ddms/app/.settings/org.eclipse.jdt.core.prefs
+++ /dev/null
@@ -1,98 +0,0 @@
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore
-org.eclipse.jdt.core.compiler.annotation.nonnull=com.android.annotations.NonNull
-org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=com.android.annotations.NonNullByDefault
-org.eclipse.jdt.core.compiler.annotation.nonnullisdefault=disabled
-org.eclipse.jdt.core.compiler.annotation.nullable=com.android.annotations.Nullable
-org.eclipse.jdt.core.compiler.annotation.nullanalysis=enabled
-org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
-org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
-org.eclipse.jdt.core.compiler.compliance=1.6
-org.eclipse.jdt.core.compiler.debug.lineNumber=generate
-org.eclipse.jdt.core.compiler.debug.localVariable=generate
-org.eclipse.jdt.core.compiler.debug.sourceFile=generate
-org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
-org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
-org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning
-org.eclipse.jdt.core.compiler.problem.deadCode=warning
-org.eclipse.jdt.core.compiler.problem.deprecation=warning
-org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
-org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
-org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
-org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore
-org.eclipse.jdt.core.compiler.problem.fallthroughCase=warning
-org.eclipse.jdt.core.compiler.problem.fatalOptionalError=enabled
-org.eclipse.jdt.core.compiler.problem.fieldHiding=warning
-org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
-org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
-org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
-org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
-org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=enabled
-org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
-org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning
-org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore
-org.eclipse.jdt.core.compiler.problem.localVariableHiding=warning
-org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
-org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore
-org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=warning
-org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled
-org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=warning
-org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=error
-org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled
-org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
-org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore
-org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
-org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
-org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
-org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error
-org.eclipse.jdt.core.compiler.problem.nullReference=error
-org.eclipse.jdt.core.compiler.problem.nullSpecInsufficientInfo=warning
-org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error
-org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=ignore
-org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
-org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore
-org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warning
-org.eclipse.jdt.core.compiler.problem.potentialNullReference=warning
-org.eclipse.jdt.core.compiler.problem.potentialNullSpecViolation=error
-org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=warning
-org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning
-org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning
-org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore
-org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore
-org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=warning
-org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore
-org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore
-org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
-org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
-org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=enabled
-org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
-org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
-org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
-org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=disabled
-org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
-org.eclipse.jdt.core.compiler.problem.unclosedCloseable=error
-org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
-org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
-org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
-org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning
-org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
-org.eclipse.jdt.core.compiler.problem.unusedImport=warning
-org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
-org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
-org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=warning
-org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
-org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled
-org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
-org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
-org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
-org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
-org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
-org.eclipse.jdt.core.compiler.source=1.6
diff --git a/ddms/app/Android.mk b/ddms/app/Android.mk
deleted file mode 100644
index d4ad1fa..0000000
--- a/ddms/app/Android.mk
+++ /dev/null
@@ -1,32 +0,0 @@
-# Copyright 2007 The Android Open Source Project
-#
-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
-
-# If the dependency list is changed, etc/manifest.txt
-# MUST be updated as well (Except for swt.jar which is dynamically
-# added based on whether the VM is 32 or 64 bit)
-LOCAL_JAVA_LIBRARIES := \
- common \
- sdkstats \
- ddmlib \
- ddmuilib \
- swt \
- swtmenubar \
- org.eclipse.jface_3.6.2.M20110210-1200 \
- org.eclipse.equinox.common_3.6.0.v20100503 \
- org.eclipse.core.commands_3.6.0.I20100512-1500
-LOCAL_MODULE := ddms
-
-LOCAL_MODULE_TAGS := debug
-
-include $(BUILD_HOST_JAVA_LIBRARY)
-
-
-# Build all sub-directories
-include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/ddms/app/NOTICE b/ddms/app/NOTICE
deleted file mode 100644
index c5b1efa..0000000
--- a/ddms/app/NOTICE
+++ /dev/null
@@ -1,190 +0,0 @@
-
- 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/ddms/app/README b/ddms/app/README
deleted file mode 100644
index 0d9bbc4..0000000
--- a/ddms/app/README
+++ /dev/null
@@ -1,75 +0,0 @@
-Using the Eclipse project DDMS
-------------------------------
-
-DDMS requires some external libraries to compile.
-If you build DDMS using the makefile, you have nothing to configure.
-However if you want to develop on DDMS using Eclipse, you need to
-perform the following configuration.
-
-
--------
-1- Projects required in Eclipse
--------
-
-To run DDMS from Eclipse, you need to import the following 5 projects:
-
- - sdk/androidpprefs: project AndroidPrefs
- - sdk/sdkstats: project SdkStatsService
- - sdk/ddms/app: project Ddms
- - sdk/ddms/libs/ddmlib: project Ddmlib
- - sdk/ddms/libs/ddmuilib: project Ddmuilib
-
-
--------
-2- DDMS requires some SWT and OSGI 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.
-SWT depends on OSGI, so we'll also create an ANDROID_OSGI library for that.
-
-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
-
-- Create a new user library named ANDROID_OSGI
-- Add the following JAR file:
-
- - prebuilt/common/eclipse/org.eclipse.osgi_3.*.jar
-
-
--------
-3- DDMS 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/ddms/app/etc/Android.mk b/ddms/app/etc/Android.mk
deleted file mode 100644
index d44d26e..0000000
--- a/ddms/app/etc/Android.mk
+++ /dev/null
@@ -1,8 +0,0 @@
-# Copyright 2007 The Android Open Source Project
-#
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_PREBUILT_EXECUTABLES := ddms
-LOCAL_MODULE_TAGS := debug
-include $(BUILD_HOST_PREBUILT)
diff --git a/ddms/app/etc/ddms b/ddms/app/etc/ddms
deleted file mode 100755
index 79b93f9..0000000
--- a/ddms/app/etc/ddms
+++ /dev/null
@@ -1,111 +0,0 @@
-#!/bin/bash
-# Copyright 2005-2007, 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.
-
-# Set up prog to be the path of this script, including following symlinks,
-# and set up progdir to be the fully-qualified pathname of its directory.
-prog="$0"
-while [ -h "${prog}" ]; do
- newProg=`/bin/ls -ld "${prog}"`
- newProg=`expr "${newProg}" : ".* -> \(.*\)$"`
- if expr "x${newProg}" : 'x/' >/dev/null; then
- prog="${newProg}"
- else
- progdir=`dirname "${prog}"`
- prog="${progdir}/${newProg}"
- fi
-done
-oldwd=`pwd`
-progdir=`dirname "${prog}"`
-cd "${progdir}"
-progdir=`pwd`
-prog="${progdir}"/`basename "${prog}"`
-cd "${oldwd}"
-
-jarfile=ddms.jar
-frameworkdir="$progdir"
-libdir="$progdir"
-if [ ! -r "$frameworkdir/$jarfile" ]
-then
- frameworkdir=`dirname "$progdir"`/tools/lib
- libdir=`dirname "$progdir"`/tools/lib
-fi
-if [ ! -r "$frameworkdir/$jarfile" ]
-then
- frameworkdir=`dirname "$progdir"`/framework
- libdir=`dirname "$progdir"`/lib
-fi
-if [ ! -r "$frameworkdir/$jarfile" ]
-then
- echo `basename "$prog"`": can't find $jarfile"
- exit 1
-fi
-
-
-# Check args.
-if [ debug = "$1" ]; then
- # add this in for debugging
- java_debug=-agentlib:jdwp=transport=dt_socket,server=y,address=8050,suspend=y
- shift 1
-else
- java_debug=
-fi
-
-javaCmd="java"
-
-# Mac OS X needs an additional arg, or you get an "illegal thread" complaint.
-if [ `uname` = "Darwin" ]; then
- os_opts="-XstartOnFirstThread"
-else
- os_opts=
-fi
-
-if [ `uname` = "Linux" ]; then
- export GDK_NATIVE_WINDOWS=true
-fi
-
-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.
-# else, if running in the Android source tree, then look for the correct swt folder in prebuilt
-# else, look for the correct swt folder in the SDK under tools/lib/
-swtpath=""
-if [ -n "$ANDROID_SWT" ]; then
- swtpath="$ANDROID_SWT"
-else
- vmarch=`${javaCmd} -jar "${frameworkdir}"/archquery.jar`
- if [ -n "$ANDROID_BUILD_TOP" ]; then
- osname=`uname -s | tr A-Z a-z`
- swtpath="${ANDROID_BUILD_TOP}/prebuilts/tools/${osname}-${vmarch}/swt"
- else
- swtpath="${frameworkdir}/${vmarch}"
- fi
-fi
-
-if [ ! -d "$swtpath" ]; then
- echo "SWT folder '${swtpath}' does not exist."
- echo "Please export ANDROID_SWT to point to the folder containing swt.jar for your platform."
- exit 1
-fi
-
-if [ -x $progdir/monitor ]; then
- echo "The standalone version of DDMS is deprecated."
- echo "Please use Android Device Monitor (tools/monitor) instead."
-fi
-exec "$javaCmd" \
- -Xmx256M $os_opts $java_debug \
- -Dcom.android.ddms.bindir="$progdir" \
- -classpath "$jarpath:$swtpath/swt.jar" \
- com.android.ddms.Main "$@"
diff --git a/ddms/app/etc/ddms.bat b/ddms/app/etc/ddms.bat
deleted file mode 100755
index d710ea6..0000000
--- a/ddms/app/etc/ddms.bat
+++ /dev/null
@@ -1,74 +0,0 @@
-@echo off
-rem Copyright (C) 2007 The Android Open Source Project
-rem
-rem Licensed under the Apache License, Version 2.0 (the "License");
-rem you may not use this file except in compliance with the License.
-rem You may obtain a copy of the License at
-rem
-rem http://www.apache.org/licenses/LICENSE-2.0
-rem
-rem Unless required by applicable law or agreed to in writing, software
-rem distributed under the License is distributed on an "AS IS" BASIS,
-rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-rem See the License for the specific language governing permissions and
-rem limitations under the License.
-
-rem don't modify the caller's environment
-setlocal
-
-rem Set up prog to be the path of this script, including following symlinks,
-rem and set up progdir to be the fully-qualified pathname of its directory.
-set prog=%~f0
-
-rem Change current directory and drive to where the script is, to avoid
-rem issues with directories containing whitespaces.
-cd /d %~dp0
-
-rem Get the CWD as a full path with short names only (without spaces)
-for %%i in ("%cd%") do set prog_dir=%%~fsi
-
-rem Check we have a valid Java.exe in the path.
-set java_exe=
-call lib\find_java.bat
-if not defined java_exe goto :EOF
-
-set jarfile=ddms.jar
-set frameworkdir=
-
-if exist %frameworkdir%%jarfile% goto JarFileOk
- set frameworkdir=lib\
-
-if exist %frameworkdir%%jarfile% goto JarFileOk
- set frameworkdir=..\framework\
-
-:JarFileOk
-
-if debug NEQ "%1" goto NoDebug
- set java_debug=-agentlib:jdwp=transport=dt_socket,server=y,address=8050,suspend=y
- shift 1
-:NoDebug
-
-set jarpath=%frameworkdir%%jarfile%;%frameworkdir%swtmenubar.jar
-
-if not defined ANDROID_SWT goto QueryArch
- set swt_path=%ANDROID_SWT%
- goto SwtDone
-
-:QueryArch
-
- for /f %%a in ('%java_exe% -jar %frameworkdir%archquery.jar') do set swt_path=%frameworkdir%%%a
-
-:SwtDone
-
-if exist %swt_path% goto SetPath
- echo SWT folder '%swt_path%' does not exist.
- echo Please set ANDROID_SWT to point to the folder containing swt.jar for your platform.
- exit /B
-
-:SetPath
-set javaextdirs=%swt_path%;%frameworkdir%
-
-echo The standalone version of DDMS is deprecated.
-echo Please use Android Device Monitor (monitor.bat) instead.
-call %java_exe% %java_debug% -Dcom.android.ddms.bindir=%prog_dir% -classpath "%jarpath%;%swt_path%\swt.jar" com.android.ddms.Main %*
-
diff --git a/ddms/app/etc/manifest.txt b/ddms/app/etc/manifest.txt
deleted file mode 100644
index f3d4fdd..0000000
--- a/ddms/app/etc/manifest.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-Main-Class: com.android.ddms.Main
-Class-Path: common.jar sdkstats.jar ddmlib.jar ddmuilib.jar swtmenubar.jar org.eclipse.jface_3.6.2.M20110210-1200.jar org.eclipse.equinox.common_3.6.0.v20100503.jar org.eclipse.core.commands_3.6.0.I20100512-1500.jar jcommon-1.0.12.jar jfreechart-1.0.9.jar jfreechart-1.0.9-swt.jar osgi.jar guava-tools.jar
-
diff --git a/ddms/app/src/com/android/ddms/AboutDialog.java b/ddms/app/src/com/android/ddms/AboutDialog.java
deleted file mode 100644
index b3ddff7..0000000
--- a/ddms/app/src/com/android/ddms/AboutDialog.java
+++ /dev/null
@@ -1,158 +0,0 @@
-/* //device/tools/ddms/src/com/android/ddms/AboutDialog.java
-**
-** Copyright 2007, 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.
-*/
-
-package com.android.ddms;
-
-import com.android.ddmlib.Log;
-import com.android.ddmuilib.ImageLoader;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Dialog;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Shell;
-
-import java.io.InputStream;
-
-/**
- * Our "about" box.
- */
-public class AboutDialog extends Dialog {
-
- private Image logoImage;
-
- /**
- * Create with default style.
- */
- public AboutDialog(Shell parent) {
- this(parent, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL);
- }
-
- /**
- * Create with app-defined style.
- */
- public AboutDialog(Shell parent, int style) {
- super(parent, style);
- }
-
- /**
- * Prepare and display the dialog.
- */
- public void open() {
- Shell parent = getParent();
- Shell shell = new Shell(parent, getStyle());
- shell.setText("About...");
-
- logoImage = loadImage(shell, "ddms-128.png"); //$NON-NLS-1$
- createContents(shell);
- shell.pack();
-
- shell.open();
- Display display = parent.getDisplay();
- while (!shell.isDisposed()) {
- if (!display.readAndDispatch())
- display.sleep();
- }
-
- logoImage.dispose();
- }
-
- /*
- * Load an image file from a resource.
- *
- * This depends on Display, so I'm not sure what the rules are for
- * loading once and caching in a static class field.
- */
- private Image loadImage(Shell shell, String fileName) {
- InputStream imageStream;
- String pathName = "/images/" + fileName; //$NON-NLS-1$
-
- imageStream = this.getClass().getResourceAsStream(pathName);
- if (imageStream == null) {
- //throw new NullPointerException("couldn't find " + pathName);
- Log.w("ddms", "Couldn't load " + pathName);
- Display display = shell.getDisplay();
- return ImageLoader.createPlaceHolderArt(display, 100, 50,
- display.getSystemColor(SWT.COLOR_BLUE));
- }
-
- Image img = new Image(shell.getDisplay(), imageStream);
- if (img == null)
- throw new NullPointerException("couldn't load " + pathName);
- return img;
- }
-
- /*
- * Create the about box contents.
- */
- private void createContents(final Shell shell) {
- GridLayout layout;
- GridData data;
- Label label;
-
- shell.setLayout(new GridLayout(2, false));
-
- // Fancy logo
- Label logo = new Label(shell, SWT.BORDER);
- logo.setImage(logoImage);
-
- // Text Area
- Composite textArea = new Composite(shell, SWT.NONE);
- layout = new GridLayout(1, true);
- textArea.setLayout(layout);
-
- // Text lines
- label = new Label(textArea, SWT.NONE);
- if (Main.sRevision != null && Main.sRevision.length() > 0) {
- label.setText("Dalvik Debug Monitor Revision " + Main.sRevision);
- } else {
- label.setText("Dalvik Debug Monitor");
- }
- label = new Label(textArea, SWT.NONE);
- // TODO: update with new year date (search this to find other occurrences to update)
- label.setText("Copyright 2007-2012, The Android Open Source Project");
- label = new Label(textArea, SWT.NONE);
- label.setText("All Rights Reserved.");
-
- // blank spot in grid
- label = new Label(shell, SWT.NONE);
-
- // "OK" button
- Button ok = new Button(shell, SWT.PUSH);
- ok.setText("OK");
- data = new GridData(GridData.HORIZONTAL_ALIGN_END);
- data.widthHint = 80;
- ok.setLayoutData(data);
- ok.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- shell.close();
- }
- });
-
- shell.pack();
-
- shell.setDefaultButton(ok);
- }
-}
diff --git a/ddms/app/src/com/android/ddms/DebugPortProvider.java b/ddms/app/src/com/android/ddms/DebugPortProvider.java
deleted file mode 100644
index 2dcd5d4..0000000
--- a/ddms/app/src/com/android/ddms/DebugPortProvider.java
+++ /dev/null
@@ -1,164 +0,0 @@
-/*
- * Copyright (C) 2007 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.
- */
-
-package com.android.ddms;
-
-import com.android.ddmlib.DebugPortManager.IDebugPortProvider;
-import com.android.ddmlib.IDevice;
-
-import org.eclipse.jface.preference.IPreferenceStore;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * DDMS implementation of the IDebugPortProvider interface.
- * This class handles saving/loading the list of static debug port from
- * the preference store and provides the port number to the Device Monitor.
- */
-public class DebugPortProvider implements IDebugPortProvider {
-
- private static DebugPortProvider sThis = new DebugPortProvider();
-
- /** Preference name for the static port list. */
- public static final String PREFS_STATIC_PORT_LIST = "android.staticPortList"; //$NON-NLS-1$
-
- /**
- * Mapping device serial numbers to maps. The embedded maps are mapping application names to
- * debugger ports.
- */
- private Map<String, Map<String, Integer>> mMap;
-
- public static DebugPortProvider getInstance() {
- return sThis;
- }
-
- private DebugPortProvider() {
- computePortList();
- }
-
- /**
- * Returns a static debug port for the specified application running on the
- * specified {@link IDevice}.
- * @param device The device the application is running on.
- * @param appName The application name, as defined in the
- * AndroidManifest.xml package attribute.
- * @return The static debug port or {@link #NO_STATIC_PORT} if there is none setup.
- *
- * @see IDebugPortProvider#getPort(IDevice, String)
- */
- @Override
- public int getPort(IDevice device, String appName) {
- if (mMap != null) {
- Map<String, Integer> deviceMap = mMap.get(device.getSerialNumber());
- if (deviceMap != null) {
- Integer i = deviceMap.get(appName);
- if (i != null) {
- return i.intValue();
- }
- }
- }
- return IDebugPortProvider.NO_STATIC_PORT;
- }
-
- /**
- * Returns the map of Static debugger ports. The map links device serial numbers to
- * a map linking application name to debugger ports.
- */
- public Map<String, Map<String, Integer>> getPortList() {
- return mMap;
- }
-
- /**
- * Create the map member from the values contained in the Preference Store.
- */
- private void computePortList() {
- mMap = new HashMap<String, Map<String, Integer>>();
-
- // get the prefs store
- IPreferenceStore store = PrefsDialog.getStore();
- String value = store.getString(PREFS_STATIC_PORT_LIST);
-
- if (value != null && value.length() > 0) {
- // format is
- // port1|port2|port3|...
- // where port# is
- // appPackageName:appPortNumber:device-serial-number
- String[] portSegments = value.split("\\|"); //$NON-NLS-1$
- for (String seg : portSegments) {
- String[] entry = seg.split(":"); //$NON-NLS-1$
-
- // backward compatibility support. if we have only 2 entry, we default
- // to the first emulator.
- String deviceName = null;
- if (entry.length == 3) {
- deviceName = entry[2];
- } else {
- deviceName = IDevice.FIRST_EMULATOR_SN;
- }
-
- // get the device map
- Map<String, Integer> deviceMap = mMap.get(deviceName);
- if (deviceMap == null) {
- deviceMap = new HashMap<String, Integer>();
- mMap.put(deviceName, deviceMap);
- }
-
- deviceMap.put(entry[0], Integer.valueOf(entry[1]));
- }
- }
- }
-
- /**
- * Sets new [device, app, port] values.
- * The values are also sync'ed in the preference store.
- * @param map The map containing the new values.
- */
- public void setPortList(Map<String, Map<String,Integer>> map) {
- // update the member map.
- mMap.clear();
- mMap.putAll(map);
-
- // create the value to store in the preference store.
- // see format definition in getPortList
- StringBuilder sb = new StringBuilder();
-
- Set<String> deviceKeys = map.keySet();
- for (String deviceKey : deviceKeys) {
- Map<String, Integer> deviceMap = map.get(deviceKey);
- if (deviceMap != null) {
- Set<String> appKeys = deviceMap.keySet();
-
- for (String appKey : appKeys) {
- Integer port = deviceMap.get(appKey);
- if (port != null) {
- sb.append(appKey).append(':').append(port.intValue()).append(':').
- append(deviceKey).append('|');
- }
- }
- }
- }
-
- String value = sb.toString();
-
- // get the prefs store.
- IPreferenceStore store = PrefsDialog.getStore();
-
- // and give it the new value.
- store.setValue(PREFS_STATIC_PORT_LIST, value);
- }
-}
diff --git a/ddms/app/src/com/android/ddms/DeviceCommandDialog.java b/ddms/app/src/com/android/ddms/DeviceCommandDialog.java
deleted file mode 100644
index 6775cbb..0000000
--- a/ddms/app/src/com/android/ddms/DeviceCommandDialog.java
+++ /dev/null
@@ -1,441 +0,0 @@
-/* //device/tools/ddms/src/com/android/ddms/DeviceCommandDialog.java
-**
-** Copyright 2007, 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.
-*/
-
-package com.android.ddms;
-
-import com.android.ddmlib.AdbCommandRejectedException;
-import com.android.ddmlib.IDevice;
-import com.android.ddmlib.IShellOutputReceiver;
-import com.android.ddmlib.Log;
-import com.android.ddmlib.ShellCommandUnresponsiveException;
-import com.android.ddmlib.TimeoutException;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.graphics.FontData;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Dialog;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.FileDialog;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-
-import java.io.BufferedOutputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.UnsupportedEncodingException;
-
-
-/**
- * Execute a command on an ADB-attached device and save the output.
- *
- * There are several ways to do this. One is to run a single command
- * and show the output. Another is to have several possible commands and
- * let the user click a button next to the one (or ones) they want. This
- * currently uses the simple 1:1 form.
- */
-public class DeviceCommandDialog extends Dialog {
-
- public static final int DEVICE_STATE = 0;
- public static final int APP_STATE = 1;
- public static final int RADIO_STATE = 2;
- public static final int LOGCAT = 3;
-
- private String mCommand;
- private String mFileName;
-
- private Label mStatusLabel;
- private Button mCancelDone;
- private Button mSave;
- private Text mText;
- private Font mFont = null;
- private boolean mCancel;
- private boolean mFinished;
-
-
- /**
- * Create with default style.
- */
- public DeviceCommandDialog(String command, String fileName, Shell parent) {
- // don't want a close button, but it seems hard to get rid of on GTK
- // keep it on all platforms for consistency
- this(command, fileName, parent,
- SWT.DIALOG_TRIM | SWT.BORDER | SWT.APPLICATION_MODAL | SWT.RESIZE);
- }
-
- /**
- * Create with app-defined style.
- */
- public DeviceCommandDialog(String command, String fileName, Shell parent,
- int style)
- {
- super(parent, style);
- mCommand = command;
- mFileName = fileName;
- }
-
- /**
- * Prepare and display the dialog.
- * @param currentDevice
- */
- public void open(IDevice currentDevice) {
- Shell parent = getParent();
- Shell shell = new Shell(parent, getStyle());
- shell.setText("Remote Command");
-
- mFinished = false;
- mFont = findFont(shell.getDisplay());
- createContents(shell);
-
- // Getting weird layout behavior under Linux when Text is added --
- // looks like text widget has min width of 400 when FILL_HORIZONTAL
- // is used, and layout gets tweaked to force this. (Might be even
- // more with the scroll bars in place -- it wigged out when the
- // file save dialog was invoked.)
- shell.setMinimumSize(500, 200);
- shell.setSize(800, 600);
- shell.open();
-
- executeCommand(shell, currentDevice);
-
- Display display = parent.getDisplay();
- while (!shell.isDisposed()) {
- if (!display.readAndDispatch())
- display.sleep();
- }
-
- if (mFont != null)
- mFont.dispose();
- }
-
- /*
- * Create a text widget to show the output and some buttons to
- * manage things.
- */
- private void createContents(final Shell shell) {
- GridData data;
-
- shell.setLayout(new GridLayout(2, true));
-
- shell.addListener(SWT.Close, new Listener() {
- @Override
- public void handleEvent(Event event) {
- if (!mFinished) {
- Log.d("ddms", "NOT closing - cancelling command");
- event.doit = false;
- mCancel = true;
- }
- }
- });
-
- mStatusLabel = new Label(shell, SWT.NONE);
- mStatusLabel.setText("Executing '" + shortCommandString() + "'");
- data = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
- data.horizontalSpan = 2;
- mStatusLabel.setLayoutData(data);
-
- mText = new Text(shell, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
- mText.setEditable(false);
- mText.setFont(mFont);
- data = new GridData(GridData.FILL_BOTH);
- data.horizontalSpan = 2;
- mText.setLayoutData(data);
-
- // "save" button
- mSave = new Button(shell, SWT.PUSH);
- mSave.setText("Save");
- data = new GridData(GridData.HORIZONTAL_ALIGN_CENTER);
- data.widthHint = 80;
- mSave.setLayoutData(data);
- mSave.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- saveText(shell);
- }
- });
- mSave.setEnabled(false);
-
- // "cancel/done" button
- mCancelDone = new Button(shell, SWT.PUSH);
- mCancelDone.setText("Cancel");
- data = new GridData(GridData.HORIZONTAL_ALIGN_CENTER);
- data.widthHint = 80;
- mCancelDone.setLayoutData(data);
- mCancelDone.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- if (!mFinished)
- mCancel = true;
- else
- shell.close();
- }
- });
- }
-
- /*
- * Figure out what font to use.
- *
- * Returns "null" if we can't figure it out, which SWT understands to
- * mean "use default system font".
- */
- private Font findFont(Display display) {
- String fontStr = PrefsDialog.getStore().getString("textOutputFont");
- if (fontStr != null) {
- FontData fdat = new FontData(fontStr);
- if (fdat != null)
- return new Font(display, fdat);
- }
- return null;
- }
-
-
- /*
- * Callback class for command execution.
- */
- class Gatherer extends Thread implements IShellOutputReceiver {
- public static final int RESULT_UNKNOWN = 0;
- public static final int RESULT_SUCCESS = 1;
- public static final int RESULT_FAILURE = 2;
- public static final int RESULT_CANCELLED = 3;
-
- private Shell mShell;
- private String mCommand;
- private Text mText;
- private int mResult;
- private IDevice mDevice;
-
- /**
- * Constructor; pass in the text widget that will receive the output.
- * @param device
- */
- public Gatherer(Shell shell, IDevice device, String command, Text text) {
- mShell = shell;
- mDevice = device;
- mCommand = command;
- mText = text;
- mResult = RESULT_UNKNOWN;
-
- // this is in outer class
- mCancel = false;
- }
-
- /**
- * Thread entry point.
- */
- @Override
- public void run() {
-
- if (mDevice == null) {
- Log.w("ddms", "Cannot execute command: no device selected.");
- mResult = RESULT_FAILURE;
- } else {
- try {
- mDevice.executeShellCommand(mCommand, this);
- if (mCancel)
- mResult = RESULT_CANCELLED;
- else
- mResult = RESULT_SUCCESS;
- }
- catch (IOException ioe) {
- Log.w("ddms", "Remote exec failed: " + ioe.getMessage());
- mResult = RESULT_FAILURE;
- } catch (TimeoutException e) {
- Log.w("ddms", "Remote exec failed: " + e.getMessage());
- mResult = RESULT_FAILURE;
- } catch (AdbCommandRejectedException e) {
- Log.w("ddms", "Remote exec failed: " + e.getMessage());
- mResult = RESULT_FAILURE;
- } catch (ShellCommandUnresponsiveException e) {
- Log.w("ddms", "Remote exec failed: " + e.getMessage());
- mResult = RESULT_FAILURE;
- }
- }
-
- mShell.getDisplay().asyncExec(new Runnable() {
- @Override
- public void run() {
- updateForResult(mResult);
- }
- });
- }
-
- /**
- * Called by executeRemoteCommand().
- */
- @Override
- public void addOutput(byte[] data, int offset, int length) {
-
- Log.v("ddms", "received " + length + " bytes");
- try {
- final String text;
- text = new String(data, offset, length, "ISO-8859-1");
-
- // add to text widget; must do in UI thread
- mText.getDisplay().asyncExec(new Runnable() {
- @Override
- public void run() {
- mText.append(text);
- }
- });
- }
- catch (UnsupportedEncodingException uee) {
- uee.printStackTrace(); // not expected
- }
- }
-
- @Override
- public void flush() {
- // nothing to flush.
- }
-
- /**
- * Called by executeRemoteCommand().
- */
- @Override
- public boolean isCancelled() {
- return mCancel;
- }
- };
-
- /*
- * Execute a remote command, add the output to the text widget, and
- * update controls.
- *
- * We have to run the command in a thread so that the UI continues
- * to work.
- */
- private void executeCommand(Shell shell, IDevice device) {
- Gatherer gath = new Gatherer(shell, device, commandString(), mText);
- gath.start();
- }
-
- /*
- * Update the controls after the remote operation completes. This
- * must be called from the UI thread.
- */
- private void updateForResult(int result) {
- if (result == Gatherer.RESULT_SUCCESS) {
- mStatusLabel.setText("Successfully executed '"
- + shortCommandString() + "'");
- mSave.setEnabled(true);
- } else if (result == Gatherer.RESULT_CANCELLED) {
- mStatusLabel.setText("Execution cancelled; partial results below");
- mSave.setEnabled(true); // save partial
- } else if (result == Gatherer.RESULT_FAILURE) {
- mStatusLabel.setText("Failed");
- }
- mStatusLabel.pack();
- mCancelDone.setText("Done");
- mFinished = true;
- }
-
- /*
- * Allow the user to save the contents of the text dialog.
- */
- private void saveText(Shell shell) {
- FileDialog dlg = new FileDialog(shell, SWT.SAVE);
- String fileName;
-
- dlg.setText("Save output...");
- dlg.setFileName(defaultFileName());
- dlg.setFilterPath(PrefsDialog.getStore().getString("lastTextSaveDir"));
- dlg.setFilterNames(new String[] {
- "Text Files (*.txt)"
- });
- dlg.setFilterExtensions(new String[] {
- "*.txt"
- });
-
- fileName = dlg.open();
- if (fileName != null) {
- PrefsDialog.getStore().setValue("lastTextSaveDir",
- dlg.getFilterPath());
-
- Log.d("ddms", "Saving output to " + fileName);
-
- /*
- * Convert to 8-bit characters.
- */
- String text = mText.getText();
- byte[] ascii;
- try {
- ascii = text.getBytes("ISO-8859-1");
- }
- catch (UnsupportedEncodingException uee) {
- uee.printStackTrace();
- ascii = new byte[0];
- }
-
- /*
- * Output data, converting CRLF to LF.
- */
- try {
- int length = ascii.length;
-
- FileOutputStream outFile = new FileOutputStream(fileName);
- BufferedOutputStream out = new BufferedOutputStream(outFile);
- for (int i = 0; i < length; i++) {
- if (i < length-1 &&
- ascii[i] == 0x0d && ascii[i+1] == 0x0a)
- {
- continue;
- }
- out.write(ascii[i]);
- }
- out.close(); // flush buffer, close file
- }
- catch (IOException ioe) {
- Log.w("ddms", "Unable to save " + fileName + ": " + ioe);
- }
- }
- }
-
-
- /*
- * Return the shell command we're going to use.
- */
- private String commandString() {
- return mCommand;
-
- }
-
- /*
- * Return a default filename for the "save" command.
- */
- private String defaultFileName() {
- return mFileName;
- }
-
- /*
- * Like commandString(), but length-limited.
- */
- private String shortCommandString() {
- String str = commandString();
- if (str.length() > 50)
- return str.substring(0, 50) + "...";
- else
- return str;
- }
-}
-
diff --git a/ddms/app/src/com/android/ddms/DropdownSelectionListener.java b/ddms/app/src/com/android/ddms/DropdownSelectionListener.java
deleted file mode 100644
index 04d921c..0000000
--- a/ddms/app/src/com/android/ddms/DropdownSelectionListener.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/* //device/tools/ddms/src/com/android/ddms/DropdownSelectionListener.java
-**
-** Copyright 2007, 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.
-*/
-
-package com.android.ddms;
-
-import com.android.ddmlib.Log;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.swt.widgets.MenuItem;
-import org.eclipse.swt.widgets.ToolItem;
-
-/**
- * Helper class for drop-down menus in toolbars.
- */
-public class DropdownSelectionListener extends SelectionAdapter {
- private Menu mMenu;
- private ToolItem mDropdown;
-
- /**
- * Basic constructor. Creates an empty Menu to hold items.
- */
- public DropdownSelectionListener(ToolItem item) {
- mDropdown = item;
- mMenu = new Menu(item.getParent().getShell(), SWT.POP_UP);
- }
-
- /**
- * Add an item to the dropdown menu.
- */
- public void add(String label) {
- MenuItem item = new MenuItem(mMenu, SWT.NONE);
- item.setText(label);
- item.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- // update the dropdown's text to match the selection
- MenuItem sel = (MenuItem) e.widget;
- mDropdown.setText(sel.getText());
- }
- });
- }
-
- /**
- * Invoked when dropdown or neighboring arrow is clicked.
- */
- @Override
- public void widgetSelected(SelectionEvent e) {
- if (e.detail == SWT.ARROW) {
- // arrow clicked, show menu
- ToolItem item = (ToolItem) e.widget;
- Rectangle rect = item.getBounds();
- Point pt = item.getParent().toDisplay(new Point(rect.x, rect.y));
- mMenu.setLocation(pt.x, pt.y + rect.height);
- mMenu.setVisible(true);
- } else {
- // button clicked
- Log.d("ddms", mDropdown.getText() + " Pressed");
- }
- }
-}
-
diff --git a/ddms/app/src/com/android/ddms/Main.java b/ddms/app/src/com/android/ddms/Main.java
deleted file mode 100644
index bfdb78b..0000000
--- a/ddms/app/src/com/android/ddms/Main.java
+++ /dev/null
@@ -1,171 +0,0 @@
-/*
- * Copyright (C) 2007 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.
- */
-
-package com.android.ddms;
-
-import com.android.ddmlib.AndroidDebugBridge;
-import com.android.ddmlib.DebugPortManager;
-import com.android.ddmlib.Log;
-import com.android.sdkstats.SdkStatsService;
-
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.lang.management.ManagementFactory;
-import java.lang.management.RuntimeMXBean;
-import java.util.Properties;
-
-
-/**
- * Start the UI and network.
- */
-public class Main {
-
- public static String sRevision;
-
- public Main() {
- }
-
- /*
- * If a thread bails with an uncaught exception, bring the whole
- * thing down.
- */
- private static class UncaughtHandler implements Thread.UncaughtExceptionHandler {
- @Override
- public void uncaughtException(Thread t, Throwable e) {
- Log.e("ddms", "shutting down due to uncaught exception");
- Log.e("ddms", e);
- System.exit(1);
- }
- }
-
- /**
- * Parse args, start threads.
- */
- public static void main(String[] args) {
- // In order to have the AWT/SWT bridge work on Leopard, we do this little hack.
- if (isMac()) {
- RuntimeMXBean rt = ManagementFactory.getRuntimeMXBean();
- System.setProperty(
- "JAVA_STARTED_ON_FIRST_THREAD_" + (rt.getName().split("@"))[0], //$NON-NLS-1$
- "1"); //$NON-NLS-1$
- }
-
- Thread.setDefaultUncaughtExceptionHandler(new UncaughtHandler());
-
- // load prefs and init the default values
- PrefsDialog.init();
-
- Log.d("ddms", "Initializing");
-
- // Create an initial shell display with the correct app name.
- Display.setAppName(UIThread.APP_NAME);
- Shell shell = new Shell(Display.getDefault());
-
- // if this is the first time using ddms or adt, open up the stats service
- // opt out dialog, and request user for permissions.
- SdkStatsService stats = new SdkStatsService();
- stats.checkUserPermissionForPing(shell);
-
- // the "ping" argument means to check in with the server and exit
- // the application name and version number must also be supplied
- if (args.length >= 3 && args[0].equals("ping")) {
- stats.ping(args);
- return;
- } else if (args.length > 0) {
- Log.e("ddms", "Unknown argument: " + args[0]);
- System.exit(1);
- }
-
- // get the ddms parent folder location
- String ddmsParentLocation = System.getProperty("com.android.ddms.bindir"); //$NON-NLS-1$
-
- if (ddmsParentLocation == null) {
- // Tip: for debugging DDMS in eclipse, set this env var to the SDK/tools
- // directory path.
- ddmsParentLocation = System.getenv("com.android.ddms.bindir"); //$NON-NLS-1$
- }
-
- // we're past the point where ddms can be called just to send a ping, so we can
- // ping for ddms itself.
- ping(stats, ddmsParentLocation);
- stats = null;
-
- DebugPortManager.setProvider(DebugPortProvider.getInstance());
-
- // create the three main threads
- UIThread ui = UIThread.getInstance();
-
- try {
- ui.runUI(ddmsParentLocation);
- } finally {
- PrefsDialog.save();
-
- AndroidDebugBridge.terminate();
- }
-
- Log.d("ddms", "Bye");
-
- // this is kinda bad, but on MacOS the shutdown doesn't seem to finish because of
- // a thread called AWT-Shutdown. This will help while I track this down.
- System.exit(0);
- }
-
- /** Return true iff we're running on a Mac */
- static boolean isMac() {
- // TODO: Replace usages of this method with
- // org.eclipse.jface.util.Util#isMac() when we switch to Eclipse 3.5
- // (ddms is currently built with SWT 3.4.2 from ANDROID_SWT)
- return System.getProperty("os.name").startsWith("Mac OS"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- private static void ping(SdkStatsService stats, String ddmsParentLocation) {
- Properties p = new Properties();
- try{
- File sourceProp;
- if (ddmsParentLocation != null && ddmsParentLocation.length() > 0) {
- sourceProp = new File(ddmsParentLocation, "source.properties"); //$NON-NLS-1$
- } else {
- sourceProp = new File("source.properties"); //$NON-NLS-1$
- }
- FileInputStream fis = null;
- try {
- fis = new FileInputStream(sourceProp);
- p.load(fis);
- } finally {
- if (fis != null) {
- try {
- fis.close();
- } catch (IOException ignore) {
- }
- }
- }
-
- sRevision = p.getProperty("Pkg.Revision"); //$NON-NLS-1$
- if (sRevision != null && sRevision.length() > 0) {
- stats.ping("ddms", sRevision); //$NON-NLS-1$
- }
- } catch (FileNotFoundException e) {
- // couldn't find the file? don't ping.
- } catch (IOException e) {
- // couldn't find the file? don't ping.
- }
- }
-}
diff --git a/ddms/app/src/com/android/ddms/PrefsDialog.java b/ddms/app/src/com/android/ddms/PrefsDialog.java
deleted file mode 100644
index acadeb8..0000000
--- a/ddms/app/src/com/android/ddms/PrefsDialog.java
+++ /dev/null
@@ -1,610 +0,0 @@
-/*
- * Copyright (C) 2007 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.
- */
-
-package com.android.ddms;
-
-import com.android.ddmlib.DdmConstants;
-import com.android.ddmlib.DdmPreferences;
-import com.android.ddmlib.Log;
-import com.android.ddmlib.Log.LogLevel;
-import com.android.ddmuilib.DdmUiPreferences;
-import com.android.ddmuilib.PortFieldEditor;
-import com.android.ddmuilib.logcat.LogCatMessageList;
-import com.android.ddmuilib.logcat.LogCatPanel;
-import com.android.sdkstats.DdmsPreferenceStore;
-import com.android.sdkstats.SdkStatsPermissionDialog;
-
-import org.eclipse.jface.preference.BooleanFieldEditor;
-import org.eclipse.jface.preference.DirectoryFieldEditor;
-import org.eclipse.jface.preference.FieldEditorPreferencePage;
-import org.eclipse.jface.preference.FontFieldEditor;
-import org.eclipse.jface.preference.IntegerFieldEditor;
-import org.eclipse.jface.preference.PreferenceDialog;
-import org.eclipse.jface.preference.PreferenceManager;
-import org.eclipse.jface.preference.PreferenceNode;
-import org.eclipse.jface.preference.PreferencePage;
-import org.eclipse.jface.preference.PreferenceStore;
-import org.eclipse.jface.preference.RadioGroupFieldEditor;
-import org.eclipse.jface.preference.StringFieldEditor;
-import org.eclipse.jface.util.IPropertyChangeListener;
-import org.eclipse.jface.util.PropertyChangeEvent;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.FontData;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Link;
-import org.eclipse.swt.widgets.Shell;
-
-import java.io.File;
-import java.io.IOException;
-
-/**
- * Preferences dialog.
- */
-public final class PrefsDialog {
-
- // public const values for storage
- public final static String SHELL_X = "shellX"; //$NON-NLS-1$
- public final static String SHELL_Y = "shellY"; //$NON-NLS-1$
- public final static String SHELL_WIDTH = "shellWidth"; //$NON-NLS-1$
- public final static String SHELL_HEIGHT = "shellHeight"; //$NON-NLS-1$
- public final static String EXPLORER_SHELL_X = "explorerShellX"; //$NON-NLS-1$
- public final static String EXPLORER_SHELL_Y = "explorerShellY"; //$NON-NLS-1$
- public final static String EXPLORER_SHELL_WIDTH = "explorerShellWidth"; //$NON-NLS-1$
- public final static String EXPLORER_SHELL_HEIGHT = "explorerShellHeight"; //$NON-NLS-1$
- public final static String SHOW_NATIVE_HEAP = "native"; //$NON-NLS-1$
-
- public final static String LOGCAT_COLUMN_MODE = "ddmsLogColumnMode"; //$NON-NLS-1$
- public final static String LOGCAT_FONT = "ddmsLogFont"; //$NON-NLS-1$
-
- public final static String LOGCAT_COLUMN_MODE_AUTO = "auto"; //$NON-NLS-1$
- public final static String LOGCAT_COLUMN_MODE_MANUAL = "manual"; //$NON-NLS-1$
-
- private final static String PREFS_DEBUG_PORT_BASE = "adbDebugBasePort"; //$NON-NLS-1$
- private final static String PREFS_SELECTED_DEBUG_PORT = "debugSelectedPort"; //$NON-NLS-1$
- private final static String PREFS_DEFAULT_THREAD_UPDATE = "defaultThreadUpdateEnabled"; //$NON-NLS-1$
- private final static String PREFS_DEFAULT_HEAP_UPDATE = "defaultHeapUpdateEnabled"; //$NON-NLS-1$
- private final static String PREFS_THREAD_REFRESH_INTERVAL = "threadStatusInterval"; //$NON-NLS-1$
- private final static String PREFS_LOG_LEVEL = "ddmsLogLevel"; //$NON-NLS-1$
- private final static String PREFS_TIMEOUT = "timeOut"; //$NON-NLS-1$
- private final static String PREFS_PROFILER_BUFFER_SIZE_MB = "profilerBufferSizeMb"; //$NON-NLS-1$
- private final static String PREFS_USE_ADBHOST = "useAdbHost"; //$NON-NLS-1$
- private final static String PREFS_ADBHOST_VALUE = "adbHostValue"; //$NON-NLS-1$
-
- // Preference store.
- private static DdmsPreferenceStore mStore = new DdmsPreferenceStore();
-
- /**
- * Private constructor -- do not instantiate.
- */
- private PrefsDialog() {}
-
- /**
- * Return the PreferenceStore that holds our values.
- *
- * @deprecated Callers should use {@link DdmsPreferenceStore} directly.
- */
- @Deprecated
- public static PreferenceStore getStore() {
- return mStore.getPreferenceStore();
- }
-
- /**
- * Save the prefs to the config file.
- *
- * @deprecated Callers should use {@link DdmsPreferenceStore} directly.
- */
- @Deprecated
- public static void save() {
- try {
- mStore.getPreferenceStore().save();
- }
- catch (IOException ioe) {
- Log.w("ddms", "Failed saving prefs file: " + ioe.getMessage());
- }
- }
-
- /**
- * Do some one-time prep.
- *
- * The original plan was to let the individual classes define their
- * own defaults, which we would get and then override with the config
- * file. However, PreferencesStore.load() doesn't trigger the "changed"
- * events, which means we have to pull the loaded config values out by
- * hand.
- *
- * So, we set the defaults, load the values from the config file, and
- * then run through and manually export the values. Then we duplicate
- * the second part later on for the "changed" events.
- */
- public static void init() {
- PreferenceStore prefStore = mStore.getPreferenceStore();
-
- if (prefStore == null) {
- // we have a serious issue here...
- Log.e("ddms",
- "failed to access both the user HOME directory and the system wide temp folder. Quitting.");
- System.exit(1);
- }
-
- // configure default values
- setDefaults(System.getProperty("user.home")); //$NON-NLS-1$
-
- // listen for changes
- prefStore.addPropertyChangeListener(new ChangeListener());
-
- // Now we initialize the value of the preference, from the values in the store.
-
- // First the ddm lib.
- DdmPreferences.setDebugPortBase(prefStore.getInt(PREFS_DEBUG_PORT_BASE));
- DdmPreferences.setSelectedDebugPort(prefStore.getInt(PREFS_SELECTED_DEBUG_PORT));
- DdmPreferences.setLogLevel(prefStore.getString(PREFS_LOG_LEVEL));
- DdmPreferences.setInitialThreadUpdate(prefStore.getBoolean(PREFS_DEFAULT_THREAD_UPDATE));
- DdmPreferences.setInitialHeapUpdate(prefStore.getBoolean(PREFS_DEFAULT_HEAP_UPDATE));
- DdmPreferences.setTimeOut(prefStore.getInt(PREFS_TIMEOUT));
- DdmPreferences.setProfilerBufferSizeMb(prefStore.getInt(PREFS_PROFILER_BUFFER_SIZE_MB));
- DdmPreferences.setUseAdbHost(prefStore.getBoolean(PREFS_USE_ADBHOST));
- DdmPreferences.setAdbHostValue(prefStore.getString(PREFS_ADBHOST_VALUE));
-
- // some static values
- String out = System.getenv("ANDROID_PRODUCT_OUT"); //$NON-NLS-1$
- DdmUiPreferences.setSymbolsLocation(out + File.separator + "symbols"); //$NON-NLS-1$
- DdmUiPreferences.setAddr2LineLocation("arm-linux-androideabi-addr2line"); //$NON-NLS-1$
-
- String traceview = System.getProperty("com.android.ddms.bindir"); //$NON-NLS-1$
- if (traceview != null && traceview.length() != 0) {
- traceview += File.separator + DdmConstants.FN_TRACEVIEW;
- } else {
- traceview = DdmConstants.FN_TRACEVIEW;
- }
- DdmUiPreferences.setTraceviewLocation(traceview);
-
- // Now the ddmui lib
- DdmUiPreferences.setStore(prefStore);
- DdmUiPreferences.setThreadRefreshInterval(prefStore.getInt(PREFS_THREAD_REFRESH_INTERVAL));
- }
-
- /*
- * Set default values for all preferences. These are either defined
- * statically or are based on the values set by the class initializers
- * in other classes.
- *
- * The other threads (e.g. VMWatcherThread) haven't been created yet,
- * so we want to use static values rather than reading fields from
- * class.getInstance().
- */
- private static void setDefaults(String homeDir) {
- PreferenceStore prefStore = mStore.getPreferenceStore();
-
- prefStore.setDefault(PREFS_DEBUG_PORT_BASE, DdmPreferences.DEFAULT_DEBUG_PORT_BASE);
-
- prefStore.setDefault(PREFS_SELECTED_DEBUG_PORT,
- DdmPreferences.DEFAULT_SELECTED_DEBUG_PORT);
-
- prefStore.setDefault(PREFS_USE_ADBHOST, DdmPreferences.DEFAULT_USE_ADBHOST);
- prefStore.setDefault(PREFS_ADBHOST_VALUE, DdmPreferences.DEFAULT_ADBHOST_VALUE);
-
- prefStore.setDefault(PREFS_DEFAULT_THREAD_UPDATE, true);
- prefStore.setDefault(PREFS_DEFAULT_HEAP_UPDATE, false);
- prefStore.setDefault(PREFS_THREAD_REFRESH_INTERVAL,
- DdmUiPreferences.DEFAULT_THREAD_REFRESH_INTERVAL);
-
- prefStore.setDefault("textSaveDir", homeDir); //$NON-NLS-1$
- prefStore.setDefault("imageSaveDir", homeDir); //$NON-NLS-1$
-
- prefStore.setDefault(PREFS_LOG_LEVEL, "info"); //$NON-NLS-1$
-
- prefStore.setDefault(PREFS_TIMEOUT, DdmPreferences.DEFAULT_TIMEOUT);
- prefStore.setDefault(PREFS_PROFILER_BUFFER_SIZE_MB,
- DdmPreferences.DEFAULT_PROFILER_BUFFER_SIZE_MB);
-
- // choose a default font for the text output
- FontData fdat = new FontData("Courier", 10, SWT.NORMAL); //$NON-NLS-1$
- prefStore.setDefault("textOutputFont", fdat.toString()); //$NON-NLS-1$
-
- // layout information.
- prefStore.setDefault(SHELL_X, 100);
- prefStore.setDefault(SHELL_Y, 100);
- prefStore.setDefault(SHELL_WIDTH, 800);
- prefStore.setDefault(SHELL_HEIGHT, 600);
-
- prefStore.setDefault(EXPLORER_SHELL_X, 50);
- prefStore.setDefault(EXPLORER_SHELL_Y, 50);
-
- prefStore.setDefault(SHOW_NATIVE_HEAP, false);
- }
-
-
- /*
- * Create a "listener" to take action when preferences change. These are
- * required for ongoing activities that don't check prefs on each use.
- *
- * This is only invoked when something explicitly changes the value of
- * a preference (e.g. not when the prefs file is loaded).
- */
- private static class ChangeListener implements IPropertyChangeListener {
- @Override
- public void propertyChange(PropertyChangeEvent event) {
- String changed = event.getProperty();
- PreferenceStore prefStore = mStore.getPreferenceStore();
-
- if (changed.equals(PREFS_DEBUG_PORT_BASE)) {
- DdmPreferences.setDebugPortBase(prefStore.getInt(PREFS_DEBUG_PORT_BASE));
- } else if (changed.equals(PREFS_SELECTED_DEBUG_PORT)) {
- DdmPreferences.setSelectedDebugPort(prefStore.getInt(PREFS_SELECTED_DEBUG_PORT));
- } else if (changed.equals(PREFS_LOG_LEVEL)) {
- DdmPreferences.setLogLevel((String)event.getNewValue());
- } else if (changed.equals("textSaveDir")) {
- prefStore.setValue("lastTextSaveDir",
- (String) event.getNewValue());
- } else if (changed.equals("imageSaveDir")) {
- prefStore.setValue("lastImageSaveDir",
- (String) event.getNewValue());
- } else if (changed.equals(PREFS_TIMEOUT)) {
- DdmPreferences.setTimeOut(prefStore.getInt(PREFS_TIMEOUT));
- } else if (changed.equals(PREFS_PROFILER_BUFFER_SIZE_MB)) {
- DdmPreferences.setProfilerBufferSizeMb(
- prefStore.getInt(PREFS_PROFILER_BUFFER_SIZE_MB));
- } else if (changed.equals(PREFS_USE_ADBHOST)) {
- DdmPreferences.setUseAdbHost(prefStore.getBoolean(PREFS_USE_ADBHOST));
- } else if (changed.equals(PREFS_ADBHOST_VALUE)) {
- DdmPreferences.setAdbHostValue(prefStore.getString(PREFS_ADBHOST_VALUE));
- } else {
- Log.v("ddms", "Preference change: " + event.getProperty()
- + ": '" + event.getOldValue()
- + "' --> '" + event.getNewValue() + "'");
- }
- }
- }
-
-
- /**
- * Create and display the dialog.
- */
- public static void run(Shell shell) {
- PreferenceStore prefStore = mStore.getPreferenceStore();
- assert prefStore != null;
-
- PreferenceManager prefMgr = new PreferenceManager();
-
- PreferenceNode node, subNode;
-
- // this didn't work -- got NPE, possibly from class lookup:
- //PreferenceNode app = new PreferenceNode("app", "Application", null,
- // AppPrefs.class.getName());
-
- node = new PreferenceNode("debugger", new DebuggerPrefs());
- prefMgr.addToRoot(node);
-
- subNode = new PreferenceNode("panel", new PanelPrefs());
- //prefMgr.addTo(node.getId(), subNode);
- prefMgr.addToRoot(subNode);
-
- node = new PreferenceNode("LogCat", new LogCatPrefs());
- prefMgr.addToRoot(node);
-
- node = new PreferenceNode("misc", new MiscPrefs());
- prefMgr.addToRoot(node);
-
- node = new PreferenceNode("stats", new UsageStatsPrefs());
- prefMgr.addToRoot(node);
-
- PreferenceDialog dlg = new PreferenceDialog(shell, prefMgr);
- dlg.setPreferenceStore(prefStore);
-
- // run it
- try {
- dlg.open();
- } catch (Throwable t) {
- Log.e("ddms", t);
- }
-
- // save prefs
- try {
- prefStore.save();
- }
- catch (IOException ioe) {
- }
-
- // discard the stuff we created
- //prefMgr.dispose();
- //dlg.dispose();
- }
-
- /**
- * "Debugger" prefs page.
- */
- private static class DebuggerPrefs extends FieldEditorPreferencePage {
-
- private BooleanFieldEditor mUseAdbHost;
- private StringFieldEditor mAdbHostValue;
-
- /**
- * Basic constructor.
- */
- public DebuggerPrefs() {
- super(GRID); // use "grid" layout so edit boxes line up
- setTitle("Debugger");
- }
-
- /**
- * Create field editors.
- */
- @Override
- protected void createFieldEditors() {
- IntegerFieldEditor ife;
-
- ife = new PortFieldEditor(PREFS_DEBUG_PORT_BASE,
- "Starting value for local port:", getFieldEditorParent());
- addField(ife);
-
- ife = new PortFieldEditor(PREFS_SELECTED_DEBUG_PORT,
- "Port of Selected VM:", getFieldEditorParent());
- addField(ife);
-
- mUseAdbHost = new BooleanFieldEditor(PREFS_USE_ADBHOST,
- "Use ADBHOST", getFieldEditorParent());
- addField(mUseAdbHost);
-
- mAdbHostValue = new StringFieldEditor(PREFS_ADBHOST_VALUE,
- "ADBHOST value:", getFieldEditorParent());
- mAdbHostValue.setEnabled(getPreferenceStore()
- .getBoolean(PREFS_USE_ADBHOST), getFieldEditorParent());
- addField(mAdbHostValue);
- }
-
- @Override
- public void propertyChange(PropertyChangeEvent event) {
- // TODO Auto-generated method stub
- if (event.getSource().equals(mUseAdbHost)) {
- mAdbHostValue.setEnabled(mUseAdbHost.getBooleanValue(), getFieldEditorParent());
- }
- }
- }
-
- /**
- * "Panel" prefs page.
- */
- private static class PanelPrefs extends FieldEditorPreferencePage {
-
- /**
- * Basic constructor.
- */
- public PanelPrefs() {
- super(FLAT); // use "flat" layout
- setTitle("Info Panels");
- }
-
- /**
- * Create field editors.
- */
- @Override
- protected void createFieldEditors() {
- BooleanFieldEditor bfe;
- IntegerFieldEditor ife;
-
- bfe = new BooleanFieldEditor(PREFS_DEFAULT_THREAD_UPDATE,
- "Thread updates enabled by default", getFieldEditorParent());
- addField(bfe);
-
- bfe = new BooleanFieldEditor(PREFS_DEFAULT_HEAP_UPDATE,
- "Heap updates enabled by default", getFieldEditorParent());
- addField(bfe);
-
- ife = new IntegerFieldEditor(PREFS_THREAD_REFRESH_INTERVAL,
- "Thread status interval (seconds):", getFieldEditorParent());
- ife.setValidRange(1, 60);
- addField(ife);
- }
- }
-
- /**
- * "logcat" prefs page.
- */
- private static class LogCatPrefs extends FieldEditorPreferencePage {
-
- /**
- * Basic constructor.
- */
- public LogCatPrefs() {
- super(FLAT); // use "flat" layout
- setTitle("Logcat");
- }
-
- /**
- * Create field editors.
- */
- @Override
- protected void createFieldEditors() {
- if (UIThread.useOldLogCatView()) {
- RadioGroupFieldEditor rgfe;
-
- rgfe = new RadioGroupFieldEditor(PrefsDialog.LOGCAT_COLUMN_MODE,
- "Message Column Resizing Mode", 1, new String[][] {
- { "Manual", PrefsDialog.LOGCAT_COLUMN_MODE_MANUAL },
- { "Automatic", PrefsDialog.LOGCAT_COLUMN_MODE_AUTO },
- },
- getFieldEditorParent(), true);
- addField(rgfe);
-
- FontFieldEditor ffe = new FontFieldEditor(PrefsDialog.LOGCAT_FONT,
- "Text output font:",
- getFieldEditorParent());
- addField(ffe);
- } else {
- FontFieldEditor ffe = new FontFieldEditor(LogCatPanel.LOGCAT_VIEW_FONT_PREFKEY,
- "Text output font:",
- getFieldEditorParent());
- addField(ffe);
-
- IntegerFieldEditor maxMessages = new IntegerFieldEditor(
- LogCatMessageList.MAX_MESSAGES_PREFKEY,
- "Maximum number of logcat messages to buffer",
- getFieldEditorParent());
- addField(maxMessages);
-
- BooleanFieldEditor autoScrollLock = new BooleanFieldEditor(
- LogCatPanel.AUTO_SCROLL_LOCK_PREFKEY,
- "Automatically enable/disable scroll lock based on the scrollbar position",
- getFieldEditorParent());
- addField(autoScrollLock);
- }
- }
- }
-
- /**
- * "misc" prefs page.
- */
- private static class MiscPrefs extends FieldEditorPreferencePage {
-
- /**
- * Basic constructor.
- */
- public MiscPrefs() {
- super(FLAT); // use "flat" layout
- setTitle("Misc");
- }
-
- /**
- * Create field editors.
- */
- @Override
- protected void createFieldEditors() {
- DirectoryFieldEditor dfe;
- FontFieldEditor ffe;
-
- IntegerFieldEditor ife = new IntegerFieldEditor(PREFS_TIMEOUT,
- "ADB connection time out (ms):", getFieldEditorParent());
- addField(ife);
-
- ife = new IntegerFieldEditor(PREFS_PROFILER_BUFFER_SIZE_MB,
- "Profiler buffer size (MB):", getFieldEditorParent());
- addField(ife);
-
- dfe = new DirectoryFieldEditor("textSaveDir",
- "Default text save dir:", getFieldEditorParent());
- addField(dfe);
-
- dfe = new DirectoryFieldEditor("imageSaveDir",
- "Default image save dir:", getFieldEditorParent());
- addField(dfe);
-
- ffe = new FontFieldEditor("textOutputFont", "Text output font:",
- getFieldEditorParent());
- addField(ffe);
-
- RadioGroupFieldEditor rgfe;
-
- rgfe = new RadioGroupFieldEditor(PREFS_LOG_LEVEL,
- "Logging Level", 1, new String[][] {
- { "Verbose", LogLevel.VERBOSE.getStringValue() },
- { "Debug", LogLevel.DEBUG.getStringValue() },
- { "Info", LogLevel.INFO.getStringValue() },
- { "Warning", LogLevel.WARN.getStringValue() },
- { "Error", LogLevel.ERROR.getStringValue() },
- { "Assert", LogLevel.ASSERT.getStringValue() },
- },
- getFieldEditorParent(), true);
- addField(rgfe);
- }
- }
-
- /**
- * "Device" prefs page.
- */
- private static class UsageStatsPrefs extends PreferencePage {
-
- private BooleanFieldEditor mOptInCheckbox;
- private Composite mTop;
-
- /**
- * Basic constructor.
- */
- public UsageStatsPrefs() {
- setTitle("Usage Stats");
- }
-
- @Override
- protected Control createContents(Composite parent) {
- mTop = new Composite(parent, SWT.NONE);
- mTop.setLayout(new GridLayout(1, false));
- mTop.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- Label text = new Label(mTop, SWT.WRAP);
- text.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- text.setText(SdkStatsPermissionDialog.BODY_TEXT);
-
- Link privacyPolicyLink = new Link(mTop, SWT.WRAP);
- privacyPolicyLink.setText(SdkStatsPermissionDialog.PRIVACY_POLICY_LINK_TEXT);
- privacyPolicyLink.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent event) {
- SdkStatsPermissionDialog.openUrl(event.text);
- }
- });
-
- mOptInCheckbox = new BooleanFieldEditor(DdmsPreferenceStore.PING_OPT_IN,
- SdkStatsPermissionDialog.CHECKBOX_TEXT, mTop);
- mOptInCheckbox.setPage(this);
- mOptInCheckbox.setPreferenceStore(getPreferenceStore());
- mOptInCheckbox.load();
-
- return null;
- }
-
- @Override
- protected Point doComputeSize() {
- if (mTop != null) {
- return mTop.computeSize(450, SWT.DEFAULT, true);
- }
-
- return super.doComputeSize();
- }
-
- @Override
- protected void performDefaults() {
- if (mOptInCheckbox != null) {
- mOptInCheckbox.loadDefault();
- }
- super.performDefaults();
- }
-
- @Override
- public void performApply() {
- if (mOptInCheckbox != null) {
- mOptInCheckbox.store();
- }
- super.performApply();
- }
-
- @Override
- public boolean performOk() {
- if (mOptInCheckbox != null) {
- mOptInCheckbox.store();
- }
- return super.performOk();
- }
- }
-
-}
-
-
diff --git a/ddms/app/src/com/android/ddms/StaticPortConfigDialog.java b/ddms/app/src/com/android/ddms/StaticPortConfigDialog.java
deleted file mode 100644
index 9a8ada3..0000000
--- a/ddms/app/src/com/android/ddms/StaticPortConfigDialog.java
+++ /dev/null
@@ -1,395 +0,0 @@
-/*
- * Copyright (C) 2007 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.
- */
-
-package com.android.ddms;
-
-import com.android.ddmuilib.TableHelper;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Dialog;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableItem;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * Dialog to configure the static debug ports.
- *
- */
-public class StaticPortConfigDialog extends Dialog {
-
- /** Preference name for the 0th column width */
- private static final String PREFS_DEVICE_COL = "spcd.deviceColumn"; //$NON-NLS-1$
-
- /** Preference name for the 1st column width */
- private static final String PREFS_APP_COL = "spcd.AppColumn"; //$NON-NLS-1$
-
- /** Preference name for the 2nd column width */
- private static final String PREFS_PORT_COL = "spcd.PortColumn"; //$NON-NLS-1$
-
- private static final int COL_DEVICE = 0;
- private static final int COL_APPLICATION = 1;
- private static final int COL_PORT = 2;
-
-
- private static final int DLG_WIDTH = 500;
- private static final int DLG_HEIGHT = 300;
-
- private Shell mShell;
- private Shell mParent;
-
- private Table mPortTable;
-
- /**
- * Array containing the list of already used static port to avoid
- * duplication.
- */
- private ArrayList<Integer> mPorts = new ArrayList<Integer>();
-
- /**
- * Basic constructor.
- * @param parent
- */
- public StaticPortConfigDialog(Shell parent) {
- super(parent, SWT.DIALOG_TRIM | SWT.BORDER | SWT.APPLICATION_MODAL);
- }
-
- /**
- * Open and display the dialog. This method returns only when the
- * user closes the dialog somehow.
- *
- */
- public void open() {
- createUI();
-
- if (mParent == null || mShell == null) {
- return;
- }
-
- updateFromStore();
-
- // Set the dialog size.
- mShell.setMinimumSize(DLG_WIDTH, DLG_HEIGHT);
- Rectangle r = mParent.getBounds();
- // get the center new top left.
- int cx = r.x + r.width/2;
- int x = cx - DLG_WIDTH / 2;
- int cy = r.y + r.height/2;
- int y = cy - DLG_HEIGHT / 2;
- mShell.setBounds(x, y, DLG_WIDTH, DLG_HEIGHT);
-
- mShell.pack();
-
- // actually open the dialog
- mShell.open();
-
- // event loop until the dialog is closed.
- Display display = mParent.getDisplay();
- while (!mShell.isDisposed()) {
- if (!display.readAndDispatch())
- display.sleep();
- }
- }
-
- /**
- * Creates the dialog ui.
- */
- private void createUI() {
- mParent = getParent();
- mShell = new Shell(mParent, getStyle());
- mShell.setText("Static Port Configuration");
-
- mShell.setLayout(new GridLayout(1, true));
-
- mShell.addListener(SWT.Close, new Listener() {
- @Override
- public void handleEvent(Event event) {
- event.doit = true;
- }
- });
-
- // center part with the list on the left and the buttons
- // on the right.
- Composite main = new Composite(mShell, SWT.NONE);
- main.setLayoutData(new GridData(GridData.FILL_BOTH));
- main.setLayout(new GridLayout(2, false));
-
- // left part: list view
- mPortTable = new Table(main, SWT.SINGLE | SWT.FULL_SELECTION);
- mPortTable.setLayoutData(new GridData(GridData.FILL_BOTH));
- mPortTable.setHeaderVisible(true);
- mPortTable.setLinesVisible(true);
-
- TableHelper.createTableColumn(mPortTable, "Device Serial Number",
- SWT.LEFT, "emulator-5554", //$NON-NLS-1$
- PREFS_DEVICE_COL, PrefsDialog.getStore());
-
- TableHelper.createTableColumn(mPortTable, "Application Package",
- SWT.LEFT, "com.android.samples.phone", //$NON-NLS-1$
- PREFS_APP_COL, PrefsDialog.getStore());
-
- TableHelper.createTableColumn(mPortTable, "Debug Port",
- SWT.RIGHT, "Debug Port", //$NON-NLS-1$
- PREFS_PORT_COL, PrefsDialog.getStore());
-
- // right part: buttons
- Composite buttons = new Composite(main, SWT.NONE);
- buttons.setLayoutData(new GridData(GridData.FILL_VERTICAL));
- buttons.setLayout(new GridLayout(1, true));
-
- Button newButton = new Button(buttons, SWT.NONE);
- newButton.setText("New...");
- newButton.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- StaticPortEditDialog dlg = new StaticPortEditDialog(mShell,
- mPorts);
- if (dlg.open()) {
- // get the text
- String device = dlg.getDeviceSN();
- String app = dlg.getAppName();
- int port = dlg.getPortNumber();
-
- // add it to the list
- addEntry(device, app, port);
- }
- }
- });
-
- final Button editButton = new Button(buttons, SWT.NONE);
- editButton.setText("Edit...");
- editButton.setEnabled(false);
- editButton.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- int index = mPortTable.getSelectionIndex();
- String oldDeviceName = getDeviceName(index);
- String oldAppName = getAppName(index);
- String oldPortNumber = getPortNumber(index);
- StaticPortEditDialog dlg = new StaticPortEditDialog(mShell,
- mPorts, oldDeviceName, oldAppName, oldPortNumber);
- if (dlg.open()) {
- // get the text
- String deviceName = dlg.getDeviceSN();
- String app = dlg.getAppName();
- int port = dlg.getPortNumber();
-
- // add it to the list
- replaceEntry(index, deviceName, app, port);
- }
- }
- });
-
- final Button deleteButton = new Button(buttons, SWT.NONE);
- deleteButton.setText("Delete");
- deleteButton.setEnabled(false);
- deleteButton.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- int index = mPortTable.getSelectionIndex();
- removeEntry(index);
- }
- });
-
- // bottom part with the ok/cancel
- Composite bottomComp = new Composite(mShell, SWT.NONE);
- bottomComp.setLayoutData(new GridData(
- GridData.HORIZONTAL_ALIGN_CENTER));
- bottomComp.setLayout(new GridLayout(2, true));
-
- Button okButton = new Button(bottomComp, SWT.NONE);
- okButton.setText("OK");
- okButton.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- updateStore();
- mShell.close();
- }
- });
-
- Button cancelButton = new Button(bottomComp, SWT.NONE);
- cancelButton.setText("Cancel");
- cancelButton.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- mShell.close();
- }
- });
-
- mPortTable.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- // get the selection index
- int index = mPortTable.getSelectionIndex();
-
- boolean enabled = index != -1;
- editButton.setEnabled(enabled);
- deleteButton.setEnabled(enabled);
- }
- });
-
- mShell.pack();
-
- }
-
- /**
- * Add a new entry in the list.
- * @param deviceName the serial number of the device
- * @param appName java package for the application
- * @param portNumber port number
- */
- private void addEntry(String deviceName, String appName, int portNumber) {
- // create a new item for the table
- TableItem item = new TableItem(mPortTable, SWT.NONE);
-
- item.setText(COL_DEVICE, deviceName);
- item.setText(COL_APPLICATION, appName);
- item.setText(COL_PORT, Integer.toString(portNumber));
-
- // add the port to the list of port number used.
- mPorts.add(portNumber);
- }
-
- /**
- * Remove an entry from the list.
- * @param index The index of the entry to be removed
- */
- private void removeEntry(int index) {
- // remove from the ui
- mPortTable.remove(index);
-
- // and from the port list.
- mPorts.remove(index);
- }
-
- /**
- * Replace an entry in the list with new values.
- * @param index The index of the item to be replaced
- * @param deviceName the serial number of the device
- * @param appName The new java package for the application
- * @param portNumber The new port number.
- */
- private void replaceEntry(int index, String deviceName, String appName, int portNumber) {
- // get the table item by index
- TableItem item = mPortTable.getItem(index);
-
- // set its new value
- item.setText(COL_DEVICE, deviceName);
- item.setText(COL_APPLICATION, appName);
- item.setText(COL_PORT, Integer.toString(portNumber));
-
- // and replace the port number in the port list.
- mPorts.set(index, portNumber);
- }
-
-
- /**
- * Returns the device name for a specific index
- * @param index The index
- * @return the java package name of the application
- */
- private String getDeviceName(int index) {
- TableItem item = mPortTable.getItem(index);
- return item.getText(COL_DEVICE);
- }
-
- /**
- * Returns the application name for a specific index
- * @param index The index
- * @return the java package name of the application
- */
- private String getAppName(int index) {
- TableItem item = mPortTable.getItem(index);
- return item.getText(COL_APPLICATION);
- }
-
- /**
- * Returns the port number for a specific index
- * @param index The index
- * @return the port number
- */
- private String getPortNumber(int index) {
- TableItem item = mPortTable.getItem(index);
- return item.getText(COL_PORT);
- }
-
- /**
- * Updates the ui from the value in the preference store.
- */
- private void updateFromStore() {
- // get the map from the debug port manager
- DebugPortProvider provider = DebugPortProvider.getInstance();
- Map<String, Map<String, Integer>> map = provider.getPortList();
-
- // we're going to loop on the keys and fill the table.
- Set<String> deviceKeys = map.keySet();
-
- for (String deviceKey : deviceKeys) {
- Map<String, Integer> deviceMap = map.get(deviceKey);
- if (deviceMap != null) {
- Set<String> appKeys = deviceMap.keySet();
-
- for (String appKey : appKeys) {
- Integer port = deviceMap.get(appKey);
- if (port != null) {
- addEntry(deviceKey, appKey, port);
- }
- }
- }
- }
- }
-
- /**
- * Update the store from the content of the ui.
- */
- private void updateStore() {
- // create a new Map object and fill it.
- HashMap<String, Map<String, Integer>> map = new HashMap<String, Map<String, Integer>>();
-
- int count = mPortTable.getItemCount();
-
- for (int i = 0 ; i < count ; i++) {
- TableItem item = mPortTable.getItem(i);
- String deviceName = item.getText(COL_DEVICE);
-
- Map<String, Integer> deviceMap = map.get(deviceName);
- if (deviceMap == null) {
- deviceMap = new HashMap<String, Integer>();
- map.put(deviceName, deviceMap);
- }
-
- deviceMap.put(item.getText(COL_APPLICATION), Integer.valueOf(item.getText(COL_PORT)));
- }
-
- // set it in the store through the debug port manager.
- DebugPortProvider provider = DebugPortProvider.getInstance();
- provider.setPortList(map);
- }
-}
diff --git a/ddms/app/src/com/android/ddms/StaticPortEditDialog.java b/ddms/app/src/com/android/ddms/StaticPortEditDialog.java
deleted file mode 100644
index c9cb044..0000000
--- a/ddms/app/src/com/android/ddms/StaticPortEditDialog.java
+++ /dev/null
@@ -1,334 +0,0 @@
-/*
- * Copyright (C) 2007 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.
- */
-
-package com.android.ddms;
-
-import com.android.ddmlib.IDevice;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Dialog;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-
-import java.util.ArrayList;
-
-/**
- * Small dialog box to edit a static port number.
- */
-public class StaticPortEditDialog extends Dialog {
-
- private static final int DLG_WIDTH = 400;
- private static final int DLG_HEIGHT = 200;
-
- private Shell mParent;
-
- private Shell mShell;
-
- private boolean mOk = false;
-
- private String mAppName;
-
- private String mPortNumber;
-
- private Button mOkButton;
-
- private Label mWarning;
-
- /** List of ports already in use */
- private ArrayList<Integer> mPorts;
-
- /** This is the port being edited. */
- private int mEditPort = -1;
- private String mDeviceSn;
-
- /**
- * Creates a dialog with empty fields.
- * @param parent The parent Shell
- * @param ports The list of already used port numbers.
- */
- public StaticPortEditDialog(Shell parent, ArrayList<Integer> ports) {
- super(parent, SWT.DIALOG_TRIM | SWT.BORDER | SWT.APPLICATION_MODAL);
- mPorts = ports;
- mDeviceSn = IDevice.FIRST_EMULATOR_SN;
- }
-
- /**
- * Creates a dialog with predefined values.
- * @param shell The parent shell
- * @param ports The list of already used port numbers.
- * @param oldDeviceSN the device serial number to display
- * @param oldAppName The application name to display
- * @param oldPortNumber The port number to display
- */
- public StaticPortEditDialog(Shell shell, ArrayList<Integer> ports,
- String oldDeviceSN, String oldAppName, String oldPortNumber) {
- this(shell, ports);
-
- mDeviceSn = oldDeviceSN;
- mAppName = oldAppName;
- mPortNumber = oldPortNumber;
- mEditPort = Integer.valueOf(mPortNumber);
- }
-
- /**
- * Opens the dialog. The method will return when the user closes the dialog
- * somehow.
- *
- * @return true if ok was pressed, false if cancelled.
- */
- public boolean open() {
- createUI();
-
- if (mParent == null || mShell == null) {
- return false;
- }
-
- mShell.setMinimumSize(DLG_WIDTH, DLG_HEIGHT);
- Rectangle r = mParent.getBounds();
- // get the center new top left.
- int cx = r.x + r.width/2;
- int x = cx - DLG_WIDTH / 2;
- int cy = r.y + r.height/2;
- int y = cy - DLG_HEIGHT / 2;
- mShell.setBounds(x, y, DLG_WIDTH, DLG_HEIGHT);
-
- mShell.open();
-
- Display display = mParent.getDisplay();
- while (!mShell.isDisposed()) {
- if (!display.readAndDispatch())
- display.sleep();
- }
-
- return mOk;
- }
-
- public String getDeviceSN() {
- return mDeviceSn;
- }
-
- public String getAppName() {
- return mAppName;
- }
-
- public int getPortNumber() {
- return Integer.valueOf(mPortNumber);
- }
-
- private void createUI() {
- mParent = getParent();
- mShell = new Shell(mParent, getStyle());
- mShell.setText("Static Port");
-
- mShell.setLayout(new GridLayout(1, false));
-
- mShell.addListener(SWT.Close, new Listener() {
- @Override
- public void handleEvent(Event event) {
- }
- });
-
- // center part with the edit field
- Composite main = new Composite(mShell, SWT.NONE);
- main.setLayoutData(new GridData(GridData.FILL_BOTH));
- main.setLayout(new GridLayout(2, false));
-
- Label l0 = new Label(main, SWT.NONE);
- l0.setText("Device Name:");
-
- final Text deviceSNText = new Text(main, SWT.SINGLE | SWT.BORDER);
- deviceSNText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- if (mDeviceSn != null) {
- deviceSNText.setText(mDeviceSn);
- }
- deviceSNText.addModifyListener(new ModifyListener() {
- @Override
- public void modifyText(ModifyEvent e) {
- mDeviceSn = deviceSNText.getText().trim();
- validate();
- }
- });
-
- Label l = new Label(main, SWT.NONE);
- l.setText("Application Name:");
-
- final Text appNameText = new Text(main, SWT.SINGLE | SWT.BORDER);
- if (mAppName != null) {
- appNameText.setText(mAppName);
- }
- appNameText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- appNameText.addModifyListener(new ModifyListener() {
- @Override
- public void modifyText(ModifyEvent e) {
- mAppName = appNameText.getText().trim();
- validate();
- }
- });
-
- Label l2 = new Label(main, SWT.NONE);
- l2.setText("Debug Port:");
-
- final Text debugPortText = new Text(main, SWT.SINGLE | SWT.BORDER);
- if (mPortNumber != null) {
- debugPortText.setText(mPortNumber);
- }
- debugPortText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- debugPortText.addModifyListener(new ModifyListener() {
- @Override
- public void modifyText(ModifyEvent e) {
- mPortNumber = debugPortText.getText().trim();
- validate();
- }
- });
-
- // warning label
- Composite warningComp = new Composite(mShell, SWT.NONE);
- warningComp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- warningComp.setLayout(new GridLayout(1, true));
-
- mWarning = new Label(warningComp, SWT.NONE);
- mWarning.setText("");
- mWarning.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- // bottom part with the ok/cancel
- Composite bottomComp = new Composite(mShell, SWT.NONE);
- bottomComp
- .setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_CENTER));
- bottomComp.setLayout(new GridLayout(2, true));
-
- mOkButton = new Button(bottomComp, SWT.NONE);
- mOkButton.setText("OK");
- mOkButton.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- mOk = true;
- mShell.close();
- }
- });
- mOkButton.setEnabled(false);
- mShell.setDefaultButton(mOkButton);
-
- Button cancelButton = new Button(bottomComp, SWT.NONE);
- cancelButton.setText("Cancel");
- cancelButton.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- mShell.close();
- }
- });
-
- validate();
- }
-
- /**
- * Validates the content of the 2 text fields and enable/disable "ok", while
- * setting up the warning/error message.
- */
- private void validate() {
- // first we reset the warning dialog. This allows us to latter
- // display warnings.
- mWarning.setText(""); //$NON-NLS-1$
-
- // check the device name field is not empty
- if (mDeviceSn == null || mDeviceSn.length() == 0) {
- mWarning.setText("Device name missing.");
- mOkButton.setEnabled(false);
- return;
- }
-
- // check the application name field is not empty
- if (mAppName == null || mAppName.length() == 0) {
- mWarning.setText("Application name missing.");
- mOkButton.setEnabled(false);
- return;
- }
-
- String packageError = "Application name must be a valid Java package name.";
-
- // validate the package name as well. It must be a fully qualified
- // java package.
- String[] packageSegments = mAppName.split("\\."); //$NON-NLS-1$
- for (String p : packageSegments) {
- if (p.matches("^[a-zA-Z][a-zA-Z0-9]*") == false) { //$NON-NLS-1$
- mWarning.setText(packageError);
- mOkButton.setEnabled(false);
- return;
- }
-
- // lets also display a warning if the package contains upper case
- // letters.
- if (p.matches("^[a-z][a-z0-9]*") == false) { //$NON-NLS-1$
- mWarning.setText("Lower case is recommended for Java packages.");
- }
- }
-
- // the split will not detect the last char being a '.'
- // so we test it manually
- if (mAppName.charAt(mAppName.length()-1) == '.') {
- mWarning.setText(packageError);
- mOkButton.setEnabled(false);
- return;
- }
-
- // now we test the package name field is not empty.
- if (mPortNumber == null || mPortNumber.length() == 0) {
- mWarning.setText("Port Number missing.");
- mOkButton.setEnabled(false);
- return;
- }
-
- // then we check it only contains digits.
- if (mPortNumber.matches("[0-9]*") == false) { //$NON-NLS-1$
- mWarning.setText("Port Number invalid.");
- mOkButton.setEnabled(false);
- return;
- }
-
- // get the int from the port number to validate
- long port = Long.valueOf(mPortNumber);
- if (port >= 32767) {
- mOkButton.setEnabled(false);
- return;
- }
-
- // check if its in the list of already used ports
- if (port != mEditPort) {
- for (Integer i : mPorts) {
- if (port == i.intValue()) {
- mWarning.setText("Port already in use.");
- mOkButton.setEnabled(false);
- return;
- }
- }
- }
-
- // at this point there's not error, so we enable the ok button.
- mOkButton.setEnabled(true);
- }
-}
diff --git a/ddms/app/src/com/android/ddms/UIThread.java b/ddms/app/src/com/android/ddms/UIThread.java
deleted file mode 100644
index 8aaa806..0000000
--- a/ddms/app/src/com/android/ddms/UIThread.java
+++ /dev/null
@@ -1,1803 +0,0 @@
-/*
- * Copyright (C) 2007 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.
- */
-
-package com.android.ddms;
-
-import com.android.ddmlib.AndroidDebugBridge;
-import com.android.ddmlib.AndroidDebugBridge.IClientChangeListener;
-import com.android.ddmlib.Client;
-import com.android.ddmlib.ClientData;
-import com.android.ddmlib.ClientData.IHprofDumpHandler;
-import com.android.ddmlib.ClientData.MethodProfilingStatus;
-import com.android.ddmlib.IDevice;
-import com.android.ddmlib.Log;
-import com.android.ddmlib.Log.ILogOutput;
-import com.android.ddmlib.Log.LogLevel;
-import com.android.ddmlib.SyncException;
-import com.android.ddmlib.SyncService;
-import com.android.ddmuilib.AllocationPanel;
-import com.android.ddmuilib.DdmUiPreferences;
-import com.android.ddmuilib.DevicePanel;
-import com.android.ddmuilib.DevicePanel.IUiSelectionListener;
-import com.android.ddmuilib.EmulatorControlPanel;
-import com.android.ddmuilib.HeapPanel;
-import com.android.ddmuilib.ITableFocusListener;
-import com.android.ddmuilib.ImageLoader;
-import com.android.ddmuilib.InfoPanel;
-import com.android.ddmuilib.NativeHeapPanel;
-import com.android.ddmuilib.ScreenShotDialog;
-import com.android.ddmuilib.SysinfoPanel;
-import com.android.ddmuilib.TablePanel;
-import com.android.ddmuilib.ThreadPanel;
-import com.android.ddmuilib.actions.ToolItemAction;
-import com.android.ddmuilib.explorer.DeviceExplorer;
-import com.android.ddmuilib.handler.BaseFileHandler;
-import com.android.ddmuilib.handler.MethodProfilingHandler;
-import com.android.ddmuilib.log.event.EventLogPanel;
-import com.android.ddmuilib.logcat.LogCatPanel;
-import com.android.ddmuilib.logcat.LogColors;
-import com.android.ddmuilib.logcat.LogFilter;
-import com.android.ddmuilib.logcat.LogPanel;
-import com.android.ddmuilib.logcat.LogPanel.ILogFilterStorageManager;
-import com.android.ddmuilib.net.NetworkPanel;
-import com.android.menubar.IMenuBarCallback;
-import com.android.menubar.IMenuBarEnhancer;
-import com.android.menubar.IMenuBarEnhancer.MenuBarMode;
-import com.android.menubar.MenuBarEnhancer;
-
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.preference.PreferenceStore;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.SWTError;
-import org.eclipse.swt.SWTException;
-import org.eclipse.swt.dnd.Clipboard;
-import org.eclipse.swt.events.ControlEvent;
-import org.eclipse.swt.events.ControlListener;
-import org.eclipse.swt.events.MenuAdapter;
-import org.eclipse.swt.events.MenuEvent;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.ShellEvent;
-import org.eclipse.swt.events.ShellListener;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.graphics.FontData;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.layout.FormAttachment;
-import org.eclipse.swt.layout.FormData;
-import org.eclipse.swt.layout.FormLayout;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.swt.widgets.MenuItem;
-import org.eclipse.swt.widgets.Sash;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.TabFolder;
-import org.eclipse.swt.widgets.TabItem;
-import org.eclipse.swt.widgets.ToolBar;
-import org.eclipse.swt.widgets.ToolItem;
-
-import java.io.File;
-import java.util.ArrayList;
-
-/**
- * This acts as the UI builder. This cannot be its own thread since this prevent using AWT in an
- * SWT application. So this class mainly builds the ui, and manages communication between the panels
- * when {@link IDevice} / {@link Client} selection changes.
- */
-public class UIThread implements IUiSelectionListener, IClientChangeListener {
- public static final String APP_NAME = "DDMS";
-
- /*
- * UI tab panel definitions. The constants here must match up with the array
- * indices in mPanels. PANEL_CLIENT_LIST is a "virtual" panel representing
- * the client list.
- */
- public static final int PANEL_CLIENT_LIST = -1;
-
- public static final int PANEL_INFO = 0;
-
- public static final int PANEL_THREAD = 1;
-
- public static final int PANEL_HEAP = 2;
-
- private static final int PANEL_NATIVE_HEAP = 3;
-
- private static final int PANEL_ALLOCATIONS = 4;
-
- private static final int PANEL_SYSINFO = 5;
-
- private static final int PANEL_NETWORK = 6;
-
- private static final int PANEL_COUNT = 7;
-
- /** Content is setup in the constructor */
- private static TablePanel[] mPanels = new TablePanel[PANEL_COUNT];
-
- private static final String[] mPanelNames = new String[] {
- "Info", "Threads", "VM Heap", "Native Heap",
- "Allocation Tracker", "Sysinfo", "Network"
- };
-
- private static final String[] mPanelTips = new String[] {
- "Client information", "Thread status", "VM heap status",
- "Native heap status", "Allocation Tracker", "Sysinfo graphs",
- "Network usage"
- };
-
- private static final String PREFERENCE_LOGSASH =
- "logSashLocation"; //$NON-NLS-1$
- private static final String PREFERENCE_SASH =
- "sashLocation"; //$NON-NLS-1$
-
- private static final String PREFS_COL_TIME =
- "logcat.time"; //$NON-NLS-1$
- private static final String PREFS_COL_LEVEL =
- "logcat.level"; //$NON-NLS-1$
- private static final String PREFS_COL_PID =
- "logcat.pid"; //$NON-NLS-1$
- private static final String PREFS_COL_TAG =
- "logcat.tag"; //$NON-NLS-1$
- private static final String PREFS_COL_MESSAGE =
- "logcat.message"; //$NON-NLS-1$
-
- private static final String PREFS_FILTERS = "logcat.filter"; //$NON-NLS-1$
-
- // singleton instance
- private static UIThread mInstance = new UIThread();
-
- // our display
- private Display mDisplay;
-
- // the table we show in the left-hand pane
- private DevicePanel mDevicePanel;
-
- private IDevice mCurrentDevice = null;
- private Client mCurrentClient = null;
-
- // status line at the bottom of the app window
- private Label mStatusLine;
-
- // some toolbar items we need to update
- private ToolItem mTBShowThreadUpdates;
- private ToolItem mTBShowHeapUpdates;
- private ToolItem mTBHalt;
- private ToolItem mTBCauseGc;
- private ToolItem mTBDumpHprof;
- private ToolItem mTBProfiling;
-
- private final class FilterStorage implements ILogFilterStorageManager {
-
- @Override
- public LogFilter[] getFilterFromStore() {
- String filterPrefs = PrefsDialog.getStore().getString(
- PREFS_FILTERS);
-
- // split in a string per filter
- String[] filters = filterPrefs.split("\\|"); //$NON-NLS-1$
-
- ArrayList<LogFilter> list =
- new ArrayList<LogFilter>(filters.length);
-
- for (String f : filters) {
- if (f.length() > 0) {
- LogFilter logFilter = new LogFilter();
- if (logFilter.loadFromString(f)) {
- list.add(logFilter);
- }
- }
- }
-
- return list.toArray(new LogFilter[list.size()]);
- }
-
- @Override
- public void saveFilters(LogFilter[] filters) {
- StringBuilder sb = new StringBuilder();
- for (LogFilter f : filters) {
- String filterString = f.toString();
- sb.append(filterString);
- sb.append('|');
- }
-
- PrefsDialog.getStore().setValue(PREFS_FILTERS, sb.toString());
- }
-
- @Override
- public boolean requiresDefaultFilter() {
- return true;
- }
- }
-
-
- /**
- * Flag to indicate whether to use the old or the new logcat view. This is a
- * temporary workaround that will be removed once the new view is complete.
- */
- private static final String USE_OLD_LOGCAT_VIEW =
- System.getenv("ANDROID_USE_OLD_LOGCAT_VIEW");
- public static boolean useOldLogCatView() {
- return USE_OLD_LOGCAT_VIEW != null;
- }
-
- private LogPanel mLogPanel; /* only valid when useOldLogCatView() == true */
- private LogCatPanel mLogCatPanel; /* only valid when useOldLogCatView() == false */
-
- private ToolItemAction mCreateFilterAction;
- private ToolItemAction mDeleteFilterAction;
- private ToolItemAction mEditFilterAction;
- private ToolItemAction mExportAction;
- private ToolItemAction mClearAction;
-
- private ToolItemAction[] mLogLevelActions;
- private String[] mLogLevelIcons = {
- "v.png", //$NON-NLS-1S
- "d.png", //$NON-NLS-1S
- "i.png", //$NON-NLS-1S
- "w.png", //$NON-NLS-1S
- "e.png", //$NON-NLS-1S
- };
-
- protected Clipboard mClipboard;
-
- private MenuItem mCopyMenuItem;
-
- private MenuItem mSelectAllMenuItem;
-
- private TableFocusListener mTableListener;
-
- private DeviceExplorer mExplorer = null;
- private Shell mExplorerShell = null;
-
- private EmulatorControlPanel mEmulatorPanel;
-
- private EventLogPanel mEventLogPanel;
-
- private Image mTracingStartImage;
-
- private Image mTracingStopImage;
-
- private ImageLoader mDdmUiLibLoader;
-
- private class TableFocusListener implements ITableFocusListener {
-
- private IFocusedTableActivator mCurrentActivator;
-
- @Override
- public void focusGained(IFocusedTableActivator activator) {
- mCurrentActivator = activator;
- if (mCopyMenuItem.isDisposed() == false) {
- mCopyMenuItem.setEnabled(true);
- mSelectAllMenuItem.setEnabled(true);
- }
- }
-
- @Override
- public void focusLost(IFocusedTableActivator activator) {
- // if we move from one table to another, it's unclear
- // if the old table lose its focus before the new
- // one gets the focus, so we need to check.
- if (activator == mCurrentActivator) {
- activator = null;
- if (mCopyMenuItem.isDisposed() == false) {
- mCopyMenuItem.setEnabled(false);
- mSelectAllMenuItem.setEnabled(false);
- }
- }
- }
-
- public void copy(Clipboard clipboard) {
- if (mCurrentActivator != null) {
- mCurrentActivator.copy(clipboard);
- }
- }
-
- public void selectAll() {
- if (mCurrentActivator != null) {
- mCurrentActivator.selectAll();
- }
- }
- }
-
- /**
- * Handler for HPROF dumps.
- * This will always prompt the user to save the HPROF file.
- */
- private class HProfHandler extends BaseFileHandler implements IHprofDumpHandler {
-
- public HProfHandler(Shell parentShell) {
- super(parentShell);
- }
-
- @Override
- public void onEndFailure(final Client client, final String message) {
- mDisplay.asyncExec(new Runnable() {
- @Override
- public void run() {
- try {
- displayErrorFromUiThread(
- "Unable to create HPROF file for application '%1$s'\n\n%2$s" +
- "Check logcat for more information.",
- client.getClientData().getClientDescription(),
- message != null ? message + "\n\n" : "");
- } finally {
- // this will make sure the dump hprof button is re-enabled for the
- // current selection. as the client is finished dumping an hprof file
- enableButtons();
- }
- }
- });
- }
-
- @Override
- public void onSuccess(final String remoteFilePath, final Client client) {
- mDisplay.asyncExec(new Runnable() {
- @Override
- public void run() {
- final IDevice device = client.getDevice();
- try {
- // get the sync service to pull the HPROF file
- final SyncService sync = client.getDevice().getSyncService();
- if (sync != null) {
- promptAndPull(sync,
- client.getClientData().getClientDescription() + ".hprof",
- remoteFilePath, "Save HPROF file");
- } else {
- displayErrorFromUiThread(
- "Unable to download HPROF file from device '%1$s'.",
- device.getSerialNumber());
- }
- } catch (SyncException e) {
- if (e.wasCanceled() == false) {
- displayErrorFromUiThread(
- "Unable to download HPROF file from device '%1$s'.\n\n%2$s",
- device.getSerialNumber(), e.getMessage());
- }
- } catch (Exception e) {
- displayErrorFromUiThread("Unable to download HPROF file from device '%1$s'.",
- device.getSerialNumber());
-
- } finally {
- // this will make sure the dump hprof button is re-enabled for the
- // current selection. as the client is finished dumping an hprof file
- enableButtons();
- }
- }
- });
- }
-
- @Override
- public void onSuccess(final byte[] data, final Client client) {
- mDisplay.asyncExec(new Runnable() {
- @Override
- public void run() {
- promptAndSave(client.getClientData().getClientDescription() + ".hprof", data,
- "Save HPROF file");
- }
- });
- }
-
- @Override
- protected String getDialogTitle() {
- return "HPROF Error";
- }
- }
-
-
- /**
- * Generic constructor.
- */
- private UIThread() {
- mPanels[PANEL_INFO] = new InfoPanel();
- mPanels[PANEL_THREAD] = new ThreadPanel();
- mPanels[PANEL_HEAP] = new HeapPanel();
- if (PrefsDialog.getStore().getBoolean(PrefsDialog.SHOW_NATIVE_HEAP)) {
- if (System.getenv("ANDROID_DDMS_OLD_HEAP_PANEL") != null) {
- mPanels[PANEL_NATIVE_HEAP] = new NativeHeapPanel();
- } else {
- mPanels[PANEL_NATIVE_HEAP] =
- new com.android.ddmuilib.heap.NativeHeapPanel(getStore());
- }
- } else {
- mPanels[PANEL_NATIVE_HEAP] = null;
- }
- mPanels[PANEL_ALLOCATIONS] = new AllocationPanel();
- mPanels[PANEL_SYSINFO] = new SysinfoPanel();
- mPanels[PANEL_NETWORK] = new NetworkPanel();
- }
-
- /**
- * Get singleton instance of the UI thread.
- */
- public static UIThread getInstance() {
- return mInstance;
- }
-
- /**
- * Return the Display. Don't try this unless you're in the UI thread.
- */
- public Display getDisplay() {
- return mDisplay;
- }
-
- public void asyncExec(Runnable r) {
- if (mDisplay != null && mDisplay.isDisposed() == false) {
- mDisplay.asyncExec(r);
- }
- }
-
- /** returns the IPreferenceStore */
- public IPreferenceStore getStore() {
- return PrefsDialog.getStore();
- }
-
- /**
- * Create SWT objects and drive the user interface event loop.
- * @param ddmsParentLocation location of the folder that contains ddms.
- */
- public void runUI(String ddmsParentLocation) {
- Display.setAppName(APP_NAME);
- mDisplay = Display.getDefault();
- final Shell shell = new Shell(mDisplay, SWT.SHELL_TRIM);
-
- // create the image loaders for DDMS and DDMUILIB
- mDdmUiLibLoader = ImageLoader.getDdmUiLibLoader();
-
- shell.setImage(ImageLoader.getLoader(this.getClass()).loadImage(mDisplay,
- "ddms-128.png", //$NON-NLS-1$
- 100, 50, null));
-
- Log.setLogOutput(new ILogOutput() {
- @Override
- public void printAndPromptLog(final LogLevel logLevel, final String tag,
- final String message) {
- Log.printLog(logLevel, tag, message);
- // dialog box only run in UI thread..
- mDisplay.asyncExec(new Runnable() {
- @Override
- public void run() {
- Shell activeShell = mDisplay.getActiveShell();
- if (logLevel == LogLevel.ERROR) {
- MessageDialog.openError(activeShell, tag, message);
- } else {
- MessageDialog.openWarning(activeShell, tag, message);
- }
- }
- });
- }
-
- @Override
- public void printLog(LogLevel logLevel, String tag, String message) {
- Log.printLog(logLevel, tag, message);
- }
- });
-
- // set the handler for hprof dump
- ClientData.setHprofDumpHandler(new HProfHandler(shell));
- ClientData.setMethodProfilingHandler(new MethodProfilingHandler(shell));
-
- // [try to] ensure ADB is running
- // in the new SDK, adb is in the platform-tools, but when run from the command line
- // in the Android source tree, then adb is next to ddms.
- String adbLocation;
- if (ddmsParentLocation != null && ddmsParentLocation.length() != 0) {
- // check if there's a platform-tools folder
- File platformTools = new File(new File(ddmsParentLocation).getParent(),
- "platform-tools"); //$NON-NLS-1$
- if (platformTools.isDirectory()) {
- adbLocation = platformTools.getAbsolutePath() + File.separator + "adb"; //$NON-NLS-1$
- } else {
- adbLocation = ddmsParentLocation + File.separator + "adb"; //$NON-NLS-1$
- }
- } else {
- adbLocation = "adb"; //$NON-NLS-1$
- }
-
- AndroidDebugBridge.init(true /* debugger support */);
- AndroidDebugBridge.createBridge(adbLocation, true /* forceNewBridge */);
-
- // we need to listen to client change to be notified of client status (profiling) change
- AndroidDebugBridge.addClientChangeListener(this);
-
- shell.setText("Dalvik Debug Monitor");
- setConfirmClose(shell);
- createMenus(shell);
- createWidgets(shell);
-
- shell.pack();
- setSizeAndPosition(shell);
- shell.open();
-
- Log.d("ddms", "UI is up");
-
- while (!shell.isDisposed()) {
- if (!mDisplay.readAndDispatch())
- mDisplay.sleep();
- }
- if (useOldLogCatView()) {
- mLogPanel.stopLogCat(true);
- }
-
- mDevicePanel.dispose();
- for (TablePanel panel : mPanels) {
- if (panel != null) {
- panel.dispose();
- }
- }
-
- ImageLoader.dispose();
-
- mDisplay.dispose();
- Log.d("ddms", "UI is down");
- }
-
- /**
- * Set the size and position of the main window from the preference, and
- * setup listeners for control events (resize/move of the window)
- */
- private void setSizeAndPosition(final Shell shell) {
- shell.setMinimumSize(400, 200);
-
- // get the x/y and w/h from the prefs
- PreferenceStore prefs = PrefsDialog.getStore();
- int x = prefs.getInt(PrefsDialog.SHELL_X);
- int y = prefs.getInt(PrefsDialog.SHELL_Y);
- int w = prefs.getInt(PrefsDialog.SHELL_WIDTH);
- int h = prefs.getInt(PrefsDialog.SHELL_HEIGHT);
-
- // check that we're not out of the display area
- Rectangle rect = mDisplay.getClientArea();
- // first check the width/height
- if (w > rect.width) {
- w = rect.width;
- prefs.setValue(PrefsDialog.SHELL_WIDTH, rect.width);
- }
- if (h > rect.height) {
- h = rect.height;
- prefs.setValue(PrefsDialog.SHELL_HEIGHT, rect.height);
- }
- // then check x. Make sure the left corner is in the screen
- if (x < rect.x) {
- x = rect.x;
- prefs.setValue(PrefsDialog.SHELL_X, rect.x);
- } else if (x >= rect.x + rect.width) {
- x = rect.x + rect.width - w;
- prefs.setValue(PrefsDialog.SHELL_X, rect.x);
- }
- // then check y. Make sure the left corner is in the screen
- if (y < rect.y) {
- y = rect.y;
- prefs.setValue(PrefsDialog.SHELL_Y, rect.y);
- } else if (y >= rect.y + rect.height) {
- y = rect.y + rect.height - h;
- prefs.setValue(PrefsDialog.SHELL_Y, rect.y);
- }
-
- // now we can set the location/size
- shell.setBounds(x, y, w, h);
-
- // add listener for resize/move
- shell.addControlListener(new ControlListener() {
- @Override
- public void controlMoved(ControlEvent e) {
- // get the new x/y
- Rectangle controlBounds = shell.getBounds();
- // store in pref file
- PreferenceStore currentPrefs = PrefsDialog.getStore();
- currentPrefs.setValue(PrefsDialog.SHELL_X, controlBounds.x);
- currentPrefs.setValue(PrefsDialog.SHELL_Y, controlBounds.y);
- }
-
- @Override
- public void controlResized(ControlEvent e) {
- // get the new w/h
- Rectangle controlBounds = shell.getBounds();
- // store in pref file
- PreferenceStore currentPrefs = PrefsDialog.getStore();
- currentPrefs.setValue(PrefsDialog.SHELL_WIDTH, controlBounds.width);
- currentPrefs.setValue(PrefsDialog.SHELL_HEIGHT, controlBounds.height);
- }
- });
- }
-
- /**
- * Set the size and position of the file explorer window from the
- * preference, and setup listeners for control events (resize/move of
- * the window)
- */
- private void setExplorerSizeAndPosition(final Shell shell) {
- shell.setMinimumSize(400, 200);
-
- // get the x/y and w/h from the prefs
- PreferenceStore prefs = PrefsDialog.getStore();
- int x = prefs.getInt(PrefsDialog.EXPLORER_SHELL_X);
- int y = prefs.getInt(PrefsDialog.EXPLORER_SHELL_Y);
- int w = prefs.getInt(PrefsDialog.EXPLORER_SHELL_WIDTH);
- int h = prefs.getInt(PrefsDialog.EXPLORER_SHELL_HEIGHT);
-
- // check that we're not out of the display area
- Rectangle rect = mDisplay.getClientArea();
- // first check the width/height
- if (w > rect.width) {
- w = rect.width;
- prefs.setValue(PrefsDialog.EXPLORER_SHELL_WIDTH, rect.width);
- }
- if (h > rect.height) {
- h = rect.height;
- prefs.setValue(PrefsDialog.EXPLORER_SHELL_HEIGHT, rect.height);
- }
- // then check x. Make sure the left corner is in the screen
- if (x < rect.x) {
- x = rect.x;
- prefs.setValue(PrefsDialog.EXPLORER_SHELL_X, rect.x);
- } else if (x >= rect.x + rect.width) {
- x = rect.x + rect.width - w;
- prefs.setValue(PrefsDialog.EXPLORER_SHELL_X, rect.x);
- }
- // then check y. Make sure the left corner is in the screen
- if (y < rect.y) {
- y = rect.y;
- prefs.setValue(PrefsDialog.EXPLORER_SHELL_Y, rect.y);
- } else if (y >= rect.y + rect.height) {
- y = rect.y + rect.height - h;
- prefs.setValue(PrefsDialog.EXPLORER_SHELL_Y, rect.y);
- }
-
- // now we can set the location/size
- shell.setBounds(x, y, w, h);
-
- // add listener for resize/move
- shell.addControlListener(new ControlListener() {
- @Override
- public void controlMoved(ControlEvent e) {
- // get the new x/y
- Rectangle controlBounds = shell.getBounds();
- // store in pref file
- PreferenceStore currentPrefs = PrefsDialog.getStore();
- currentPrefs.setValue(PrefsDialog.EXPLORER_SHELL_X, controlBounds.x);
- currentPrefs.setValue(PrefsDialog.EXPLORER_SHELL_Y, controlBounds.y);
- }
-
- @Override
- public void controlResized(ControlEvent e) {
- // get the new w/h
- Rectangle controlBounds = shell.getBounds();
- // store in pref file
- PreferenceStore currentPrefs = PrefsDialog.getStore();
- currentPrefs.setValue(PrefsDialog.EXPLORER_SHELL_WIDTH, controlBounds.width);
- currentPrefs.setValue(PrefsDialog.EXPLORER_SHELL_HEIGHT, controlBounds.height);
- }
- });
- }
-
- /*
- * Set the confirm-before-close dialog.
- */
- private void setConfirmClose(final Shell shell) {
- // Note: there was some commented out code to display a confirmation box
- // when closing. The feature seems unnecessary and the code was not being
- // used, so it has been removed.
- }
-
- /*
- * Create the menu bar and items.
- */
- private void createMenus(final Shell shell) {
- // create menu bar
- Menu menuBar = new Menu(shell, SWT.BAR);
-
- // create top-level items
- MenuItem fileItem = new MenuItem(menuBar, SWT.CASCADE);
- fileItem.setText("&File");
- MenuItem editItem = new MenuItem(menuBar, SWT.CASCADE);
- editItem.setText("&Edit");
- MenuItem actionItem = new MenuItem(menuBar, SWT.CASCADE);
- actionItem.setText("&Actions");
- MenuItem deviceItem = new MenuItem(menuBar, SWT.CASCADE);
- deviceItem.setText("&Device");
-
- // create top-level menus
- Menu fileMenu = new Menu(menuBar);
- fileItem.setMenu(fileMenu);
- Menu editMenu = new Menu(menuBar);
- editItem.setMenu(editMenu);
- Menu actionMenu = new Menu(menuBar);
- actionItem.setMenu(actionMenu);
- Menu deviceMenu = new Menu(menuBar);
- deviceItem.setMenu(deviceMenu);
-
- MenuItem item;
-
- // create File menu items
- item = new MenuItem(fileMenu, SWT.NONE);
- item.setText("&Static Port Configuration...");
- item.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- StaticPortConfigDialog dlg = new StaticPortConfigDialog(shell);
- dlg.open();
- }
- });
-
- IMenuBarEnhancer enhancer = MenuBarEnhancer.setupMenu(APP_NAME, fileMenu,
- new IMenuBarCallback() {
- @Override
- public void printError(String format, Object... args) {
- Log.e("DDMS Menu Bar", String.format(format, args));
- }
-
- @Override
- public void onPreferencesMenuSelected() {
- PrefsDialog.run(shell);
- }
-
- @Override
- public void onAboutMenuSelected() {
- AboutDialog dlg = new AboutDialog(shell);
- dlg.open();
- }
- });
-
- if (enhancer.getMenuBarMode() == MenuBarMode.GENERIC) {
- new MenuItem(fileMenu, SWT.SEPARATOR);
-
- item = new MenuItem(fileMenu, SWT.NONE);
- item.setText("E&xit\tCtrl-Q");
- item.setAccelerator('Q' | SWT.MOD1);
- item.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- shell.close();
- }
- });
- }
-
- // create edit menu items
- mCopyMenuItem = new MenuItem(editMenu, SWT.NONE);
- mCopyMenuItem.setText("&Copy\tCtrl-C");
- mCopyMenuItem.setAccelerator('C' | SWT.MOD1);
- mCopyMenuItem.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- mTableListener.copy(mClipboard);
- }
- });
-
- new MenuItem(editMenu, SWT.SEPARATOR);
-
- mSelectAllMenuItem = new MenuItem(editMenu, SWT.NONE);
- mSelectAllMenuItem.setText("Select &All\tCtrl-A");
- mSelectAllMenuItem.setAccelerator('A' | SWT.MOD1);
- mSelectAllMenuItem.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- mTableListener.selectAll();
- }
- });
-
- // create Action menu items
- // TODO: this should come with a confirmation dialog
- final MenuItem actionHaltItem = new MenuItem(actionMenu, SWT.NONE);
- actionHaltItem.setText("&Halt VM");
- actionHaltItem.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- mDevicePanel.killSelectedClient();
- }
- });
-
- final MenuItem actionCauseGcItem = new MenuItem(actionMenu, SWT.NONE);
- actionCauseGcItem.setText("Cause &GC");
- actionCauseGcItem.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- mDevicePanel.forceGcOnSelectedClient();
- }
- });
-
- final MenuItem actionResetAdb = new MenuItem(actionMenu, SWT.NONE);
- actionResetAdb.setText("&Reset adb");
- actionResetAdb.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- AndroidDebugBridge bridge = AndroidDebugBridge.getBridge();
- if (bridge != null) {
- bridge.restart();
- }
- }
- });
-
- // configure Action items based on current state
- actionMenu.addMenuListener(new MenuAdapter() {
- @Override
- public void menuShown(MenuEvent e) {
- actionHaltItem.setEnabled(mTBHalt.getEnabled() && mCurrentClient != null);
- actionCauseGcItem.setEnabled(mTBCauseGc.getEnabled() && mCurrentClient != null);
- actionResetAdb.setEnabled(true);
- }
- });
-
- // create Device menu items
- final MenuItem screenShotItem = new MenuItem(deviceMenu, SWT.NONE);
-
- // The \tCtrl-S "keybinding text" here isn't right for the Mac - but
- // it's stripped out and replaced by the proper keyboard accelerator
- // text (e.g. the unicode symbol for the command key + S) anyway
- // so it's fine to leave it there for the other platforms.
- screenShotItem.setText("&Screen capture...\tCtrl-S");
- screenShotItem.setAccelerator('S' | SWT.MOD1);
- screenShotItem.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- if (mCurrentDevice != null) {
- ScreenShotDialog dlg = new ScreenShotDialog(shell);
- dlg.open(mCurrentDevice);
- }
- }
- });
-
- new MenuItem(deviceMenu, SWT.SEPARATOR);
-
- final MenuItem explorerItem = new MenuItem(deviceMenu, SWT.NONE);
- explorerItem.setText("File Explorer...");
- explorerItem.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- createFileExplorer();
- }
- });
-
- new MenuItem(deviceMenu, SWT.SEPARATOR);
-
- final MenuItem processItem = new MenuItem(deviceMenu, SWT.NONE);
- processItem.setText("Show &process status...");
- processItem.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- DeviceCommandDialog dlg;
- dlg = new DeviceCommandDialog("ps -x", "ps-x.txt", shell);
- dlg.open(mCurrentDevice);
- }
- });
-
- final MenuItem deviceStateItem = new MenuItem(deviceMenu, SWT.NONE);
- deviceStateItem.setText("Dump &device state...");
- deviceStateItem.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- DeviceCommandDialog dlg;
- dlg = new DeviceCommandDialog("/system/bin/dumpstate /proc/self/fd/0",
- "device-state.txt", shell);
- dlg.open(mCurrentDevice);
- }
- });
-
- final MenuItem appStateItem = new MenuItem(deviceMenu, SWT.NONE);
- appStateItem.setText("Dump &app state...");
- appStateItem.setEnabled(false);
- appStateItem.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- DeviceCommandDialog dlg;
- dlg = new DeviceCommandDialog("dumpsys", "app-state.txt", shell);
- dlg.open(mCurrentDevice);
- }
- });
-
- final MenuItem radioStateItem = new MenuItem(deviceMenu, SWT.NONE);
- radioStateItem.setText("Dump &radio state...");
- radioStateItem.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- DeviceCommandDialog dlg;
- dlg = new DeviceCommandDialog(
- "cat /data/logs/radio.4 /data/logs/radio.3"
- + " /data/logs/radio.2 /data/logs/radio.1"
- + " /data/logs/radio",
- "radio-state.txt", shell);
- dlg.open(mCurrentDevice);
- }
- });
-
- final MenuItem logCatItem = new MenuItem(deviceMenu, SWT.NONE);
- logCatItem.setText("Run &logcat...");
- logCatItem.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- DeviceCommandDialog dlg;
- dlg = new DeviceCommandDialog("logcat '*:d jdwp:w'", "log.txt",
- shell);
- dlg.open(mCurrentDevice);
- }
- });
-
- // configure Action items based on current state
- deviceMenu.addMenuListener(new MenuAdapter() {
- @Override
- public void menuShown(MenuEvent e) {
- boolean deviceEnabled = mCurrentDevice != null;
- screenShotItem.setEnabled(deviceEnabled);
- explorerItem.setEnabled(deviceEnabled);
- processItem.setEnabled(deviceEnabled);
- deviceStateItem.setEnabled(deviceEnabled);
- appStateItem.setEnabled(deviceEnabled);
- radioStateItem.setEnabled(deviceEnabled);
- logCatItem.setEnabled(deviceEnabled);
- }
- });
-
- // tell the shell to use this menu
- shell.setMenuBar(menuBar);
- }
-
- /*
- * Create the widgets in the main application window. The basic layout is a
- * two-panel sash, with a scrolling list of VMs on the left and detailed
- * output for a single VM on the right.
- */
- private void createWidgets(final Shell shell) {
- Color darkGray = shell.getDisplay().getSystemColor(SWT.COLOR_DARK_GRAY);
-
- /*
- * Create three areas: tool bar, split panels, status line
- */
- shell.setLayout(new GridLayout(1, false));
-
- // 1. panel area
- final Composite panelArea = new Composite(shell, SWT.BORDER);
-
- // make the panel area absorb all space
- panelArea.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- // 2. status line.
- mStatusLine = new Label(shell, SWT.NONE);
-
- // make status line extend all the way across
- mStatusLine.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- mStatusLine.setText("Initializing...");
-
- /*
- * Configure the split-panel area.
- */
- final PreferenceStore prefs = PrefsDialog.getStore();
-
- Composite topPanel = new Composite(panelArea, SWT.NONE);
- final Sash sash = new Sash(panelArea, SWT.HORIZONTAL);
- sash.setBackground(darkGray);
- Composite bottomPanel = new Composite(panelArea, SWT.NONE);
-
- panelArea.setLayout(new FormLayout());
-
- createTopPanel(topPanel, darkGray);
-
- mClipboard = new Clipboard(panelArea.getDisplay());
- if (useOldLogCatView()) {
- createBottomPanel(bottomPanel);
- } else {
- createLogCatView(bottomPanel);
- }
-
- // form layout data
- FormData data = new FormData();
- data.top = new FormAttachment(0, 0);
- data.bottom = new FormAttachment(sash, 0);
- data.left = new FormAttachment(0, 0);
- data.right = new FormAttachment(100, 0);
- topPanel.setLayoutData(data);
-
- final FormData sashData = new FormData();
- if (prefs != null && prefs.contains(PREFERENCE_LOGSASH)) {
- sashData.top = new FormAttachment(0, prefs.getInt(
- PREFERENCE_LOGSASH));
- } else {
- sashData.top = new FormAttachment(50,0); // 50% across
- }
- sashData.left = new FormAttachment(0, 0);
- sashData.right = new FormAttachment(100, 0);
- sash.setLayoutData(sashData);
-
- data = new FormData();
- data.top = new FormAttachment(sash, 0);
- data.bottom = new FormAttachment(100, 0);
- data.left = new FormAttachment(0, 0);
- data.right = new FormAttachment(100, 0);
- bottomPanel.setLayoutData(data);
-
- // allow resizes, but cap at minPanelWidth
- sash.addListener(SWT.Selection, new Listener() {
- @Override
- public void handleEvent(Event e) {
- Rectangle sashRect = sash.getBounds();
- Rectangle panelRect = panelArea.getClientArea();
- int bottom = panelRect.height - sashRect.height - 100;
- e.y = Math.max(Math.min(e.y, bottom), 100);
- if (e.y != sashRect.y) {
- sashData.top = new FormAttachment(0, e.y);
- if (prefs != null) {
- prefs.setValue(PREFERENCE_LOGSASH, e.y);
- }
- panelArea.layout();
- }
- }
- });
-
- // add a global focus listener for all the tables
- mTableListener = new TableFocusListener();
-
- // now set up the listener in the various panels
- if (useOldLogCatView()) {
- mLogPanel.setTableFocusListener(mTableListener);
- } else {
- mLogCatPanel.setTableFocusListener(mTableListener);
- }
- mEventLogPanel.setTableFocusListener(mTableListener);
- for (TablePanel p : mPanels) {
- if (p != null) {
- p.setTableFocusListener(mTableListener);
- }
- }
-
- mStatusLine.setText("");
- }
-
- /*
- * Populate the tool bar.
- */
- private void createDevicePanelToolBar(ToolBar toolBar) {
- Display display = toolBar.getDisplay();
-
- // add "show heap updates" button
- mTBShowHeapUpdates = new ToolItem(toolBar, SWT.CHECK);
- mTBShowHeapUpdates.setImage(mDdmUiLibLoader.loadImage(display,
- DevicePanel.ICON_HEAP, DevicePanel.ICON_WIDTH, DevicePanel.ICON_WIDTH, null));
- mTBShowHeapUpdates.setToolTipText("Show heap updates");
- mTBShowHeapUpdates.setEnabled(false);
- mTBShowHeapUpdates.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- if (mCurrentClient != null) {
- // boolean status = ((ToolItem)e.item).getSelection();
- // invert previous state
- boolean enable = !mCurrentClient.isHeapUpdateEnabled();
- mCurrentClient.setHeapUpdateEnabled(enable);
- } else {
- e.doit = false; // this has no effect?
- }
- }
- });
-
- // add "dump HPROF" button
- mTBDumpHprof = new ToolItem(toolBar, SWT.PUSH);
- mTBDumpHprof.setToolTipText("Dump HPROF file");
- mTBDumpHprof.setEnabled(false);
- mTBDumpHprof.setImage(mDdmUiLibLoader.loadImage(display,
- DevicePanel.ICON_HPROF, DevicePanel.ICON_WIDTH, DevicePanel.ICON_WIDTH, null));
- mTBDumpHprof.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- mDevicePanel.dumpHprof();
-
- // this will make sure the dump hprof button is disabled for the current selection
- // as the client is already dumping an hprof file
- enableButtons();
- }
- });
-
- // add "cause GC" button
- mTBCauseGc = new ToolItem(toolBar, SWT.PUSH);
- mTBCauseGc.setToolTipText("Cause an immediate GC");
- mTBCauseGc.setEnabled(false);
- mTBCauseGc.setImage(mDdmUiLibLoader.loadImage(display,
- DevicePanel.ICON_GC, DevicePanel.ICON_WIDTH, DevicePanel.ICON_WIDTH, null));
- mTBCauseGc.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- mDevicePanel.forceGcOnSelectedClient();
- }
- });
-
- new ToolItem(toolBar, SWT.SEPARATOR);
-
- // add "show thread updates" button
- mTBShowThreadUpdates = new ToolItem(toolBar, SWT.CHECK);
- mTBShowThreadUpdates.setImage(mDdmUiLibLoader.loadImage(display,
- DevicePanel.ICON_THREAD, DevicePanel.ICON_WIDTH, DevicePanel.ICON_WIDTH, null));
- mTBShowThreadUpdates.setToolTipText("Show thread updates");
- mTBShowThreadUpdates.setEnabled(false);
- mTBShowThreadUpdates.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- if (mCurrentClient != null) {
- // boolean status = ((ToolItem)e.item).getSelection();
- // invert previous state
- boolean enable = !mCurrentClient.isThreadUpdateEnabled();
-
- mCurrentClient.setThreadUpdateEnabled(enable);
- } else {
- e.doit = false; // this has no effect?
- }
- }
- });
-
- // add a start/stop method tracing
- mTracingStartImage = mDdmUiLibLoader.loadImage(display,
- DevicePanel.ICON_TRACING_START,
- DevicePanel.ICON_WIDTH, DevicePanel.ICON_WIDTH, null);
- mTracingStopImage = mDdmUiLibLoader.loadImage(display,
- DevicePanel.ICON_TRACING_STOP,
- DevicePanel.ICON_WIDTH, DevicePanel.ICON_WIDTH, null);
- mTBProfiling = new ToolItem(toolBar, SWT.PUSH);
- mTBProfiling.setToolTipText("Start Method Profiling");
- mTBProfiling.setEnabled(false);
- mTBProfiling.setImage(mTracingStartImage);
- mTBProfiling.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- mDevicePanel.toggleMethodProfiling();
- }
- });
-
- new ToolItem(toolBar, SWT.SEPARATOR);
-
- // add "kill VM" button; need to make this visually distinct from
- // the status update buttons
- mTBHalt = new ToolItem(toolBar, SWT.PUSH);
- mTBHalt.setToolTipText("Halt the target VM");
- mTBHalt.setEnabled(false);
- mTBHalt.setImage(mDdmUiLibLoader.loadImage(display,
- DevicePanel.ICON_HALT, DevicePanel.ICON_WIDTH, DevicePanel.ICON_WIDTH, null));
- mTBHalt.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- mDevicePanel.killSelectedClient();
- }
- });
-
- toolBar.pack();
- }
-
- private void createTopPanel(final Composite comp, Color darkGray) {
- final PreferenceStore prefs = PrefsDialog.getStore();
-
- comp.setLayout(new FormLayout());
-
- Composite leftPanel = new Composite(comp, SWT.NONE);
- final Sash sash = new Sash(comp, SWT.VERTICAL);
- sash.setBackground(darkGray);
- Composite rightPanel = new Composite(comp, SWT.NONE);
-
- createLeftPanel(leftPanel);
- createRightPanel(rightPanel);
-
- FormData data = new FormData();
- data.top = new FormAttachment(0, 0);
- data.bottom = new FormAttachment(100, 0);
- data.left = new FormAttachment(0, 0);
- data.right = new FormAttachment(sash, 0);
- leftPanel.setLayoutData(data);
-
- final FormData sashData = new FormData();
- sashData.top = new FormAttachment(0, 0);
- sashData.bottom = new FormAttachment(100, 0);
- if (prefs != null && prefs.contains(PREFERENCE_SASH)) {
- sashData.left = new FormAttachment(0, prefs.getInt(
- PREFERENCE_SASH));
- } else {
- // position the sash 380 from the right instead of x% (done by using
- // FormAttachment(x, 0)) in order to keep the sash at the same
- // position
- // from the left when the window is resized.
- // 380px is just enough to display the left table with no horizontal
- // scrollbar with the default font.
- sashData.left = new FormAttachment(0, 380);
- }
- sash.setLayoutData(sashData);
-
- data = new FormData();
- data.top = new FormAttachment(0, 0);
- data.bottom = new FormAttachment(100, 0);
- data.left = new FormAttachment(sash, 0);
- data.right = new FormAttachment(100, 0);
- rightPanel.setLayoutData(data);
-
- final int minPanelWidth = 60;
-
- // allow resizes, but cap at minPanelWidth
- sash.addListener(SWT.Selection, new Listener() {
- @Override
- public void handleEvent(Event e) {
- Rectangle sashRect = sash.getBounds();
- Rectangle panelRect = comp.getClientArea();
- int right = panelRect.width - sashRect.width - minPanelWidth;
- e.x = Math.max(Math.min(e.x, right), minPanelWidth);
- if (e.x != sashRect.x) {
- sashData.left = new FormAttachment(0, e.x);
- if (prefs != null) {
- prefs.setValue(PREFERENCE_SASH, e.x);
- }
- comp.layout();
- }
- }
- });
- }
-
- private void createBottomPanel(final Composite comp) {
- final PreferenceStore prefs = PrefsDialog.getStore();
-
- // create clipboard
- Display display = comp.getDisplay();
-
- LogColors colors = new LogColors();
-
- colors.infoColor = new Color(display, 0, 127, 0);
- colors.debugColor = new Color(display, 0, 0, 127);
- colors.errorColor = new Color(display, 255, 0, 0);
- colors.warningColor = new Color(display, 255, 127, 0);
- colors.verboseColor = new Color(display, 0, 0, 0);
-
- // set the preferences names
- LogPanel.PREFS_TIME = PREFS_COL_TIME;
- LogPanel.PREFS_LEVEL = PREFS_COL_LEVEL;
- LogPanel.PREFS_PID = PREFS_COL_PID;
- LogPanel.PREFS_TAG = PREFS_COL_TAG;
- LogPanel.PREFS_MESSAGE = PREFS_COL_MESSAGE;
-
- comp.setLayout(new GridLayout(1, false));
-
- ToolBar toolBar = new ToolBar(comp, SWT.HORIZONTAL);
-
- mCreateFilterAction = new ToolItemAction(toolBar, SWT.PUSH);
- mCreateFilterAction.item.setToolTipText("Create Filter");
- mCreateFilterAction.item.setImage(mDdmUiLibLoader.loadImage(mDisplay,
- "add.png", //$NON-NLS-1$
- DevicePanel.ICON_WIDTH, DevicePanel.ICON_WIDTH, null));
- mCreateFilterAction.item.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- mLogPanel.addFilter();
- }
- });
-
- mEditFilterAction = new ToolItemAction(toolBar, SWT.PUSH);
- mEditFilterAction.item.setToolTipText("Edit Filter");
- mEditFilterAction.item.setImage(mDdmUiLibLoader.loadImage(mDisplay,
- "edit.png", //$NON-NLS-1$
- DevicePanel.ICON_WIDTH, DevicePanel.ICON_WIDTH, null));
- mEditFilterAction.item.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- mLogPanel.editFilter();
- }
- });
-
- mDeleteFilterAction = new ToolItemAction(toolBar, SWT.PUSH);
- mDeleteFilterAction.item.setToolTipText("Delete Filter");
- mDeleteFilterAction.item.setImage(mDdmUiLibLoader.loadImage(mDisplay,
- "delete.png", //$NON-NLS-1$
- DevicePanel.ICON_WIDTH, DevicePanel.ICON_WIDTH, null));
- mDeleteFilterAction.item.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- mLogPanel.deleteFilter();
- }
- });
-
-
- new ToolItem(toolBar, SWT.SEPARATOR);
-
- LogLevel[] levels = LogLevel.values();
- mLogLevelActions = new ToolItemAction[mLogLevelIcons.length];
- for (int i = 0 ; i < mLogLevelActions.length; i++) {
- String name = levels[i].getStringValue();
- final ToolItemAction newAction = new ToolItemAction(toolBar, SWT.CHECK);
- mLogLevelActions[i] = newAction;
- //newAction.item.setText(name);
- newAction.item.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- // disable the other actions and record current index
- for (int k = 0 ; k < mLogLevelActions.length; k++) {
- ToolItemAction a = mLogLevelActions[k];
- if (a == newAction) {
- a.setChecked(true);
-
- // set the log level
- mLogPanel.setCurrentFilterLogLevel(k+2);
- } else {
- a.setChecked(false);
- }
- }
- }
- });
-
- newAction.item.setToolTipText(name);
- newAction.item.setImage(mDdmUiLibLoader.loadImage(mDisplay,
- mLogLevelIcons[i],
- DevicePanel.ICON_WIDTH, DevicePanel.ICON_WIDTH, null));
- }
-
- new ToolItem(toolBar, SWT.SEPARATOR);
-
- mClearAction = new ToolItemAction(toolBar, SWT.PUSH);
- mClearAction.item.setToolTipText("Clear Log");
-
- mClearAction.item.setImage(mDdmUiLibLoader.loadImage(mDisplay,
- "clear.png", //$NON-NLS-1$
- DevicePanel.ICON_WIDTH, DevicePanel.ICON_WIDTH, null));
- mClearAction.item.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- mLogPanel.clear();
- }
- });
-
- new ToolItem(toolBar, SWT.SEPARATOR);
-
- mExportAction = new ToolItemAction(toolBar, SWT.PUSH);
- mExportAction.item.setToolTipText("Export Selection As Text...");
- mExportAction.item.setImage(mDdmUiLibLoader.loadImage(mDisplay,
- "save.png", //$NON-NLS-1$
- DevicePanel.ICON_WIDTH, DevicePanel.ICON_WIDTH, null));
- mExportAction.item.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- mLogPanel.save();
- }
- });
-
-
- toolBar.pack();
-
- // now create the log view
- mLogPanel = new LogPanel(colors, new FilterStorage(), LogPanel.FILTER_MANUAL);
-
- mLogPanel.setActions(mDeleteFilterAction, mEditFilterAction, mLogLevelActions);
-
- String colMode = prefs.getString(PrefsDialog.LOGCAT_COLUMN_MODE);
- if (PrefsDialog.LOGCAT_COLUMN_MODE_AUTO.equals(colMode)) {
- mLogPanel.setColumnMode(LogPanel.COLUMN_MODE_AUTO);
- }
-
- String fontStr = PrefsDialog.getStore().getString(PrefsDialog.LOGCAT_FONT);
- if (fontStr != null) {
- try {
- FontData fdat = new FontData(fontStr);
- mLogPanel.setFont(new Font(display, fdat));
- } catch (IllegalArgumentException e) {
- // Looks like fontStr isn't a valid font representation.
- // We do nothing in this case, the logcat view will use the default font.
- } catch (SWTError e2) {
- // Looks like the Font() constructor failed.
- // We do nothing in this case, the logcat view will use the default font.
- }
- }
-
- mLogPanel.createPanel(comp);
-
- // and start the logcat
- mLogPanel.startLogCat(mCurrentDevice);
- }
-
- private void createLogCatView(Composite parent) {
- IPreferenceStore prefStore = DdmUiPreferences.getStore();
- mLogCatPanel = new LogCatPanel(prefStore);
- mLogCatPanel.createPanel(parent);
-
- if (mCurrentDevice != null) {
- mLogCatPanel.deviceSelected(mCurrentDevice);
- }
- }
-
- /*
- * Create the contents of the left panel: a table of VMs.
- */
- private void createLeftPanel(final Composite comp) {
- comp.setLayout(new GridLayout(1, false));
- ToolBar toolBar = new ToolBar(comp, SWT.HORIZONTAL | SWT.RIGHT | SWT.WRAP);
- toolBar.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- createDevicePanelToolBar(toolBar);
-
- Composite c = new Composite(comp, SWT.NONE);
- c.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- mDevicePanel = new DevicePanel(true /* showPorts */);
- mDevicePanel.createPanel(c);
-
- // add ourselves to the device panel selection listener
- mDevicePanel.addSelectionListener(this);
- }
-
- /*
- * Create the contents of the right panel: tabs with VM information.
- */
- private void createRightPanel(final Composite comp) {
- TabItem item;
- TabFolder tabFolder;
-
- comp.setLayout(new FillLayout());
-
- tabFolder = new TabFolder(comp, SWT.NONE);
-
- for (int i = 0; i < mPanels.length; i++) {
- if (mPanels[i] != null) {
- item = new TabItem(tabFolder, SWT.NONE);
- item.setText(mPanelNames[i]);
- item.setToolTipText(mPanelTips[i]);
- item.setControl(mPanels[i].createPanel(tabFolder));
- }
- }
-
- // add the emulator control panel to the folders.
- item = new TabItem(tabFolder, SWT.NONE);
- item.setText("Emulator Control");
- item.setToolTipText("Emulator Control Panel");
- mEmulatorPanel = new EmulatorControlPanel();
- item.setControl(mEmulatorPanel.createPanel(tabFolder));
-
- // add the event log panel to the folders.
- item = new TabItem(tabFolder, SWT.NONE);
- item.setText("Event Log");
- item.setToolTipText("Event Log");
-
- // create the composite that will hold the toolbar and the event log panel.
- Composite eventLogTopComposite = new Composite(tabFolder, SWT.NONE);
- item.setControl(eventLogTopComposite);
- eventLogTopComposite.setLayout(new GridLayout(1, false));
-
- // create the toolbar and the actions
- ToolBar toolbar = new ToolBar(eventLogTopComposite, SWT.HORIZONTAL);
- toolbar.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- ToolItemAction optionsAction = new ToolItemAction(toolbar, SWT.PUSH);
- optionsAction.item.setToolTipText("Opens the options panel");
- optionsAction.item.setImage(mDdmUiLibLoader.loadImage(comp.getDisplay(),
- "edit.png", //$NON-NLS-1$
- DevicePanel.ICON_WIDTH, DevicePanel.ICON_WIDTH, null));
-
- ToolItemAction clearAction = new ToolItemAction(toolbar, SWT.PUSH);
- clearAction.item.setToolTipText("Clears the event log");
- clearAction.item.setImage(mDdmUiLibLoader.loadImage(comp.getDisplay(),
- "clear.png", //$NON-NLS-1$
- DevicePanel.ICON_WIDTH, DevicePanel.ICON_WIDTH, null));
-
- new ToolItem(toolbar, SWT.SEPARATOR);
-
- ToolItemAction saveAction = new ToolItemAction(toolbar, SWT.PUSH);
- saveAction.item.setToolTipText("Saves the event log");
- saveAction.item.setImage(mDdmUiLibLoader.loadImage(comp.getDisplay(),
- "save.png", //$NON-NLS-1$
- DevicePanel.ICON_WIDTH, DevicePanel.ICON_WIDTH, null));
-
- ToolItemAction loadAction = new ToolItemAction(toolbar, SWT.PUSH);
- loadAction.item.setToolTipText("Loads an event log");
- loadAction.item.setImage(mDdmUiLibLoader.loadImage(comp.getDisplay(),
- "load.png", //$NON-NLS-1$
- DevicePanel.ICON_WIDTH, DevicePanel.ICON_WIDTH, null));
-
- ToolItemAction importBugAction = new ToolItemAction(toolbar, SWT.PUSH);
- importBugAction.item.setToolTipText("Imports a bug report");
- importBugAction.item.setImage(mDdmUiLibLoader.loadImage(comp.getDisplay(),
- "importBug.png", //$NON-NLS-1$
- DevicePanel.ICON_WIDTH, DevicePanel.ICON_WIDTH, null));
-
- // create the event log panel
- mEventLogPanel = new EventLogPanel();
-
- // set the external actions
- mEventLogPanel.setActions(optionsAction, clearAction, saveAction, loadAction,
- importBugAction);
-
- // create the panel
- mEventLogPanel.createPanel(eventLogTopComposite);
- }
-
- private void createFileExplorer() {
- if (mExplorer == null) {
- mExplorerShell = new Shell(mDisplay);
-
- // create the ui
- mExplorerShell.setLayout(new GridLayout(1, false));
-
- // toolbar + action
- ToolBar toolBar = new ToolBar(mExplorerShell, SWT.HORIZONTAL);
- toolBar.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- ToolItemAction pullAction = new ToolItemAction(toolBar, SWT.PUSH);
- pullAction.item.setToolTipText("Pull File from Device");
- Image image = mDdmUiLibLoader.loadImage("pull.png", mDisplay); //$NON-NLS-1$
- if (image != null) {
- pullAction.item.setImage(image);
- } else {
- // this is for debugging purpose when the icon is missing
- pullAction.item.setText("Pull"); //$NON-NLS-1$
- }
-
- ToolItemAction pushAction = new ToolItemAction(toolBar, SWT.PUSH);
- pushAction.item.setToolTipText("Push file onto Device");
- image = mDdmUiLibLoader.loadImage("push.png", mDisplay); //$NON-NLS-1$
- if (image != null) {
- pushAction.item.setImage(image);
- } else {
- // this is for debugging purpose when the icon is missing
- pushAction.item.setText("Push"); //$NON-NLS-1$
- }
-
- ToolItemAction deleteAction = new ToolItemAction(toolBar, SWT.PUSH);
- deleteAction.item.setToolTipText("Delete");
- image = mDdmUiLibLoader.loadImage("delete.png", mDisplay); //$NON-NLS-1$
- if (image != null) {
- deleteAction.item.setImage(image);
- } else {
- // this is for debugging purpose when the icon is missing
- deleteAction.item.setText("Delete"); //$NON-NLS-1$
- }
-
- ToolItemAction createNewFolderAction = new ToolItemAction(toolBar, SWT.PUSH);
- createNewFolderAction.item.setToolTipText("New Folder");
- image = mDdmUiLibLoader.loadImage("add.png", mDisplay); //$NON-NLS-1$
- if (image != null) {
- createNewFolderAction.item.setImage(image);
- } else {
- // this is for debugging purpose when the icon is missing
- createNewFolderAction.item.setText("New Folder"); //$NON-NLS-1$
- }
-
- // device explorer
- mExplorer = new DeviceExplorer();
- mExplorer.setActions(pushAction, pullAction, deleteAction, createNewFolderAction);
-
- pullAction.item.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- mExplorer.pullSelection();
- }
- });
- pullAction.setEnabled(false);
-
- pushAction.item.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- mExplorer.pushIntoSelection();
- }
- });
- pushAction.setEnabled(false);
-
- deleteAction.item.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- mExplorer.deleteSelection();
- }
- });
- deleteAction.setEnabled(false);
-
- createNewFolderAction.item.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- mExplorer.createNewFolderInSelection();
- }
- });
- createNewFolderAction.setEnabled(false);
-
- Composite parent = new Composite(mExplorerShell, SWT.NONE);
- parent.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- mExplorer.createPanel(parent);
- mExplorer.switchDevice(mCurrentDevice);
-
- mExplorerShell.addShellListener(new ShellListener() {
- @Override
- public void shellActivated(ShellEvent e) {
- // pass
- }
-
- @Override
- public void shellClosed(ShellEvent e) {
- mExplorer = null;
- mExplorerShell = null;
- }
-
- @Override
- public void shellDeactivated(ShellEvent e) {
- // pass
- }
-
- @Override
- public void shellDeiconified(ShellEvent e) {
- // pass
- }
-
- @Override
- public void shellIconified(ShellEvent e) {
- // pass
- }
- });
-
- mExplorerShell.pack();
- setExplorerSizeAndPosition(mExplorerShell);
- mExplorerShell.open();
- } else {
- if (mExplorerShell != null) {
- mExplorerShell.forceActive();
- }
- }
- }
-
- /**
- * Set the status line. TODO: make this a stack, so we can safely have
- * multiple things trying to set it all at once. Also specify an expiration?
- */
- public void setStatusLine(final String str) {
- try {
- mDisplay.asyncExec(new Runnable() {
- @Override
- public void run() {
- doSetStatusLine(str);
- }
- });
- } catch (SWTException swte) {
- if (!mDisplay.isDisposed())
- throw swte;
- }
- }
-
- private void doSetStatusLine(String str) {
- if (mStatusLine.isDisposed())
- return;
-
- if (!mStatusLine.getText().equals(str)) {
- mStatusLine.setText(str);
-
- // try { Thread.sleep(100); }
- // catch (InterruptedException ie) {}
- }
- }
-
- public void displayError(final String msg) {
- try {
- mDisplay.syncExec(new Runnable() {
- @Override
- public void run() {
- MessageDialog.openError(mDisplay.getActiveShell(), "Error",
- msg);
- }
- });
- } catch (SWTException swte) {
- if (!mDisplay.isDisposed())
- throw swte;
- }
- }
-
- private void enableButtons() {
- if (mCurrentClient != null) {
- mTBShowThreadUpdates.setSelection(mCurrentClient.isThreadUpdateEnabled());
- mTBShowThreadUpdates.setEnabled(true);
- mTBShowHeapUpdates.setSelection(mCurrentClient.isHeapUpdateEnabled());
- mTBShowHeapUpdates.setEnabled(true);
- mTBHalt.setEnabled(true);
- mTBCauseGc.setEnabled(true);
-
- ClientData data = mCurrentClient.getClientData();
-
- if (data.hasFeature(ClientData.FEATURE_HPROF)) {
- mTBDumpHprof.setEnabled(data.hasPendingHprofDump() == false);
- mTBDumpHprof.setToolTipText("Dump HPROF file");
- } else {
- mTBDumpHprof.setEnabled(false);
- mTBDumpHprof.setToolTipText("Dump HPROF file (not supported by this VM)");
- }
-
- if (data.hasFeature(ClientData.FEATURE_PROFILING)) {
- mTBProfiling.setEnabled(true);
- if (data.getMethodProfilingStatus() == MethodProfilingStatus.ON) {
- mTBProfiling.setToolTipText("Stop Method Profiling");
- mTBProfiling.setImage(mTracingStopImage);
- } else {
- mTBProfiling.setToolTipText("Start Method Profiling");
- mTBProfiling.setImage(mTracingStartImage);
- }
- } else {
- mTBProfiling.setEnabled(false);
- mTBProfiling.setImage(mTracingStartImage);
- mTBProfiling.setToolTipText("Start Method Profiling (not supported by this VM)");
- }
- } else {
- // list is empty, disable these
- mTBShowThreadUpdates.setSelection(false);
- mTBShowThreadUpdates.setEnabled(false);
- mTBShowHeapUpdates.setSelection(false);
- mTBShowHeapUpdates.setEnabled(false);
- mTBHalt.setEnabled(false);
- mTBCauseGc.setEnabled(false);
-
- mTBDumpHprof.setEnabled(false);
- mTBDumpHprof.setToolTipText("Dump HPROF file");
-
- mTBProfiling.setEnabled(false);
- mTBProfiling.setImage(mTracingStartImage);
- mTBProfiling.setToolTipText("Start Method Profiling");
- }
- }
-
- /**
- * Sent when a new {@link IDevice} and {@link Client} are selected.
- * @param selectedDevice the selected device. If null, no devices are selected.
- * @param selectedClient The selected client. If null, no clients are selected.
- *
- * @see IUiSelectionListener
- */
- @Override
- public void selectionChanged(IDevice selectedDevice, Client selectedClient) {
- if (mCurrentDevice != selectedDevice) {
- mCurrentDevice = selectedDevice;
- for (TablePanel panel : mPanels) {
- if (panel != null) {
- panel.deviceSelected(mCurrentDevice);
- }
- }
-
- mEmulatorPanel.deviceSelected(mCurrentDevice);
- if (useOldLogCatView()) {
- mLogPanel.deviceSelected(mCurrentDevice);
- } else {
- mLogCatPanel.deviceSelected(mCurrentDevice);
- }
- if (mEventLogPanel != null) {
- mEventLogPanel.deviceSelected(mCurrentDevice);
- }
-
- if (mExplorer != null) {
- mExplorer.switchDevice(mCurrentDevice);
- }
- }
-
- if (mCurrentClient != selectedClient) {
- AndroidDebugBridge.getBridge().setSelectedClient(selectedClient);
- mCurrentClient = selectedClient;
- for (TablePanel panel : mPanels) {
- if (panel != null) {
- panel.clientSelected(mCurrentClient);
- }
- }
-
- enableButtons();
- }
- }
-
- @Override
- public void clientChanged(Client client, int changeMask) {
- if ((changeMask & Client.CHANGE_METHOD_PROFILING_STATUS) ==
- Client.CHANGE_METHOD_PROFILING_STATUS) {
- if (mCurrentClient == client) {
- mDisplay.asyncExec(new Runnable() {
- @Override
- public void run() {
- // force refresh of the button enabled state.
- enableButtons();
- }
- });
- }
- }
- }
-}
diff --git a/ddms/app/src/images/ddms-128.png b/ddms/app/src/images/ddms-128.png
deleted file mode 100644
index 392a8f3..0000000
--- a/ddms/app/src/images/ddms-128.png
+++ /dev/null
Binary files differ