tags:

views:

454

answers:

2

Hello!

We're working on creating a modeling tool based on the GMF framework and tools. We have a requirement to allow users to add views (figures) at runtime and use them in their diagrams. We will be using SVG files to represent figures.

What's the correct structure of EditParts and other GEF related classes in such a case? We were thinking of implementing a single GEF EditPart class, that would create the appropriate figure based on a parameter (path to SVG file) present in the model. So far it doesn't seem to be working.

There HAS to be someone who's already done something like this before. Googling and the Eclipse forums have not been helpful so far...

A: 

Well we found a (partial) solution. We have one element, and depending on a parameter we create a child figure inside it, which uses an SVG file (based on the parameter).

The following test code is called in the constructor of the Figure:

ScalableImageFigure svg; URL url; if (type == 1) { url = ArchitectureStudioDiagramEditorPlugin.getInstance().getBundle().getEntry( "icons" + IPath.SEPARATOR + "shadow-box.svg"); } else { url = ArchitectureStudioDiagramEditorPlugin.getInstance().getBundle().getEntry( "icons" + IPath.SEPARATOR + "star.svg"); } svg = new ScalableImageFigure(RenderedImageFactory.getInstance(url), true, true, true);

this.add(svg);

Now we need to figure out how to have multiple elements in the Palette.

Jaffer
A: 

Hi , The correct way is to have one to one mapping between figure and editpart . Also painting task should be left to the figure . How the image should be painted , the logic must be inside the figure not in the editpart.

Thanks

Jijoy