Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Iteratively go through model
Iteratively go through model [message #215826] Mon, 19 January 2009 13:38 Go to next message
Conor Missing name is currently offline Conor Missing nameFriend
Messages: 159
Registered: July 2009
Senior Member
Hi all,

I would like to add functionality to my GMF editor that allows me to
iterate through each of the elements that are in the model. The idea is
that the iteration would be done in the background (program) and the
function that I apply to each element in the model will check a property
of the element for a certain value. If the value exists then the nodes
colour would change graphically.

My question is how do I 'get' the model (of all a certain type) and
iterate through it.

Example:

I have different types of nodes in my model: AAA, BBB, CCC

I want to iterate through all the nodes of type AAA and change their fill
colour to red if one of their properties = xxx

Thanks for your help,

Gaff
Re: Iteratively go through model [message #215927 is a reply to message #215826] Tue, 20 January 2009 20:05 Go to previous messageGo to next message
Seweryn Niemiec is currently offline Seweryn NiemiecFriend
Messages: 80
Registered: July 2009
Member
Gaff wrote:
> I want to iterate through all the nodes of type AAA and change their
> fill colour to red if one of their properties = xxx

Maybe you do not have to iterate through the nodes. You could make
figures update themselves automatically when properties are changed.
Check one of those links:
http://serdom.eu/ser/2009/01/21/eclipse-gmf-making-figures-s ensitive-to-attributes-of-semantic-elements
http://wiki.eclipse.org/GMF_Tips#Making_figures_sensitive_to _attributes_of_semantic_elements

--
Greetings,
Seweryn
Re: Iteratively go through model [message #216042 is a reply to message #215927] Wed, 21 January 2009 19:04 Go to previous messageGo to next message
Conor Missing name is currently offline Conor Missing nameFriend
Messages: 159
Registered: July 2009
Senior Member
Hi Seweryn,

That's actually pretty helpful BUT I still need to be able to iteratively
go through elements in the model.

What I want to allow the user to do is highlight certain nodes that have a
particular value in one of their properties - so yep you have the right
idea with the graphical view being related with the properties. The
difference is that I need to allow the user to be able to turn on and off
this functionality. So they can highlight based on one property and value,
change the value or examine another property or switch it off all together.

I also might need to be able to iterate through the model for some other
functionality that I'm thinking about.

Code would go something like:

mymodel = WHAT_EVER_WINDOW_IS_IN_VIEW.getModel

for(int i=0; i<mymodel.getSize() ;i++){

// DO SOMETHING WITH ONE OF THE NODES AT POSITION i LIKE CHANGE FILL COLOR

}


Any idea how I might do something like this?

Thanks,

Gaff
Re: Iteratively go through model [message #216091 is a reply to message #216042] Thu, 22 January 2009 08:23 Go to previous messageGo to next message
Seweryn Niemiec is currently offline Seweryn NiemiecFriend
Messages: 80
Registered: July 2009
Member
Gaff wrote:
> mymodel = WHAT_EVER_WINDOW_IS_IN_VIEW.getModel

There are many ways to get the model. For example, if you want to walk
through model when user calls an action (for example from context menu),
you will get selected *EditPart in IStructuredSelection. From this
*EditPart you can reach everything in your model (models actually -
notation and semantic).

--
Greetings,
Seweryn
Re: Iteratively go through model [message #218591 is a reply to message #216091] Thu, 12 February 2009 19:49 Go to previous message
Conor Missing name is currently offline Conor Missing nameFriend
Messages: 159
Registered: July 2009
Senior Member
Hi Seweryn,

I have an action set up that allows the user to right click on any blank
space within the editor (I call it the Canvas) and make a selection from
the pop-up menu that I've added.

The action that gets called looks like this:

public void run(IAction action) {

IGraphicalEditPart editPart = (IGraphicalEditPart) editParter;
EObject modelElement = editPart.resolveSemanticElement();
final Canvas my_canvas = (Canvas) modelElement;
...

What I would like to do from here is go through all of the nodes that are
of type AAA (which are contained in the Canvas) and change their line
color IF one of their properties contains a certain value.

I know I can get a list of the nodes with:

List <AAA> list_of_aaa = my_canvas.getAAA();

but I don't know how to access all the AAA nodes in the model to apply
functionality.

I think the following might be used (as you mentioned
IStructuredSelection) but I'm not sure how exactly:

public void selectionChanged(IAction action, ISelection selection) {
...


Thanks very much for your help.

Regards,

Gaff
Previous Topic:Where is the Listener of the PropertySection?
Next Topic:Extending EMF EClass
Goto Forum:
  


Current Time: Tue Apr 23 16:10:15 GMT 2024

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

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

Back to the top