[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
|
[news.eclipse.tools.gef] Re: editable figure
|
What Randy means is, in EditPart#createFigure of the connection you create
2 figures. One is the the PolylineConnection that you used for the
connection (this is the figure you return from createFigure) and a second
Label figure that you use to label the connection. You can add this figure
as a child of the main figure using Figure#add but I think that would mess
up the layout of the main figure and its genuine children. So better is to
place the label onto your diagram layer yourself. As I mentioned in my
previous post, you can implement AncestorListener in your Label figure so
that it moves along with the main figure. Have a look at some of the Handles
in GEF to see how this works.
Regarding the DirectEditing with this technique; I'm not too sure.
If you choose to use a complete model / EditPart to implement labels, then
DirectEditing is not a big problem - it's exactly the same as direct editing
in Logic. If you wanted to allow the user the flexibility of positioning the
label himself, I think it would not be too hard either. The figure used for
the Label editpart is the same as detailed above. The label model must NOT
be added as a child of the model to be labelled - else the label will mess
up the layout of the figure again.
> If i create separate Editpart, Model for Label, is it possible
>to add Labels along with connections, figures?.
>for example,
> public IFigure createFigute(){
>Connection con = new PolylineConnection();
> con.add(new MyLabel());
> }
If MyLabel is a model class, you cannot add it as a child to the connection
FIGURE. I would suggest that your model class (of the figure to be labelled)
should have a member variable for the labels model.
Depending on the flexibility you need, both approaches (with and without
model / editParts) are workable, (I started off without using a separate
model / editpart, but ultimately found that for my needs, using a model for
the label would be simpler and cleaner).
Have a look at my "Labelling EditParts" post for more details.
All the best,
Brian.