|
Re: Projects Conflicting with Custom Editor [message #329769 is a reply to message #329759] |
Thu, 03 July 2008 12:23 |
Derek Rea 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
|
|
|
Powered by
FUDForum. Page generated in 0.35980 seconds