|
|
|
@ -68,6 +68,7 @@ public class ProjectAssetManager extends DesktopAssetManager { |
|
|
|
|
private List<String> folderNames = new LinkedList<String>(); |
|
|
|
|
private List<AssetEventListener> assetEventListeners = new LinkedList<AssetEventListener>(); |
|
|
|
|
private URLClassLoader loader; |
|
|
|
|
private LinkedList<FileObject> classPathItems = new LinkedList<FileObject>(); |
|
|
|
|
|
|
|
|
|
public ProjectAssetManager(Project prj, String folderName) { |
|
|
|
|
super(true); |
|
|
|
@ -82,9 +83,39 @@ public class ProjectAssetManager extends DesktopAssetManager { |
|
|
|
|
updateClassLoader(); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
prepAssetEventListeners(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public ProjectAssetManager(FileObject path) { |
|
|
|
|
super(true); |
|
|
|
|
if (path == null) { |
|
|
|
|
this.project = new DummyProject(this); |
|
|
|
|
} else { |
|
|
|
|
this.project = new DummyProject(this, path); |
|
|
|
|
} |
|
|
|
|
String string = project.getProjectDirectory().getPath(); |
|
|
|
|
Logger.getLogger(this.getClass().getName()).log(Level.INFO, "Add locator: {0}", string); |
|
|
|
|
registerLocator(string, "com.jme3.asset.plugins.FileLocator"); |
|
|
|
|
for (AssetManagerConfigurator di : Lookup.getDefault().lookupAll(AssetManagerConfigurator.class)) { |
|
|
|
|
di.prepareManager(this); |
|
|
|
|
} |
|
|
|
|
prepAssetEventListeners(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public ProjectAssetManager() { |
|
|
|
|
this(null); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void updateClassLoader() { |
|
|
|
|
for (FileObject fileObject : classPathItems) { |
|
|
|
|
try { |
|
|
|
|
unregisterLocator(fileObject.getURL().toExternalForm(), |
|
|
|
|
com.jme3.asset.plugins.UrlLocator.class); |
|
|
|
|
} catch (FileStateInvalidException ex) { |
|
|
|
|
Exceptions.printStackTrace(ex); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
classPathItems.clear(); |
|
|
|
|
Sources sources = project.getLookup().lookup(Sources.class); |
|
|
|
|
if (sources != null) { |
|
|
|
|
if (loader != null) { |
|
|
|
@ -95,11 +126,16 @@ public class ProjectAssetManager extends DesktopAssetManager { |
|
|
|
|
for (SourceGroup sourceGroup : groups) { |
|
|
|
|
ClassPath path = ClassPath.getClassPath(sourceGroup.getRootFolder(), ClassPath.EXECUTE); |
|
|
|
|
if (path != null) { |
|
|
|
|
System.out.println("Classpath: " + path); |
|
|
|
|
try { |
|
|
|
|
FileObject[] roots = path.getRoots(); |
|
|
|
|
for (FileObject fileObject : roots) { |
|
|
|
|
urls.add(fileObject.getURL()); |
|
|
|
|
if(fileObject.getURL().toExternalForm().startsWith("jar")){ |
|
|
|
|
Logger.getLogger(this.getClass().getName()).log(Level.INFO, "Add classpath locator:{0}", fileObject.getURL()); |
|
|
|
|
urls.add(fileObject.getURL()); |
|
|
|
|
classPathItems.add(fileObject); |
|
|
|
|
registerLocator(fileObject.getURL().toExternalForm(), |
|
|
|
|
"com.jme3.asset.plugins.UrlLocator"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} catch (FileStateInvalidException ex) { |
|
|
|
|
Exceptions.printStackTrace(ex); |
|
|
|
@ -111,26 +147,6 @@ public class ProjectAssetManager extends DesktopAssetManager { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public ProjectAssetManager(FileObject path) { |
|
|
|
|
super(true); |
|
|
|
|
if (path == null) { |
|
|
|
|
this.project = new DummyProject(this); |
|
|
|
|
} else { |
|
|
|
|
this.project = new DummyProject(this, path); |
|
|
|
|
} |
|
|
|
|
String string = project.getProjectDirectory().getPath(); |
|
|
|
|
Logger.getLogger(this.getClass().getName()).log(Level.INFO, "Add locator: {0}", string); |
|
|
|
|
registerLocator(string, "com.jme3.asset.plugins.FileLocator"); |
|
|
|
|
for (AssetManagerConfigurator di : Lookup.getDefault().lookupAll(AssetManagerConfigurator.class)) { |
|
|
|
|
di.prepareManager(this); |
|
|
|
|
} |
|
|
|
|
prepAssetEventListeners(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public ProjectAssetManager() { |
|
|
|
|
this(null); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void prepAssetEventListeners() { |
|
|
|
|
setAssetEventListener(new AssetEventListener() { |
|
|
|
|
|
|
|
|
|