diff --git a/sdk/jme3-core/src/com/jme3/gde/core/assets/ProjectAssetManager.java b/sdk/jme3-core/src/com/jme3/gde/core/assets/ProjectAssetManager.java index 2f922eea8..ee37f944a 100644 --- a/sdk/jme3-core/src/com/jme3/gde/core/assets/ProjectAssetManager.java +++ b/sdk/jme3-core/src/com/jme3/gde/core/assets/ProjectAssetManager.java @@ -73,15 +73,16 @@ import org.openide.util.lookup.Lookups; */ @SuppressWarnings("unchecked") public class ProjectAssetManager extends DesktopAssetManager { + private static final Logger logger = Logger.getLogger(ProjectAssetManager.class.getName()); private Project project; + private URLClassLoader loader; private List folderNames = new LinkedList(); + private LinkedList jarItems = new LinkedList(); private final List assetEventListeners = Collections.synchronizedList(new LinkedList()); private final List classPathListeners = Collections.synchronizedList(new LinkedList()); - private URLClassLoader loader; private final List classPaths = Collections.synchronizedList(new LinkedList()); private final List classPathItems = Collections.synchronizedList(new LinkedList()); - private LinkedList jarItems = new LinkedList(); private final Mutex mutex = new Mutex(); public ProjectAssetManager(Project prj, String folderName) { @@ -137,7 +138,7 @@ public class ProjectAssetManager extends DesktopAssetManager { classPaths.clear(); } - private synchronized void loadClassLoader() { + private void loadClassLoader() { Sources sources = ProjectUtils.getSources(project); if (sources != null) { if (loader != null) { @@ -215,7 +216,7 @@ public class ProjectAssetManager extends DesktopAssetManager { } }; - private synchronized void updateClassLoader() { + private void updateClassLoader() { ProjectManager.mutex().postWriteRequest(new Runnable() { public void run() { synchronized (classPathItems) { @@ -299,7 +300,7 @@ public class ProjectAssetManager extends DesktopAssetManager { public String[] getModels() { return filesWithSuffix("j3o"); } - + public String[] getMaterials() { return filesWithSuffix("j3m"); } @@ -327,13 +328,13 @@ public class ProjectAssetManager extends DesktopAssetManager { public String[] getMatDefs() { return filesWithSuffix("j3md"); } - - public String[] getAssetsWithSuffix(String string){ + + public String[] getAssetsWithSuffix(String string) { return filesWithSuffix(string); } - - private String[] filesWithSuffix(String string){ - List list=collectFilesWithSuffix(string); + + private String[] filesWithSuffix(String string) { + List list = collectFilesWithSuffix(string); return list.toArray(new String[list.size()]); } @@ -356,24 +357,21 @@ public class ProjectAssetManager extends DesktopAssetManager { } } - if (classPathItems != null) { - synchronized (classPathItems) { - // TODO I need to find out if classPathItems contains all jars added to a project - Iterator classPathItemsIter = classPathItems.iterator(); - while (classPathItemsIter.hasNext()) { - ClassPathItem classPathItem = classPathItemsIter.next(); - FileObject jarFile = classPathItem.object; - - Enumeration jarEntry = (Enumeration) jarFile.getChildren(true); - while (jarEntry.hasMoreElements()) { - FileObject jarEntryAsset = jarEntry.nextElement(); - if (jarEntryAsset.getExt().equalsIgnoreCase(suffix)) { - if (!jarEntryAsset.getPath().startsWith("/")) { - list.add(jarEntryAsset.getPath()); - } + synchronized (classPathItems) { + // TODO I need to find out if classPathItems contains all jars added to a project + Iterator classPathItemsIter = classPathItems.iterator(); + while (classPathItemsIter.hasNext()) { + ClassPathItem classPathItem = classPathItemsIter.next(); + FileObject jarFile = classPathItem.object; + + Enumeration jarEntry = (Enumeration) jarFile.getChildren(true); + while (jarEntry.hasMoreElements()) { + FileObject jarEntryAsset = jarEntry.nextElement(); + if (jarEntryAsset.getExt().equalsIgnoreCase(suffix)) { + if (!jarEntryAsset.getPath().startsWith("/")) { + list.add(jarEntryAsset.getPath()); } } - } } } @@ -384,24 +382,22 @@ public class ProjectAssetManager extends DesktopAssetManager { public InputStream getResourceAsStream(String name) { InputStream in = null;//JmeSystem.getResourceAsStream(name); synchronized (classPathItems) { - if (in == null && classPathItems != null) { - // TODO I need to find out if classPathItems contains all jars added to a project - Iterator classPathItemsIter = classPathItems.iterator(); - while (classPathItemsIter.hasNext()) { - ClassPathItem classPathItem = classPathItemsIter.next(); - FileObject jarFile = classPathItem.object; - - Enumeration jarEntry = (Enumeration) jarFile.getChildren(true); - while (jarEntry.hasMoreElements()) { - FileObject jarEntryAsset = jarEntry.nextElement(); - if (jarEntryAsset.getPath().equalsIgnoreCase(name)) { - try { - in = jarEntryAsset.getInputStream(); - } catch (FileNotFoundException ex) { - Exceptions.printStackTrace(ex); - } - break; + // TODO I need to find out if classPathItems contains all jars added to a project + Iterator classPathItemsIter = classPathItems.iterator(); + while (classPathItemsIter.hasNext()) { + ClassPathItem classPathItem = classPathItemsIter.next(); + FileObject jarFile = classPathItem.object; + + Enumeration jarEntry = (Enumeration) jarFile.getChildren(true); + while (jarEntry.hasMoreElements()) { + FileObject jarEntryAsset = jarEntry.nextElement(); + if (jarEntryAsset.getPath().equalsIgnoreCase(name)) { + try { + in = jarEntryAsset.getInputStream(); + } catch (FileNotFoundException ex) { + Exceptions.printStackTrace(ex); } + break; } } }