Creating a Form with Table in main editor window

Answered

HI JB Team,

I have a JTree structure in TolWIndow, whenever a user clicks an element in JTree I want to create a new file and display a form with JTable in that.

Also, I don't want to save this file in localFileSystem(when the user closes form this needs to be deleted) and also it is read-only.  How can I achieve this? I got stuck at creating a new file in editor pane and displaying form content.

Please Help.

1
5 comments

You can customize editors (display Table instead of text editor) via com.intellij.openapi.fileEditor.FileEditorProvider. You can use in-memory files built via com.intellij.testFramework.LightVirtualFile.

1
Avatar
Permanently deleted user

Hi Yann,

As suggested by you, |'ve Implemented FileEditorProvider and FileEditor interfaces and also added the extension in plugin.xml. The mouse click is opening a new form.

My FileEditorProvider accept is like below

public boolean accept(@NotNull Project project, @NotNull VirtualFile file) {
return true;
}

In FileEditor.getComponent() I'm returning Jpanel of a form.

After that when the user double clicks an element in the Jtree I'm calling below code.

LightVirtualFile vFile = new LightVirtualFile("tb1.myFileExtension");
FileEditorManager.getInstance(project).openFile(vFile,true);

 

How can I check a particular LightVirtualFile  is already opened? So that when user clicks the same item rather than opening a new tab, we can move to already open file?

0

Please post link to full plugin sources

 

1
Avatar
Permanently deleted user

Hi, Thanks for your reply. 

Unfortunately, I can't share plugin source as I don't know my company policy will allow that or not.

As suggested by you I am able to open a form whenever a JTree element is selected.

But every time I select JTree element it is creating new Form in new Tab. I want to check whether the file corresponding to selected element(determine by filename) is already opened in the editor and if so, I want to change the focus to the existing file rather than creating a new file.

0

Please try overriding equals() in your LightVirtualFile object according to your semantics

0

Please sign in to leave a comment.