Netbeans Platform and Memory File System
September 1st, 2007 | by Tonny Kohar |Normally, using Netbeans Platform you have to use DataObject.find() and use the OpenCookie to open the DataObject (eg: file, etc) to be opened on the Editor TopComponent. However, for certain case, I do not have the file yet eg: in Sketsa menu File - New. We do not want to create or store this as file yet, in case the user choose to discard the file. The file will be written to the disk, when the user choose either Save or Save As
Fortunately, Netbeans Platform have build in memory FileSystem that we could use for this kind of problem
FileSystem fs = FileUtil.createMemoryFileSystem(); FileObject fob = fs.getRoot().createData(name,"svg"); DataObject data = DataObject.find(fob); OpenCookie cookie = (OpenCookie)data.getCookie(OpenCookie.class); cookie.open();









3 Responses to “Netbeans Platform and Memory File System”
By Pavel Buzek on Sep 8, 2007 | Reply
I am curious, how did you make the first Save for .svg file to behave like SaveAs? Is this handled in you SaveCookie or have you changed some code in NetBeans to achieve this? Thanks.
By Tonny Kohar on Sep 8, 2007 | Reply
Actually, our SaveCookie implementation is very simple. It is just forward the call to our SVGEditorSupport.saveDocument() methods.
We handled the first Save behaviour in the editorSupport.saveDocument methods by checking the document URI (note: this is SVGDataObject specific).
Alternatively, you could check for the real physical file exists or not. Since it is memory filesystem, there should not be real file exists (note: we haven’t tried this methods)
By Vinod Kumar Saini on Jan 6, 2009 | Reply
http://www.smarterdeals.com/Goods.aspx?stxt=&cat_id=All&brand=All&vendor=810&price_from=&price_to=&vpn=&id=