IMprove Ascape Swing compatibility. Class loader now handles conflicting package names well, fixes to chart generation.
diff --git a/org.eclipse.amp.escape/plugins/org.eclipse.amp.escape.ide/META-INF/MANIFEST.MF b/org.eclipse.amp.escape/plugins/org.eclipse.amp.escape.ide/META-INF/MANIFEST.MF
index a3063ba..7ed0db9 100644
--- a/org.eclipse.amp.escape/plugins/org.eclipse.amp.escape.ide/META-INF/MANIFEST.MF
+++ b/org.eclipse.amp.escape/plugins/org.eclipse.amp.escape.ide/META-INF/MANIFEST.MF
@@ -8,11 +8,12 @@
 Bundle-Activator: org.eclipse.amp.escape.ide.EscapeIDEPlugin
 Bundle-ClassPath: .
 Bundle-ActivationPolicy: lazy
-Eclipse-BuddyPolicy: global
+Eclipse-BuddyPolicy: dependent
 Import-Package: org.apache.commons.lang
 Export-Package: org.eclipse.amp.escape.command,
  org.eclipse.amp.escape.ide
-Require-Bundle: org.eclipse.core.resources;bundle-version="3.5.0",
+Require-Bundle: org.ascape.ui.amp;bundle-version="0.8.0",
+ org.eclipse.core.resources;bundle-version="3.5.0",
  org.eclipse.core.runtime;bundle-version="3.5.0",
  org.eclipse.jdt.core;bundle-version="3.5.0",
  org.eclipse.jface;bundle-version="3.5.0",
@@ -34,5 +35,5 @@
  org.eclipse.amp.axf.core;bundle-version="0.5.0",
  org.eclipse.amp.agf3d;bundle-version="0.5.0";resolution:=optional,
  org.eclipse.amp.escape.ascape.agf3d;bundle-version="0.5.0";resolution:=optional,
- org.ascape.ui.amp;bundle-version="0.8.0"
+ org.eclipse.amp.escape.ascape.chart;bundle-version="0.5.0"
 Bundle-Localization: plugin
diff --git a/org.eclipse.amp.escape/plugins/org.eclipse.amp.escape.ide/build.properties b/org.eclipse.amp.escape/plugins/org.eclipse.amp.escape.ide/build.properties
index 23ea21d..1d2ba11 100644
--- a/org.eclipse.amp.escape/plugins/org.eclipse.amp.escape.ide/build.properties
+++ b/org.eclipse.amp.escape/plugins/org.eclipse.amp.escape.ide/build.properties
@@ -5,11 +5,9 @@
                plugin.xml,\
                plugin.properties,\
                icons/,\
-               res/,\
                about.html,\
                about.ini,\
                about.properties,\
                amp32.png
 source.. = src/
-src.includes = src/,\
-               res/
+src.includes = src/
diff --git a/org.eclipse.amp.escape/plugins/org.eclipse.amp.escape.ide/src/org/eclipse/amp/escape/ide/ProjectLoader.java b/org.eclipse.amp.escape/plugins/org.eclipse.amp.escape.ide/src/org/eclipse/amp/escape/ide/ProjectLoader.java
index b580de3..bf53117 100644
--- a/org.eclipse.amp.escape/plugins/org.eclipse.amp.escape.ide/src/org/eclipse/amp/escape/ide/ProjectLoader.java
+++ b/org.eclipse.amp.escape/plugins/org.eclipse.amp.escape.ide/src/org/eclipse/amp/escape/ide/ProjectLoader.java
@@ -18,10 +18,14 @@
 import java.io.File;
 import java.net.URL;
 import java.net.URLClassLoader;
+import java.util.ArrayList;
+import java.util.List;
 
 import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.Platform;
 import org.eclipse.jdt.core.IJavaProject;
 import org.eclipse.jdt.core.JavaCore;
+import org.osgi.framework.Bundle;
 
 // TODO: Auto-generated Javadoc
 /**
@@ -36,6 +40,8 @@
 
     public ClassLoader mainLoader;
 
+    private Bundle bundle;
+
     /**
      * Instantiates a new project loader.
      * 
@@ -50,9 +56,33 @@
         try {
             project.open(null);
             IJavaProject javaProject = JavaCore.create(project);
-            URL[] outputURL = { new File(project.getLocation() + "/"
-                                         + javaProject.getOutputLocation().removeFirstSegments(1) + "/").toURL() };
-            addURL(outputURL[0]);
+            List<URL> outputURL = new ArrayList<URL>();
+            // URL[] outputURL = new URL[allPackageFragmentRoots.length + 1];
+
+            // IPackageFragmentRoot[] allPackageFragmentRoots = javaProject.getAllPackageFragmentRoots();
+            // int index = 0;
+            // for (IPackageFragmentRoot fragmentRoot : allPackageFragmentRoots) {
+            // String osString = fragmentRoot.getPath().toOSString();
+            // if (osString.contains("org.ascape.ui.amp")) {
+            // outputURL.add(new File(osString).toURI().toURL());
+            // }
+            // }
+            // for (IPackageFragmentRoot fragmentRoot : allPackageFragmentRoots) {
+            // String osString = fragmentRoot.getPath().toOSString();
+            // URL url = new File(osString).toURI().toURL();
+            // try {
+            // fragmentRoot.open(null);
+            // } catch (JavaModelException e) {
+            // throw new RuntimeException(e);
+            // }
+            // outputURL[index++] = url;
+            // }
+            outputURL.add(new File(project.getLocation() + "/" + javaProject.getOutputLocation().removeFirstSegments(1)
+                                   + "/").toURI().toURL());
+            for (URL url : outputURL) {
+                addURL(url);
+                System.err.println("url " + url);
+            }
             activate();
         } catch (Exception e1) {
             throw new LoaderCreationException("Couldn't load class", e1);
@@ -65,6 +95,7 @@
      * @throws LoaderCreationException the loader creation exception
      */
     public void activate() throws LoaderCreationException {
+        bundle = Platform.getBundle("org.eclipse.amp.escape.runtime");
         mainLoader = Thread.currentThread().getContextClassLoader();
         Thread.currentThread().setContextClassLoader(this);
     }
@@ -76,25 +107,38 @@
         Thread.currentThread().setContextClassLoader(mainLoader);
     }
 
-    /* (non-Javadoc)
+    /*
+     * (non-Javadoc)
+     * 
      * @see java.lang.ClassLoader#loadClass(java.lang.String)
      */
     /**
-     *
+     * 
      * @see java.lang.ClassLoader#loadClass(java.lang.String)
      */
     @Override
     public Class<?> loadClass(String name) throws ClassNotFoundException {
+        System.err.println("FIND " + name);
         try {
-            return super.loadClass(name);
+            Class<?> loadClass = super.loadClass(name);
+            System.err.println("su: " + loadClass + " " + loadClass.getClassLoader());
+            return loadClass;
         } catch (NoClassDefFoundError classNotFoundException) {
-            return mainLoader.loadClass(name);
+            Class<?> loadClassI = bundle.loadClass(name);
+            System.err.println("ncd: " + loadClassI + " " + loadClassI.getClassLoader());
+            return loadClassI;
         } catch (NoSuchMethodError classNotFoundException) {
-            return mainLoader.loadClass(name);
+            Class<?> loadClassI = bundle.loadClass(name);
+            System.err.println("nsm: " + loadClassI);
+            return loadClassI;
         } catch (ClassNotFoundException classNotFoundException) {
-            return mainLoader.loadClass(name);
+            Class<?> loadClassI = bundle.loadClass(name);
+            System.err.println("cnf: " + loadClassI);
+            return loadClassI;
         } catch (UnsupportedClassVersionError classNotFoundException) {
             throw new RuntimeException("Bad class: " + name, classNotFoundException);
+        } catch (Exception e) {
+            throw new RuntimeException("Unexpected Exception for " + name, e);
         }
     }
 }