0

I'm currently learning GEF (as in the Eclipse project), and while doing so have come across a question.

In my future application I will have to connect a Figure with the nested figure of some other Figure. I have found that via the following code (quoted from memory, used in a pure Draw2D application) I can access the nested figure.

(Figure)someFigure.getChildren().get(1)

From trying it out I have found out that when the accessed Figure has added to it a) a Label and b) a Figure (add()ed in this order), the above code will return the nested Figure.

Obviously this isn't optimal, as the same code with get(0) will probably result in an error (I guess a casting error).

My question is: Is there a native/easier way to access nested figures, especially without having to cast?

Many thanks in advance!

s.d
  • 4,017
  • 5
  • 35
  • 65

1 Answers1

1

Don't think there is a way. If you own the code that adds the figures, why not create your own model instead of relying on draw2d (BTW, this is what GEF does).

vainolo
  • 6,907
  • 4
  • 24
  • 47
  • Thanks! Now that I've walked a bit further along the path so to speak, I understand what you mean :). Yes, I do own the code, and thus will be able to access the figures much better... Btw, thanks for the amazing `GEF` Editor tut you have on your blog! Reeeeeally good! For everyone looking after an answer to a `GEF` question, here it is: http://www.vainolo.com/2011/06/12/creating-a-gef-editor-part-1-defining-the-model-2/. – s.d Mar 16 '12 at 21:04