Skip to main content



      Home
Home » Eclipse Projects » GEF » Is it possible to have two figures attached to the same model?
Is it possible to have two figures attached to the same model? [message #48485] Sun, 08 December 2002 20:38 Go to next message
Eclipse UserFriend
Originally posted by: rspbr.hotmail.com

Hi,

I'm trying to implement an editor that shows a figure for a particular
element of a model and a label for that figure.

The problem is that I wished that the label could be manipulated as an
independent figure - the user should be able to move it around separately
from the "main" figure, allowing him to better place the labels to avoid
collisions.

Even better than that: Would it be possible to have that label to act like a
connection figure? I mean, the user can modify it but when the main figure
is selected the label is unselected?

I was trying to "brute force" adding those extra labels by overriding the
add(IEditorPart) method, but without success. Anybody has any idea on the
right way of doing this?

Thanks for any help,
Ricardo


---

Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.427 / Virus Database: 240 - Release Date: 6/12/2002
Re: Is it possible to have two figures attached to the same model? [message #48517 is a reply to message #48485] Sun, 08 December 2002 23:38 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: hudsonr.us.eye-bee-em.com

Can you give a better description of what you want to do? Instead of
describing the behavior completely, maybe there is another program that does
the same thing.

You can have 2 EditParts that correspond to the same model object, but I'm
not sure this is necessary here.

"Ricardo Sangoi Padilha" <rspbr@hotmail.com> wrote in message
news:at0s23$8p3$1@rogue.oti.com...
> Hi,
>
> I'm trying to implement an editor that shows a figure for a particular
> element of a model and a label for that figure.
>
> The problem is that I wished that the label could be manipulated as an
> independent figure - the user should be able to move it around separately
> from the "main" figure, allowing him to better place the labels to avoid
> collisions.
>
> Even better than that: Would it be possible to have that label to act like
a
> connection figure? I mean, the user can modify it but when the main figure
> is selected the label is unselected?
>
> I was trying to "brute force" adding those extra labels by overriding the
> add(IEditorPart) method, but without success. Anybody has any idea on the
> right way of doing this?
>
> Thanks for any help,
> Ricardo
>
>
> ---
>
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.427 / Virus Database: 240 - Release Date: 6/12/2002
>
>
Re: Is it possible to have two figures attached to the same model? [message #48576 is a reply to message #48517] Mon, 09 December 2002 14:13 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: rspbr.hotmail.com

Hi,

> Can you give a better description of what you want to do? Instead of
> describing the behavior completely, maybe there is another program that
does
> the same thing.

Well, I'm working in a complete Petri net editor for Eclipse. Normally,
places and transitions have a label associated to them, but this label has
to be "moveable" so users can place them out of the arcs' way.

The problem is that I'm having trouble adding this label as an independent
figure. For example, the idea is to have a figure (EllipseFigure) that
represents the place and a figure (Label) to display the place's label.

The question is: how to make this label independent from the ellipse, even
if they do refer to the same model?

At a later time, I wish that the label would behave like connections. That
means: user can select it directly and move it around, but when a marquee
selection is made, the labels are excluded.

That way I could update the position of the label each time that the ellipse
is moved around. The label would have then a "relative" position to the
ellipse instead of an "absolute" position to the canvas.

Thanks again for any help,
Ricardo


---

Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.427 / Virus Database: 240 - Release Date: 6/12/2002
Re: Is it possible to have two figures attached to the same model? [message #48606 is a reply to message #48576] Mon, 09 December 2002 20:23 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: hudsonr.us.eye-bee-em.com

I've had to do the same thing in an Editor. Basically, I made the labels
child EditParts to the things which they label (connection or node). It
isn't really a child in the model, so the EditPart returns a bogus list of
model children (one for each label), which are simply strings. You could
make something more elaborate, but I didn't see the point.

List getModelChildren() {
ArrayList list = new ArrayList();
list.add("Source label");
list.add("Target label");
return list;
}

Now, for each item in the List, and you may have just one, an EditPart needs
to get created. So, you can override createEditPart(Object model) in that
EditPart, and instantiate a LabelEditPart, passing it the real model (the
node or connection), and perhaps the label type if you display 2 or more
labels.

If you want to prevent these EditParts from getting found by Marquee, please
open a bugzilla, and any suggestions are welcome.

"Ricardo Sangoi Padilha" <rspbr@hotmail.com> wrote in message
news:at2pr9$a19$1@rogue.oti.com...
> Hi,
>
> > Can you give a better description of what you want to do? Instead of
> > describing the behavior completely, maybe there is another program that
> does
> > the same thing.
>
> Well, I'm working in a complete Petri net editor for Eclipse. Normally,
> places and transitions have a label associated to them, but this label has
> to be "moveable" so users can place them out of the arcs' way.
>
> The problem is that I'm having trouble adding this label as an independent
> figure. For example, the idea is to have a figure (EllipseFigure) that
> represents the place and a figure (Label) to display the place's label.
>
> The question is: how to make this label independent from the ellipse, even
> if they do refer to the same model?
>
> At a later time, I wish that the label would behave like connections. That
> means: user can select it directly and move it around, but when a marquee
> selection is made, the labels are excluded.
>
> That way I could update the position of the label each time that the
ellipse
> is moved around. The label would have then a "relative" position to the
> ellipse instead of an "absolute" position to the canvas.
>
> Thanks again for any help,
> Ricardo
>
>
> ---
>
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.427 / Virus Database: 240 - Release Date: 6/12/2002
>
>
Re: Is it possible to have two figures attached to the same model? [message #49356 is a reply to message #48606] Thu, 12 December 2002 17:49 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: rspbr.hotmail.com

Hi,

Thanks for the help, but (correct me if I'm wrong) this method creates the
label _inside_ the "parent" figure (in terms of painting). What I had in
mind was something like a label that could be moved outside the boundaries
of the parent figure and still be visible.

Any suggestions?

"Randy Hudson" <hudsonr@us.eye-bee-em.com> wrote in message
news:at3fhc$m7k$1@rogue.oti.com...
> I've had to do the same thing in an Editor. Basically, I made the labels
> child EditParts to the things which they label (connection or node). It
> isn't really a child in the model, so the EditPart returns a bogus list of
> model children (one for each label), which are simply strings. You could
> make something more elaborate, but I didn't see the point.
>
> List getModelChildren() {
> ArrayList list = new ArrayList();
> list.add("Source label");
> list.add("Target label");
> return list;
> }
>
> Now, for each item in the List, and you may have just one, an EditPart
needs
> to get created. So, you can override createEditPart(Object model) in that
> EditPart, and instantiate a LabelEditPart, passing it the real model (the
> node or connection), and perhaps the label type if you display 2 or more
> labels.
>
> If you want to prevent these EditParts from getting found by Marquee,
please
> open a bugzilla, and any suggestions are welcome.
>
> "Ricardo Sangoi Padilha" <rspbr@hotmail.com> wrote in message
> news:at2pr9$a19$1@rogue.oti.com...
> > Hi,
> >
> > > Can you give a better description of what you want to do? Instead of
> > > describing the behavior completely, maybe there is another program
that
> > does
> > > the same thing.
> >
> > Well, I'm working in a complete Petri net editor for Eclipse. Normally,
> > places and transitions have a label associated to them, but this label
has
> > to be "moveable" so users can place them out of the arcs' way.
> >
> > The problem is that I'm having trouble adding this label as an
independent
> > figure. For example, the idea is to have a figure (EllipseFigure) that
> > represents the place and a figure (Label) to display the place's label.
> >
> > The question is: how to make this label independent from the ellipse,
even
> > if they do refer to the same model?
> >
> > At a later time, I wish that the label would behave like connections.
That
> > means: user can select it directly and move it around, but when a
marquee
> > selection is made, the labels are excluded.
> >
> > That way I could update the position of the label each time that the
> ellipse
> > is moved around. The label would have then a "relative" position to the
> > ellipse instead of an "absolute" position to the canvas.
> >
> > Thanks again for any help,
> > Ricardo
> >
> >
> > ---
> >
> > Checked by AVG anti-virus system (http://www.grisoft.com).
> > Version: 6.0.427 / Virus Database: 240 - Release Date: 6/12/2002
> >
> >
>
>


---

Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.427 / Virus Database: 240 - Release Date: 6/12/2002
Re: Is it possible to have two figures attached to the same model? [message #49446 is a reply to message #49356] Fri, 13 December 2002 09:28 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: hudsonr.us.eye-bee-em.com

For a connection, children can be anywhere, and the connections bounds will
automatically include the children.

For a node, you could do some work to make the children EditParts have
Figures that are *not* children. You would have to override
addChildVisual(), removeChildVisual(). Perhaps these methods would place
the labels on another layer, instead of inside the contents pane. You need
to be sure that these figures are removed when the EditPart is removed.
This won't happen automatically, since the figures aren't contained, so you
would have to override removeNotify().

"Ricardo Sangoi Padilha" <rspbr@hotmail.com> wrote in message
news:atb3js$k0$1@rogue.oti.com...
> Hi,
>
> Thanks for the help, but (correct me if I'm wrong) this method creates the
> label _inside_ the "parent" figure (in terms of painting). What I had in
> mind was something like a label that could be moved outside the boundaries
> of the parent figure and still be visible.
>
> Any suggestions?
>
> "Randy Hudson" <hudsonr@us.eye-bee-em.com> wrote in message
> news:at3fhc$m7k$1@rogue.oti.com...
> > I've had to do the same thing in an Editor. Basically, I made the
labels
> > child EditParts to the things which they label (connection or node). It
> > isn't really a child in the model, so the EditPart returns a bogus list
of
> > model children (one for each label), which are simply strings. You
could
> > make something more elaborate, but I didn't see the point.
> >
> > List getModelChildren() {
> > ArrayList list = new ArrayList();
> > list.add("Source label");
> > list.add("Target label");
> > return list;
> > }
> >
> > Now, for each item in the List, and you may have just one, an EditPart
> needs
> > to get created. So, you can override createEditPart(Object model) in
that
> > EditPart, and instantiate a LabelEditPart, passing it the real model
(the
> > node or connection), and perhaps the label type if you display 2 or more
> > labels.
> >
> > If you want to prevent these EditParts from getting found by Marquee,
> please
> > open a bugzilla, and any suggestions are welcome.
> >
> > "Ricardo Sangoi Padilha" <rspbr@hotmail.com> wrote in message
> > news:at2pr9$a19$1@rogue.oti.com...
> > > Hi,
> > >
> > > > Can you give a better description of what you want to do? Instead of
> > > > describing the behavior completely, maybe there is another program
> that
> > > does
> > > > the same thing.
> > >
> > > Well, I'm working in a complete Petri net editor for Eclipse.
Normally,
> > > places and transitions have a label associated to them, but this label
> has
> > > to be "moveable" so users can place them out of the arcs' way.
> > >
> > > The problem is that I'm having trouble adding this label as an
> independent
> > > figure. For example, the idea is to have a figure (EllipseFigure) that
> > > represents the place and a figure (Label) to display the place's
label.
> > >
> > > The question is: how to make this label independent from the ellipse,
> even
> > > if they do refer to the same model?
> > >
> > > At a later time, I wish that the label would behave like connections.
> That
> > > means: user can select it directly and move it around, but when a
> marquee
> > > selection is made, the labels are excluded.
> > >
> > > That way I could update the position of the label each time that the
> > ellipse
> > > is moved around. The label would have then a "relative" position to
the
> > > ellipse instead of an "absolute" position to the canvas.
> > >
> > > Thanks again for any help,
> > > Ricardo
> > >
> > >
> > > ---
> > >
> > > Checked by AVG anti-virus system (http://www.grisoft.com).
> > > Version: 6.0.427 / Virus Database: 240 - Release Date: 6/12/2002
> > >
> > >
> >
> >
>
>
> ---
>
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.427 / Virus Database: 240 - Release Date: 6/12/2002
>
>
Re: Is it possible to have two figures attached to the same model? [message #49475 is a reply to message #48606] Fri, 13 December 2002 17:21 Go to previous messageGo to next message
Eclipse UserFriend
Hi!

I have the same need in my project.

I have written a ConnectionLabelEditPart that creates a draw2d.Label and
added a getModelChildren as you said below that returns a List of one
String.

Running this code I get a call to my EditPartFactory with this string as
model and I returned a new ConnectionLabelEditPart here that get displayed
in the window.

But then I'm confused. Where can I override a createEditPart? This method is
not part of EditPart. Do you mean createChild of the parent EditPart (a
ConnectionEditPart in my case) and filter away this bogus model from getting
to the EditPartFactory?
This works for me, but I get an error later if I do setModel of the new
ConnectionLabelEditPart to the ConnectionEditPart model.

/Dag
-
"Randy Hudson" <hudsonr@us.eye-bee-em.com> skrev i meddelandet
news:at3fhc$m7k$1@rogue.oti.com...
> I've had to do the same thing in an Editor. Basically, I made the labels
> child EditParts to the things which they label (connection or node). It
> isn't really a child in the model, so the EditPart returns a bogus list of
> model children (one for each label), which are simply strings. You could
> make something more elaborate, but I didn't see the point.
>
> List getModelChildren() {
> ArrayList list = new ArrayList();
> list.add("Source label");
> list.add("Target label");
> return list;
> }
>
> Now, for each item in the List, and you may have just one, an EditPart
needs
> to get created. So, you can override createEditPart(Object model) in that
> EditPart, and instantiate a LabelEditPart, passing it the real model (the
> node or connection), and perhaps the label type if you display 2 or more
> labels.
>
> If you want to prevent these EditParts from getting found by Marquee,
please
> open a bugzilla, and any suggestions are welcome.
>
> "Ricardo Sangoi Padilha" <rspbr@hotmail.com> wrote in message
> news:at2pr9$a19$1@rogue.oti.com...
> > Hi,
> >
> > > Can you give a better description of what you want to do? Instead of
> > > describing the behavior completely, maybe there is another program
that
> > does
> > > the same thing.
> >
> > Well, I'm working in a complete Petri net editor for Eclipse. Normally,
> > places and transitions have a label associated to them, but this label
has
> > to be "moveable" so users can place them out of the arcs' way.
> >
> > The problem is that I'm having trouble adding this label as an
independent
> > figure. For example, the idea is to have a figure (EllipseFigure) that
> > represents the place and a figure (Label) to display the place's label.
> >
> > The question is: how to make this label independent from the ellipse,
even
> > if they do refer to the same model?
> >
> > At a later time, I wish that the label would behave like connections.
That
> > means: user can select it directly and move it around, but when a
marquee
> > selection is made, the labels are excluded.
> >
> > That way I could update the position of the label each time that the
> ellipse
> > is moved around. The label would have then a "relative" position to the
> > ellipse instead of an "absolute" position to the canvas.
> >
> > Thanks again for any help,
> > Ricardo
> >
> >
> > ---
> >
> > Checked by AVG anti-virus system (http://www.grisoft.com).
> > Version: 6.0.427 / Virus Database: 240 - Release Date: 6/12/2002
> >
> >
>
>
Re: Is it possible to have two figures attached to the same model? [message #49505 is a reply to message #49475] Fri, 13 December 2002 17:39 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: hudsonr.us.eye-bee-em.com

"Dag Rende" <dag.rende@applied.se> wrote in message
news:atdm5o$gag$1@rogue.oti.com...
> Hi!
>
> I have the same need in my project.
>
> I have written a ConnectionLabelEditPart that creates a draw2d.Label and
> added a getModelChildren as you said below that returns a List of one
> String.
>
> Running this code I get a call to my EditPartFactory with this string as
> model and I returned a new ConnectionLabelEditPart here that get displayed
> in the window.
>
> But then I'm confused. Where can I override a createEditPart? This method
is
> not part of EditPart. Do you mean createChild of the parent EditPart (a
> ConnectionEditPart in my case) and filter away this bogus model from
getting
> to the EditPartFactory?
> This works for me, but I get an error later if I do setModel of the new
> ConnectionLabelEditPart to the ConnectionEditPart model.

Yes, I meant createChild(). What error do you get?
You generally should set the model immediately on the LabelEditPart.

> /Dag
> -
> "Randy Hudson" <hudsonr@us.eye-bee-em.com> skrev i meddelandet
> news:at3fhc$m7k$1@rogue.oti.com...
> > I've had to do the same thing in an Editor. Basically, I made the
labels
> > child EditParts to the things which they label (connection or node). It
> > isn't really a child in the model, so the EditPart returns a bogus list
of
> > model children (one for each label), which are simply strings. You
could
> > make something more elaborate, but I didn't see the point.
> >
> > List getModelChildren() {
> > ArrayList list = new ArrayList();
> > list.add("Source label");
> > list.add("Target label");
> > return list;
> > }
> >
> > Now, for each item in the List, and you may have just one, an EditPart
> needs
> > to get created. So, you can override createEditPart(Object model) in
that
> > EditPart, and instantiate a LabelEditPart, passing it the real model
(the
> > node or connection), and perhaps the label type if you display 2 or more
> > labels.
> >
> > If you want to prevent these EditParts from getting found by Marquee,
> please
> > open a bugzilla, and any suggestions are welcome.
> >
> > "Ricardo Sangoi Padilha" <rspbr@hotmail.com> wrote in message
> > news:at2pr9$a19$1@rogue.oti.com...
> > > Hi,
> > >
> > > > Can you give a better description of what you want to do? Instead of
> > > > describing the behavior completely, maybe there is another program
> that
> > > does
> > > > the same thing.
> > >
> > > Well, I'm working in a complete Petri net editor for Eclipse.
Normally,
> > > places and transitions have a label associated to them, but this label
> has
> > > to be "moveable" so users can place them out of the arcs' way.
> > >
> > > The problem is that I'm having trouble adding this label as an
> independent
> > > figure. For example, the idea is to have a figure (EllipseFigure) that
> > > represents the place and a figure (Label) to display the place's
label.
> > >
> > > The question is: how to make this label independent from the ellipse,
> even
> > > if they do refer to the same model?
> > >
> > > At a later time, I wish that the label would behave like connections.
> That
> > > means: user can select it directly and move it around, but when a
> marquee
> > > selection is made, the labels are excluded.
> > >
> > > That way I could update the position of the label each time that the
> > ellipse
> > > is moved around. The label would have then a "relative" position to
the
> > > ellipse instead of an "absolute" position to the canvas.
> > >
> > > Thanks again for any help,
> > > Ricardo
> > >
> > >
> > > ---
> > >
> > > Checked by AVG anti-virus system (http://www.grisoft.com).
> > > Version: 6.0.427 / Virus Database: 240 - Release Date: 6/12/2002
> > >
> > >
> >
> >
>
>
Re: Is it possible to have two figures attached to the same model? [message #50308 is a reply to message #49505] Tue, 17 December 2002 11:32 Go to previous messageGo to next message
Eclipse UserFriend
OK. Now I think I know how to do this.

In MyConnectionEditPart i override getModelChildren() and createChild(Object
model).
I let getModelChildren return a List of a unique object - a string for
example. In createChild, i check if the model is the unique object above,
and create MyConnectionLabelEditPart and set its model. Here it is important
to not use the same model as for the parent (the MyConnectionEditPart),
because GEF keeps a map of all models and their corresponding EditParts. If
I use the same model for two edit parts GEF will not be able to find the
right EditPart later on. In my test code i simply wrap the
MyConnectionEditPart model in an array to get a unique object of it, and now
it works.

The above code is only a proof of concept, and places the label in the wrong
position relative to the connection figure.
What is left now to design is handling of placement of connection label
figures, policies for moving them with the mouse, updating their text as the
main model changes etc. I think the main ConnectionEditPart may take the
reponsibility to create the label part and connect them with a Locator
object that has an offset from midpoint o any end point so that the labels
will be placed relative to the right part of the connection figure. The
moving policy could then change the locator offset when the user uses the
mose on the label.

/Dag
------------
Here is my test code for the above methods and the label edit part class:

in MyCoonectionEditPart:
/**
* fake model children for the label
*/
public List getModelChildren() {
ArrayList list = new ArrayList();
list.add("Connection label");
return list;
}

/**
* @see org.eclipse.gef.editparts.AbstractEditPart#createChild(Objec t)
*/
protected EditPart createChild(Object model) {
if (model instanceof String
&& "Connection label".equals(model)) {
EditPart editPart = new ConnectionLabelEditPart();
editPart.setModel(new Object[] {getModel()});
return editPart;
}
return super.createChild(model);
}

---------------------
public class AssociationLabelEditPart extends AbstractGraphicalEditPart {
protected IFigure createFigure() {
MyConnectionModel[] model = (MyConnectionModel[])getModel();
IFigure labelFigure = new Label(model[0].getName());
labelFigure.setOpaque(true);
return labelFigure;
}

protected void createEditPolicies() {
}
}

"Randy Hudson" <hudsonr@us.eye-bee-em.com> skrev i meddelandet
news:atdnbk$gtp$1@rogue.oti.com...
>
> "Dag Rende" <dag.rende@applied.se> wrote in message
> news:atdm5o$gag$1@rogue.oti.com...
> > Hi!
> >
> > I have the same need in my project.
> >
> > I have written a ConnectionLabelEditPart that creates a draw2d.Label and
> > added a getModelChildren as you said below that returns a List of one
> > String.
> >
> > Running this code I get a call to my EditPartFactory with this string as
> > model and I returned a new ConnectionLabelEditPart here that get
displayed
> > in the window.
> >
> > But then I'm confused. Where can I override a createEditPart? This
method
> is
> > not part of EditPart. Do you mean createChild of the parent EditPart (a
> > ConnectionEditPart in my case) and filter away this bogus model from
> getting
> > to the EditPartFactory?
> > This works for me, but I get an error later if I do setModel of the new
> > ConnectionLabelEditPart to the ConnectionEditPart model.
>
> Yes, I meant createChild(). What error do you get?
> You generally should set the model immediately on the LabelEditPart.
>
> > /Dag
> > -
> > "Randy Hudson" <hudsonr@us.eye-bee-em.com> skrev i meddelandet
> > news:at3fhc$m7k$1@rogue.oti.com...
> > > I've had to do the same thing in an Editor. Basically, I made the
> labels
> > > child EditParts to the things which they label (connection or node).
It
> > > isn't really a child in the model, so the EditPart returns a bogus
list
> of
> > > model children (one for each label), which are simply strings. You
> could
> > > make something more elaborate, but I didn't see the point.
> > >
> > > List getModelChildren() {
> > > ArrayList list = new ArrayList();
> > > list.add("Source label");
> > > list.add("Target label");
> > > return list;
> > > }
> > >
> > > Now, for each item in the List, and you may have just one, an EditPart
> > needs
> > > to get created. So, you can override createEditPart(Object model) in
> that
> > > EditPart, and instantiate a LabelEditPart, passing it the real model
> (the
> > > node or connection), and perhaps the label type if you display 2 or
more
> > > labels.
> > >
> > > If you want to prevent these EditParts from getting found by Marquee,
> > please
> > > open a bugzilla, and any suggestions are welcome.
> > >
> > > "Ricardo Sangoi Padilha" <rspbr@hotmail.com> wrote in message
> > > news:at2pr9$a19$1@rogue.oti.com...
> > > > Hi,
> > > >
> > > > > Can you give a better description of what you want to do? Instead
of
> > > > > describing the behavior completely, maybe there is another program
> > that
> > > > does
> > > > > the same thing.
> > > >
> > > > Well, I'm working in a complete Petri net editor for Eclipse.
> Normally,
> > > > places and transitions have a label associated to them, but this
label
> > has
> > > > to be "moveable" so users can place them out of the arcs' way.
> > > >
> > > > The problem is that I'm having trouble adding this label as an
> > independent
> > > > figure. For example, the idea is to have a figure (EllipseFigure)
that
> > > > represents the place and a figure (Label) to display the place's
> label.
> > > >
> > > > The question is: how to make this label independent from the
ellipse,
> > even
> > > > if they do refer to the same model?
> > > >
> > > > At a later time, I wish that the label would behave like
connections.
> > That
> > > > means: user can select it directly and move it around, but when a
> > marquee
> > > > selection is made, the labels are excluded.
> > > >
> > > > That way I could update the position of the label each time that the
> > > ellipse
> > > > is moved around. The label would have then a "relative" position to
> the
> > > > ellipse instead of an "absolute" position to the canvas.
> > > >
> > > > Thanks again for any help,
> > > > Ricardo
> > > >
> > > >
> > > > ---
> > > >
> > > > Checked by AVG anti-virus system (http://www.grisoft.com).
> > > > Version: 6.0.427 / Virus Database: 240 - Release Date: 6/12/2002
> > > >
> > > >
> > >
> > >
> >
> >
>
>
Re: Is it possible to have two figures attached to the same model? [message #50454 is a reply to message #50308] Wed, 18 December 2002 12:27 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: hudsonr.us.eye-bee-em.com

"Dag Rende" <dag.rende@applied.se> wrote in message
news:atnj4v$fj2$1@rogue.oti.com...
> OK. Now I think I know how to do this.
>
> In MyConnectionEditPart i override getModelChildren() and
createChild(Object
> model).
> I let getModelChildren return a List of a unique object - a string for
> example. In createChild, i check if the model is the unique object above,
> and create MyConnectionLabelEditPart and set its model. Here it is
important
> to not use the same model as for the parent (the MyConnectionEditPart),
> because GEF keeps a map of all models and their corresponding EditParts.
If

Actually, if one of the two EditParts does not require connection support
(it is neither the source or target of connections), then you can prevent
that EditPart from registering its model by overriding the appropriate
method to do nothing. The only reason EditParts are registered by model is
so a Connection can find its source/target. This will remove the collision
you describe, and you can use the same model for both.

> I use the same model for two edit parts GEF will not be able to find the
> right EditPart later on. In my test code i simply wrap the
> MyConnectionEditPart model in an array to get a unique object of it, and
now
> it works.
>
> The above code is only a proof of concept, and places the label in the
wrong
> position relative to the connection figure.
> What is left now to design is handling of placement of connection label
> figures, policies for moving them with the mouse, updating their text as
the
> main model changes etc. I think the main ConnectionEditPart may take the
> reponsibility to create the label part and connect them with a Locator
> object that has an offset from midpoint o any end point so that the labels
> will be placed relative to the right part of the connection figure. The
> moving policy could then change the locator offset when the user uses the
> mose on the label.

We provide half of this already in ConnectionEndpointLocator. This locator
supports an offset from the node (u distance), and an offset from the
connection (v distance). You would still have to write your own
NonResizableEditPolicy to interpret "move" requests, and re-calculate the
new U and V values. This would imply that you have the inverse algorithm of
our ConnecitonEndpointLocator . . . good luck! Feel free to submit anything
you come up with.

>
> /Dag
> ------------
> Here is my test code for the above methods and the label edit part class:
>
> in MyCoonectionEditPart:
> /**
> * fake model children for the label
> */
> public List getModelChildren() {
> ArrayList list = new ArrayList();
> list.add("Connection label");
> return list;
> }
>
> /**
> * @see org.eclipse.gef.editparts.AbstractEditPart#createChild(Objec t)
> */
> protected EditPart createChild(Object model) {
> if (model instanceof String
> && "Connection label".equals(model)) {
> EditPart editPart = new ConnectionLabelEditPart();
> editPart.setModel(new Object[] {getModel()});
> return editPart;
> }
> return super.createChild(model);
> }
>
> ---------------------
> public class AssociationLabelEditPart extends AbstractGraphicalEditPart {
> protected IFigure createFigure() {
> MyConnectionModel[] model = (MyConnectionModel[])getModel();
> IFigure labelFigure = new Label(model[0].getName());
> labelFigure.setOpaque(true);
> return labelFigure;
> }
>
> protected void createEditPolicies() {
> }
> }
>
> "Randy Hudson" <hudsonr@us.eye-bee-em.com> skrev i meddelandet
> news:atdnbk$gtp$1@rogue.oti.com...
> >
> > "Dag Rende" <dag.rende@applied.se> wrote in message
> > news:atdm5o$gag$1@rogue.oti.com...
> > > Hi!
> > >
> > > I have the same need in my project.
> > >
> > > I have written a ConnectionLabelEditPart that creates a draw2d.Label
and
> > > added a getModelChildren as you said below that returns a List of one
> > > String.
> > >
> > > Running this code I get a call to my EditPartFactory with this string
as
> > > model and I returned a new ConnectionLabelEditPart here that get
> displayed
> > > in the window.
> > >
> > > But then I'm confused. Where can I override a createEditPart? This
> method
> > is
> > > not part of EditPart. Do you mean createChild of the parent EditPart
(a
> > > ConnectionEditPart in my case) and filter away this bogus model from
> > getting
> > > to the EditPartFactory?
> > > This works for me, but I get an error later if I do setModel of the
new
> > > ConnectionLabelEditPart to the ConnectionEditPart model.
> >
> > Yes, I meant createChild(). What error do you get?
> > You generally should set the model immediately on the LabelEditPart.
> >
> > > /Dag
> > > -
> > > "Randy Hudson" <hudsonr@us.eye-bee-em.com> skrev i meddelandet
> > > news:at3fhc$m7k$1@rogue.oti.com...
> > > > I've had to do the same thing in an Editor. Basically, I made the
> > labels
> > > > child EditParts to the things which they label (connection or node).
> It
> > > > isn't really a child in the model, so the EditPart returns a bogus
> list
> > of
> > > > model children (one for each label), which are simply strings. You
> > could
> > > > make something more elaborate, but I didn't see the point.
> > > >
> > > > List getModelChildren() {
> > > > ArrayList list = new ArrayList();
> > > > list.add("Source label");
> > > > list.add("Target label");
> > > > return list;
> > > > }
> > > >
> > > > Now, for each item in the List, and you may have just one, an
EditPart
> > > needs
> > > > to get created. So, you can override createEditPart(Object model) in
> > that
> > > > EditPart, and instantiate a LabelEditPart, passing it the real model
> > (the
> > > > node or connection), and perhaps the label type if you display 2 or
> more
> > > > labels.
> > > >
> > > > If you want to prevent these EditParts from getting found by
Marquee,
> > > please
> > > > open a bugzilla, and any suggestions are welcome.
> > > >
> > > > "Ricardo Sangoi Padilha" <rspbr@hotmail.com> wrote in message
> > > > news:at2pr9$a19$1@rogue.oti.com...
> > > > > Hi,
> > > > >
> > > > > > Can you give a better description of what you want to do?
Instead
> of
> > > > > > describing the behavior completely, maybe there is another
program
> > > that
> > > > > does
> > > > > > the same thing.
> > > > >
> > > > > Well, I'm working in a complete Petri net editor for Eclipse.
> > Normally,
> > > > > places and transitions have a label associated to them, but this
> label
> > > has
> > > > > to be "moveable" so users can place them out of the arcs' way.
> > > > >
> > > > > The problem is that I'm having trouble adding this label as an
> > > independent
> > > > > figure. For example, the idea is to have a figure (EllipseFigure)
> that
> > > > > represents the place and a figure (Label) to display the place's
> > label.
> > > > >
> > > > > The question is: how to make this label independent from the
> ellipse,
> > > even
> > > > > if they do refer to the same model?
> > > > >
> > > > > At a later time, I wish that the label would behave like
> connections.
> > > That
> > > > > means: user can select it directly and move it around, but when a
> > > marquee
> > > > > selection is made, the labels are excluded.
> > > > >
> > > > > That way I could update the position of the label each time that
the
> > > > ellipse
> > > > > is moved around. The label would have then a "relative" position
to
> > the
> > > > > ellipse instead of an "absolute" position to the canvas.
> > > > >
> > > > > Thanks again for any help,
> > > > > Ricardo
> > > > >
> > > > >
> > > > > ---
> > > > >
> > > > > Checked by AVG anti-virus system (http://www.grisoft.com).
> > > > > Version: 6.0.427 / Virus Database: 240 - Release Date: 6/12/2002
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >
> >
> >
>
>
Re: Is it possible to have two figures attached to the same model? [message #53419 is a reply to message #50454] Fri, 10 January 2003 10:00 Go to previous messageGo to next message
Eclipse UserFriend
Hi again!

I
Re: Is it possible to have two figures attached to the same model? [message #59595 is a reply to message #53419] Wed, 29 January 2003 11:42 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: none.us.ibm.com

Selecting just the label is useful in programs like Rational Rose, where the
user can say that he doesn't want to see the multiplicity label by deleting
it.

Go back and read my original suggestions. Making the labels children of the
connection is the easiest way to do this.
Re: Is it possible to have two figures attached to the same model? [message #59616 is a reply to message #59595] Wed, 29 January 2003 11:43 Go to previous message
Eclipse UserFriend
Originally posted by: none.us.ibm.com

"Randy Hudson" <none@us.ibm.com> wrote in message
news:b18v93$2lh$1@rogue.oti.com...
> Selecting just the label is useful in programs like Rational Rose, where
the
> user can say that he doesn't want to see the multiplicity label by
deleting
> it.
>
> Go back and read my original suggestions. Making the labels children of
the
> connection is the easiest way to do this.
>
>

To clarify "this" == what you are describing, as well as the behavior of
Rational Rose. i.e. either way.
Previous Topic:Drag from Package Explorer View/Hierarchy View in JDT to Graph Editor
Next Topic:Problem with logic editor
Goto Forum:
  


Current Time: Mon Jul 21 21:48:22 EDT 2025

Powered by FUDForum. Page generated in 0.11821 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top