How to make different figures share same model and part [message #177630] |
Thu, 14 April 2005 14:08  |
Eclipse User |
|
|
|
Originally posted by: jduley.mail.arc.nasa.gov
Hello,
I am creating an application where a node can be represented by either a
rectangle-like figure or an ellipse-like figure (both are on my
palette). Each node is really the same so I would like to use thesame
editpart and model. What is the preferred way to acheive this? In the
editpart createFigure method, I suppose I could look at the model and
check for value "isRectangle" or something? In this approach, how can I
initialize the model before this method runs? Any assistance would be
most appreciated. Thanks.
Jason
|
|
|
|
|
Re: How to make different figures share same model and part [message #178052 is a reply to message #177684] |
Sun, 17 April 2005 23:46  |
Eclipse User |
|
|
|
Originally posted by: none.us.ibm.com
Instead of an instancof test, you could do some other test like
shape.getType(), etc. If you cannot distinguish the models, it is
impossible to know which shape to create.
> Randy,
> It appears that in the shape example, there are two different models in
> use for the two figures.
>
> private IFigure createFigureForModel() {
> if (getModel() instanceof EllipticalShape) {
> return new Ellipse();
> }
> else if (getModel() instanceof RectangularShape) {
> return new RectangleFigure();
> }
> else {
> // if Shapes gets extended the conditions above must be updated
> throw new IllegalArgumentException();
> }
>
> I am trying to create the figure based on the same model type so this
> "instanceof" test will not work. If it is possible to intialize the model
> class when the node is created via the palette, where would this be done?
|
|
|
Powered by
FUDForum. Page generated in 0.03719 seconds