Search code examples
javanetbeansnetbeans-platformnetbeans-plugins

NetBeans Platform: Updating editor window content


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();

Solution

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