java - How to get notified about file content changes in NetBeans with DataObject API -
i'm trying implement navigatorpanel netbeans module. notified whenever associated dataobject modified can invoke parser , update navigator.
i tried adding propertychangelistener dataobject, notifies me first change made document , that's it. however, i've noticed first time propertychangelistener.propertychange() method invoked, propertyname set "cookie" , second time "modified".
any ideas on how always notified when content of document in editor (not underlying fileobject!) has changed?
edit: looked @ http://wiki.netbeans.org/devfaqlistenforsaveevents. state propertychangelistener used getting informed documents being saved (e.g. ctrl+s) , if 1 wants notified modifications content, filechangelistener should used instead. didn't work me. in either case don't notified when i'm modifying document in editor, except when using propertychangelistener, notified, first time edit (exactly opposite write in faq).
edit2: haven't figured out how notified yet. in case should have approached goal different perspective, i.e. since want update navigatorpanel based on parsing results, should registering parserresulttask. can define when should notified, , when notified parsed results need updating panel.
well, not direct answer actual question more suitable solution particular problem.
here works me. mind event fired when save changes. note code below might not compile have deleted code make concise. simple implementing filechangelistener on dataobject. geertjan did blog post on while ago. let me know how goes.
https://blogs.oracle.com/geertjan/entry/org_openide_filesystems_filechangelistener
public class yourdataobject extends multidataobject implements filechangelistener { public yourdataobject(fileobject pf, multifileloader loader) throws dataobjectexistsexception, ioexception { super(pf, loader); pf.addfilechangelistener(this); registereditor("text/x-puml", true); } @override protected int associatelookup() { return 1; } @override public void filefoldercreated(fileevent fe) {} @override public void filedatacreated(fileevent fe) {} @override public void filechanged(fileevent fe) { system.out.println("here =========== :" + fe); } @override public void filedeleted(fileevent fe) {} @override public void filerenamed(filerenameevent fre) {} @override public void fileattributechanged(fileattributeevent fae) {} }
edit
nevermind, forgot didn't want deal fileobject. here netbeans forum post.
Comments
Post a Comment