Forcing Content Update in Custom and Default FileEditors
I have implemented a custom File Editor and it does its job. The default editor is also shown as a tab along with mu custom editor.
How can I force the content to change in other editor if user update the content in one of these 2 editor?
Content in both of the editors needs to be sync always.
Please sign in to leave a comment.
Default text editor makes changes to a Document instance. That instance generates change events, which can be processed by another editor to update its view. Default text editor also will update its view, if its document is changed externally. Document instance can be obtained for a given VirtualFile using FileDocumentManager.
I am using the below approach to update the file in my custom editor.
Based on your response I assume this is a wrong approach to update the file directly via VFS Utils.
How do I update the file using Document instance? Any help would be useful.
You can try
FileDocumentManger.getInstance().getDocument(myFile).setText(gson.toJson(response))
This works great. But when I edit the file in default editor, it's not updated in my custom editor.
Any tip on loading the updated file content?
Try getting the content from the document, not from the file.
I am doing the same in my custom editor panel.
I am having a custom JSON editor which shows the json file content in a JTable view. From the gson object I update the JTable view.
Maybe you just need to reload your panel, when document contents changes?
You can listen to changes in document - see Document.addDocumentListener
Works now. Thanks.