in Idea3.0, you can use OpenFileDescriptor fileDesc = new OpenFileDescriptor(VirtualFile); FileEditorManager.getInstance(Project).openFile(fileDesc,ScrollType.RELATIVE,true);
Thanks for your response but it's not what I'm looking for. I have a file already open in an editor, and what I want to to make this editor's tab the active tab. Your solution allows me to create a new editor.
I haven't fount it. Generally it's hard to do much with just an editor. The best you can do is register a FileEditorManagerListener and implement this:
public void fileOpened(FileEditorManager source, VirtualFile file) { FileEditor fileEditor = source.getSelectedEditor(file); if (fileEditor instanceof TextEditor) { TextEditor editor = (TextEditor)fileEditor; // Attach a reference to thefile to the Editor. editor.getEditor().putUserData("VIRTUAL_FILE", file); } }
Now when you have an editor, check the user data for the file, if any, it is associated with. Now I assume if you call openFile, it will just bring the already-opened file to the front. But I have not tried this yet.
Erb
============================================================== "Most of you are familiar with the virtues of a programmer. There are three, of course: laziness, impatience, and hubris." - Larry Wall ==============================================================
Vincent wrote:
Thanks for your response but it's not what I'm looking for. I have a file already open in an editor, and what I want to to make this editor's tab the active tab. Your solution allows me to create a new editor.
I tried:
editor.getComponent().setVisible(true);
and:
editor.getContentComponent().setVisible(true);
But it does not work. Any idea?
Could somebody please post the code for the Goto Next Tab action so that I can have an idea?
Thanks,
Vincent
in Idea3.0, you can use
OpenFileDescriptor fileDesc = new OpenFileDescriptor(VirtualFile);
FileEditorManager.getInstance(Project).openFile(fileDesc,ScrollType.RELATIVE,true);
but I don't know whether it exist in build 929.
Thanks for your response but it's not what I'm looking for.
I have a file already open in an editor, and what I want to to make this editor's tab the active tab.
Your solution allows me to create a new editor.
-Vincent.
I haven't fount it. Generally it's hard to do much with just an editor.
The best you can do is register a FileEditorManagerListener and implement this:
public void fileOpened(FileEditorManager source, VirtualFile file) {
FileEditor fileEditor = source.getSelectedEditor(file);
if (fileEditor instanceof TextEditor) {
TextEditor editor = (TextEditor)fileEditor;
// Attach a reference to thefile to the Editor.
editor.getEditor().putUserData("VIRTUAL_FILE", file);
}
}
Now when you have an editor, check the user data for the file, if any, it is associated
with. Now I assume if you call openFile, it will just bring the already-opened file to the front.
But I have not tried this yet.
Erb
==============================================================
"Most of you are familiar with the virtues of a programmer.
There are three, of course: laziness, impatience, and hubris."
- Larry Wall
==============================================================
Vincent wrote: