Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Common Navigator Framework - Keeping models in sync with view
icon5.gif  Common Navigator Framework - Keeping models in sync with view [message #758516] Wed, 23 November 2011 14:37 Go to next message
Daniel Willig is currently offline Daniel WilligFriend
Messages: 3
Registered: November 2011
Junior Member
Hey,

I have a custom project nature whose main artifact is a file in some custom XML format. Additionally I've created an object model representing this artifact. I'm using the CNF to display my model.

Is there a best practice approach to keep the model in sync with the tree view?

I'm thinking of:

  • Adding/Closing projects
  • File is modified in the file system
  • Some action modifies the object model.


[edit]
I think I have to give you a little bit more information. Smile

The goal of the project is to group existing projects inside the workspace under one "super project". I am using a custom navigator because I only want to see my own projects.

Example project in my navigator:

index.php/fa/6238/0/

The above image shows the visualization of the following project artifact
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<BpelGroup>
    <imports>
        <import>
            <path>c:/test/</path>
        </import>
        <import>
            <path>c:/test/hello/world</path>
        </import>
    </imports>
    <data>
        <element>
            <name>Data Element 1</name>
        </element>
        <element>
            <name>Data Element 2</name>
        </element>
	<element>
            <name>Data Element 3.2</name>
        </element>
	<element>
            <name>Data Element 3.1</name>
        </element>
    </data>
</BpelGroup>


I have no problem with the visualization itself. My problem is that I don't know how/where to make sure that the view is in sync with the model.


Thanks,
Daniel
  • Attachment: navigator.png
    (Size: 12.55KB, Downloaded 295 times)

[Updated on: Thu, 24 November 2011 13:16]

Report message to a moderator

Re: Common Navigator Framework - Keeping models in sync with view [message #758518 is a reply to message #758516] Wed, 23 November 2011 14:45 Go to previous messageGo to next message
Mark Walters is currently offline Mark WaltersFriend
Messages: 25
Registered: June 2011
Junior Member
Daniel,
I've recently been through this process and think perhaps using EMF modelling might be a better approach unless you *have* to have your own custom model for other reasons. Even then, it might be better to concentrate on mapping your model to an EMF model.

Our approach was to create a model manager that responds to workspace and editor changes and polls its listeners with these events.

You register your content provider as a listener (and implement the listener interface on it) then respond to the events sent to your content provider by your model.

The content provider can then modify the model of your view and request the viewer to refresh the corresponding tree elements.

This approach is pretty laborious but has the advantage of fine grain control of all aspects of model and workspace changes.

Let me know if you want any more specific details.

Ta,
Mark.
Re: Common Navigator Framework - Keeping models in sync with view [message #758545 is a reply to message #758516] Wed, 23 November 2011 16:02 Go to previous messageGo to next message
Francis Upton IV is currently offline Francis Upton IVFriend
Messages: 472
Registered: July 2009
Location: Oakland, CA
Senior Member
Quote:
I have a custom project nature whose main artifact is a file in some custom XML format. Additionally I've created an object model representing this artifact. I'm using the CNF to display my model.

Is there a best practice approach to keep the model in sync with the tree view?

I'm thinking of:

Adding/Closing projects
File is modified in the file system
Some action modifies the object model.


If you are thinking of having this be part of the Project Explorer, then using the CNF seems to be the right way to go (note I presume you can also use EMF to help you but they are two different things depending on what you are doing). The use of the CNF within the project explorer will allow your model objects to be found and displayed the way you want them in the Project Explorer (which is an implementation of the CNF).

You would configure the CNF to have your Navigator Context Extension be invoked on your project nature and then within that provide the necessary content and label providers to work with your model objects and display them the way you like. This is particularly useful if your model objects have to interact with other things that are displayed in the Project Explorer (like resources or Java objects).

If you can provide more details of what you are interested in, I can try to help further (I feel like my response is kind of vague).

Francis


Re: Common Navigator Framework - Keeping models in sync with view [message #758748 is a reply to message #758545] Thu, 24 November 2011 13:13 Go to previous messageGo to next message
Daniel Willig is currently offline Daniel WilligFriend
Messages: 3
Registered: November 2011
Junior Member
Thanks for your replies so far. I've updated my initial post to provide more information. I hope this makes my problem more clear. Smile

Daniel
Re: Common Navigator Framework - Keeping models in sync with view [message #758801 is a reply to message #758748] Thu, 24 November 2011 15:36 Go to previous messageGo to next message
Francis Upton IV is currently offline Francis Upton IVFriend
Messages: 472
Registered: July 2009
Location: Oakland, CA
Senior Member
Now I understand, you just have to make sure you call the right update/refresh methods on the CommonViewer (associated with the CommonNavigator object [the ProjectExplorer]) when your model changes.

Re: Common Navigator Framework - Keeping models in sync with view [message #758966 is a reply to message #758801] Fri, 25 November 2011 12:09 Go to previous message
Daniel Willig is currently offline Daniel WilligFriend
Messages: 3
Registered: November 2011
Junior Member
Francis Upton wrote on Thu, 24 November 2011 10:36
Now I understand, you just have to make sure you call the right update/refresh methods on the CommonViewer (associated with the CommonNavigator object [the ProjectExplorer]) when your model changes.

I didn't think it was that easy Smile. Thank you!

Regards,
Daniel
Previous Topic:How to check if UIThread is finnished?
Next Topic:RCP templates are not available in selection list
Goto Forum:
  


Current Time: Sun Dec 21 17:30:13 GMT 2014

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

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