You are viewing a plain text version of this content. The canonical link for it is here.
Posted to kato-commits@incubator.apache.org by sp...@apache.org on 2009/05/26 12:33:44 UTC
svn commit: r778673 - in
/incubator/kato/branches/experimental/maven_restructure/org.apache.kato/plugins:
kato.api.plugin/ kato.api.plugin/META-INF/ kato.api.registry.plugin/
kato.api.registry.plugin/META-INF/
kato.api.registry.plugin/src/main/java/org...
Author: spoole
Date: Tue May 26 12:33:43 2009
New Revision: 778673
URL: http://svn.apache.org/viewvc?rev=778673&view=rev
Log:
trying to eclipse feature build via maven
Added:
incubator/kato/branches/experimental/maven_restructure/org.apache.kato/plugins/kato.api.plugin/META-INF/
incubator/kato/branches/experimental/maven_restructure/org.apache.kato/plugins/kato.api.plugin/META-INF/MANIFEST.MF
incubator/kato/branches/experimental/maven_restructure/org.apache.kato/plugins/kato.explorer.plugin/icons/
incubator/kato/branches/experimental/maven_restructure/org.apache.kato/plugins/kato.explorer.plugin/icons/sample.gif (with props)
incubator/kato/branches/experimental/maven_restructure/org.apache.kato/plugins/kato.explorer.plugin/plugin.xml
incubator/kato/branches/experimental/maven_restructure/org.apache.kato/plugins/kato.explorer.plugin/src/main/java/org/
incubator/kato/branches/experimental/maven_restructure/org.apache.kato/plugins/kato.explorer.plugin/src/main/java/org/apache/
incubator/kato/branches/experimental/maven_restructure/org.apache.kato/plugins/kato.explorer.plugin/src/main/java/org/apache/kato/
incubator/kato/branches/experimental/maven_restructure/org.apache.kato/plugins/kato.explorer.plugin/src/main/java/org/apache/kato/tools/
incubator/kato/branches/experimental/maven_restructure/org.apache.kato/plugins/kato.explorer.plugin/src/main/java/org/apache/kato/tools/explorer/
incubator/kato/branches/experimental/maven_restructure/org.apache.kato/plugins/kato.explorer.plugin/src/main/java/org/apache/kato/tools/explorer/plugin/
incubator/kato/branches/experimental/maven_restructure/org.apache.kato/plugins/kato.explorer.plugin/src/main/java/org/apache/kato/tools/explorer/plugin/views/
incubator/kato/branches/experimental/maven_restructure/org.apache.kato/plugins/kato.explorer.plugin/src/main/java/org/apache/kato/tools/explorer/plugin/views/ExplorerView.java
incubator/kato/branches/experimental/maven_restructure/org.apache.kato/plugins/kato.explorer.plugin/src/main/java/org/apache/kato/tools/explorer/plugin/views/LazyNode.java
incubator/kato/branches/experimental/maven_restructure/org.apache.kato/plugins/kato.explorer.plugin/src/main/java/org/apache/kato/tools/explorer/plugin/views/RTEDataException.java
incubator/kato/branches/experimental/maven_restructure/org.apache.kato/plugins/kato.explorer.plugin/src/main/java/org/apache/kato/tools/explorer/plugin/views/RuntimeExplorer.java
Modified:
incubator/kato/branches/experimental/maven_restructure/org.apache.kato/plugins/kato.api.plugin/.classpath
incubator/kato/branches/experimental/maven_restructure/org.apache.kato/plugins/kato.api.plugin/plugin.xml
incubator/kato/branches/experimental/maven_restructure/org.apache.kato/plugins/kato.api.registry.plugin/.classpath
incubator/kato/branches/experimental/maven_restructure/org.apache.kato/plugins/kato.api.registry.plugin/META-INF/MANIFEST.MF
incubator/kato/branches/experimental/maven_restructure/org.apache.kato/plugins/kato.api.registry.plugin/build.properties
incubator/kato/branches/experimental/maven_restructure/org.apache.kato/plugins/kato.api.registry.plugin/pom.xml
incubator/kato/branches/experimental/maven_restructure/org.apache.kato/plugins/kato.api.registry.plugin/src/main/java/org/apache/kato/api/plugin/Activator.java
incubator/kato/branches/experimental/maven_restructure/org.apache.kato/plugins/kato.explorer.plugin/ (props changed)
incubator/kato/branches/experimental/maven_restructure/org.apache.kato/plugins/kato.explorer.plugin/.settings/org.eclipse.jdt.core.prefs
incubator/kato/branches/experimental/maven_restructure/org.apache.kato/plugins/kato.explorer.plugin/META-INF/MANIFEST.MF
incubator/kato/branches/experimental/maven_restructure/org.apache.kato/plugins/kato.explorer.plugin/build.properties
incubator/kato/branches/experimental/maven_restructure/org.apache.kato/plugins/kato.explorer.plugin/pom.xml
Modified: incubator/kato/branches/experimental/maven_restructure/org.apache.kato/plugins/kato.api.plugin/.classpath
URL: http://svn.apache.org/viewvc/incubator/kato/branches/experimental/maven_restructure/org.apache.kato/plugins/kato.api.plugin/.classpath?rev=778673&r1=778672&r2=778673&view=diff
==============================================================================
--- incubator/kato/branches/experimental/maven_restructure/org.apache.kato/plugins/kato.api.plugin/.classpath (original)
+++ incubator/kato/branches/experimental/maven_restructure/org.apache.kato/plugins/kato.api.plugin/.classpath Tue May 26 12:33:43 2009
@@ -4,6 +4,7 @@
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"/>
<classpathentry kind="src" output="target/test-classes" path="src/test/java"/>
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources"/>
+ <classpathentry exported="true" kind="lib" path="lib/kato.api-0.0.1-SNAPSHOT.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
Added: incubator/kato/branches/experimental/maven_restructure/org.apache.kato/plugins/kato.api.plugin/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/incubator/kato/branches/experimental/maven_restructure/org.apache.kato/plugins/kato.api.plugin/META-INF/MANIFEST.MF?rev=778673&view=auto
==============================================================================
--- incubator/kato/branches/experimental/maven_restructure/org.apache.kato/plugins/kato.api.plugin/META-INF/MANIFEST.MF (added)
+++ incubator/kato/branches/experimental/maven_restructure/org.apache.kato/plugins/kato.api.plugin/META-INF/MANIFEST.MF Tue May 26 12:33:43 2009
@@ -0,0 +1,13 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Apache Kato Registry
+Bundle-SymbolicName: org.apache.kato.api.plugin;singleton:=true
+Bundle-Version: 0.0.1
+Bundle-ClassPath: .,
+ lib/kato.api-0.0.1-SNAPSHOT.jar
+Bundle-Vendor: Apache Software Foundation
+Bundle-Localization: plugin
+Export-Package: org.apache.kato,
+ org.apache.kato.image,
+ org.apache.kato.java,
+ org.apache.kato.runtime
Modified: incubator/kato/branches/experimental/maven_restructure/org.apache.kato/plugins/kato.api.plugin/plugin.xml
URL: http://svn.apache.org/viewvc/incubator/kato/branches/experimental/maven_restructure/org.apache.kato/plugins/kato.api.plugin/plugin.xml?rev=778673&r1=778672&r2=778673&view=diff
==============================================================================
--- incubator/kato/branches/experimental/maven_restructure/org.apache.kato/plugins/kato.api.plugin/plugin.xml (original)
+++ incubator/kato/branches/experimental/maven_restructure/org.apache.kato/plugins/kato.api.plugin/plugin.xml Tue May 26 12:33:43 2009
@@ -1,25 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.2"?>
-<plugin
- id="org.apache.kato.api.plugin"
- name="Apache Kato Registry"
- version="0.0.1"
- provider-name="Apache Software Foundation">
- <runtime>
- <library name="."/>
- <library name="lib/kato.api-0.0.1-SNAPSHOT.jar">
- <export
- name="org.apache.kato.*">
- </export>
- <export
- name="org.apache.kato.image.*">
- </export>
- <export
- name="org.apache.kato.java.*">
- </export>
- <export
- name="org.apache.kato.runtime.*">
- </export>
- </library>
- </runtime>
+<plugin>
+
</plugin>
Modified: incubator/kato/branches/experimental/maven_restructure/org.apache.kato/plugins/kato.api.registry.plugin/.classpath
URL: http://svn.apache.org/viewvc/incubator/kato/branches/experimental/maven_restructure/org.apache.kato/plugins/kato.api.registry.plugin/.classpath?rev=778673&r1=778672&r2=778673&view=diff
==============================================================================
--- incubator/kato/branches/experimental/maven_restructure/org.apache.kato/plugins/kato.api.registry.plugin/.classpath (original)
+++ incubator/kato/branches/experimental/maven_restructure/org.apache.kato/plugins/kato.api.registry.plugin/.classpath Tue May 26 12:33:43 2009
@@ -6,5 +6,6 @@
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
Modified: incubator/kato/branches/experimental/maven_restructure/org.apache.kato/plugins/kato.api.registry.plugin/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/incubator/kato/branches/experimental/maven_restructure/org.apache.kato/plugins/kato.api.registry.plugin/META-INF/MANIFEST.MF?rev=778673&r1=778672&r2=778673&view=diff
==============================================================================
--- incubator/kato/branches/experimental/maven_restructure/org.apache.kato/plugins/kato.api.registry.plugin/META-INF/MANIFEST.MF (original)
+++ incubator/kato/branches/experimental/maven_restructure/org.apache.kato/plugins/kato.api.registry.plugin/META-INF/MANIFEST.MF Tue May 26 12:33:43 2009
@@ -11,8 +11,8 @@
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
org.eclipse.core.runtime.compatibility,
- org.eclipse.ui.ide;bundle-version="3.4.2",
- org.eclipse.ui.editors;bundle-version="3.4.0",
- org.apache.kato.api.plugin;bundle-version="0.0.1";visibility:=reexport
+ org.eclipse.ui.ide,
+ org.eclipse.ui.editors,
+ org.apache.kato.api.plugin
Export-Package: org.apache.kato.api.plugin,
org.apache.kato.api.plugin.preferences
Modified: incubator/kato/branches/experimental/maven_restructure/org.apache.kato/plugins/kato.api.registry.plugin/build.properties
URL: http://svn.apache.org/viewvc/incubator/kato/branches/experimental/maven_restructure/org.apache.kato/plugins/kato.api.registry.plugin/build.properties?rev=778673&r1=778672&r2=778673&view=diff
==============================================================================
--- incubator/kato/branches/experimental/maven_restructure/org.apache.kato/plugins/kato.api.registry.plugin/build.properties (original)
+++ incubator/kato/branches/experimental/maven_restructure/org.apache.kato/plugins/kato.api.registry.plugin/build.properties Tue May 26 12:33:43 2009
@@ -3,7 +3,8 @@
bin.includes = plugin.xml,\
META-INF/,\
.,\
- icons/
+ icons/,\
+ target/classes/
javacTarget=1.6
javacSource=1.6
Modified: incubator/kato/branches/experimental/maven_restructure/org.apache.kato/plugins/kato.api.registry.plugin/pom.xml
URL: http://svn.apache.org/viewvc/incubator/kato/branches/experimental/maven_restructure/org.apache.kato/plugins/kato.api.registry.plugin/pom.xml?rev=778673&r1=778672&r2=778673&view=diff
==============================================================================
--- incubator/kato/branches/experimental/maven_restructure/org.apache.kato/plugins/kato.api.registry.plugin/pom.xml (original)
+++ incubator/kato/branches/experimental/maven_restructure/org.apache.kato/plugins/kato.api.registry.plugin/pom.xml Tue May 26 12:33:43 2009
@@ -25,6 +25,24 @@
<configuration>
<eclipseInstall>/home/spoole/eclipseinstall/eclipse</eclipseInstall>
</configuration>
+ <executions>
+ <execution>
+ <id>build-pde</id>
+ <phase>compile</phase>
+ <goals>
+ <goal>attach</goal>
+ </goals>
+ </execution>
+ <!-- Also bind to mvn clean -->
+ <execution>
+ <id>clean-pde</id>
+ <phase>clean</phase>
+ <goals>
+ <goal>clean</goal>
+ </goals>
+ </execution>
+ </executions>
+
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Modified: incubator/kato/branches/experimental/maven_restructure/org.apache.kato/plugins/kato.api.registry.plugin/src/main/java/org/apache/kato/api/plugin/Activator.java
URL: http://svn.apache.org/viewvc/incubator/kato/branches/experimental/maven_restructure/org.apache.kato/plugins/kato.api.registry.plugin/src/main/java/org/apache/kato/api/plugin/Activator.java?rev=778673&r1=778672&r2=778673&view=diff
==============================================================================
--- incubator/kato/branches/experimental/maven_restructure/org.apache.kato/plugins/kato.api.registry.plugin/src/main/java/org/apache/kato/api/plugin/Activator.java (original)
+++ incubator/kato/branches/experimental/maven_restructure/org.apache.kato/plugins/kato.api.registry.plugin/src/main/java/org/apache/kato/api/plugin/Activator.java Tue May 26 12:33:43 2009
@@ -6,7 +6,6 @@
import org.apache.kato.FactoryRegistry;
import org.apache.kato.image.Image;
import org.apache.kato.image.ImageFactory;
-import org.eclipse.core.runtime.content.IContentTypeManager;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;
Propchange: incubator/kato/branches/experimental/maven_restructure/org.apache.kato/plugins/kato.explorer.plugin/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Tue May 26 12:33:43 2009
@@ -1 +1,5 @@
target
+temp.folder
+build.xml
+contexts.xml
+javaCompiler...args
Modified: incubator/kato/branches/experimental/maven_restructure/org.apache.kato/plugins/kato.explorer.plugin/.settings/org.eclipse.jdt.core.prefs
URL: http://svn.apache.org/viewvc/incubator/kato/branches/experimental/maven_restructure/org.apache.kato/plugins/kato.explorer.plugin/.settings/org.eclipse.jdt.core.prefs?rev=778673&r1=778672&r2=778673&view=diff
==============================================================================
--- incubator/kato/branches/experimental/maven_restructure/org.apache.kato/plugins/kato.explorer.plugin/.settings/org.eclipse.jdt.core.prefs (original)
+++ incubator/kato/branches/experimental/maven_restructure/org.apache.kato/plugins/kato.explorer.plugin/.settings/org.eclipse.jdt.core.prefs Tue May 26 12:33:43 2009
@@ -1,5 +1,12 @@
-#Tue May 26 08:00:52 BST 2009
+#Tue May 26 09:23:13 BST 2009
eclipse.preferences.version=1
+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.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.6
Modified: incubator/kato/branches/experimental/maven_restructure/org.apache.kato/plugins/kato.explorer.plugin/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/incubator/kato/branches/experimental/maven_restructure/org.apache.kato/plugins/kato.explorer.plugin/META-INF/MANIFEST.MF?rev=778673&r1=778672&r2=778673&view=diff
==============================================================================
--- incubator/kato/branches/experimental/maven_restructure/org.apache.kato/plugins/kato.explorer.plugin/META-INF/MANIFEST.MF (original)
+++ incubator/kato/branches/experimental/maven_restructure/org.apache.kato/plugins/kato.explorer.plugin/META-INF/MANIFEST.MF Tue May 26 12:33:43 2009
@@ -1,7 +1,10 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Plugin
-Bundle-SymbolicName: kato.explorer.plugin
+Bundle-SymbolicName: kato.explorer.plugin;singleton:=true
Bundle-Version: 1.0.0
-Require-Bundle: org.apache.kato.api.plugin;bundle-version="0.0.1",
- org.apache.kato.api.registry.plugin;bundle-version="1.0.0"
+Require-Bundle: org.apache.kato.api.plugin,
+ org.apache.kato.api.registry.plugin,
+ org.eclipse.core.runtime,
+ org.eclipse.ui
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Modified: incubator/kato/branches/experimental/maven_restructure/org.apache.kato/plugins/kato.explorer.plugin/build.properties
URL: http://svn.apache.org/viewvc/incubator/kato/branches/experimental/maven_restructure/org.apache.kato/plugins/kato.explorer.plugin/build.properties?rev=778673&r1=778672&r2=778673&view=diff
==============================================================================
--- incubator/kato/branches/experimental/maven_restructure/org.apache.kato/plugins/kato.explorer.plugin/build.properties (original)
+++ incubator/kato/branches/experimental/maven_restructure/org.apache.kato/plugins/kato.explorer.plugin/build.properties Tue May 26 12:33:43 2009
@@ -3,4 +3,10 @@
src/test/java/,\
src/test/resources/
bin.includes = META-INF/,\
- .
+ .,\
+ plugin.xml,\
+ target/
+
+javacTarget=1.6
+javacSource=1.6
+
\ No newline at end of file
Added: incubator/kato/branches/experimental/maven_restructure/org.apache.kato/plugins/kato.explorer.plugin/icons/sample.gif
URL: http://svn.apache.org/viewvc/incubator/kato/branches/experimental/maven_restructure/org.apache.kato/plugins/kato.explorer.plugin/icons/sample.gif?rev=778673&view=auto
==============================================================================
Binary file - no diff available.
Propchange: incubator/kato/branches/experimental/maven_restructure/org.apache.kato/plugins/kato.explorer.plugin/icons/sample.gif
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: incubator/kato/branches/experimental/maven_restructure/org.apache.kato/plugins/kato.explorer.plugin/plugin.xml
URL: http://svn.apache.org/viewvc/incubator/kato/branches/experimental/maven_restructure/org.apache.kato/plugins/kato.explorer.plugin/plugin.xml?rev=778673&view=auto
==============================================================================
--- incubator/kato/branches/experimental/maven_restructure/org.apache.kato/plugins/kato.explorer.plugin/plugin.xml (added)
+++ incubator/kato/branches/experimental/maven_restructure/org.apache.kato/plugins/kato.explorer.plugin/plugin.xml Tue May 26 12:33:43 2009
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+ <extension
+ point="org.eclipse.ui.views">
+ <category
+ id="kato.explorer.plugin"
+ name="Apache Kato">
+ </category>
+ <view
+ category="kato.explorer.plugin"
+ class="org.apache.kato.tools.explorer.plugin.views.ExplorerView"
+ icon="icons/sample.gif"
+ id="kato.explorer.plugin.views.ExplorerView"
+ name="Explorer View">
+ </view>
+ </extension>
+ <extension
+ point="org.eclipse.ui.perspectiveExtensions">
+ <perspectiveExtension
+ targetID="org.eclipse.jdt.ui.JavaPerspective">
+ <view
+ id="kato.explorer.plugin.views.ExplorerView"
+ ratio="0.5"
+ relationship="right"
+ relative="org.eclipse.ui.views.TaskList">
+ </view>
+ </perspectiveExtension>
+ </extension>
+ <extension
+ point="org.eclipse.help.contexts">
+ <contexts
+ file="contexts.xml">
+ </contexts>
+ </extension>
+
+</plugin>
Modified: incubator/kato/branches/experimental/maven_restructure/org.apache.kato/plugins/kato.explorer.plugin/pom.xml
URL: http://svn.apache.org/viewvc/incubator/kato/branches/experimental/maven_restructure/org.apache.kato/plugins/kato.explorer.plugin/pom.xml?rev=778673&r1=778672&r2=778673&view=diff
==============================================================================
--- incubator/kato/branches/experimental/maven_restructure/org.apache.kato/plugins/kato.explorer.plugin/pom.xml (original)
+++ incubator/kato/branches/experimental/maven_restructure/org.apache.kato/plugins/kato.explorer.plugin/pom.xml Tue May 26 12:33:43 2009
@@ -7,6 +7,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.kato</groupId>
<artifactId>kato.explorer.plugin</artifactId>
+ <packaging>zip</packaging>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<dependency>
@@ -21,4 +22,24 @@
<type>zip</type>
</dependency>
</dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>pde-maven-plugin</artifactId>
+ <extensions>true</extensions>
+ <configuration>
+ <eclipseInstall>/home/spoole/eclipseinstall/eclipse</eclipseInstall>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
</project>
\ No newline at end of file
Added: incubator/kato/branches/experimental/maven_restructure/org.apache.kato/plugins/kato.explorer.plugin/src/main/java/org/apache/kato/tools/explorer/plugin/views/ExplorerView.java
URL: http://svn.apache.org/viewvc/incubator/kato/branches/experimental/maven_restructure/org.apache.kato/plugins/kato.explorer.plugin/src/main/java/org/apache/kato/tools/explorer/plugin/views/ExplorerView.java?rev=778673&view=auto
==============================================================================
--- incubator/kato/branches/experimental/maven_restructure/org.apache.kato/plugins/kato.explorer.plugin/src/main/java/org/apache/kato/tools/explorer/plugin/views/ExplorerView.java (added)
+++ incubator/kato/branches/experimental/maven_restructure/org.apache.kato/plugins/kato.explorer.plugin/src/main/java/org/apache/kato/tools/explorer/plugin/views/ExplorerView.java Tue May 26 12:33:43 2009
@@ -0,0 +1,287 @@
+package org.apache.kato.tools.explorer.plugin.views;
+
+import java.util.ArrayList;
+
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.part.*;
+import org.eclipse.jface.viewers.*;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.jface.action.*;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.ui.*;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.SWT;
+import org.eclipse.core.runtime.IAdaptable;
+
+
+/**
+ * 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 ExplorerView extends ViewPart {
+ private TreeViewer viewer;
+ private DrillDownAdapter drillDownAdapter;
+ private Action action1;
+ private Action action2;
+ private Action doubleClickAction;
+
+ /*
+ * The content provider class is responsible for
+ * providing objects to the view. It can wrap
+ * existing objects in adapters or simply return
+ * objects as-is. These objects may be sensitive
+ * to the current input of the view, or ignore
+ * it and always show the same content
+ * (like Task List, for example).
+ */
+
+ class TreeObject implements IAdaptable {
+ private String name;
+ private TreeParent parent;
+
+ public TreeObject(String name) {
+ this.name = name;
+ }
+ public String getName() {
+ return name;
+ }
+ public void setParent(TreeParent parent) {
+ this.parent = parent;
+ }
+ public TreeParent getParent() {
+ return parent;
+ }
+ public String toString() {
+ return getName();
+ }
+ public Object getAdapter(Class key) {
+ return null;
+ }
+ }
+
+ class TreeParent extends TreeObject {
+ private ArrayList children;
+ public TreeParent(String name) {
+ super(name);
+ children = new ArrayList();
+ }
+ public void addChild(TreeObject child) {
+ children.add(child);
+ child.setParent(this);
+ }
+ public void removeChild(TreeObject child) {
+ children.remove(child);
+ child.setParent(null);
+ }
+ public TreeObject [] getChildren() {
+ return (TreeObject [])children.toArray(new TreeObject[children.size()]);
+ }
+ public boolean hasChildren() {
+ return children.size()>0;
+ }
+ }
+
+ class ViewContentProvider implements IStructuredContentProvider,
+ ITreeContentProvider {
+ private TreeParent invisibleRoot;
+
+ public void inputChanged(Viewer v, Object oldInput, Object newInput) {
+ }
+ public void dispose() {
+ }
+ public Object[] getElements(Object parent) {
+ if (parent.equals(getViewSite())) {
+ if (invisibleRoot==null) initialize();
+ return getChildren(invisibleRoot);
+ }
+ return getChildren(parent);
+ }
+ public Object getParent(Object child) {
+ if (child instanceof TreeObject) {
+ return ((TreeObject)child).getParent();
+ }
+ return null;
+ }
+ public Object [] getChildren(Object parent) {
+ if (parent instanceof TreeParent) {
+ return ((TreeParent)parent).getChildren();
+ }
+ return new Object[0];
+ }
+ public boolean hasChildren(Object parent) {
+ if (parent instanceof TreeParent)
+ return ((TreeParent)parent).hasChildren();
+ return false;
+ }
+/*
+ * We will set up a dummy model to initialize tree heararchy.
+ * In a real code, you will connect to a real model and
+ * expose its hierarchy.
+ */
+ private void initialize() {
+ TreeObject to1 = new TreeObject("Leaf 1");
+ TreeObject to2 = new TreeObject("Leaf 2");
+ TreeObject to3 = new TreeObject("Leaf 3");
+ TreeParent p1 = new TreeParent("Parent 1");
+ p1.addChild(to1);
+ p1.addChild(to2);
+ p1.addChild(to3);
+
+ TreeObject to4 = new TreeObject("Leaf 4");
+ TreeParent p2 = new TreeParent("Parent 2");
+ p2.addChild(to4);
+
+ TreeParent root = new TreeParent("Root");
+ root.addChild(p1);
+ root.addChild(p2);
+
+ invisibleRoot = new TreeParent("");
+ invisibleRoot.addChild(root);
+ }
+ }
+ class ViewLabelProvider extends LabelProvider {
+
+ public String getText(Object obj) {
+ return obj.toString();
+ }
+ public Image getImage(Object obj) {
+ String imageKey = ISharedImages.IMG_OBJ_ELEMENT;
+ if (obj instanceof TreeParent)
+ imageKey = ISharedImages.IMG_OBJ_FOLDER;
+ return PlatformUI.getWorkbench().getSharedImages().getImage(imageKey);
+ }
+ }
+ class NameSorter extends ViewerSorter {
+ }
+
+ /**
+ * The constructor.
+ */
+ public ExplorerView() {
+ }
+
+ /**
+ * This is a callback that will allow us
+ * to create the viewer and initialize it.
+ */
+ public void createPartControl(Composite parent) {
+ viewer = new TreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
+ drillDownAdapter = new DrillDownAdapter(viewer);
+ viewer.setContentProvider(new ViewContentProvider());
+ viewer.setLabelProvider(new ViewLabelProvider());
+ viewer.setSorter(new NameSorter());
+ viewer.setInput(getViewSite());
+
+ // Create the help context id for the viewer's control
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(viewer.getControl(), "kato.explorer.plugin.viewer");
+ makeActions();
+ hookContextMenu();
+ hookDoubleClickAction();
+ contributeToActionBars();
+ }
+
+ private void hookContextMenu() {
+ MenuManager menuMgr = new MenuManager("#PopupMenu");
+ menuMgr.setRemoveAllWhenShown(true);
+ menuMgr.addMenuListener(new IMenuListener() {
+ public void menuAboutToShow(IMenuManager manager) {
+ ExplorerView.this.fillContextMenu(manager);
+ }
+ });
+ Menu menu = menuMgr.createContextMenu(viewer.getControl());
+ viewer.getControl().setMenu(menu);
+ getSite().registerContextMenu(menuMgr, viewer);
+ }
+
+ private void contributeToActionBars() {
+ IActionBars bars = getViewSite().getActionBars();
+ fillLocalPullDown(bars.getMenuManager());
+ fillLocalToolBar(bars.getToolBarManager());
+ }
+
+ private void fillLocalPullDown(IMenuManager manager) {
+ manager.add(action1);
+ manager.add(new Separator());
+ manager.add(action2);
+ }
+
+ private void fillContextMenu(IMenuManager manager) {
+ manager.add(action1);
+ manager.add(action2);
+ manager.add(new Separator());
+ drillDownAdapter.addNavigationActions(manager);
+ // Other plug-ins can contribute there actions here
+ manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
+ }
+
+ private void fillLocalToolBar(IToolBarManager manager) {
+ manager.add(action1);
+ manager.add(action2);
+ manager.add(new Separator());
+ drillDownAdapter.addNavigationActions(manager);
+ }
+
+ private void makeActions() {
+ action1 = new Action() {
+ public void run() {
+ showMessage("Action 1 executed");
+ }
+ };
+ action1.setText("Action 1");
+ action1.setToolTipText("Action 1 tooltip");
+ action1.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().
+ getImageDescriptor(ISharedImages.IMG_OBJS_INFO_TSK));
+
+ action2 = new Action() {
+ public void run() {
+ showMessage("Action 2 executed");
+ }
+ };
+ action2.setText("Action 2");
+ action2.setToolTipText("Action 2 tooltip");
+ action2.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().
+ getImageDescriptor(ISharedImages.IMG_OBJS_INFO_TSK));
+ doubleClickAction = new Action() {
+ public void run() {
+ ISelection selection = viewer.getSelection();
+ Object obj = ((IStructuredSelection)selection).getFirstElement();
+ showMessage("Double-click detected on "+obj.toString());
+ }
+ };
+ }
+
+ private void hookDoubleClickAction() {
+ viewer.addDoubleClickListener(new IDoubleClickListener() {
+ public void doubleClick(DoubleClickEvent event) {
+ doubleClickAction.run();
+ }
+ });
+ }
+ private void showMessage(String message) {
+ MessageDialog.openInformation(
+ viewer.getControl().getShell(),
+ "Explorer View",
+ message);
+ }
+
+ /**
+ * Passing the focus request to the viewer's control.
+ */
+ public void setFocus() {
+ viewer.getControl().setFocus();
+ }
+}
\ No newline at end of file
Added: incubator/kato/branches/experimental/maven_restructure/org.apache.kato/plugins/kato.explorer.plugin/src/main/java/org/apache/kato/tools/explorer/plugin/views/LazyNode.java
URL: http://svn.apache.org/viewvc/incubator/kato/branches/experimental/maven_restructure/org.apache.kato/plugins/kato.explorer.plugin/src/main/java/org/apache/kato/tools/explorer/plugin/views/LazyNode.java?rev=778673&view=auto
==============================================================================
--- incubator/kato/branches/experimental/maven_restructure/org.apache.kato/plugins/kato.explorer.plugin/src/main/java/org/apache/kato/tools/explorer/plugin/views/LazyNode.java (added)
+++ incubator/kato/branches/experimental/maven_restructure/org.apache.kato/plugins/kato.explorer.plugin/src/main/java/org/apache/kato/tools/explorer/plugin/views/LazyNode.java Tue May 26 12:33:43 2009
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * 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 org.apache.kato.tools.explorer.plugin.views;
+
+import java.lang.reflect.Method;
+
+public class LazyNode {
+ private Object item;
+ private Method method;
+
+ public LazyNode(Object item, Method method) {
+ super();
+ this.item = item;
+ this.method = method;
+ }
+
+ public Object getItem() {
+ return item;
+ }
+
+ public void setItem(Object item) {
+ this.item = item;
+ }
+
+ public Method getMethod() {
+ return method;
+ }
+
+ public void setMethod(Method method) {
+ this.method = method;
+ }
+
+
+}
Added: incubator/kato/branches/experimental/maven_restructure/org.apache.kato/plugins/kato.explorer.plugin/src/main/java/org/apache/kato/tools/explorer/plugin/views/RTEDataException.java
URL: http://svn.apache.org/viewvc/incubator/kato/branches/experimental/maven_restructure/org.apache.kato/plugins/kato.explorer.plugin/src/main/java/org/apache/kato/tools/explorer/plugin/views/RTEDataException.java?rev=778673&view=auto
==============================================================================
--- incubator/kato/branches/experimental/maven_restructure/org.apache.kato/plugins/kato.explorer.plugin/src/main/java/org/apache/kato/tools/explorer/plugin/views/RTEDataException.java (added)
+++ incubator/kato/branches/experimental/maven_restructure/org.apache.kato/plugins/kato.explorer.plugin/src/main/java/org/apache/kato/tools/explorer/plugin/views/RTEDataException.java Tue May 26 12:33:43 2009
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * 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 org.apache.kato.tools.explorer.plugin.views;
+
+public class RTEDataException extends RuntimeException {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -195004880819773897L;
+
+ public RTEDataException() {
+ super();
+ }
+
+ public RTEDataException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public RTEDataException(String message) {
+ super(message);
+ }
+
+ public RTEDataException(Throwable cause) {
+ super(cause);
+ }
+
+}
Added: incubator/kato/branches/experimental/maven_restructure/org.apache.kato/plugins/kato.explorer.plugin/src/main/java/org/apache/kato/tools/explorer/plugin/views/RuntimeExplorer.java
URL: http://svn.apache.org/viewvc/incubator/kato/branches/experimental/maven_restructure/org.apache.kato/plugins/kato.explorer.plugin/src/main/java/org/apache/kato/tools/explorer/plugin/views/RuntimeExplorer.java?rev=778673&view=auto
==============================================================================
--- incubator/kato/branches/experimental/maven_restructure/org.apache.kato/plugins/kato.explorer.plugin/src/main/java/org/apache/kato/tools/explorer/plugin/views/RuntimeExplorer.java (added)
+++ incubator/kato/branches/experimental/maven_restructure/org.apache.kato/plugins/kato.explorer.plugin/src/main/java/org/apache/kato/tools/explorer/plugin/views/RuntimeExplorer.java Tue May 26 12:33:43 2009
@@ -0,0 +1,606 @@
+/*******************************************************************************
+ * 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 org.apache.kato.tools.explorer.plugin.views;
+
+import java.io.File;
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.kato.image.CorruptDataException;
+import org.apache.kato.image.DataUnavailable;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IMenuListener;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.IToolBarManager;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.DoubleClickEvent;
+import org.eclipse.jface.viewers.IDoubleClickListener;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.ITreeViewerListener;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.TreeExpansionEvent;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerSorter;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.ISelectionListener;
+import org.eclipse.ui.ISharedImages;
+import org.eclipse.ui.IWorkbenchActionConstants;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.part.DrillDownAdapter;
+import org.eclipse.ui.part.ViewPart;
+
+
+
+/**
+ * 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 RuntimeExplorer extends ViewPart {
+ private TreeViewer viewer;
+ private DrillDownAdapter drillDownAdapter;
+ private Action action1;
+ private Action action2;
+ private Action doubleClickAction;
+ private ViewContentProvider contentProvider = new ViewContentProvider();
+ private HashMap<TreeParent, LazyNode> lazyNodes = new HashMap<TreeParent, LazyNode>();
+ private ISelectionListener selectionListener = null;
+ private File dataFile = null; //file currently being viewed
+ private final String saveFileName = "rte.dat";
+
+ /*
+ * The content provider class is responsible for
+ * providing objects to the view. It can wrap
+ * existing objects in adapters or simply return
+ * objects as-is. These objects may be sensitive
+ * to the current input of the view, or ignore
+ * it and always show the same content
+ * (like Task List, for example).
+ */
+
+ class TreeObject implements IAdaptable {
+ private String name;
+ private TreeParent parent;
+
+ public TreeObject(String name) {
+ this.name = name;
+ }
+ public String getName() {
+ return name;
+ }
+ public void setParent(TreeParent parent) {
+ this.parent = parent;
+ }
+ public TreeParent getParent() {
+ return parent;
+ }
+ public String toString() {
+ return getName();
+ }
+ public Object getAdapter(Class key) {
+ return null;
+ }
+ }
+
+ class TreeParent extends TreeObject {
+ private ArrayList children;
+ public TreeParent(String name) {
+ super(name);
+ children = new ArrayList();
+ }
+ public void addChild(TreeObject child) {
+ children.add(child);
+ child.setParent(this);
+ }
+ public void removeChild(TreeObject child) {
+ children.remove(child);
+ child.setParent(null);
+ }
+ public TreeObject [] getChildren() {
+ return (TreeObject [])children.toArray(new TreeObject[children.size()]);
+ }
+ public boolean hasChildren() {
+ return children.size()>0;
+ }
+ }
+
+ class ViewContentProvider implements IStructuredContentProvider,
+ ITreeContentProvider, ITreeViewerListener {
+ private TreeParent invisibleRoot;
+ private HashSet<String> containerNames = new HashSet<String>();
+ private HashSet<String> primitiveNames = new HashSet<String>();
+ private TreeObject nodeDataNotLoaded = new TreeObject("");
+ private Viewer viewer = null;
+ private File dump = null;
+
+ public ViewContentProvider() {
+ containerNames.add(Iterator.class.getName());
+ primitiveNames.add(Long.class.getName());
+ primitiveNames.add(Integer.class.getName());
+ primitiveNames.add(String.class.getName());
+ primitiveNames.add(Short.class.getName());
+ primitiveNames.add(Float.class.getName());
+ primitiveNames.add(Double.class.getName());
+ primitiveNames.add("long");
+ primitiveNames.add("int");
+ primitiveNames.add("boolean");
+ primitiveNames.add("float");
+ primitiveNames.add("short");
+ primitiveNames.add("double");
+ }
+
+ public void inputChanged(Viewer v, Object oldInput, Object newInput) {
+ if(viewer == null) {
+ viewer = v; //cache reference to viewer
+ }
+ if((newInput != null) && (newInput instanceof File)) {
+ invisibleRoot = null;
+ dump = (File)newInput;
+ return;
+ }
+ if((newInput != null) && (newInput instanceof String)) { //assumes that the string is the full path
+ invisibleRoot = null;
+ dump = new File((String)newInput);
+ return;
+ }
+ }
+
+ public void dispose() {
+ }
+
+ public Object[] getElements(Object parent) {
+// if (parent.equals(getViewSite())) {
+// if (invisibleRoot==null) getRuntime();
+// return getChildren(invisibleRoot);
+// }
+ if (invisibleRoot==null) {
+ getRuntime();
+ return getChildren(invisibleRoot);
+ }
+ return getChildren(parent);
+ }
+ public Object getParent(Object child) {
+ if (child instanceof TreeObject) {
+ return ((TreeObject)child).getParent();
+ }
+ return null;
+ }
+ public Object [] getChildren(Object obj) {
+ if (obj instanceof TreeParent) {
+ TreeParent parent = (TreeParent)obj;
+ loadDataForLazyNodes(parent);
+ return parent.getChildren();
+ }
+ return new Object[0];
+ }
+
+ public void loadDataForLazyNodes(TreeParent parent) {
+ try {
+ if(parent.hasChildren()) {
+ TreeObject child = parent.getChildren()[0];
+ if(child == nodeDataNotLoaded) {
+ parent.removeChild(child);
+ if(lazyNodes.containsKey(parent)) {
+ LazyNode node = lazyNodes.get(parent);
+ if(node.getMethod().getReturnType() == Iterator.class) {
+ Iterator i = (Iterator) node.getMethod().invoke(node.getItem(), (Object[]) null);
+ createNodeFromIterator(parent, i);
+ return;
+ }
+ if(node.getMethod().getReturnType() == List.class) {
+ List l = (List) node.getMethod().invoke(node.getItem(), (Object[]) null);
+ createNodeFromIterator(parent, l.iterator());
+ return;
+ }
+ Object obj = node.getMethod().invoke(node.getItem(), (Object[]) null);
+ Class iface = getKatoInterface(obj.getClass());
+ createNodeFromItem(parent, iface, obj);
+ }
+ }
+ }
+ } catch (Exception e) {
+ throw new RTEDataException("Could not expand node ", e);
+ }
+ }
+
+ public boolean hasChildren(Object parent) {
+ if (parent instanceof TreeParent)
+ return ((TreeParent)parent).hasChildren();
+ return false;
+ }
+
+ //get the runtime
+ private void getRuntime() {
+
+ if(dump.exists()) {
+ try {
+ org.apache.kato.image.Image image = org.apache.kato.api.plugin.Activator.getDefault().getImage(dump);
+ TreeParent root = createNodeFromItem(dump.getName(), org.apache.kato.image.Image.class, image);
+ invisibleRoot = new TreeParent("");
+ invisibleRoot.addChild(root);
+ } catch (IOException e) {
+ showMessage("Error getting ImageFactory : " + e.getMessage());
+ e.printStackTrace();
+ }
+ } else {
+ showMessage("File " + dump.getAbsolutePath() + " does not exist");
+ }
+ }
+
+ private void createNodeFromIterator(TreeParent parent, Iterator i) {
+ try {
+ Class iface = null;
+ for(;i.hasNext();) {
+ Object obj = i.next();
+ if(iface == null) {
+ iface = getKatoInterface(obj.getClass());
+ }
+ TreeParent itemParent = createNodeFromItem(obj.toString(), iface, obj);
+ parent.addChild(itemParent);
+ }
+ } catch (Exception e) {
+ throw new RTEDataException("Could not add node", e);
+ }
+ }
+
+ private Class getKatoInterface(Class clazz) {
+ Class[] ifaces = clazz.getInterfaces();
+ for(int i = 0; i < ifaces.length; i++) {
+ if(ifaces[i].getName().startsWith("org.apache.kato")) {
+ return ifaces[i];
+ }
+ }
+ if(clazz.getSuperclass() != null) {
+ return getKatoInterface(clazz.getSuperclass());
+ }
+ throw new RTEDataException("Could not find kato interface for " + clazz.getName());
+ }
+
+ private TreeParent createNodeFromItem(String name, Class iface, Object item) {
+ TreeParent parent = new TreeParent(name);
+ createNodeFromItem(parent, iface, item);
+ return parent;
+ }
+
+ private void createNodeFromItem(TreeParent parent, Class iface, Object item) {
+ Method[] methods = iface.getMethods();
+ for(int j = 0; j < methods.length; j++) {
+ if(methods[j].getParameterTypes().length == 0) {
+ String nodeName = getDisplayName(methods[j].getName());
+ if(isPrimitive(methods[j].getReturnType())) {
+ Object data = null;
+ if(methods[j].getParameterTypes().length == 0) {
+ data = getItemData(item, methods[j].getName(), null);
+ } else {
+ data = "";
+ }
+ TreeObject tobj = new TreeObject(nodeName + " : " + data.toString());
+ parent.addChild(tobj);
+ } else {
+ TreeParent container = new TreeParent(nodeName);
+ container.addChild(nodeDataNotLoaded); //add special marker node to indicate that the underlying data has not been loaded yet
+ lazyNodes.put(container, new LazyNode(item, methods[j]));
+ parent.addChild(container);
+ }
+ } else {
+ //TODO methods which take parameters should be added to the popup menu so that they can be invoked by the user
+ }
+ }
+ }
+
+ private String getDisplayName(String rawName) {
+ StringBuffer displayName = new StringBuffer();
+ int state = 0;
+ for(int i = 0; i < rawName.length(); i++) {
+ switch(state) {
+ case 0:
+ if(Character.isUpperCase(rawName.charAt(i))) {
+ state = 1;
+ displayName.append(rawName.charAt(i));
+ }
+ break;
+ case 1:
+ if(Character.isUpperCase(rawName.charAt(i))) {
+ if(i < (rawName.length() - 1)) {
+ if(Character.isLowerCase(rawName.charAt(i+1))) {
+ displayName.append(" ");
+ }
+ } else {
+ displayName.append(" ");
+ }
+ }
+ displayName.append(rawName.charAt(i));
+ }
+
+ }
+ return displayName.toString();
+ }
+
+ private boolean isContainer(Class clazz) {
+ if(containerNames.contains(clazz.getName())) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ private boolean isPrimitive(Class clazz) {
+ if(primitiveNames.contains(clazz.getName())) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ private Method findMethod(Class clazz, String methodName, Object[] types) {
+ Method[] methods = clazz.getMethods();
+ for(int i = 0; i < methods.length; i++) {
+ if(methods[i].getName().equals(methodName)) {
+ if((methods[i].getParameterTypes().length == 0) && (types == null)) {
+ return methods[i];
+ }
+ if((methods[i].getParameterTypes().length == 0) && (types.length == 0)) {
+ return methods[i];
+ }
+ Class[] params = methods[i].getParameterTypes();
+ boolean match = true;
+ for(int j = 0; j < params.length; j++) {
+ if(!params[j].isInstance(types[j])) {
+ match = false;
+ break;
+ }
+ }
+ if(match) {
+ return methods[i];
+ }
+ }
+ }
+ if(clazz.getSuperclass() == null) {
+ throw new RTEDataException("Could not find method " + methodName);
+ } else {
+ return findMethod(clazz.getSuperclass(), methodName, types);
+ }
+ }
+
+ private Object getItemData(Object item, String methodName, Object[] parameters) {
+ try {
+ Class[] types = null;
+ if(parameters != null) {
+ types = new Class[parameters.length];
+ }
+ Method method = item.getClass().getMethod(methodName, types);
+ //Method method = findMethod(item.getClass(), methodName, types);
+ try {
+ Object result = method.invoke(item, parameters);
+ if(result == null) {
+ return "<null>";
+ }
+ return result;
+ } catch (InvocationTargetException e) {
+ if(e.getCause() instanceof CorruptDataException) {
+ return "Corrupt data";
+ }
+ if(e.getCause() instanceof DataUnavailable) {
+ return "Data unavailable";
+ }
+ throw new RTEDataException("Could not read data for " + methodName, e);
+ }
+ } catch (Exception e) {
+ throw new RTEDataException("Could not read data for " + methodName, e);
+ }
+ }
+
+ public void treeCollapsed(TreeExpansionEvent arg0) {
+ // NOOP
+ }
+
+ public void treeExpanded(TreeExpansionEvent event) {
+ try {
+ TreeParent parent = (TreeParent) event.getElement();
+ if(parent.hasChildren()) {
+ TreeObject child = parent.getChildren()[0];
+ if(child == nodeDataNotLoaded) {
+ parent.removeChild(child);
+ if(lazyNodes.containsKey(parent)) {
+ LazyNode node = lazyNodes.get(parent);
+ if(node.getMethod().getReturnType() == Iterator.class) {
+ Iterator i = (Iterator) node.getMethod().invoke(node.getItem(), (Object[]) null);
+ createNodeFromIterator(parent, i);
+ }
+ }
+ }
+ }
+ } catch (Exception e) {
+ throw new RTEDataException("Could not expand node ", e);
+ }
+ }
+
+
+ }
+ class ViewLabelProvider extends LabelProvider {
+
+ public String getText(Object obj) {
+ return obj.toString();
+ }
+ public Image getImage(Object obj) {
+ String imageKey = ISharedImages.IMG_OBJ_ELEMENT;
+ if (obj instanceof TreeParent)
+ imageKey = ISharedImages.IMG_OBJ_FOLDER;
+ return PlatformUI.getWorkbench().getSharedImages().getImage(imageKey);
+ }
+ }
+ class NameSorter extends ViewerSorter {
+ }
+
+ /**
+ * The constructor.
+ */
+ public RuntimeExplorer() {
+ int a=1;
+ System.out.println("in RT");
+ }
+
+ /**
+ * This is a callback that will allow us
+ * to create the viewer and initialize it.
+ */
+ public void createPartControl(Composite parent) {
+ viewer = new TreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
+ drillDownAdapter = new DrillDownAdapter(viewer);
+ viewer.setContentProvider(contentProvider);
+ viewer.setLabelProvider(new ViewLabelProvider());
+ viewer.setSorter(new NameSorter());
+ //viewer.setInput(getViewSite());
+
+ // Create the help context id for the viewer's control
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(viewer.getControl(), "Kato_Plugins_Runtime_Explorer.viewer");
+ makeActions();
+ hookContextMenu();
+ hookDoubleClickAction();
+ contributeToActionBars();
+ //loadState();
+ }
+
+ private void hookContextMenu() {
+ MenuManager menuMgr = new MenuManager("#PopupMenu");
+ menuMgr.setRemoveAllWhenShown(true);
+ menuMgr.addMenuListener(new IMenuListener() {
+ public void menuAboutToShow(IMenuManager manager) {
+ RuntimeExplorer.this.fillContextMenu(manager);
+ }
+ });
+ Menu menu = menuMgr.createContextMenu(viewer.getControl());
+ viewer.getControl().setMenu(menu);
+ getSite().registerContextMenu(menuMgr, viewer);
+ }
+
+ private void contributeToActionBars() {
+ IActionBars bars = getViewSite().getActionBars();
+ fillLocalPullDown(bars.getMenuManager());
+ fillLocalToolBar(bars.getToolBarManager());
+ }
+
+ private void fillLocalPullDown(IMenuManager manager) {
+ manager.add(action1);
+ manager.add(new Separator());
+ manager.add(action2);
+ }
+
+ private void fillContextMenu(IMenuManager manager) {
+ manager.add(action1);
+ manager.add(action2);
+ manager.add(new Separator());
+ drillDownAdapter.addNavigationActions(manager);
+ // Other plug-ins can contribute there actions here
+ manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
+ }
+
+ private void fillLocalToolBar(IToolBarManager manager) {
+ manager.add(action1);
+ manager.add(action2);
+ manager.add(new Separator());
+ drillDownAdapter.addNavigationActions(manager);
+ }
+
+ private void makeActions() {
+ action1 = new Action() {
+ public void run() {
+ showMessage("Action 1 executed");
+ }
+ };
+ action1.setText("Action 1");
+ action1.setToolTipText("Action 1 tooltip");
+ action1.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().
+ getImageDescriptor(ISharedImages.IMG_OBJS_INFO_TSK));
+
+ action2 = new Action() {
+ public void run() {
+ showMessage("Action 2 executed");
+ }
+ };
+ action2.setText("Action 2");
+ action2.setToolTipText("Action 2 tooltip");
+ action2.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().
+ getImageDescriptor(ISharedImages.IMG_OBJS_INFO_TSK));
+ doubleClickAction = new Action() {
+ public void run() {
+ ISelection selection = viewer.getSelection();
+ Object obj = ((IStructuredSelection)selection).getFirstElement();
+ showMessage("Double-click detected on "+obj.toString());
+ }
+ };
+ }
+
+ private void hookDoubleClickAction() {
+ viewer.addDoubleClickListener(new IDoubleClickListener() {
+ public void doubleClick(DoubleClickEvent event) {
+ doubleClickAction.run();
+ }
+ });
+ }
+
+ private void showMessage(String message) {
+ MessageDialog.openInformation(
+ viewer.getControl().getShell(),
+ "Apache Kato Runtime Explorer",
+ message);
+ }
+
+ /**
+ * Passing the focus request to the viewer's control.
+ */
+ public void setFocus() {
+ viewer.getControl().setFocus();
+ }
+
+ /**
+ public void openFile(IFile file) {
+ dataFile = file.getLocation().toFile();
+ viewer.setInput(dataFile);
+ }
+ **/
+
+
+
+}
\ No newline at end of file