Last active
December 12, 2015 04:48
-
-
Save sharwell/4716408 to your computer and use it in GitHub Desktop.
NetBeans API: Create and open a temporary in-memory file with explicit non-serialized semantic data.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FileSystem fileSystem = FileUtil.createMemoryFileSystem(); | |
// Store the actual text that will be displayed to the memory file system | |
FileObject tempFileObject = FileUtil.copyFile(FileUtil.toFileObject(inputFile), fileSystem.getRoot(), inputFile.getName(), "linterp"); | |
DataObject od = DataObject.find(tempFileObject); | |
EditorCookie ec = od.getLookup().lookup(EditorCookie.class); | |
Document opened = ec.openDocument(); | |
if (opened != null) { | |
// here I add the additional data as a property to the Document without needing to serialize it | |
opened.putProperty(LexerDebuggerEditorKit.PROP_INTERP_DATA, lexerInterpreterData); | |
final OpenCookie oc = od.getLookup().lookup(OpenCookie.class); | |
if (oc != null) { | |
if (SwingUtilities.isEventDispatchThread()) { | |
oc.open(); | |
} else { | |
SwingUtilities.invokeLater(new Runnable() { | |
@Override | |
public void run() { | |
oc.open(); | |
} | |
}); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment