|
@@ -51,6 +51,7 @@ import java.util.LinkedList;
|
|
import java.util.concurrent.Callable;
|
|
import java.util.concurrent.Callable;
|
|
import java.util.concurrent.ExecutionException;
|
|
import java.util.concurrent.ExecutionException;
|
|
import org.openide.filesystems.FileObject;
|
|
import org.openide.filesystems.FileObject;
|
|
|
|
+import org.openide.filesystems.FileUtil;
|
|
import org.openide.loaders.DataObject;
|
|
import org.openide.loaders.DataObject;
|
|
import org.openide.nodes.Node;
|
|
import org.openide.nodes.Node;
|
|
import org.openide.util.Exceptions;
|
|
import org.openide.util.Exceptions;
|
|
@@ -97,7 +98,7 @@ public class MaterialPropertyEditor implements PropertyEditor, SceneExplorerProp
|
|
}
|
|
}
|
|
|
|
|
|
public void setAsText(final String text) throws IllegalArgumentException {
|
|
public void setAsText(final String text) throws IllegalArgumentException {
|
|
- if ("create j3m file".equals(text)) {
|
|
|
|
|
|
+ if ("create j3m file".equals(text)) {
|
|
try {
|
|
try {
|
|
Node geom = SceneExplorerTopComponent.findInstance().getLastSelected();
|
|
Node geom = SceneExplorerTopComponent.findInstance().getLastSelected();
|
|
assert (geom != null);
|
|
assert (geom != null);
|
|
@@ -106,8 +107,10 @@ public class MaterialPropertyEditor implements PropertyEditor, SceneExplorerProp
|
|
DataObject obj = geom.getLookup().lookup(DataObject.class);
|
|
DataObject obj = geom.getLookup().lookup(DataObject.class);
|
|
assert (obj != null);
|
|
assert (obj != null);
|
|
FileObject currentFile = obj.getPrimaryFile();
|
|
FileObject currentFile = obj.getPrimaryFile();
|
|
- FileObject currentFolder = currentFile.getParent();
|
|
|
|
-
|
|
|
|
|
|
+ FileObject currentFolder = pm.getAssetFolder().getFileObject("Materials/");
|
|
|
|
+ if (currentFolder == null) {
|
|
|
|
+ currentFolder = FileUtil.createFolder(pm.getAssetFolder(), "Materials");
|
|
|
|
+ }
|
|
int i = 0;
|
|
int i = 0;
|
|
String newFileName = currentFile.getName() + "-" + sanitizeFileName(geom.getName());
|
|
String newFileName = currentFile.getName() + "-" + sanitizeFileName(geom.getName());
|
|
FileObject newFile = currentFolder.getFileObject(newFileName, "j3m");
|
|
FileObject newFile = currentFolder.getFileObject(newFileName, "j3m");
|
|
@@ -131,8 +134,8 @@ public class MaterialPropertyEditor implements PropertyEditor, SceneExplorerProp
|
|
applyMaterial(text);
|
|
applyMaterial(text);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
- private String sanitizeFileName(String input){
|
|
|
|
|
|
+
|
|
|
|
+ private String sanitizeFileName(String input) {
|
|
return input.replaceAll("[^A-Za-z0-9 ]", "_");
|
|
return input.replaceAll("[^A-Za-z0-9 ]", "_");
|
|
}
|
|
}
|
|
|
|
|
|
@@ -140,7 +143,6 @@ public class MaterialPropertyEditor implements PropertyEditor, SceneExplorerProp
|
|
try {
|
|
try {
|
|
Material old = material;
|
|
Material old = material;
|
|
SceneApplication.getApplication().enqueue(new Callable<Void>() {
|
|
SceneApplication.getApplication().enqueue(new Callable<Void>() {
|
|
-
|
|
|
|
public Void call() throws Exception {
|
|
public Void call() throws Exception {
|
|
SceneRequest request = SceneApplication.getApplication().getCurrentSceneRequest();
|
|
SceneRequest request = SceneApplication.getApplication().getCurrentSceneRequest();
|
|
((DesktopAssetManager) request.getManager()).deleteFromCache(new MaterialKey(text));
|
|
((DesktopAssetManager) request.getManager()).deleteFromCache(new MaterialKey(text));
|