Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Update Navigator IResource-Children progrmatically
Update Navigator IResource-Children progrmatically [message #335747] Sun, 26 April 2009 12:17 Go to next message
Joerg is currently offline Joerg
Messages: 9
Registered: July 2009
Junior Member
Hello there,

I am using the common navigator and have a custom content provider. This
provider delivers for example one or more children for an xml file
depending on its content.

If I edit the content in an editor, I fire an update method and the
navigator makes the following statements:

IPath path = new Path(changedInst.getPath());
IFile iFile = wsRoot.getFileForLocation(path);
try {
iFile.refreshLocal(IResource.DEPTH_INFINITE, null);
} catch (CoreException e) {
}

The decorater is updated fine, but not the children of the content provider.

If I right click the file and invoke refresh (F5) explicitly, the new
children are shown as intended.

What does a F5-refresh do more then refreshLocal in the code?


Thanks in advance,
Joerg
Re: Update Navigator IResource-Children progrmatically [message #335748 is a reply to message #335747] Sun, 26 April 2009 23:34 Go to previous messageGo to next message
Eclipse User
Originally posted by: francis.oaklandsoftware.com

I'm not sure I understand your question.

You are saying that you edit the file in an external editor and are trying
to do a programatic refresh with the code below? Are you using the
Project Explorer (sounds like you are)?

The refresh you do below should trigger a resource notification to the
Project Explorer and it should then refresh the viewer if the file
actually changed. This should then invoke your content provider.

I would set a breakpoint at StructuredViewer.refresh(element) in the
F5-refresh case to see what it's doing there, and then in your programatic
case to see what it's doing differently (is the resource change
notification happening? Is the viewer refresh happening?).

Also please mention what version you are on.

HTH,

Francis

On Sun, 26 Apr 2009 09:17:44 -0700, Joerg <paukenj@fh-trier.de> wrote:

> Hello there,
>
> I am using the common navigator and have a custom content provider. This
> provider delivers for example one or more children for an xml file
> depending on its content.
>
> If I edit the content in an editor, I fire an update method and the
> navigator makes the following statements:
>
> IPath path = new Path(changedInst.getPath());
> IFile iFile = wsRoot.getFileForLocation(path);
> try {
> iFile.refreshLocal(IResource.DEPTH_INFINITE, null);
> } catch (CoreException e) {
> }
>
> The decorater is updated fine, but not the children of the content
> provider.
>
> If I right click the file and invoke refresh (F5) explicitly, the new
> children are shown as intended.
>
> What does a F5-refresh do more then refreshLocal in the code?
>
>
> Thanks in advance,
> Joerg



--
Common Navigator Framework section in Platform Plugin Developer Guide
(Programmer's Guide)
http://help.eclipse.org/ganymede/topic/org.eclipse.platform. doc.isv/guide/cnf.htm

http://dev.eclipse.org/blogs/francis
http://wiki.eclipse.org/Common_Navigator_Framework
http://wiki.eclipse.org/Common_Navigator_Framework_Use_Cases


You have brains in your head.
You have feet in your shoes.
- Dr Seuss, Oh the Places You'll Go
Re: Update Navigator IResource-Children progrmatically [message #335753 is a reply to message #335748] Mon, 27 April 2009 08:36 Go to previous message
Joerg is currently offline Joerg
Messages: 9
Registered: July 2009
Junior Member
Hello Francis,

thanks, your post helped me to solve the problem! The refresh of the
viewer was the one I needed.

Summary:
I subclassed the the CommonNavigator class to obtain a customized
Project Explorer with my own content provider. That content provider
added some virtual folder objects as children of a xml file. The count
of these children are depending on the xml content.

When I edit the the xml content, the contents are posted to my model,
that is not working with IResource object but with java.io.File objects.

Therefore I wanted to refresh the navigator on model changes with:

IPath path = new Path(changedInst.getPath());
IFile iFile = wsRoot.getFileForLocation(path);
iFile.refreshLocal(IResource.DEPTH_INFINITE, null);

But that does not lead to an update of the children origened from the
content provider. But the following did:

IPath path = new Path(changedInst.getPath());
IFile iFile = wsRoot.getFileForLocation(path);
getCommonViewer().refresh(iFile, true);

Regards,
Joerg


Francis Upton schrieb:
> I'm not sure I understand your question.
>
> You are saying that you edit the file in an external editor and are
> trying to do a programatic refresh with the code below? Are you using
> the Project Explorer (sounds like you are)?
>
> The refresh you do below should trigger a resource notification to the
> Project Explorer and it should then refresh the viewer if the file
> actually changed. This should then invoke your content provider.
>
> I would set a breakpoint at StructuredViewer.refresh(element) in the
> F5-refresh case to see what it's doing there, and then in your
> programatic case to see what it's doing differently (is the resource
> change notification happening? Is the viewer refresh happening?).
>
> Also please mention what version you are on.
>
> HTH,
>
> Francis
>
> On Sun, 26 Apr 2009 09:17:44 -0700, Joerg <paukenj@fh-trier.de> wrote:
>
>> Hello there,
>>
>> I am using the common navigator and have a custom content provider.
>> This provider delivers for example one or more children for an xml
>> file depending on its content.
>>
>> If I edit the content in an editor, I fire an update method and the
>> navigator makes the following statements:
>>
>> IPath path = new Path(changedInst.getPath());
>> IFile iFile = wsRoot.getFileForLocation(path);
>> try {
>> iFile.refreshLocal(IResource.DEPTH_INFINITE, null);
>> } catch (CoreException e) {
>> }
>>
>> The decorater is updated fine, but not the children of the content
>> provider.
>>
>> If I right click the file and invoke refresh (F5) explicitly, the new
>> children are shown as intended.
>>
>> What does a F5-refresh do more then refreshLocal in the code?
>>
>>
>> Thanks in advance,
>> Joerg
>
>
>
Previous Topic:CVS Deletion of CVS directories created outside of eclipse
Next Topic:access file within plug-in?
Goto Forum:
  


Current Time: Tue Jul 22 09:37:29 EDT 2014

Powered by FUDForum. Page generated in 0.01746 seconds