Eclipse Graphiti, How to create “CustomFeature's create & get all Elements”?

I have 2 questions, maybe somebody can give me an idea how i can do this

I've created new "testFeature" extended from AbstractCustomFeature and can call it in my Diagram. How can i get a List which contains all Elements from the Diagram?(i want to update their names and colors at start and later)

My second question is: I'm trying to add some Elements to the Diagram without drag and drop them from the palette.

For example i have some Elements saved in the Diagram and my "model say i miss 3 Elements in the Diagram". I want to write an Custom Feature, which draw/put missing Elements in the Graphiti Diagram with just one/two clicks, maybe i need to use Zest at this part? but at the beginning i just want to put few elements without drop them from the Palette, how can i do this?

Maybe somebody can give me direction?

Thanks for your help!

Answers


How can i get a List which contains all Elements from the Diagram?

Diagram is a ContainerShape, you can call getChildren() to retrieve all shapes

add some Elements to the Diagram without drag and drop them from the palette.

Is the object already created, inside the EMF model, and you only want it to add its graphical counterpart to the diagram? If so, you need to instantiate and execute yourself your corresponding XXXAddFeature class.

Elsewhere (more probable, if you want to mimic some drag-n-drop from the palette), you must call the proper XXXCreateFeature, which will add ("create", in Graphiti parlance) the element to the model (typically, the create body will at the end invoke addGraphicalRepresentation() which will also add the corresponding graphical element to the diagram by calling, internally the appropiate XXXAddFeature).


Need Your Help

Wicket form ajax

java ajax forms wicket

This code is from the Wicket in Action book.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.