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