SDK:
- Store j3m files in Materials folder git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@10125 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
This commit is contained in:
parent
071581ad30
commit
461f653cf7
@ -51,6 +51,7 @@ import java.util.LinkedList;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import org.openide.filesystems.FileObject;
|
||||
import org.openide.filesystems.FileUtil;
|
||||
import org.openide.loaders.DataObject;
|
||||
import org.openide.nodes.Node;
|
||||
import org.openide.util.Exceptions;
|
||||
@ -97,7 +98,7 @@ public class MaterialPropertyEditor implements PropertyEditor, SceneExplorerProp
|
||||
}
|
||||
|
||||
public void setAsText(final String text) throws IllegalArgumentException {
|
||||
if ("create j3m file".equals(text)) {
|
||||
if ("create j3m file".equals(text)) {
|
||||
try {
|
||||
Node geom = SceneExplorerTopComponent.findInstance().getLastSelected();
|
||||
assert (geom != null);
|
||||
@ -106,8 +107,10 @@ public class MaterialPropertyEditor implements PropertyEditor, SceneExplorerProp
|
||||
DataObject obj = geom.getLookup().lookup(DataObject.class);
|
||||
assert (obj != null);
|
||||
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;
|
||||
String newFileName = currentFile.getName() + "-" + sanitizeFileName(geom.getName());
|
||||
FileObject newFile = currentFolder.getFileObject(newFileName, "j3m");
|
||||
@ -131,8 +134,8 @@ public class MaterialPropertyEditor implements PropertyEditor, SceneExplorerProp
|
||||
applyMaterial(text);
|
||||
}
|
||||
}
|
||||
|
||||
private String sanitizeFileName(String input){
|
||||
|
||||
private String sanitizeFileName(String input) {
|
||||
return input.replaceAll("[^A-Za-z0-9 ]", "_");
|
||||
}
|
||||
|
||||
@ -140,7 +143,6 @@ public class MaterialPropertyEditor implements PropertyEditor, SceneExplorerProp
|
||||
try {
|
||||
Material old = material;
|
||||
SceneApplication.getApplication().enqueue(new Callable<Void>() {
|
||||
|
||||
public Void call() throws Exception {
|
||||
SceneRequest request = SceneApplication.getApplication().getCurrentSceneRequest();
|
||||
((DesktopAssetManager) request.getManager()).deleteFromCache(new MaterialKey(text));
|
||||
|
@ -97,6 +97,7 @@ public final class StoreTextureWizardWizardAction implements ActionListener {
|
||||
file = FileUtil.createData(mgr.getAssetFolder(), path);
|
||||
out = new BufferedOutputStream(file.getOutputStream());
|
||||
out.write(data);
|
||||
file.getParent().refresh();
|
||||
} catch (IOException ex) {
|
||||
DialogDisplayer.getDefault().notifyLater(new NotifyDescriptor.Message("Failed to create data!\n" + ex));
|
||||
Exceptions.printStackTrace(ex);
|
||||
|
Loading…
x
Reference in New Issue
Block a user