SDK:
- add editing/uasge of any classpath j3md files in material editor (thanks to @H) git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@9859 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
This commit is contained in:
parent
f7d6c30db3
commit
ea9ebd8a22
@ -35,14 +35,18 @@ import com.jme3.asset.AssetEventListener;
|
||||
import com.jme3.asset.AssetKey;
|
||||
import com.jme3.asset.AssetManager;
|
||||
import com.jme3.asset.DesktopAssetManager;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
import java.net.URLClassLoader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.netbeans.api.java.classpath.ClassPath;
|
||||
@ -200,7 +204,7 @@ public class ProjectAssetManager extends DesktopAssetManager {
|
||||
clearClassLoader();
|
||||
loadClassLoader();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setAssetEventListener(AssetEventListener listener) {
|
||||
throw new UnsupportedOperationException("Setting the asset event listener is not allowed for ProjectAssetManager, use addAssetEventListener instead");
|
||||
@ -329,7 +333,7 @@ public class ProjectAssetManager extends DesktopAssetManager {
|
||||
* @return
|
||||
*/
|
||||
private String[] collectFilesWithSuffix(String suffix) {
|
||||
ArrayList<String> list = new ArrayList<String>();
|
||||
Set<String> list = new HashSet<String>();
|
||||
FileObject assetsFolder = getAssetFolder();
|
||||
if (assetsFolder != null) {
|
||||
Enumeration<FileObject> assets = (Enumeration<FileObject>) assetsFolder.getChildren(true);
|
||||
@ -364,6 +368,34 @@ public class ProjectAssetManager extends DesktopAssetManager {
|
||||
return list.toArray(new String[list.size()]);
|
||||
}
|
||||
|
||||
public InputStream getResourceAsStream(String name) {
|
||||
InputStream in = this.getClass().getResourceAsStream(name);
|
||||
|
||||
if (in == null && classPathItems != null) {
|
||||
// TODO I need to find out if classPathItems contains all jars added to a project
|
||||
Iterator<ClassPathItem> classPathItemsIter = classPathItems.iterator();
|
||||
while (classPathItemsIter.hasNext()) {
|
||||
ClassPathItem classPathItem = classPathItemsIter.next();
|
||||
FileObject jarFile = classPathItem.object;
|
||||
|
||||
Enumeration<FileObject> jarEntry = (Enumeration<FileObject>) 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return in;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the folderName
|
||||
*/
|
||||
|
@ -177,7 +177,7 @@ public class EditableMaterialFile {
|
||||
fs = FileUtil.createMemoryFileSystem();
|
||||
matDef = fs.getRoot().createData(name, "j3md");
|
||||
OutputStream out = matDef.getOutputStream();
|
||||
InputStream in = JmeSystem.getResourceAsStream("/" + getMatDefName());
|
||||
InputStream in = manager.getResourceAsStream(getMatDefName());
|
||||
if (in != null) {
|
||||
int input = in.read();
|
||||
while (input != -1) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user