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.

Bug 79722 - extend file system to allow deleting writable instances of files from xml layers
Summary: extend file system to allow deleting writable instances of files from xml layers
Status: RESOLVED FIXED
Alias: None
Product: platform
Classification: Unclassified
Component: Filesystems (show other bugs)
Version: 5.x
Hardware: All All
: P3 blocker (vote)
Assignee: Stanislav Aubrecht
URL:
Keywords: API, API_REVIEW_FAST
Depends on:
Blocks: 12573 81206 81786 81787
  Show dependency tree
 
Reported: 2006-07-04 16:24 UTC by Stanislav Aubrecht
Modified: 2008-12-22 17:58 UTC (History)
3 users (show)

See Also:
Issue Type: TASK
Exception Reporter:


Attachments
core/startup api changes (1.81 KB, patch)
2006-07-04 16:42 UTC, Stanislav Aubrecht
Details | Diff
openide/filesystem api changes (2.18 KB, patch)
2006-07-04 16:43 UTC, Stanislav Aubrecht
Details | Diff
core/startup/SystemFileSystem (974 bytes, text/plain)
2006-07-04 16:44 UTC, Stanislav Aubrecht
Details
openide/fs/MultiFileObject (997 bytes, patch)
2006-07-04 16:45 UTC, Stanislav Aubrecht
Details | Diff
openide/fs/MultiFileSystem (538 bytes, patch)
2006-07-04 16:46 UTC, Stanislav Aubrecht
Details | Diff
a better solution (4.22 KB, patch)
2006-07-25 14:57 UTC, Stanislav Aubrecht
Details | Diff
unit tests (7.02 KB, text/plain)
2006-08-01 15:48 UTC, Stanislav Aubrecht
Details
api changes and documentation in openide/modules (3.59 KB, patch)
2006-08-01 15:50 UTC, Stanislav Aubrecht
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Stanislav Aubrecht 2006-07-04 16:24:05 UTC
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.
Comment 1 Stanislav Aubrecht 2006-07-04 16:42:59 UTC
Created attachment 31629 [details]
core/startup api changes
Comment 2 Stanislav Aubrecht 2006-07-04 16:43:39 UTC
Created attachment 31630 [details]
openide/filesystem api changes
Comment 3 Stanislav Aubrecht 2006-07-04 16:44:34 UTC
Created attachment 31631 [details]
core/startup/SystemFileSystem
Comment 4 Stanislav Aubrecht 2006-07-04 16:45:28 UTC
Created attachment 31632 [details]
openide/fs/MultiFileObject
Comment 5 Stanislav Aubrecht 2006-07-04 16:46:01 UTC
Created attachment 31633 [details]
openide/fs/MultiFileSystem
Comment 6 Stanislav Aubrecht 2006-07-04 16:49:18 UTC
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.
Comment 7 Stanislav Aubrecht 2006-07-04 16:51:42 UTC
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.
Comment 8 Jesse Glick 2006-07-11 17:05:24 UTC
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.
Comment 9 Stanislav Aubrecht 2006-07-25 10:36:11 UTC
Callable can throw an exception to indicate that the operation failed.

anybody else cares to comment? it's been over two weeks by now...
Comment 10 rmatous 2006-07-25 12:25:19 UTC
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 ?

Comment 11 Stanislav Aubrecht 2006-07-25 14:57:45 UTC
Created attachment 32184 [details]
a better solution
Comment 12 Stanislav Aubrecht 2006-07-25 14:58:44 UTC
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.
Comment 13 Jesse Glick 2006-07-26 10:30:57 UTC
"....implements Callable<Void>" for JDK 5.


Some arch.xml patch needed.
Comment 14 Stanislav Aubrecht 2006-08-01 15:48:26 UTC
Created attachment 32413 [details]
unit tests
Comment 15 Stanislav Aubrecht 2006-08-01 15:50:53 UTC
Created attachment 32414 [details]
api changes and documentation in openide/modules
Comment 16 Stanislav Aubrecht 2006-08-01 15:51:40 UTC
if there are no more objections, i'd like to integrate this feature to trunk on
thursday (aug 3rd)
Comment 17 Stanislav Aubrecht 2006-08-03 10:58:27 UTC
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
Comment 18 Stanislav Aubrecht 2006-08-03 11:03:13 UTC
closing