|
|
Re: Problems getting content of loaded resource [message #430557 is a reply to message #430555] |
Wed, 27 May 2009 11:02 |
Hallvard Traetteberg Messages: 673 Registered: July 2009 Location: Trondheim, Norway |
Senior Member |
|
|
Ed Merks wrote:
> Hallvard,
>
>> When a new resource appears, I look at the content of the newly
>> added resource using resource.getContents().size() and
>> resource.getContents().get(0); For some reason the contents is empty
>> because the platform:/plugin/ uri cannot be found.
> Did you determine this reason by looking at Resource.getErrors()?
I caught an exception saying the resource pointed at by the URI couldn't
be found. For me it looked like the resource had been loaded, but that
the content wasn't filled due to the above error. From looking at the
ResourceImpl code, I gathered that this is normal: A resource is
considered loaded also when it has tried, but failed?
> Keep in mind that when a resource is added to the resource set, it
> generally isn't loaded yet. I.e., this logic creates it and then later
> loads it:
OK, so first the resource is demand created, then adapters are notified
that it has been added, and then it is loaded? I thought it was loaded
before it was added.
But I still wonder about the URI not resolving or finding the the
resource. Perhaps I have misinterpreted the exception? Is there
something that triggers activation of the platform URI handler and this
is done by the editor and not by my code?
> So it sounds like you should really be listening to the resource set for
> resources being added, check if the added resource's isLoaded is true,
> and also listen to the new resource to see when it's loaded, unloaded,
> or otherwise has it's getContents modified...
I will.
Hallvard
|
|
|
Re: Problems getting content of loaded resource [message #430561 is a reply to message #430557] |
Wed, 27 May 2009 12:50 |
Ed Merks Messages: 33140 Registered: July 2009 |
Senior Member |
|
|
Hallvard,
Comments below.
Hallvard Trætteberg wrote:
> Ed Merks wrote:
>> Hallvard,
>>
>>> When a new resource appears, I look at the content of the newly
>>> added resource using resource.getContents().size() and
>>> resource.getContents().get(0); For some reason the contents is empty
>>> because the platform:/plugin/ uri cannot be found.
>> Did you determine this reason by looking at Resource.getErrors()?
>
> I caught an exception saying the resource pointed at by the URI
> couldn't be found. For me it looked like the resource had been loaded,
> but that the content wasn't filled due to the above error. From
> looking at the ResourceImpl code, I gathered that this is normal: A
> resource is considered loaded also when it has tried, but failed?
Yes, this prevents repeated (expensive) attempts to load the resource.
>
>> Keep in mind that when a resource is added to the resource set, it
>> generally isn't loaded yet. I.e., this logic creates it and then
>> later loads it:
>
> OK, so first the resource is demand created, then adapters are
> notified that it has been added, and then it is loaded?
Yes.
> I thought it was loaded before it was added.
No.
>
> But I still wonder about the URI not resolving or finding the the
> resource.
Yes, that seems odd. A platform:/plugin URI is handled just as a "plain
old java.net.URL" for which the Eclipse platform registers a URL handler.
> Perhaps I have misinterpreted the exception?
Perhaps.
> Is there something that triggers activation of the platform URI
> handler and this is done by the editor and not by my code?
I think these handlers are registered during startup. Try creating just
a URL and calling openStream on it to see if that's working... That's
basically all the URIConverter will do...
>
>> So it sounds like you should really be listening to the resource set
>> for resources being added, check if the added resource's isLoaded is
>> true, and also listen to the new resource to see when it's loaded,
>> unloaded, or otherwise has it's getContents modified...
>
> I will.
>
> Hallvard
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Powered by
FUDForum. Page generated in 0.03146 seconds