DevFaqListenForSaveEvents

(Difference between revisions)
m (How can I be notified when a file is modified and saved??)
Line 2: Line 2:
===How can I be notified when a file is modified and saved??===
===How can I be notified when a file is modified and saved??===
-
The [http://www.netbeans.org/download/dev/javadoc/org-openide-loaders/org/openide/loaders/DataObject.Registry.html DataObject.Registry] in [http://www.netbeans.org/download/dev/javadoc/org-openide-loaders/allclasses-frame.html LoadersAPI] gives you a set of modified DataObjects. You can also add a listener and be notified when the set of modified objects changes.
+
The [http://www.netbeans.org/download/dev/javadoc/org-openide-loaders/org/openide/loaders/DataObject.Registry.html DataObject.Registry] in [http://www.netbeans.org/download/dev/javadoc/org-openide-loaders LoadersAPI] gives you a set of modified DataObjects. You can also add a listener and be notified when the set of modified objects changes.
As this operates on DataObjects you will first need to get a DataObject for your FileObject using [http://www.netbeans.org/download/dev/javadoc/org-openide-loaders/org/openide/loaders/DataObject.html#find(org.openide.filesystems.FileObject) DataObject.find()].
As this operates on DataObjects you will first need to get a DataObject for your FileObject using [http://www.netbeans.org/download/dev/javadoc/org-openide-loaders/org/openide/loaders/DataObject.html#find(org.openide.filesystems.FileObject) DataObject.find()].
Or you can take the modified DataObjects and do dataObject.getPrimaryFile().
Or you can take the modified DataObjects and do dataObject.getPrimaryFile().

Revision as of 10:55, 3 December 2009

How can I be notified when a file is modified and saved??

The DataObject.Registry in LoadersAPI gives you a set of modified DataObjects. You can also add a listener and be notified when the set of modified objects changes.

As this operates on DataObjects you will first need to get a DataObject for your FileObject using DataObject.find(). Or you can take the modified DataObjects and do dataObject.getPrimaryFile().

Not logged in. Log in, Register

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo