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.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; | ||||||
| @ -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"); | ||||||
| @ -132,7 +135,7 @@ public class MaterialPropertyEditor implements PropertyEditor, SceneExplorerProp | |||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     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)); | ||||||
|  | |||||||
| @ -97,6 +97,7 @@ public final class StoreTextureWizardWizardAction implements ActionListener { | |||||||
|                     file = FileUtil.createData(mgr.getAssetFolder(), path); |                     file = FileUtil.createData(mgr.getAssetFolder(), path); | ||||||
|                     out = new BufferedOutputStream(file.getOutputStream()); |                     out = new BufferedOutputStream(file.getOutputStream()); | ||||||
|                     out.write(data); |                     out.write(data); | ||||||
|  |                     file.getParent().refresh(); | ||||||
|                 } catch (IOException ex) { |                 } catch (IOException ex) { | ||||||
|                     DialogDisplayer.getDefault().notifyLater(new NotifyDescriptor.Message("Failed to create data!\n" + ex)); |                     DialogDisplayer.getDefault().notifyLater(new NotifyDescriptor.Message("Failed to create data!\n" + ex)); | ||||||
|                     Exceptions.printStackTrace(ex); |                     Exceptions.printStackTrace(ex); | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user