First commit... Ignore *.java files, they are there just so it builds.

Change-Id: Ibf159c32cee7a770f1c36f387fe646d9ecabe168
diff --git a/eclipse/plugins/com.android.ide.eclipse.hierarchyviewer/.classpath b/eclipse/plugins/com.android.ide.eclipse.hierarchyviewer/.classpath
new file mode 100644
index 0000000..e2c0625
--- /dev/null
+++ b/eclipse/plugins/com.android.ide.eclipse.hierarchyviewer/.classpath
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+	<classpathentry kind="src" path="src"/>
+	<classpathentry kind="lib" path="libs/hierarchyviewerlib.jar" sourcepath="/ddmlib"/>
+	<classpathentry kind="lib" path="libs/hierarchyvieweruilib.jar" sourcepath="/ddmuilib"/>
+	<classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/eclipse/plugins/com.android.ide.eclipse.hierarchyviewer/.project b/eclipse/plugins/com.android.ide.eclipse.hierarchyviewer/.project
new file mode 100644
index 0000000..9a33e7b
--- /dev/null
+++ b/eclipse/plugins/com.android.ide.eclipse.hierarchyviewer/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>hierarchyviewer-plugin</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.pde.ManifestBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.pde.SchemaBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.pde.PluginNature</nature>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+	</natures>
+</projectDescription>
diff --git a/eclipse/plugins/com.android.ide.eclipse.hierarchyviewer/META-INF/MANIFEST.MF b/eclipse/plugins/com.android.ide.eclipse.hierarchyviewer/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..716c0f4
--- /dev/null
+++ b/eclipse/plugins/com.android.ide.eclipse.hierarchyviewer/META-INF/MANIFEST.MF
@@ -0,0 +1,14 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Hierarchy Viewer
+Bundle-SymbolicName: com.android.ide.eclipse.hierarchyviewer;singleton:=true
+Bundle-Version: 1.0.0.qualifier
+Bundle-Activator: com.android.ide.eclipse.hierarchyviewer.HierarchyViewerPlugin
+Bundle-Vendor: The Android Open Source Project
+Bundle-Localization: plugin
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime
+Bundle-ActivationPolicy: lazy
+Bundle-ClassPath: .,
+ libs/hierarchyviewerlib.jar,
+ libs/hierearchyvieweruilib.jar
diff --git a/eclipse/plugins/com.android.ide.eclipse.hierarchyviewer/MODULE_LICENSE_APACHE2 b/eclipse/plugins/com.android.ide.eclipse.hierarchyviewer/MODULE_LICENSE_APACHE2
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/eclipse/plugins/com.android.ide.eclipse.hierarchyviewer/MODULE_LICENSE_APACHE2
diff --git a/eclipse/plugins/com.android.ide.eclipse.hierarchyviewer/build.properties b/eclipse/plugins/com.android.ide.eclipse.hierarchyviewer/build.properties
new file mode 100644
index 0000000..7fce1ca
--- /dev/null
+++ b/eclipse/plugins/com.android.ide.eclipse.hierarchyviewer/build.properties
@@ -0,0 +1,7 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+               icons/,\
+               plugin.xml,\
+               .,\
+               libs/
\ No newline at end of file
diff --git a/eclipse/plugins/com.android.ide.eclipse.hierarchyviewer/icons/sample.gif b/eclipse/plugins/com.android.ide.eclipse.hierarchyviewer/icons/sample.gif
new file mode 100644
index 0000000..34fb3c9
--- /dev/null
+++ b/eclipse/plugins/com.android.ide.eclipse.hierarchyviewer/icons/sample.gif
Binary files differ
diff --git a/eclipse/plugins/com.android.ide.eclipse.hierarchyviewer/plugin.xml b/eclipse/plugins/com.android.ide.eclipse.hierarchyviewer/plugin.xml
new file mode 100644
index 0000000..06e1f14
--- /dev/null
+++ b/eclipse/plugins/com.android.ide.eclipse.hierarchyviewer/plugin.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+   <extension
+         point="org.eclipse.ui.views">
+      <category
+            id="com.android.ide.eclipse.ddms.views.category"
+            name="Android">
+      </category>
+      <view
+            category="com.android.ide.eclipse.ddms.views.category"
+            class="com.android.ide.eclipse.hierarchyviewer.views.SampleView"
+            icon="icons/sample.gif"
+            id="com.android.ide.eclipse.hierarchyviewer.views.SampleView"
+            name="Sample View">
+      </view>
+   </extension>
+   <extension
+         point="org.eclipse.ui.perspectiveExtensions">
+      <perspectiveExtension
+            targetID="org.eclipse.jdt.ui.JavaPerspective">
+         <view
+               id="com.android.ide.eclipse.hierarchyviewer.views.SampleView"
+               ratio="0.5"
+               relationship="right"
+               relative="org.eclipse.ui.views.TaskList">
+         </view>
+      </perspectiveExtension>
+   </extension>
+</plugin>
diff --git a/eclipse/plugins/com.android.ide.eclipse.hierarchyviewer/src/com/android/ide/eclipse/hierarchyviewer/HierarchyViewerPlugin.java b/eclipse/plugins/com.android.ide.eclipse.hierarchyviewer/src/com/android/ide/eclipse/hierarchyviewer/HierarchyViewerPlugin.java
new file mode 100644
index 0000000..b6f0ed3
--- /dev/null
+++ b/eclipse/plugins/com.android.ide.eclipse.hierarchyviewer/src/com/android/ide/eclipse/hierarchyviewer/HierarchyViewerPlugin.java
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.ide.eclipse.hierarchyviewer;
+
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class HierarchyViewerPlugin extends AbstractUIPlugin {
+
+    public static final String PLUGIN_ID = "com.android.ide.eclipse.hierarchyviewer";
+
+    // The shared instance
+    private static HierarchyViewerPlugin plugin;
+
+    /**
+     * The constructor
+     */
+    public HierarchyViewerPlugin() {
+    }
+
+    public void start(BundleContext context) throws Exception {
+        super.start(context);
+        plugin = this;
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see
+     * org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext
+     * )
+     */
+    public void stop(BundleContext context) throws Exception {
+        plugin = null;
+        super.stop(context);
+    }
+
+    /**
+     * Returns the shared instance
+     * 
+     * @return the shared instance
+     */
+    public static HierarchyViewerPlugin getDefault() {
+        return plugin;
+    }
+
+}
diff --git a/eclipse/plugins/com.android.ide.eclipse.hierarchyviewer/src/com/android/ide/eclipse/hierarchyviewer/views/SampleView.java b/eclipse/plugins/com.android.ide.eclipse.hierarchyviewer/src/com/android/ide/eclipse/hierarchyviewer/views/SampleView.java
new file mode 100644
index 0000000..13c7ff4
--- /dev/null
+++ b/eclipse/plugins/com.android.ide.eclipse.hierarchyviewer/src/com/android/ide/eclipse/hierarchyviewer/views/SampleView.java
@@ -0,0 +1,120 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.ide.eclipse.hierarchyviewer.views;
+
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.core.runtime.IExtensionRegistry;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.events.MouseListener;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.part.ViewPart;
+import org.eclipse.core.runtime.jobs.Job;
+
+/**
+ * This sample class demonstrates how to plug-in a new workbench view. The view
+ * shows data obtained from the model. The sample creates a dummy model on the
+ * fly, but a real implementation would connect to the model available either in
+ * this or another plug-in (e.g. the workspace). The view is connected to the
+ * model using a content provider.
+ * <p>
+ * The view uses a label provider to define how model objects should be
+ * presented in the view. Each view can present the same model objects using
+ * different labels and icons, if needed. Alternatively, a single label provider
+ * can be shared between views in order to ensure that objects of the same type
+ * are presented in the same way everywhere.
+ * <p>
+ */
+
+public class SampleView extends ViewPart {
+
+    /**
+     * The ID of the view as specified by the extension.
+     */
+    public static final String ID = "com.android.ide.eclipse.hierarchyviewer.views.SampleView";
+
+    private Text text;
+
+    /**
+     * The constructor.
+     */
+    public SampleView() {
+    }
+
+    /**
+     * This is a callback that will allow us to create the viewer and initialize
+     * it.
+     */
+    public void createPartControl(Composite parent) {
+        parent.setLayout(new FillLayout());
+        text = new Text(parent, SWT.MULTI | SWT.READ_ONLY | SWT.V_SCROLL);
+        text.addMouseListener(new MouseListener() {
+
+            public void mouseDoubleClick(MouseEvent e) {
+                text.setText(text.getText() + "Scheduling\n");
+                Job test = new Job("Simple Job") {
+                    @Override
+                    protected IStatus run(IProgressMonitor monitor) {
+                        try {
+                            Display.getDefault().syncExec(new Runnable() {
+                                public void run() {
+                                    text.setText(text.getText() + "SLEEPING\n");
+                                }
+                            });
+                            Thread.sleep(5000);
+                            Display.getDefault().syncExec(new Runnable() {
+                                public void run() {
+                                    text.setText(text.getText() + "DONE SLEEPING\n");
+                                }
+                            });
+                        } catch (InterruptedException e) {
+                            // TODO Auto-generated catch block
+                            e.printStackTrace();
+                        }
+                        return Status.OK_STATUS;
+                    }
+
+                };
+                test.schedule();
+                text.setText(text.getText() + "Done Scheduling\n");
+            }
+
+            public void mouseDown(MouseEvent e) {
+                // TODO Auto-generated method stub
+
+            }
+
+            public void mouseUp(MouseEvent e) {
+                // TODO Auto-generated method stub
+
+            }
+
+        });
+    }
+
+    /**
+     * Passing the focus request to the viewer's control.
+     */
+    public void setFocus() {
+        text.setFocus();
+    }
+}
diff --git a/eclipse/scripts/create_all_symlinks.sh b/eclipse/scripts/create_all_symlinks.sh
index acda10f..99b81df 100755
--- a/eclipse/scripts/create_all_symlinks.sh
+++ b/eclipse/scripts/create_all_symlinks.sh
@@ -23,5 +23,7 @@
 $DEST/create_test_symlinks.sh "$*"
 echo ; echo "### BRIDGE ###" ; echo
 $DEST/create_bridge_symlinks.sh "$*"
+echo ; echo "### HIERARCHYVIEWER ###" ; echo
+$DEST/create_hierarchyviewer_symlinks.sh "$*"
 
 echo "### $0 done"
diff --git a/eclipse/scripts/create_hierarchyviewer_symlinks.sh b/eclipse/scripts/create_hierarchyviewer_symlinks.sh
new file mode 100755
index 0000000..ce7bf4b
--- /dev/null
+++ b/eclipse/scripts/create_hierarchyviewer_symlinks.sh
@@ -0,0 +1,69 @@
+#!/bin/bash
+#----------------------------------------------------------------------------|
+# Creates the links to use hierarchyviewer{ui}lib in the eclipse-ide plugin.
+# Run this from sdk/eclipse/scripts
+#----------------------------------------------------------------------------|
+
+set -e
+
+function die() {
+    echo "Error: $*"
+    exit 1
+}
+
+HOST=`uname`
+
+if [ "${HOST:0:6}" == "CYGWIN" ]; then
+    PLATFORM="windows-x86"
+
+    # We can't use symlinks under Cygwin
+
+    function cpfile { # $1=dest $2=source
+        cp -fv $2 $1/
+    }
+
+    function cpdir() { # $1=dest $2=source
+        rsync -avW --delete-after $2 $1
+    }
+
+else
+    if [ "$HOST" == "Linux" ]; then
+        PLATFORM="linux-x86"
+    elif [ "$HOST" == "Darwin" ]; then
+        PLATFORM="darwin-x86"
+    else
+        echo "Unsupported platform ($HOST). Nothing done."
+    fi
+
+    # For all other systems which support symlinks
+
+    # computes the "reverse" path, e.g. "a/b/c" => "../../.."
+    function back() {
+        echo $1 | sed 's@[^/]*@..@g'
+    }
+
+    function cpfile { # $1=dest $2=source
+        ln -svf `back $1`/$2 $1/
+    }
+
+    function cpdir() { # $1=dest $2=source
+        ln -svf `back $1`/$2 $1
+    }
+fi
+
+# CD to the top android directory
+D=`dirname "$0"`
+cd "$D/../../../"
+
+BASE="sdk/eclipse/plugins/com.android.ide.eclipse.hierarchyviewer"
+DEST=$BASE/libs
+
+mkdir -p $DEST
+
+LIBS="hierarchyviewerlib hierarchyvieweruilib"
+echo "make java libs ..."
+make -j3 showcommands $LIBS || die "Hierarchy Viewer: Fail to build one of $LIBS."
+
+for LIB in $LIBS; do
+    cpfile $DEST out/host/$PLATFORM/framework/$LIB.jar
+done
\ No newline at end of file
diff --git a/hierarchyviewer2/Android.mk b/hierarchyviewer2/Android.mk
new file mode 100644
index 0000000..411fbba
--- /dev/null
+++ b/hierarchyviewer2/Android.mk
@@ -0,0 +1,17 @@
+# Copyright (C) 2010 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+HIERARCHYVIEWER_LOCAL_DIR := $(call my-dir)
+include $(HIERARCHYVIEWER_LOCAL_DIR)/app/Android.mk
+include $(HIERARCHYVIEWER_LOCAL_DIR)/libs/Android.mk
diff --git a/hierarchyviewer2/MODULE_LICENSE_APACHE2 b/hierarchyviewer2/MODULE_LICENSE_APACHE2
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/hierarchyviewer2/MODULE_LICENSE_APACHE2
diff --git a/hierarchyviewer2/app/.classpath b/hierarchyviewer2/app/.classpath
new file mode 100644
index 0000000..fb50116
--- /dev/null
+++ b/hierarchyviewer2/app/.classpath
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" path="src"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+	<classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/hierarchyviewer2/app/.project b/hierarchyviewer2/app/.project
new file mode 100644
index 0000000..9a663d4
--- /dev/null
+++ b/hierarchyviewer2/app/.project
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>hierarchyviewer</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/hierarchyviewer2/app/Android.mk b/hierarchyviewer2/app/Android.mk
new file mode 100644
index 0000000..2927f1d
--- /dev/null
+++ b/hierarchyviewer2/app/Android.mk
@@ -0,0 +1,17 @@
+# Copyright (C) 2010 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+HIERARCHYVIEWERAPP_LOCAL_DIR := $(call my-dir)
+include $(HIERARCHYVIEWERAPP_LOCAL_DIR)/etc/Android.mk
+include $(HIERARCHYVIEWERAPP_LOCAL_DIR)/src/Android.mk
diff --git a/hierarchyviewer2/app/etc/Android.mk b/hierarchyviewer2/app/etc/Android.mk
new file mode 100644
index 0000000..89832ad
--- /dev/null
+++ b/hierarchyviewer2/app/etc/Android.mk
@@ -0,0 +1,20 @@
+# Copyright (C) 2010 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_PREBUILT_EXECUTABLES := hierarchyviewer2
+include $(BUILD_HOST_PREBUILT)
+
diff --git a/hierarchyviewer2/app/etc/hierarchyviewer2 b/hierarchyviewer2/app/etc/hierarchyviewer2
new file mode 100755
index 0000000..18a3aca
--- /dev/null
+++ b/hierarchyviewer2/app/etc/hierarchyviewer2
@@ -0,0 +1,110 @@
+#!/bin/sh
+# Copyright 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.
+# 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=hierarchyviewer2.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
+
+# 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
+
+if [ "$OSTYPE" = "cygwin" ] ; then
+    jarpath=`cygpath -w  "$frameworkdir/$jarfile"`
+    progdir=`cygpath -w  "$progdir"`
+else
+    jarpath="$frameworkdir/$jarfile"
+fi
+
+# 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=`java -jar "${frameworkdir}"/archquery.jar`
+    if [ -n "$ANDROID_BUILD_TOP" ]; then
+        osname=`uname -s | tr A-Z a-z`
+        swtpath="${ANDROID_BUILD_TOP}/prebuilt/${osname}-${vmarch}/swt"
+    else
+        swtpath="${frameworkdir}/${vmarch}"
+    fi
+fi
+
+# Combine the swtpath and the framework dir path.
+if [ -d "$swtpath" ]; then
+    frameworkdir="${swtpath}:${frameworkdir}"
+else
+    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
+
+# need to use "java.ext.dirs" because "-jar" causes classpath to be ignored
+# might need more memory, e.g. -Xmx128M
+exec java -Xmx512M $java_debug -Djava.ext.dirs="$frameworkdir" -Dcom.android.hierarchyviewer.bindir="$progdir" -jar "$jarpath" "$@"
diff --git a/hierarchyviewer2/app/etc/hierarchyviewer2.bat b/hierarchyviewer2/app/etc/hierarchyviewer2.bat
new file mode 100755
index 0000000..d0b8bef
--- /dev/null
+++ b/hierarchyviewer2/app/etc/hierarchyviewer2.bat
@@ -0,0 +1,69 @@
+@echo off
+rem Copyright (C) 2008 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 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=hierarchyviewer2.jar
+set frameworkdir=
+set libdir=
+
+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%
+
+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%
+
+call %java_exe% %java_debug% -Xmx512m -Djava.ext.dirs=%frameworkdir% -Dcom.android.hierarchyviewer.bindir= -jar %jarpath% %*
diff --git a/hierarchyviewer2/app/etc/manifest.txt b/hierarchyviewer2/app/etc/manifest.txt
new file mode 100644
index 0000000..ef45052
--- /dev/null
+++ b/hierarchyviewer2/app/etc/manifest.txt
@@ -0,0 +1,2 @@
+Main-Class: com.android.hierarchyviewer.HierarchyViewerApplication
+Class-Path: ddmlib.jar hierarchyviewerlib.jar hierarchyvieweruilib.jar
diff --git a/hierarchyviewer2/app/src/Android.mk b/hierarchyviewer2/app/src/Android.mk
new file mode 100644
index 0000000..dedc028
--- /dev/null
+++ b/hierarchyviewer2/app/src/Android.mk
@@ -0,0 +1,30 @@
+# Copyright (C) 2010 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := $(call all-subdir-java-files)
+
+LOCAL_JAR_MANIFEST := ../etc/manifest.txt
+LOCAL_JAVA_LIBRARIES := \
+	ddmlib \
+	hierarchyviewerlib \
+	hierarchyvieweruilib \
+	swt
+
+LOCAL_MODULE := hierarchyviewer2
+
+include $(BUILD_HOST_JAVA_LIBRARY)
+
diff --git a/hierarchyviewer2/app/src/com/android/hierarchyviewer/HierarchyViewerApplication.java b/hierarchyviewer2/app/src/com/android/hierarchyviewer/HierarchyViewerApplication.java
new file mode 100644
index 0000000..acc79b7
--- /dev/null
+++ b/hierarchyviewer2/app/src/com/android/hierarchyviewer/HierarchyViewerApplication.java
@@ -0,0 +1,23 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.hierarchyviewer;
+
+public class HierarchyViewerApplication {
+    public static void main(String[] args) {
+    	System.out.println("TEST");
+    }
+}
diff --git a/hierarchyviewer2/libs/Android.mk b/hierarchyviewer2/libs/Android.mk
new file mode 100644
index 0000000..7d5c631
--- /dev/null
+++ b/hierarchyviewer2/libs/Android.mk
@@ -0,0 +1,17 @@
+# Copyright (C) 2010 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+HIERARCHYVIEWERLIBS_LOCAL_DIR := $(call my-dir)
+include $(HIERARCHYVIEWERLIBS_LOCAL_DIR)/hierarchyviewerlib/Android.mk
+include $(HIERARCHYVIEWERLIBS_LOCAL_DIR)/hierarchyvieweruilib/Android.mk
diff --git a/hierarchyviewer2/libs/hierarchyviewerlib/.classpath b/hierarchyviewer2/libs/hierarchyviewerlib/.classpath
new file mode 100644
index 0000000..fb50116
--- /dev/null
+++ b/hierarchyviewer2/libs/hierarchyviewerlib/.classpath
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" path="src"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+	<classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/hierarchyviewer2/libs/hierarchyviewerlib/.project b/hierarchyviewer2/libs/hierarchyviewerlib/.project
new file mode 100644
index 0000000..b3c994a
--- /dev/null
+++ b/hierarchyviewer2/libs/hierarchyviewerlib/.project
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>hierarchyviewerlib</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/hierarchyviewer2/libs/hierarchyviewerlib/Android.mk b/hierarchyviewer2/libs/hierarchyviewerlib/Android.mk
new file mode 100644
index 0000000..b76c127
--- /dev/null
+++ b/hierarchyviewer2/libs/hierarchyviewerlib/Android.mk
@@ -0,0 +1,16 @@
+# Copyright (C) 2010 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+HIERARCHYVIEWERLIB_LOCAL_DIR := $(call my-dir)
+include $(HIERARCHYVIEWERLIB_LOCAL_DIR)/src/Android.mk
diff --git a/hierarchyviewer2/libs/hierarchyviewerlib/src/Android.mk b/hierarchyviewer2/libs/hierarchyviewerlib/src/Android.mk
new file mode 100644
index 0000000..77808b1
--- /dev/null
+++ b/hierarchyviewer2/libs/hierarchyviewerlib/src/Android.mk
@@ -0,0 +1,24 @@
+# Copyright (C) 2010 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := $(call all-subdir-java-files)
+
+LOCAL_JAVA_LIBRARIES := ddmlib
+LOCAL_MODULE := hierarchyviewerlib
+
+include $(BUILD_HOST_JAVA_LIBRARY)
+
diff --git a/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/Test.java b/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/Test.java
new file mode 100644
index 0000000..ad6db3d
--- /dev/null
+++ b/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/Test.java
@@ -0,0 +1,3 @@
+package com.android.hierarchyviewerlib;
+public class Test {
+}
\ No newline at end of file
diff --git a/hierarchyviewer2/libs/hierarchyvieweruilib/.classpath b/hierarchyviewer2/libs/hierarchyvieweruilib/.classpath
new file mode 100644
index 0000000..fb50116
--- /dev/null
+++ b/hierarchyviewer2/libs/hierarchyvieweruilib/.classpath
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" path="src"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+	<classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/hierarchyviewer2/libs/hierarchyvieweruilib/.project b/hierarchyviewer2/libs/hierarchyvieweruilib/.project
new file mode 100644
index 0000000..e9b1298
--- /dev/null
+++ b/hierarchyviewer2/libs/hierarchyvieweruilib/.project
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>hierarchyvieweruilib</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/hierarchyviewer2/libs/hierarchyvieweruilib/Android.mk b/hierarchyviewer2/libs/hierarchyvieweruilib/Android.mk
new file mode 100644
index 0000000..341880b
--- /dev/null
+++ b/hierarchyviewer2/libs/hierarchyvieweruilib/Android.mk
@@ -0,0 +1,16 @@
+# Copyright (C) 2010 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+HIERARCHYVIEWERUILIB_LOCAL_DIR := $(call my-dir)
+include $(HIERARCHYVIEWERUILIB_LOCAL_DIR)/src/Android.mk
diff --git a/hierarchyviewer2/libs/hierarchyvieweruilib/src/Android.mk b/hierarchyviewer2/libs/hierarchyvieweruilib/src/Android.mk
new file mode 100644
index 0000000..0240688
--- /dev/null
+++ b/hierarchyviewer2/libs/hierarchyvieweruilib/src/Android.mk
@@ -0,0 +1,26 @@
+# Copyright (C) 2010 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := $(call all-subdir-java-files)
+
+LOCAL_JAVA_LIBRARIES := \
+	hierarchyviewerlib \
+	swt
+LOCAL_MODULE := hierarchyvieweruilib
+
+include $(BUILD_HOST_JAVA_LIBRARY)
+
diff --git a/hierarchyviewer2/libs/hierarchyvieweruilib/src/com/android/hierarchyvieweruilib/Test.java b/hierarchyviewer2/libs/hierarchyvieweruilib/src/com/android/hierarchyvieweruilib/Test.java
new file mode 100644
index 0000000..c519cbc
--- /dev/null
+++ b/hierarchyviewer2/libs/hierarchyvieweruilib/src/com/android/hierarchyvieweruilib/Test.java
@@ -0,0 +1,3 @@
+package com.android.hierarchyvieweruilib;
+public class Test {
+}