This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
to implement issue http://www.netbeans.org/issues/show_bug.cgi?id=12573 (reset toolbars to their default state) i need to remove the local writable instances of toolbar configuration files.
Created attachment 31629 [details] core/startup api changes
Created attachment 31630 [details] openide/filesystem api changes
Created attachment 31631 [details] core/startup/SystemFileSystem
Created attachment 31632 [details] openide/fs/MultiFileObject
Created attachment 31633 [details] openide/fs/MultiFileSystem
the enhancement i propose defines a new FileObject attribute that returns a Callable implementation that removes all writable instances of that file. so when i want to reset toolbars to their default settings (as defined in xml layers), i'd call: FileSystem fs = Repository.getDefault().getDefaultFileSystem(); FileObject fo = fs.findResource( "Toolbars" ); Object attr = fo.getAttribute( "removeWritables" ); if( null != attr && attr instanceof Callable ) { ((Callable)attr).call(); } the same functionality will be used to reset the window system and the common palette to their default settings.
please note that there are no unit tests available yet because i'll be on vacations for the next two weeks. i'll add the test later. in the mean time, please let me know what you think about this and whether there is a better way to go.
This seems like a hack, and for something rather central (reverting modifications). Would prefer a proper API in FileSystem or FileObject, which ideally would have methods like (say on FO) boolean isModified(); void resetModifications() throws IOException; Radek should comment. Anyway, assuming we do go with the currently proposed style, other comments: Why Callable rather than Runnable? I guess it's stylistic. Anyone else have a preference? I don't think MultiFileSystem actually needs to be changed. Rather, SFS.create should make a LocalFileSystemEx which sets a delegating attr overriding readAttribute.
Callable can throw an exception to indicate that the operation failed. anybody else cares to comment? it's been over two weeks by now...
1/ I would rather put the code into writable layer implemented currently in LocalFileSystemEx constructed in SFS.create as Jesse suggested. 2/ If there is obvious that this functionality will be needed generally then API isModified, resetModification would be better but I cannot imagine how to design it properly. Both methods has sense just for MultiFileSystem not for any other general FileSystem. The methods would fit best into MultiFileObject which is just package private. Put it into MultiFileSystem with absolute path as a parameter ?
Created attachment 32184 [details] a better solution
i followed jesse's suggestion and it seems a bit better. the change is also more isolated in the source code, see the new diff.
"....implements Callable<Void>" for JDK 5. Some arch.xml patch needed.
Created attachment 32413 [details] unit tests
Created attachment 32414 [details] api changes and documentation in openide/modules
if there are no more objections, i'd like to integrate this feature to trunk on thursday (aug 3rd)
merged to trunk: Checking in openide/modules/manifest.mf; /cvs/openide/modules/manifest.mf,v <-- manifest.mf new revision: 1.13; previous revision: 1.12 done Checking in openide/modules/apichanges.xml; /cvs/openide/modules/apichanges.xml,v <-- apichanges.xml new revision: 1.9; previous revision: 1.8 done RCS file: /cvs/core/startup/test/unit/src/org/netbeans/core/startup/layers/RemoveWritablesTest.java,v done Checking in core/startup/test/unit/src/org/netbeans/core/startup/layers/RemoveWritablesTest.java; /cvs/core/startup/test/unit/src/org/netbeans/core/startup/layers/RemoveWritablesTest.java,v <-- RemoveWritablesTest.java initial revision: 1.1 done Checking in core/startup/src/org/netbeans/core/startup/layers/LocalFileSystemEx.java; /cvs/core/startup/src/org/netbeans/core/startup/layers/LocalFileSystemEx.java,v <-- LocalFileSystemEx.java new revision: 1.5; previous revision: 1.4 done Checking in core/startup/src/org/netbeans/core/startup/layers/SystemFileSystem.java; /cvs/core/startup/src/org/netbeans/core/startup/layers/SystemFileSystem.java,v <-- SystemFileSystem.java new revision: 1.8; previous revision: 1.7 done RCS file: /cvs/core/startup/test/unit/src/org/netbeans/core/startup/layers/data/layer3.xml,v done Checking in core/startup/test/unit/src/org/netbeans/core/startup/layers/data/layer3.xml; /cvs/core/startup/test/unit/src/org/netbeans/core/startup/layers/data/layer3.xml,v <-- layer3.xml initial revision: 1.1 done Checking in openide/modules/src/org/openide/modules/doc-files/api.html; /cvs/openide/modules/src/org/openide/modules/doc-files/api.html,v <-- api.html new revision: 1.12; previous revision: 1.11 done
closing