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.AssetKey;
|
||||||
import com.jme3.asset.AssetManager;
|
import com.jme3.asset.AssetManager;
|
||||||
import com.jme3.asset.DesktopAssetManager;
|
import com.jme3.asset.DesktopAssetManager;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
|
import java.io.InputStream;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.URLClassLoader;
|
import java.net.URLClassLoader;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Enumeration;
|
import java.util.Enumeration;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import org.netbeans.api.java.classpath.ClassPath;
|
import org.netbeans.api.java.classpath.ClassPath;
|
||||||
@ -329,7 +333,7 @@ public class ProjectAssetManager extends DesktopAssetManager {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private String[] collectFilesWithSuffix(String suffix) {
|
private String[] collectFilesWithSuffix(String suffix) {
|
||||||
ArrayList<String> list = new ArrayList<String>();
|
Set<String> list = new HashSet<String>();
|
||||||
FileObject assetsFolder = getAssetFolder();
|
FileObject assetsFolder = getAssetFolder();
|
||||||
if (assetsFolder != null) {
|
if (assetsFolder != null) {
|
||||||
Enumeration<FileObject> assets = (Enumeration<FileObject>) assetsFolder.getChildren(true);
|
Enumeration<FileObject> assets = (Enumeration<FileObject>) assetsFolder.getChildren(true);
|
||||||
@ -364,6 +368,34 @@ public class ProjectAssetManager extends DesktopAssetManager {
|
|||||||
return list.toArray(new String[list.size()]);
|
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
|
* @return the folderName
|
||||||
*/
|
*/
|
||||||
|
@ -177,7 +177,7 @@ public class EditableMaterialFile {
|
|||||||
fs = FileUtil.createMemoryFileSystem();
|
fs = FileUtil.createMemoryFileSystem();
|
||||||
matDef = fs.getRoot().createData(name, "j3md");
|
matDef = fs.getRoot().createData(name, "j3md");
|
||||||
OutputStream out = matDef.getOutputStream();
|
OutputStream out = matDef.getOutputStream();
|
||||||
InputStream in = JmeSystem.getResourceAsStream("/" + getMatDefName());
|
InputStream in = manager.getResourceAsStream(getMatDefName());
|
||||||
if (in != null) {
|
if (in != null) {
|
||||||
int input = in.read();
|
int input = in.read();
|
||||||
while (input != -1) {
|
while (input != -1) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user