Current ActivePage.findEditor(IEditorInput input) triggered SafeRunner [message #479069] |
Sat, 08 August 2009 15:18  |
Eclipse User |
|
|
|
Hi all,
Here's my code to find the current editor for the file:
IEditorPart editor =
MyPlugin.getActiveWorkbenchWindow().getActivePage().findEdit or(new
FileEditorInput(file));
When the file is open in an editor which is activated and focused, it
will return the IEditorPart. But if the file is open in an editor while
the editor is not activated in the current active page, it will trigger
the SafeRunner class.
I need to get the IEditorPart even if the open editor is not activated
as long as the file is open in it. Can some one point me the way to work
around this?
Thanks.
Jing
|
|
|
|
Re: Current ActivePage.findEditor(IEditorInput input) triggered SafeRunner [message #479909 is a reply to message #479628] |
Wed, 12 August 2009 23:15  |
Eclipse User |
|
|
|
Nitin Dahyabhai wrote:
> Jing Xie wrote:
>> Here's my code to find the current editor for the file:
>> IEditorPart editor =
>> MyPlugin.getActiveWorkbenchWindow().getActivePage().findEdit or(new
>> FileEditorInput(file));
>>
>> When the file is open in an editor which is activated and focused, it
>> will return the IEditorPart. But if the file is open in an editor
>> while the editor is not activated in the current active page, it will
>> trigger the SafeRunner class.
>>
>> I need to get the IEditorPart even if the open editor is not activated
>> as long as the file is open in it. Can some one point me the way to
>> work around this?
>
> What's wrong with triggering the SafeRunner class?
>
> You could instead get the IEditorReferences of that page and check their
> editor inputs yourself.
>
Hi Nitin,
Thanks for your reply.
Once the SafeRunner class is triggered, the program stops right there
and nothing goes further.
I tried using IEditorReferences instead as you suggested and here's the
code:
public static IEditorPart findEditorForFile(IFile file)
throws PartInitException {
IEditorPart editor = null;
IEditorReference[] references = InputValidationPlugin
.getActiveWorkbenchWindow().getActivePage()
.getEditorReferences();
for (int i = 0; i < references.length; i++) {
IEditorReference reference = references[i];
if (reference.getEditorInput().equals(new FileEditorInput(file))) {
editor = reference.getEditor(true);
}
}
return editor;
}
This time, when the getEditor() was invoked, the program choked there
and there was never an object of IEditorPart returned.
Any other ways I can try to possibly work around this?
Thanks,
Jing
|
|
|
Powered by
FUDForum. Page generated in 0.07991 seconds