Skip to main content



      Home
Home » Language IDEs » Java Development Tools (JDT) » Current ActivePage.findEditor(IEditorInput input) triggered SafeRunner
Current ActivePage.findEditor(IEditorInput input) triggered SafeRunner [message #479069] Sat, 08 August 2009 15:18 Go to next message
Eclipse UserFriend
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 #479628 is a reply to message #479069] Tue, 11 August 2009 14:45 Go to previous messageGo to next message
Eclipse UserFriend
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.

--
---
Nitin Dahyabhai
Eclipse WTP Source Editing
IBM Rational
Re: Current ActivePage.findEditor(IEditorInput input) triggered SafeRunner [message #479909 is a reply to message #479628] Wed, 12 August 2009 23:15 Go to previous message
Eclipse UserFriend
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
Previous Topic:MethodDeclaration heritage-information?
Next Topic:Re: Create Java Project using Ant build file
Goto Forum:
  


Current Time: Mon Jul 28 04:45:22 EDT 2025

Powered by FUDForum. Page generated in 0.06496 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top