0

I'm writing a plugin for the NetBeans Platform and would like to know if it's possible to force an editor window to update it's content from harddrive. I'm in the situation that I know some file on the HDD has changed but NetBeans doesn't recognize that.

dataObject.getLookup().lookup(EditorCookie.class);
StyledDocument document = cookie.getDocument();
JEditorPane editor = cookie.getOpenedPanes()[0];

// Looking for something like
document.forceUpdate();
//or
editor.forceUpdate();
//or
dataObject.forceUpdate();
Yser
  • 2,086
  • 22
  • 28

1 Answers1

0

FileObject.refresh() is what you're looking for. The editor should listen to its changes (through layers that you've mentioned).

Radim
  • 4,721
  • 1
  • 22
  • 25
  • The funny thing is, if you are looking at the sources of FileObject the implementation of refresh() is empty and the refresh(boolean) is pointing to refresh(). Nevertheless i'll give it a try, maybe some magic with reflection is happening in the background. – Yser Nov 17 '14 at 06:45
  • `FileObject` in FileSystems API is abstract. So called magic is somewhere in real implementation. For example `masterfs/src/org/netbeans/modules/masterfs/filebasedfs/fileobjects/BaseFileObj.java` – Radim Nov 17 '14 at 08:14
  • Ups, correct. Nevertheless refresh() is not updating the editor properly. Actually it does sometimes but just in really raw cases e.g. once the IDE is booted up on the first call of refresh(). But again not all the time. – Yser Nov 17 '14 at 09:32