소스 검색

SDK:
- fix custom controls and classpath updating

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@9835 75d07b2b-3a1a-0410-a2c5-0572b91ccdca

nor..67 13 년 전
부모
커밋
cccda94bef

+ 16 - 6
jme3-core/src/com/jme3/gde/core/assets/ProjectAssetManager.java

@@ -112,11 +112,11 @@ public class ProjectAssetManager extends DesktopAssetManager {
         this(null);
     }
 
-    private synchronized void updateClassLoader() {
+    private void clearClassLoader() {
         for (FileObject fileObject : jarItems) {
             try {
                 Logger.getLogger(this.getClass().getName()).log(Level.INFO, "Remove locator:{0}", fileObject.getURL());
-                unregisterLocator(fileObject.getURL().toExternalForm(),
+                unregisterLocator(fileObject.toURL().toExternalForm(),
                         com.jme3.asset.plugins.UrlLocator.class);
             } catch (FileStateInvalidException ex) {
                 Exceptions.printStackTrace(ex);
@@ -128,6 +128,9 @@ public class ProjectAssetManager extends DesktopAssetManager {
             fileObject.object.removeRecursiveListener(fileObject.listener);
         }
         classPathItems.clear();
+    }
+
+    private synchronized void loadClassLoader() {
         Sources sources = project.getLookup().lookup(Sources.class);
         if (sources != null) {
             if (loader != null) {
@@ -148,7 +151,9 @@ public class ProjectAssetManager extends DesktopAssetManager {
                                     }
 
                                     public void fileDataCreated(FileEvent fe) {
-//                                    notifyClassPathListeners();
+                                        if (!fe.isExpected()) {
+                                            notifyClassPathListeners();
+                                        }
                                     }
 
                                     public void fileChanged(FileEvent fe) {
@@ -172,12 +177,12 @@ public class ProjectAssetManager extends DesktopAssetManager {
                                 fileObject.addRecursiveListener(listener);
                                 Logger.getLogger(this.getClass().getName()).log(Level.INFO, "Add classpath:{0}", fileObject);
                                 classPathItems.add(new ClassPathItem(fileObject, listener));
-                                urls.add(fileObject.getURL());
+                                urls.add(fileObject.toURL());
                             }
-                            if (fileObject.getURL().toExternalForm().startsWith("jar")) {
+                            if (fileObject.toURL().toExternalForm().startsWith("jar")) {
                                 Logger.getLogger(this.getClass().getName()).log(Level.INFO, "Add locator:{0}", fileObject.getURL());
                                 jarItems.add(fileObject);
-                                registerLocator(fileObject.getURL().toExternalForm(),
+                                registerLocator(fileObject.toURL().toExternalForm(),
                                         "com.jme3.asset.plugins.UrlLocator");
                             }
                         }
@@ -191,6 +196,11 @@ public class ProjectAssetManager extends DesktopAssetManager {
         }
     }
 
+    private synchronized void updateClassLoader() {
+        clearClassLoader();
+        loadClassLoader();
+    }
+    
     @Override
     public void setAssetEventListener(AssetEventListener listener) {
         throw new UnsupportedOperationException("Setting the asset event listener is not allowed for ProjectAssetManager, use addAssetEventListener instead");

+ 18 - 15
jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/impl/NewCustomControlVisualPanel1.java

@@ -59,7 +59,9 @@ public final class NewCustomControlVisualPanel1 extends JPanel {
 
     Project proj;
 
-    /** Creates new form NewCustomControlVisualPanel1 */
+    /**
+     * Creates new form NewCustomControlVisualPanel1
+     */
     public NewCustomControlVisualPanel1() {
         this.proj = proj;
         initComponents();
@@ -98,7 +100,6 @@ public final class NewCustomControlVisualPanel1 extends JPanel {
                         JavaSource js = JavaSource.create(cpInfo);
                         try {
                             js.runUserActionTask(new Task<CompilationController>() {
-
                                 public void run(CompilationController control)
                                         throws Exception {
                                     control.toPhase(Phase.RESOLVED);
@@ -106,18 +107,20 @@ public final class NewCustomControlVisualPanel1 extends JPanel {
 //                                    TypeUtilities util = control.getTypeUtilities();//.isCastable(Types., null)
 //                                    util.isCastable(null, null);
                                     TypeElement elem = elementHandle.resolve(control);
-                                    List<? extends TypeMirror> interfaces = elem.getInterfaces();
-                                    for (TypeMirror typeMirror : interfaces) {
-                                        String interfaceName = typeMirror.toString();
-                                        if ("com.jme3.scene.control.Control".equals(interfaceName)) {
+                                    if (elem != null) {
+                                        List<? extends TypeMirror> interfaces = elem.getInterfaces();
+                                        for (TypeMirror typeMirror : interfaces) {
+                                            String interfaceName = typeMirror.toString();
+                                            if ("com.jme3.scene.control.Control".equals(interfaceName)) {
+                                                list.add(elem.getQualifiedName().toString());
+                                            }
+                                        }
+                                        TypeMirror superClass = elem.getSuperclass();
+                                        String superClassName = superClass.toString();
+                                        if ("com.jme3.scene.control.AbstractControl".equals(superClassName)) {
                                             list.add(elem.getQualifiedName().toString());
                                         }
                                     }
-                                    TypeMirror superClass = elem.getSuperclass();
-                                    String superClassName = superClass.toString();
-                                    if ("com.jme3.scene.control.AbstractControl".equals(superClassName)) {
-                                        list.add(elem.getQualifiedName().toString());
-                                    }
                                 }
                             }, false);
                         } catch (Exception ioe) {
@@ -136,10 +139,10 @@ public final class NewCustomControlVisualPanel1 extends JPanel {
         scanControls();
     }
 
-    /** This method is called from within the constructor to
-     * initialize the form.
-     * WARNING: Do NOT modify this code. The content of this method is
-     * always regenerated by the Form Editor.
+    /**
+     * This method is called from within the constructor to initialize the form.
+     * WARNING: Do NOT modify this code. The content of this method is always
+     * regenerated by the Form Editor.
      */
     // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
     private void initComponents() {