Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » Grouping objects under a folder
Grouping objects under a folder [message #579564] Mon, 05 June 2006 03:54
Eclipse UserFriend
Originally posted by: hocnt.cybersoft-vn.com

Dear All,

I use EMF to define my domain model. In the editor of my data model, I
display my data model in a TreeViewer. Now I want to group objects of
the same type in its own folder. My problem is that I can not refresh
immediately the objects under folder after creating a new object. If
anyone has ever implemented a similar feature, could you share that with me?

Here is an example of my model and how I implement it:
- I manage a pet store, I define an EMF model, let's say PetStore model.
The root element of my TreeViewer is a Store object
- I can add animals to my pet store
- I want to group objects of the same type in a specific folder, for
example: mammal, reptile.
- My problem is that I can not refresh immediately the objects under
folder after creating a new object.
- To implement the folder, I define another model, let's say UIThing
model. I don't want to tie the 'folder' concept to my PerStore model.
- In UIThing model, I define a DummyFolder object which does not know
anything about PerStore model. It has a attribute which is an EMF
feature. It also has a 'parent' attribute which is an EObject. Here, the
DummyFolder is generic and not tied to any specific model.
- To make DummyFolder displayed in the TreeViewer, I do like this:
+ Override the StoreItemProvider.getChilden(). I add two DummyFolder
objects for mammal and reptile to the returned children collection. I
set parent and feature for the two DummyFolder objects accordingly.
+ Override the DummyFolderItemProvider.getChilden(). I get the parent
object and then get all children of the type 'feature' (mammal or reptile).
- I get existing objects displayed correctly under its own folder nicely.
- When I add a new animal, I can not refresh the content (children) of
the DummyFolder object immediately and keep the collapse/expand status!
- In the StoreItemProvider.notifyChanged(), I can only refresh the
Store's content by calling:

case PetStorePackage.ANIMAL__MAMMAL:
fireNotifyChanged(new ViewerNotification(notification,
notification.getNotifier(), true, false));

- The content of the Store is updated, and also the content of MAMMAL
dummy folder, but the "collapse/expand" state of the mammal dummy folder
is set to "collapsed", even though it's was expanded before adding new
animal! That's quite right because only the Store object is updated, and
DummyFolder is a (fake) 'child' of it, it will only update the 'plus'
sign, and make the DummyFolder collapsed.

- I've tried to modify the "notification" to refresh the DummyFolder but
no success.

I'm really stuck at that point. Any suggestion will be appreciated.

Thanks,
Hoc
Previous Topic:ToStringVisitorImpl.toString returning null
Next Topic:using WorkspaceCommandStack of EMFT Transaction
Goto Forum:
  


Current Time: Wed May 22 15:52:09 GMT 2024

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

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

Back to the top