Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Projects Conflicting with Custom Editor
Projects Conflicting with Custom Editor [message #329759] Wed, 02 July 2008 21:43 Go to next message
Derek Rea is currently offline Derek ReaFriend
Messages: 14
Registered: July 2009
Junior Member
Hello,

I am frustrated trying to figure this one out, so ill see if anyone else
has encountered it.

I created a view that displays a tree of resources. These resources can
be opened in an editor that I have also created by:
1)right click->open from within the my view (my own action), or
2)adding the resource to a project (of custom nature) and right
click->open from within the Project Explorer (Project Explorer
functionality).

Both options work great, unless I attempt to open a resource from within
my view when it is currently part of a project as well. When I do this,
my editor's document is returned as null and I get a NullPointerException
during creation of the editor. If I delete the resource from the project
and then try to open it from my view, it works fine again.

The resources are linked (not actual files on my PC), and therefore the
same openInputStream method is called when they are opened from within my
view and from within a project. I am using a TextFileDocumentProvider in
my custom editor. Any ideas as to why this is happening?

Thanks,
Derek
Re: Projects Conflicting with Custom Editor [message #329769 is a reply to message #329759] Thu, 03 July 2008 12:23 Go to previous message
Derek Rea is currently offline Derek ReaFriend
Messages: 14
Registered: July 2009
Junior Member
I think I have found the issue...

In TextFileDocumentProvider's createFileInfo(Object element) method (sorry
if the formatting of the code is off):


ILocationProvider provider= (ILocationProvider)
adaptable.getAdapter(ILocationProvider.class);
if (provider instanceof ILocationProviderExtension)
{
URI uri= ((ILocationProviderExtension)provider).getURI(element);
if
(ResourcesPlugin.getWorkspace().getRoot().findFilesForLocati onURI(uri).length
== 0)
{
IFileStore fileStore= EFS.getStore(uri);
manager.connectFileStore(fileStore, getProgressMonitor());
fileBuffer= manager.getFileStoreTextFileBuffer(fileStore);
}
}
if (fileBuffer == null && provider != null)
{
IPath location= provider.getPath(element);
if (location == null)
return null;
.
.
.
}


The code above is finding a file in the workspace that matches the one in
my view because they have the same URI (since I am using linked
resources), so the .length check returns false. Due to this, the code
jumps down to the fileBuffer and provider null check and attempts to get
the IPath of the element. provider.getPath(element) returns null however,
since the linked resource does not actually exist in the local file system
(the workspace). createFileInfo then returns null, causing my editor to
not have a document as well as the NullPointerException.

For now, I have extended TextFileDocumentProvider and slightly modified
the createFileInfo method to not check for files in the workspace, which
works - is this the best solution though? Or is there some type of
attribute I should be using on my linked resources that would prevent this
from happening? Or something else?

Thanks,
Derek


Derek R. wrote:

> Hello,

> I am frustrated trying to figure this one out, so ill see if anyone else
> has encountered it.

> I created a view that displays a tree of resources. These resources can
> be opened in an editor that I have also created by:
> 1)right click->open from within the my view (my own action), or
> 2)adding the resource to a project (of custom nature) and right
> click->open from within the Project Explorer (Project Explorer
> functionality).

> Both options work great, unless I attempt to open a resource from within
> my view when it is currently part of a project as well. When I do this,
> my editor's document is returned as null and I get a NullPointerException
> during creation of the editor. If I delete the resource from the project
> and then try to open it from my view, it works fine again.

> The resources are linked (not actual files on my PC), and therefore the
> same openInputStream method is called when they are opened from within my
> view and from within a project. I am using a TextFileDocumentProvider in
> my custom editor. Any ideas as to why this is happening?

> Thanks,
> Derek
Previous Topic:Code that was compiling in 3.3.2 doesn't compile in 3.4
Next Topic:Widget disposed error in Progress monitor
Goto Forum:
  


Current Time: Wed Jul 17 19:32:28 GMT 2024

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

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

Back to the top