Home » Eclipse Projects » GEF » How to add edit part to a PolyLineConnection
How to add edit part to a PolyLineConnection [message #20712] |
Wed, 25 September 2002 12:06  |
Eclipse User |
|
|
|
Hi,
In the Draw2D help, it has an example of adding a Label (IFigure) to a
PolyLineConnection.
<From the help >
PolylineConnection conn = new PolylineConnection();
Label label = new Label ("Midpoint");
label.setOpaque(true);
label.setBackgroundColor(ColorConstants.buttonLightest);
label.setBorder(new LineBorder());
conn.add(label, new MidpointLocator (conn, 0));
I would like to know how to add an edit Part (e.g. LogicLabelEditPart) to a
PolyLineConnection?
LogicLabelEditPart is NOTan implementation of IFigure, but its
createFigure() cretains a Label.
I appreciate if someone can tell me how to add the logicLabelEditPart to the
connection.
Thanks.
Sam
|
|
| | | |
Re: How to add edit part to a PolyLineConnection [message #21153 is a reply to message #21031] |
Thu, 26 September 2002 10:45   |
Eclipse User |
|
|
|
Actually, I want to add a LogicalLabelEdit in the middle of the
WireEditPart.
You are correct that WireEditPart creates the Bendable wire
(PolylineConnection) in method createFigure().
But when I call getModelChildren(), it returns an empty list. How can I add
an LogicalLabelEdit in the middle of the WireEditPart? and when users move
the Wire, the logical label move along with it?
Thank you.
"Randy Hudson" <hudsonr@us.eye-bee-em.com> wrote in message
news:amtoh3$6qj$1@rogue.oti.com...
> I don't understand the question. The ConnectionEditPart creates the
> PolylineConnection. Not vice versa. You "node" EditPart should create
> ConnectionEditParts. Put a breakpoint in the constructor for
> ConnectionEditPart.
>
> "Sam Cheung" <scheung@novarra.com> wrote in message
> news:amsoeu$l63$1@rogue.oti.com...
> > Thanks for your help. I want an editable label on the connection.
> > How can I get the ConnectionEditPart from a polyline connection. I can't
> > find such a method on the javadoc of polylineConnection.
> >
> > "Randy Hudson" <hudsonr@us.eye-bee-em.com> wrote in message
> > news:amsm5t$jie$1@rogue.oti.com...
> > > Treat the ConnectionEditPart as a container. Containers return
> > > getModelChildren(), which would then be used to create an EditPart for
> > each
> > > label on the connection. If you want to interact with the labels, you
> > > should represent them with EditParts.
> > >
> > > If you just want to see a label on the connection, do what the draw2d
> > > example does. The ConnectionEdtiPart would place the label.
> > >
> > > "Sam Cheung" <scheung@novarra.com> wrote in message
> > > news:amslr5$jb9$1@rogue.oti.com...
> > > > Hi,
> > > >
> > > > In the Draw2D help, it has an example of adding a Label (IFigure) to
a
> > > > PolyLineConnection.
> > > > <From the help >
> > > >
> > > > PolylineConnection conn = new PolylineConnection();
> > > >
> > > > Label label = new Label ("Midpoint");
> > > > label.setOpaque(true);
> > > > label.setBackgroundColor(ColorConstants.buttonLightest);
> > > > label.setBorder(new LineBorder());
> > > > conn.add(label, new MidpointLocator (conn, 0));
> > > >
> > > > I would like to know how to add an edit Part (e.g.
LogicLabelEditPart)
> > to
> > > a
> > > > PolyLineConnection?
> > > > LogicLabelEditPart is NOTan implementation of IFigure, but its
> > > > createFigure() cretains a Label.
> > > > I appreciate if someone can tell me how to add the
logicLabelEditPart
> to
> > > the
> > > > connection.
> > > >
> > > > Thanks.
> > > > Sam
> > > >
> > > >
> > > >
> > > >
> > >
> > >
> >
> >
>
>
|
|
|
Re: How to add edit part to a PolyLineConnection [message #21169 is a reply to message #21153] |
Thu, 26 September 2002 10:52   |
Eclipse User |
|
|
|
Originally posted by: hudsonr.us.eye-bee-em.com
"Sam Cheung" <scheung@novarra.com> wrote in message
news:amv5da$umc$1@rogue.oti.com...
> Actually, I want to add a LogicalLabelEdit in the middle of the
> WireEditPart.
> You are correct that WireEditPart creates the Bendable wire
> (PolylineConnection) in method createFigure().
>
> But when I call getModelChildren(), it returns an empty list. How can I
add
You'd have to change the Wire model and WireEditPart for that. It sounds
like a simple change. You might want to add a label to Wires in the
constructor, since support label creation will take some extra effort.
> an LogicalLabelEdit in the middle of the WireEditPart? and when users move
> the Wire, the logical label move along with it?
Use a new ConnectionLocator(conn). Set that as the constraint for the
*LAYOUT*, not the Connection Router. A connection has two objects that do
two separate things. Routing comes first, then laying out of children.
conn.getLayout().setConstraint(label, new ConnectionLocator(conn));
>
> Thank you.
>
> "Randy Hudson" <hudsonr@us.eye-bee-em.com> wrote in message
> news:amtoh3$6qj$1@rogue.oti.com...
> > I don't understand the question. The ConnectionEditPart creates the
> > PolylineConnection. Not vice versa. You "node" EditPart should create
> > ConnectionEditParts. Put a breakpoint in the constructor for
> > ConnectionEditPart.
> >
> > "Sam Cheung" <scheung@novarra.com> wrote in message
> > news:amsoeu$l63$1@rogue.oti.com...
> > > Thanks for your help. I want an editable label on the connection.
> > > How can I get the ConnectionEditPart from a polyline connection. I
can't
> > > find such a method on the javadoc of polylineConnection.
> > >
> > > "Randy Hudson" <hudsonr@us.eye-bee-em.com> wrote in message
> > > news:amsm5t$jie$1@rogue.oti.com...
> > > > Treat the ConnectionEditPart as a container. Containers return
> > > > getModelChildren(), which would then be used to create an EditPart
for
> > > each
> > > > label on the connection. If you want to interact with the labels,
you
> > > > should represent them with EditParts.
> > > >
> > > > If you just want to see a label on the connection, do what the
draw2d
> > > > example does. The ConnectionEdtiPart would place the label.
> > > >
> > > > "Sam Cheung" <scheung@novarra.com> wrote in message
> > > > news:amslr5$jb9$1@rogue.oti.com...
> > > > > Hi,
> > > > >
> > > > > In the Draw2D help, it has an example of adding a Label (IFigure)
to
> a
> > > > > PolyLineConnection.
> > > > > <From the help >
> > > > >
> > > > > PolylineConnection conn = new PolylineConnection();
> > > > >
> > > > > Label label = new Label ("Midpoint");
> > > > > label.setOpaque(true);
> > > > > label.setBackgroundColor(ColorConstants.buttonLightest);
> > > > > label.setBorder(new LineBorder());
> > > > > conn.add(label, new MidpointLocator (conn, 0));
> > > > >
> > > > > I would like to know how to add an edit Part (e.g.
> LogicLabelEditPart)
> > > to
> > > > a
> > > > > PolyLineConnection?
> > > > > LogicLabelEditPart is NOTan implementation of IFigure, but its
> > > > > createFigure() cretains a Label.
> > > > > I appreciate if someone can tell me how to add the
> logicLabelEditPart
> > to
> > > > the
> > > > > connection.
> > > > >
> > > > > Thanks.
> > > > > Sam
> > > > >
> > > > >
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >
> >
> >
>
>
|
|
|
Re: How to add edit part to a PolyLineConnection [message #21291 is a reply to message #21169] |
Thu, 26 September 2002 20:15   |
Eclipse User |
|
|
|
Sorry for keeping bothering you with this.
But if I want my label to be editable, I can't just add an label in teh
WireEditPart, I need to add a LogicLabelEditPart().
I can create the LogicLabelEditPart in the constructor of WireEditPart, but
the setConstraint() of the layout manager of the connection only take an
IFigure, and LogicLabelEditPart() is not an IFigure.
So how can I add a LogicLabelEditPart (the editable label) to the middle of
the wire?
Thank you.
"Randy Hudson" <hudsonr@us.eye-bee-em.com> wrote in message
news:amv5q7$uvc$1@rogue.oti.com...
>
> "Sam Cheung" <scheung@novarra.com> wrote in message
> news:amv5da$umc$1@rogue.oti.com...
> > Actually, I want to add a LogicalLabelEdit in the middle of the
> > WireEditPart.
> > You are correct that WireEditPart creates the Bendable wire
> > (PolylineConnection) in method createFigure().
> >
> > But when I call getModelChildren(), it returns an empty list. How can I
> add
>
> You'd have to change the Wire model and WireEditPart for that. It sounds
> like a simple change. You might want to add a label to Wires in the
> constructor, since support label creation will take some extra effort.
>
> > an LogicalLabelEdit in the middle of the WireEditPart? and when users
move
> > the Wire, the logical label move along with it?
>
> Use a new ConnectionLocator(conn). Set that as the constraint for the
> *LAYOUT*, not the Connection Router. A connection has two objects that do
> two separate things. Routing comes first, then laying out of children.
>
> conn.getLayout().setConstraint(label, new ConnectionLocator(conn));
>
> >
> > Thank you.
> >
> > "Randy Hudson" <hudsonr@us.eye-bee-em.com> wrote in message
> > news:amtoh3$6qj$1@rogue.oti.com...
> > > I don't understand the question. The ConnectionEditPart creates the
> > > PolylineConnection. Not vice versa. You "node" EditPart should
create
> > > ConnectionEditParts. Put a breakpoint in the constructor for
> > > ConnectionEditPart.
> > >
> > > "Sam Cheung" <scheung@novarra.com> wrote in message
> > > news:amsoeu$l63$1@rogue.oti.com...
> > > > Thanks for your help. I want an editable label on the connection.
> > > > How can I get the ConnectionEditPart from a polyline connection. I
> can't
> > > > find such a method on the javadoc of polylineConnection.
> > > >
> > > > "Randy Hudson" <hudsonr@us.eye-bee-em.com> wrote in message
> > > > news:amsm5t$jie$1@rogue.oti.com...
> > > > > Treat the ConnectionEditPart as a container. Containers return
> > > > > getModelChildren(), which would then be used to create an EditPart
> for
> > > > each
> > > > > label on the connection. If you want to interact with the labels,
> you
> > > > > should represent them with EditParts.
> > > > >
> > > > > If you just want to see a label on the connection, do what the
> draw2d
> > > > > example does. The ConnectionEdtiPart would place the label.
> > > > >
> > > > > "Sam Cheung" <scheung@novarra.com> wrote in message
> > > > > news:amslr5$jb9$1@rogue.oti.com...
> > > > > > Hi,
> > > > > >
> > > > > > In the Draw2D help, it has an example of adding a Label
(IFigure)
> to
> > a
> > > > > > PolyLineConnection.
> > > > > > <From the help >
> > > > > >
> > > > > > PolylineConnection conn = new PolylineConnection();
> > > > > >
> > > > > > Label label = new Label ("Midpoint");
> > > > > > label.setOpaque(true);
> > > > > > label.setBackgroundColor(ColorConstants.buttonLightest);
> > > > > > label.setBorder(new LineBorder());
> > > > > > conn.add(label, new MidpointLocator (conn, 0));
> > > > > >
> > > > > > I would like to know how to add an edit Part (e.g.
> > LogicLabelEditPart)
> > > > to
> > > > > a
> > > > > > PolyLineConnection?
> > > > > > LogicLabelEditPart is NOTan implementation of IFigure, but its
> > > > > > createFigure() cretains a Label.
> > > > > > I appreciate if someone can tell me how to add the
> > logicLabelEditPart
> > > to
> > > > > the
> > > > > > connection.
> > > > > >
> > > > > > Thanks.
> > > > > > Sam
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >
> >
> >
>
>
|
|
|
Re: How to add edit part to a PolyLineConnection [message #21515 is a reply to message #21291] |
Thu, 26 September 2002 21:43   |
Eclipse User |
|
|
|
Originally posted by: hudsonr.us.eye-bee-em.com
> Sorry for keeping bothering you with this.
>
> But if I want my label to be editable, I can't just add an label in teh
> WireEditPart, I need to add a LogicLabelEditPart().
Actually, you should never "add" an EditPart. It gets added automatically
by refreshChildren() in AbstractEditPart. EditParts are kept in sync with
the corresponding model object that is returned in getModelChildren(). What
you need to do is make sure WireEditPart returns model children with a
LogicLabel.
> I can create the LogicLabelEditPart in the constructor of WireEditPart,
but
> the setConstraint() of the layout manager of the connection only take an
> IFigure, and LogicLabelEditPart() is not an IFigure.
Look at how the Logic example sets constraints for "normal" children. It is
in refreshVisuals(). Do the same thing, except the constraint is a locator,
not a Rectangle.
> So how can I add a LogicLabelEditPart (the editable label) to the middle
of
> the wire?
>
> Thank you.
>
>
> "Randy Hudson" <hudsonr@us.eye-bee-em.com> wrote in message
> news:amv5q7$uvc$1@rogue.oti.com...
> >
> > "Sam Cheung" <scheung@novarra.com> wrote in message
> > news:amv5da$umc$1@rogue.oti.com...
> > > Actually, I want to add a LogicalLabelEdit in the middle of the
> > > WireEditPart.
> > > You are correct that WireEditPart creates the Bendable wire
> > > (PolylineConnection) in method createFigure().
> > >
> > > But when I call getModelChildren(), it returns an empty list. How can
I
> > add
> >
> > You'd have to change the Wire model and WireEditPart for that. It
sounds
> > like a simple change. You might want to add a label to Wires in the
> > constructor, since support label creation will take some extra effort.
> >
> > > an LogicalLabelEdit in the middle of the WireEditPart? and when users
> move
> > > the Wire, the logical label move along with it?
> >
> > Use a new ConnectionLocator(conn). Set that as the constraint for the
> > *LAYOUT*, not the Connection Router. A connection has two objects that
do
> > two separate things. Routing comes first, then laying out of children.
> >
> > conn.getLayout().setConstraint(label, new ConnectionLocator(conn));
> >
> > >
> > > Thank you.
> > >
> > > "Randy Hudson" <hudsonr@us.eye-bee-em.com> wrote in message
> > > news:amtoh3$6qj$1@rogue.oti.com...
> > > > I don't understand the question. The ConnectionEditPart creates the
> > > > PolylineConnection. Not vice versa. You "node" EditPart should
> create
> > > > ConnectionEditParts. Put a breakpoint in the constructor for
> > > > ConnectionEditPart.
> > > >
> > > > "Sam Cheung" <scheung@novarra.com> wrote in message
> > > > news:amsoeu$l63$1@rogue.oti.com...
> > > > > Thanks for your help. I want an editable label on the connection.
> > > > > How can I get the ConnectionEditPart from a polyline connection. I
> > can't
> > > > > find such a method on the javadoc of polylineConnection.
> > > > >
> > > > > "Randy Hudson" <hudsonr@us.eye-bee-em.com> wrote in message
> > > > > news:amsm5t$jie$1@rogue.oti.com...
> > > > > > Treat the ConnectionEditPart as a container. Containers return
> > > > > > getModelChildren(), which would then be used to create an
EditPart
> > for
> > > > > each
> > > > > > label on the connection. If you want to interact with the
labels,
> > you
> > > > > > should represent them with EditParts.
> > > > > >
> > > > > > If you just want to see a label on the connection, do what the
> > draw2d
> > > > > > example does. The ConnectionEdtiPart would place the label.
> > > > > >
> > > > > > "Sam Cheung" <scheung@novarra.com> wrote in message
> > > > > > news:amslr5$jb9$1@rogue.oti.com...
> > > > > > > Hi,
> > > > > > >
> > > > > > > In the Draw2D help, it has an example of adding a Label
> (IFigure)
> > to
> > > a
> > > > > > > PolyLineConnection.
> > > > > > > <From the help >
> > > > > > >
> > > > > > > PolylineConnection conn = new PolylineConnection();
> > > > > > >
> > > > > > > Label label = new Label ("Midpoint");
> > > > > > > label.setOpaque(true);
> > > > > > > label.setBackgroundColor(ColorConstants.buttonLightest);
> > > > > > > label.setBorder(new LineBorder());
> > > > > > > conn.add(label, new MidpointLocator (conn, 0));
> > > > > > >
> > > > > > > I would like to know how to add an edit Part (e.g.
> > > LogicLabelEditPart)
> > > > > to
> > > > > > a
> > > > > > > PolyLineConnection?
> > > > > > > LogicLabelEditPart is NOTan implementation of IFigure, but its
> > > > > > > createFigure() cretains a Label.
> > > > > > > I appreciate if someone can tell me how to add the
> > > logicLabelEditPart
> > > > to
> > > > > > the
> > > > > > > connection.
> > > > > > >
> > > > > > > Thanks.
> > > > > > > Sam
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >
> >
> >
>
>
|
|
|
Re: How to add edit part to a PolyLineConnection [message #22370 is a reply to message #21515] |
Fri, 27 September 2002 23:24   |
Eclipse User |
|
|
|
Thanks again.
In WireEditPart, I add a list which will be returned by getModelChildren().
And in the contructor of WireEditPart, I add a LogicLabel.
When I try this, I got the following ClassClassException:
Unhandled exception caught in event loop.
Reason:
Failed to execute runnable (java.lang.ClassCastException:
org.eclipse.draw2d.geometry.Rectangle)
*** Stack trace of contained exception ***
Reason:
org.eclipse.draw2d.geometry.Rectangle
And in the refreshVisuals of other EditParts of the example, they just set
color of the editPart. I don't see an example of setConstraints().
And the SetConstraints command of the code just use setLocation() method.
Thanks for your help again.
Sam
"Randy Hudson" <hudsonr@us.eye-bee-em.com> wrote in message
news:an0bvr$l9j$1@rogue.oti.com...
> > Sorry for keeping bothering you with this.
> >
> > But if I want my label to be editable, I can't just add an label in teh
> > WireEditPart, I need to add a LogicLabelEditPart().
>
> Actually, you should never "add" an EditPart. It gets added automatically
> by refreshChildren() in AbstractEditPart. EditParts are kept in sync with
> the corresponding model object that is returned in getModelChildren().
What
> you need to do is make sure WireEditPart returns model children with a
> LogicLabel.
>
> > I can create the LogicLabelEditPart in the constructor of WireEditPart,
> but
> > the setConstraint() of the layout manager of the connection only take an
> > IFigure, and LogicLabelEditPart() is not an IFigure.
>
> Look at how the Logic example sets constraints for "normal" children. It
is
> in refreshVisuals(). Do the same thing, except the constraint is a
locator,
> not a Rectangle.
>
> > So how can I add a LogicLabelEditPart (the editable label) to the middle
> of
> > the wire?
> >
> > Thank you.
> >
> >
> > "Randy Hudson" <hudsonr@us.eye-bee-em.com> wrote in message
> > news:amv5q7$uvc$1@rogue.oti.com...
> > >
> > > "Sam Cheung" <scheung@novarra.com> wrote in message
> > > news:amv5da$umc$1@rogue.oti.com...
> > > > Actually, I want to add a LogicalLabelEdit in the middle of the
> > > > WireEditPart.
> > > > You are correct that WireEditPart creates the Bendable wire
> > > > (PolylineConnection) in method createFigure().
> > > >
> > > > But when I call getModelChildren(), it returns an empty list. How
can
> I
> > > add
> > >
> > > You'd have to change the Wire model and WireEditPart for that. It
> sounds
> > > like a simple change. You might want to add a label to Wires in the
> > > constructor, since support label creation will take some extra effort.
> > >
> > > > an LogicalLabelEdit in the middle of the WireEditPart? and when
users
> > move
> > > > the Wire, the logical label move along with it?
> > >
> > > Use a new ConnectionLocator(conn). Set that as the constraint for the
> > > *LAYOUT*, not the Connection Router. A connection has two objects
that
> do
> > > two separate things. Routing comes first, then laying out of
children.
> > >
> > > conn.getLayout().setConstraint(label, new ConnectionLocator(conn));
> > >
> > > >
> > > > Thank you.
> > > >
> > > > "Randy Hudson" <hudsonr@us.eye-bee-em.com> wrote in message
> > > > news:amtoh3$6qj$1@rogue.oti.com...
> > > > > I don't understand the question. The ConnectionEditPart creates
the
> > > > > PolylineConnection. Not vice versa. You "node" EditPart should
> > create
> > > > > ConnectionEditParts. Put a breakpoint in the constructor for
> > > > > ConnectionEditPart.
> > > > >
> > > > > "Sam Cheung" <scheung@novarra.com> wrote in message
> > > > > news:amsoeu$l63$1@rogue.oti.com...
> > > > > > Thanks for your help. I want an editable label on the
connection.
> > > > > > How can I get the ConnectionEditPart from a polyline connection.
I
> > > can't
> > > > > > find such a method on the javadoc of polylineConnection.
> > > > > >
> > > > > > "Randy Hudson" <hudsonr@us.eye-bee-em.com> wrote in message
> > > > > > news:amsm5t$jie$1@rogue.oti.com...
> > > > > > > Treat the ConnectionEditPart as a container. Containers
return
> > > > > > > getModelChildren(), which would then be used to create an
> EditPart
> > > for
> > > > > > each
> > > > > > > label on the connection. If you want to interact with the
> labels,
> > > you
> > > > > > > should represent them with EditParts.
> > > > > > >
> > > > > > > If you just want to see a label on the connection, do what the
> > > draw2d
> > > > > > > example does. The ConnectionEdtiPart would place the label.
> > > > > > >
> > > > > > > "Sam Cheung" <scheung@novarra.com> wrote in message
> > > > > > > news:amslr5$jb9$1@rogue.oti.com...
> > > > > > > > Hi,
> > > > > > > >
> > > > > > > > In the Draw2D help, it has an example of adding a Label
> > (IFigure)
> > > to
> > > > a
> > > > > > > > PolyLineConnection.
> > > > > > > > <From the help >
> > > > > > > >
> > > > > > > > PolylineConnection conn = new PolylineConnection();
> > > > > > > >
> > > > > > > > Label label = new Label ("Midpoint");
> > > > > > > > label.setOpaque(true);
> > > > > > > > label.setBackgroundColor(ColorConstants.buttonLightest);
> > > > > > > > label.setBorder(new LineBorder());
> > > > > > > > conn.add(label, new MidpointLocator (conn, 0));
> > > > > > > >
> > > > > > > > I would like to know how to add an edit Part (e.g.
> > > > LogicLabelEditPart)
> > > > > > to
> > > > > > > a
> > > > > > > > PolyLineConnection?
> > > > > > > > LogicLabelEditPart is NOTan implementation of IFigure, but
its
> > > > > > > > createFigure() cretains a Label.
> > > > > > > > I appreciate if someone can tell me how to add the
> > > > logicLabelEditPart
> > > > > to
> > > > > > > the
> > > > > > > > connection.
> > > > > > > >
> > > > > > > > Thanks.
> > > > > > > > Sam
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > > >
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >
> >
> >
>
>
|
|
|
Re: How to add edit part to a PolyLineConnection [message #22391 is a reply to message #22370] |
Sun, 29 September 2002 00:40   |
Eclipse User |
|
|
|
In the refreshVisuals() of WireEditPart, I try to call setLayoutConstraint()
to set the constraint of the label, like below:
setLayoutConstraint(label, figure, new ConnectionLocator ( (Connection)
getFigure() ) );
but I can't get the figure of the label from the label. The getFigure()
method also exist for the LabelEditPart, not the Label itself. And the
WireEditPart only has "Label".
Thanks for any help.
Sam
"Sam Cheung" <scheung@novarra.com> wrote in message
news:an3680$6ft$1@rogue.oti.com...
> Thanks again.
>
> In WireEditPart, I add a list which will be returned by
getModelChildren().
> And in the contructor of WireEditPart, I add a LogicLabel.
>
> When I try this, I got the following ClassClassException:
>
> Unhandled exception caught in event loop.
>
> Reason:
>
> Failed to execute runnable (java.lang.ClassCastException:
> org.eclipse.draw2d.geometry.Rectangle)
>
> *** Stack trace of contained exception ***
>
> Reason:
>
> org.eclipse.draw2d.geometry.Rectangle
>
> And in the refreshVisuals of other EditParts of the example, they just set
> color of the editPart. I don't see an example of setConstraints().
> And the SetConstraints command of the code just use setLocation() method.
>
> Thanks for your help again.
> Sam
>
> "Randy Hudson" <hudsonr@us.eye-bee-em.com> wrote in message
> news:an0bvr$l9j$1@rogue.oti.com...
> > > Sorry for keeping bothering you with this.
> > >
> > > But if I want my label to be editable, I can't just add an label in
teh
> > > WireEditPart, I need to add a LogicLabelEditPart().
> >
> > Actually, you should never "add" an EditPart. It gets added
automatically
> > by refreshChildren() in AbstractEditPart. EditParts are kept in sync
with
> > the corresponding model object that is returned in getModelChildren().
> What
> > you need to do is make sure WireEditPart returns model children with a
> > LogicLabel.
> >
> > > I can create the LogicLabelEditPart in the constructor of
WireEditPart,
> > but
> > > the setConstraint() of the layout manager of the connection only take
an
> > > IFigure, and LogicLabelEditPart() is not an IFigure.
> >
> > Look at how the Logic example sets constraints for "normal" children.
It
> is
> > in refreshVisuals(). Do the same thing, except the constraint is a
> locator,
> > not a Rectangle.
> >
> > > So how can I add a LogicLabelEditPart (the editable label) to the
middle
> > of
> > > the wire?
> > >
> > > Thank you.
> > >
> > >
> > > "Randy Hudson" <hudsonr@us.eye-bee-em.com> wrote in message
> > > news:amv5q7$uvc$1@rogue.oti.com...
> > > >
> > > > "Sam Cheung" <scheung@novarra.com> wrote in message
> > > > news:amv5da$umc$1@rogue.oti.com...
> > > > > Actually, I want to add a LogicalLabelEdit in the middle of the
> > > > > WireEditPart.
> > > > > You are correct that WireEditPart creates the Bendable wire
> > > > > (PolylineConnection) in method createFigure().
> > > > >
> > > > > But when I call getModelChildren(), it returns an empty list. How
> can
> > I
> > > > add
> > > >
> > > > You'd have to change the Wire model and WireEditPart for that. It
> > sounds
> > > > like a simple change. You might want to add a label to Wires in the
> > > > constructor, since support label creation will take some extra
effort.
> > > >
> > > > > an LogicalLabelEdit in the middle of the WireEditPart? and when
> users
> > > move
> > > > > the Wire, the logical label move along with it?
> > > >
> > > > Use a new ConnectionLocator(conn). Set that as the constraint for
the
> > > > *LAYOUT*, not the Connection Router. A connection has two objects
> that
> > do
> > > > two separate things. Routing comes first, then laying out of
> children.
> > > >
> > > > conn.getLayout().setConstraint(label, new ConnectionLocator(conn));
> > > >
> > > > >
> > > > > Thank you.
> > > > >
> > > > > "Randy Hudson" <hudsonr@us.eye-bee-em.com> wrote in message
> > > > > news:amtoh3$6qj$1@rogue.oti.com...
> > > > > > I don't understand the question. The ConnectionEditPart creates
> the
> > > > > > PolylineConnection. Not vice versa. You "node" EditPart should
> > > create
> > > > > > ConnectionEditParts. Put a breakpoint in the constructor for
> > > > > > ConnectionEditPart.
> > > > > >
> > > > > > "Sam Cheung" <scheung@novarra.com> wrote in message
> > > > > > news:amsoeu$l63$1@rogue.oti.com...
> > > > > > > Thanks for your help. I want an editable label on the
> connection.
> > > > > > > How can I get the ConnectionEditPart from a polyline
connection.
> I
> > > > can't
> > > > > > > find such a method on the javadoc of polylineConnection.
> > > > > > >
> > > > > > > "Randy Hudson" <hudsonr@us.eye-bee-em.com> wrote in message
> > > > > > > news:amsm5t$jie$1@rogue.oti.com...
> > > > > > > > Treat the ConnectionEditPart as a container. Containers
> return
> > > > > > > > getModelChildren(), which would then be used to create an
> > EditPart
> > > > for
> > > > > > > each
> > > > > > > > label on the connection. If you want to interact with the
> > labels,
> > > > you
> > > > > > > > should represent them with EditParts.
> > > > > > > >
> > > > > > > > If you just want to see a label on the connection, do what
the
> > > > draw2d
> > > > > > > > example does. The ConnectionEdtiPart would place the label.
> > > > > > > >
> > > > > > > > "Sam Cheung" <scheung@novarra.com> wrote in message
> > > > > > > > news:amslr5$jb9$1@rogue.oti.com...
> > > > > > > > > Hi,
> > > > > > > > >
> > > > > > > > > In the Draw2D help, it has an example of adding a Label
> > > (IFigure)
> > > > to
> > > > > a
> > > > > > > > > PolyLineConnection.
> > > > > > > > > <From the help >
> > > > > > > > >
> > > > > > > > > PolylineConnection conn = new PolylineConnection();
> > > > > > > > >
> > > > > > > > > Label label = new Label ("Midpoint");
> > > > > > > > > label.setOpaque(true);
> > > > > > > > > label.setBackgroundColor(ColorConstants.buttonLightest);
> > > > > > > > > label.setBorder(new LineBorder());
> > > > > > > > > conn.add(label, new MidpointLocator (conn, 0));
> > > > > > > > >
> > > > > > > > > I would like to know how to add an edit Part (e.g.
> > > > > LogicLabelEditPart)
> > > > > > > to
> > > > > > > > a
> > > > > > > > > PolyLineConnection?
> > > > > > > > > LogicLabelEditPart is NOTan implementation of IFigure, but
> its
> > > > > > > > > createFigure() cretains a Label.
> > > > > > > > > I appreciate if someone can tell me how to add the
> > > > > logicLabelEditPart
> > > > > > to
> > > > > > > > the
> > > > > > > > > connection.
> > > > > > > > >
> > > > > > > > > Thanks.
> > > > > > > > > Sam
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > > >
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >
> >
> >
>
>
|
|
|
Re: How to add edit part to a PolyLineConnection [message #22414 is a reply to message #22391] |
Sun, 29 September 2002 19:36   |
Eclipse User |
|
|
|
Per Randy's suggestion, I think I need to set the layout constraint for the
label (now a children of Wire),
but the setLayoutConstraint() method needs an edit part, and a IFigure as
its first 2 parameters.
From the label object, it does not have a reference to the editpart, so I
can't get a reference of LabelEditPart from the Label object.
So how can I set the layout constraint of the label in the refreshVisuals()
of the Wire method?
Thanks for any suggestion.
> In the refreshVisuals() of WireEditPart, I try to call
setLayoutConstraint()
> to set the constraint of the label, like below:
>
> setLayoutConstraint(label, figure, new ConnectionLocator ( (Connection)
> getFigure() ) );
>
> but I can't get the figure of the label from the label. The getFigure()
> method also exist for the LabelEditPart, not the Label itself. And the
> WireEditPart only has "Label".
>
> Thanks for any help.
>
> Sam
>
>
> "Sam Cheung" <scheung@novarra.com> wrote in message
> news:an3680$6ft$1@rogue.oti.com...
> > Thanks again.
> >
> > In WireEditPart, I add a list which will be returned by
> getModelChildren().
> > And in the contructor of WireEditPart, I add a LogicLabel.
> >
> > When I try this, I got the following ClassClassException:
> >
> > Unhandled exception caught in event loop.
> >
> > Reason:
> >
> > Failed to execute runnable (java.lang.ClassCastException:
> > org.eclipse.draw2d.geometry.Rectangle)
> >
> > *** Stack trace of contained exception ***
> >
> > Reason:
> >
> > org.eclipse.draw2d.geometry.Rectangle
> >
> > And in the refreshVisuals of other EditParts of the example, they just
set
> > color of the editPart. I don't see an example of setConstraints().
> > And the SetConstraints command of the code just use setLocation()
method.
> >
> > Thanks for your help again.
> > Sam
> >
> > "Randy Hudson" <hudsonr@us.eye-bee-em.com> wrote in message
> > news:an0bvr$l9j$1@rogue.oti.com...
> > > > Sorry for keeping bothering you with this.
> > > >
> > > > But if I want my label to be editable, I can't just add an label in
> teh
> > > > WireEditPart, I need to add a LogicLabelEditPart().
> > >
> > > Actually, you should never "add" an EditPart. It gets added
> automatically
> > > by refreshChildren() in AbstractEditPart. EditParts are kept in sync
> with
> > > the corresponding model object that is returned in getModelChildren().
> > What
> > > you need to do is make sure WireEditPart returns model children with a
> > > LogicLabel.
> > >
> > > > I can create the LogicLabelEditPart in the constructor of
> WireEditPart,
> > > but
> > > > the setConstraint() of the layout manager of the connection only
take
> an
> > > > IFigure, and LogicLabelEditPart() is not an IFigure.
> > >
> > > Look at how the Logic example sets constraints for "normal" children.
> It
> > is
> > > in refreshVisuals(). Do the same thing, except the constraint is a
> > locator,
> > > not a Rectangle.
> > >
> > > > So how can I add a LogicLabelEditPart (the editable label) to the
> middle
> > > of
> > > > the wire?
> > > >
> > > > Thank you.
> > > >
> > > >
> > > > "Randy Hudson" <hudsonr@us.eye-bee-em.com> wrote in message
> > > > news:amv5q7$uvc$1@rogue.oti.com...
> > > > >
> > > > > "Sam Cheung" <scheung@novarra.com> wrote in message
> > > > > news:amv5da$umc$1@rogue.oti.com...
> > > > > > Actually, I want to add a LogicalLabelEdit in the middle of the
> > > > > > WireEditPart.
> > > > > > You are correct that WireEditPart creates the Bendable wire
> > > > > > (PolylineConnection) in method createFigure().
> > > > > >
> > > > > > But when I call getModelChildren(), it returns an empty list.
How
> > can
> > > I
> > > > > add
> > > > >
> > > > > You'd have to change the Wire model and WireEditPart for that. It
> > > sounds
> > > > > like a simple change. You might want to add a label to Wires in
the
> > > > > constructor, since support label creation will take some extra
> effort.
> > > > >
> > > > > > an LogicalLabelEdit in the middle of the WireEditPart? and when
> > users
> > > > move
> > > > > > the Wire, the logical label move along with it?
> > > > >
> > > > > Use a new ConnectionLocator(conn). Set that as the constraint for
> the
> > > > > *LAYOUT*, not the Connection Router. A connection has two objects
> > that
> > > do
> > > > > two separate things. Routing comes first, then laying out of
> > children.
> > > > >
> > > > > conn.getLayout().setConstraint(label, new
ConnectionLocator(conn));
> > > > >
> > > > > >
> > > > > > Thank you.
> > > > > >
> > > > > > "Randy Hudson" <hudsonr@us.eye-bee-em.com> wrote in message
> > > > > > news:amtoh3$6qj$1@rogue.oti.com...
> > > > > > > I don't understand the question. The ConnectionEditPart
creates
> > the
> > > > > > > PolylineConnection. Not vice versa. You "node" EditPart
should
> > > > create
> > > > > > > ConnectionEditParts. Put a breakpoint in the constructor for
> > > > > > > ConnectionEditPart.
> > > > > > >
> > > > > > > "Sam Cheung" <scheung@novarra.com> wrote in message
> > > > > > > news:amsoeu$l63$1@rogue.oti.com...
> > > > > > > > Thanks for your help. I want an editable label on the
> > connection.
> > > > > > > > How can I get the ConnectionEditPart from a polyline
> connection.
> > I
> > > > > can't
> > > > > > > > find such a method on the javadoc of polylineConnection.
> > > > > > > >
> > > > > > > > "Randy Hudson" <hudsonr@us.eye-bee-em.com> wrote in message
> > > > > > > > news:amsm5t$jie$1@rogue.oti.com...
> > > > > > > > > Treat the ConnectionEditPart as a container. Containers
> > return
> > > > > > > > > getModelChildren(), which would then be used to create an
> > > EditPart
> > > > > for
> > > > > > > > each
> > > > > > > > > label on the connection. If you want to interact with the
> > > labels,
> > > > > you
> > > > > > > > > should represent them with EditParts.
> > > > > > > > >
> > > > > > > > > If you just want to see a label on the connection, do what
> the
> > > > > draw2d
> > > > > > > > > example does. The ConnectionEdtiPart would place the
label.
> > > > > > > > >
> > > > > > > > > "Sam Cheung" <scheung@novarra.com> wrote in message
> > > > > > > > > news:amslr5$jb9$1@rogue.oti.com...
> > > > > > > > > > Hi,
> > > > > > > > > >
> > > > > > > > > > In the Draw2D help, it has an example of adding a Label
> > > > (IFigure)
> > > > > to
> > > > > > a
> > > > > > > > > > PolyLineConnection.
> > > > > > > > > > <From the help >
> > > > > > > > > >
> > > > > > > > > > PolylineConnection conn = new PolylineConnection();
> > > > > > > > > >
> > > > > > > > > > Label label = new Label ("Midpoint");
> > > > > > > > > > label.setOpaque(true);
> > > > > > > > > > label.setBackgroundColor(ColorConstants.buttonLightest);
> > > > > > > > > > label.setBorder(new LineBorder());
> > > > > > > > > > conn.add(label, new MidpointLocator (conn, 0));
> > > > > > > > > >
> > > > > > > > > > I would like to know how to add an edit Part (e.g.
> > > > > > LogicLabelEditPart)
> > > > > > > > to
> > > > > > > > > a
> > > > > > > > > > PolyLineConnection?
> > > > > > > > > > LogicLabelEditPart is NOTan implementation of IFigure,
but
> > its
> > > > > > > > > > createFigure() cretains a Label.
> > > > > > > > > > I appreciate if someone can tell me how to add the
> > > > > > logicLabelEditPart
> > > > > > > to
> > > > > > > > > the
> > > > > > > > > > connection.
> > > > > > > > > >
> > > > > > > > > > Thanks.
> > > > > > > > > > Sam
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > > >
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >
> >
> >
>
>
|
|
|
Re: How to add edit part to a PolyLineConnection [message #22457 is a reply to message #22391] |
Sun, 29 September 2002 21:06   |
Eclipse User |
|
|
|
Originally posted by: hudsonr.us.eye-bee-em.com
This is typically done from the child EditPart. The location of the label
is generally a property of the label, and this is true in the logic example.
So, the LabelEditPart already implements refreshVisuals, except it doesn't
know that it is in a connection.
Even if you do what you are trying, you still need to override
refreshVisuals() in LabelEditPart, because it thinks that Rectangle is used
as the constraint.
"Sam Cheung" <scheung@novarra.com> wrote in message
news:an5v0k$4be$1@rogue.oti.com...
> In the refreshVisuals() of WireEditPart, I try to call
setLayoutConstraint()
> to set the constraint of the label, like below:
>
> setLayoutConstraint(label, figure, new ConnectionLocator ( (Connection)
> getFigure() ) );
>
> but I can't get the figure of the label from the label. The getFigure()
> method also exist for the LabelEditPart, not the Label itself. And the
> WireEditPart only has "Label".
>
> Thanks for any help.
>
> Sam
>
>
> "Sam Cheung" <scheung@novarra.com> wrote in message
> news:an3680$6ft$1@rogue.oti.com...
> > Thanks again.
> >
> > In WireEditPart, I add a list which will be returned by
> getModelChildren().
> > And in the contructor of WireEditPart, I add a LogicLabel.
> >
> > When I try this, I got the following ClassClassException:
> >
> > Unhandled exception caught in event loop.
> >
> > Reason:
> >
> > Failed to execute runnable (java.lang.ClassCastException:
> > org.eclipse.draw2d.geometry.Rectangle)
> >
> > *** Stack trace of contained exception ***
> >
> > Reason:
> >
> > org.eclipse.draw2d.geometry.Rectangle
> >
> > And in the refreshVisuals of other EditParts of the example, they just
set
> > color of the editPart. I don't see an example of setConstraints().
> > And the SetConstraints command of the code just use setLocation()
method.
> >
> > Thanks for your help again.
> > Sam
> >
> > "Randy Hudson" <hudsonr@us.eye-bee-em.com> wrote in message
> > news:an0bvr$l9j$1@rogue.oti.com...
> > > > Sorry for keeping bothering you with this.
> > > >
> > > > But if I want my label to be editable, I can't just add an label in
> teh
> > > > WireEditPart, I need to add a LogicLabelEditPart().
> > >
> > > Actually, you should never "add" an EditPart. It gets added
> automatically
> > > by refreshChildren() in AbstractEditPart. EditParts are kept in sync
> with
> > > the corresponding model object that is returned in getModelChildren().
> > What
> > > you need to do is make sure WireEditPart returns model children with a
> > > LogicLabel.
> > >
> > > > I can create the LogicLabelEditPart in the constructor of
> WireEditPart,
> > > but
> > > > the setConstraint() of the layout manager of the connection only
take
> an
> > > > IFigure, and LogicLabelEditPart() is not an IFigure.
> > >
> > > Look at how the Logic example sets constraints for "normal" children.
> It
> > is
> > > in refreshVisuals(). Do the same thing, except the constraint is a
> > locator,
> > > not a Rectangle.
> > >
> > > > So how can I add a LogicLabelEditPart (the editable label) to the
> middle
> > > of
> > > > the wire?
> > > >
> > > > Thank you.
> > > >
> > > >
> > > > "Randy Hudson" <hudsonr@us.eye-bee-em.com> wrote in message
> > > > news:amv5q7$uvc$1@rogue.oti.com...
> > > > >
> > > > > "Sam Cheung" <scheung@novarra.com> wrote in message
> > > > > news:amv5da$umc$1@rogue.oti.com...
> > > > > > Actually, I want to add a LogicalLabelEdit in the middle of the
> > > > > > WireEditPart.
> > > > > > You are correct that WireEditPart creates the Bendable wire
> > > > > > (PolylineConnection) in method createFigure().
> > > > > >
> > > > > > But when I call getModelChildren(), it returns an empty list.
How
> > can
> > > I
> > > > > add
> > > > >
> > > > > You'd have to change the Wire model and WireEditPart for that. It
> > > sounds
> > > > > like a simple change. You might want to add a label to Wires in
the
> > > > > constructor, since support label creation will take some extra
> effort.
> > > > >
> > > > > > an LogicalLabelEdit in the middle of the WireEditPart? and when
> > users
> > > > move
> > > > > > the Wire, the logical label move along with it?
> > > > >
> > > > > Use a new ConnectionLocator(conn). Set that as the constraint for
> the
> > > > > *LAYOUT*, not the Connection Router. A connection has two objects
> > that
> > > do
> > > > > two separate things. Routing comes first, then laying out of
> > children.
> > > > >
> > > > > conn.getLayout().setConstraint(label, new
ConnectionLocator(conn));
> > > > >
> > > > > >
> > > > > > Thank you.
> > > > > >
> > > > > > "Randy Hudson" <hudsonr@us.eye-bee-em.com> wrote in message
> > > > > > news:amtoh3$6qj$1@rogue.oti.com...
> > > > > > > I don't understand the question. The ConnectionEditPart
creates
> > the
> > > > > > > PolylineConnection. Not vice versa. You "node" EditPart
should
> > > > create
> > > > > > > ConnectionEditParts. Put a breakpoint in the constructor for
> > > > > > > ConnectionEditPart.
> > > > > > >
> > > > > > > "Sam Cheung" <scheung@novarra.com> wrote in message
> > > > > > > news:amsoeu$l63$1@rogue.oti.com...
> > > > > > > > Thanks for your help. I want an editable label on the
> > connection.
> > > > > > > > How can I get the ConnectionEditPart from a polyline
> connection.
> > I
> > > > > can't
> > > > > > > > find such a method on the javadoc of polylineConnection.
> > > > > > > >
> > > > > > > > "Randy Hudson" <hudsonr@us.eye-bee-em.com> wrote in message
> > > > > > > > news:amsm5t$jie$1@rogue.oti.com...
> > > > > > > > > Treat the ConnectionEditPart as a container. Containers
> > return
> > > > > > > > > getModelChildren(), which would then be used to create an
> > > EditPart
> > > > > for
> > > > > > > > each
> > > > > > > > > label on the connection. If you want to interact with the
> > > labels,
> > > > > you
> > > > > > > > > should represent them with EditParts.
> > > > > > > > >
> > > > > > > > > If you just want to see a label on the connection, do what
> the
> > > > > draw2d
> > > > > > > > > example does. The ConnectionEdtiPart would place the
label.
> > > > > > > > >
> > > > > > > > > "Sam Cheung" <scheung@novarra.com> wrote in message
> > > > > > > > > news:amslr5$jb9$1@rogue.oti.com...
> > > > > > > > > > Hi,
> > > > > > > > > >
> > > > > > > > > > In the Draw2D help, it has an example of adding a Label
> > > > (IFigure)
> > > > > to
> > > > > > a
> > > > > > > > > > PolyLineConnection.
> > > > > > > > > > <From the help >
> > > > > > > > > >
> > > > > > > > > > PolylineConnection conn = new PolylineConnection();
> > > > > > > > > >
> > > > > > > > > > Label label = new Label ("Midpoint");
> > > > > > > > > > label.setOpaque(true);
> > > > > > > > > > label.setBackgroundColor(ColorConstants.buttonLightest);
> > > > > > > > > > label.setBorder(new LineBorder());
> > > > > > > > > > conn.add(label, new MidpointLocator (conn, 0));
> > > > > > > > > >
> > > > > > > > > > I would like to know how to add an edit Part (e.g.
> > > > > > LogicLabelEditPart)
> > > > > > > > to
> > > > > > > > > a
> > > > > > > > > > PolyLineConnection?
> > > > > > > > > > LogicLabelEditPart is NOTan implementation of IFigure,
but
> > its
> > > > > > > > > > createFigure() cretains a Label.
> > > > > > > > > > I appreciate if someone can tell me how to add the
> > > > > > logicLabelEditPart
> > > > > > > to
> > > > > > > > > the
> > > > > > > > > > connection.
> > > > > > > > > >
> > > > > > > > > > Thanks.
> > > > > > > > > > Sam
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > > >
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >
> >
> >
>
>
|
|
|
Re: How to add edit part to a PolyLineConnection [message #22590 is a reply to message #22457] |
Mon, 30 September 2002 19:21   |
Eclipse User |
|
|
|
Thanks for the suggestion. I add the following code in refreshVisuals of the
LogicLabelEditPart, but I got an exception saying "Figure is not a child".
EditPart parent = getParent();
if (parent instanceof WireEditPart) {
WireEditPart wire = (WireEditPart)parent;
// this should be LogicLabelEditPart, getFigure should return Label
setLayoutConstraint(this, getFigure(), new ConnectionLocator
((Connection)wire.getFigure()));
}
The exception:
Unhandled exception caught in event loop.
Reason:
IWAG0004E Figure.setConstraint(..): Figure is not a child
Thanks for any advice.
"Randy Hudson" <hudsonr@us.eye-bee-em.com> wrote in message
news:an86s0$2a1$1@rogue.oti.com...
> This is typically done from the child EditPart. The location of the label
> is generally a property of the label, and this is true in the logic
example.
> So, the LabelEditPart already implements refreshVisuals, except it doesn't
> know that it is in a connection.
>
> Even if you do what you are trying, you still need to override
> refreshVisuals() in LabelEditPart, because it thinks that Rectangle is
used
> as the constraint.
>
> "Sam Cheung" <scheung@novarra.com> wrote in message
> news:an5v0k$4be$1@rogue.oti.com...
> > In the refreshVisuals() of WireEditPart, I try to call
> setLayoutConstraint()
> > to set the constraint of the label, like below:
> >
> > setLayoutConstraint(label, figure, new ConnectionLocator (
(Connection)
> > getFigure() ) );
> >
> > but I can't get the figure of the label from the label. The getFigure()
> > method also exist for the LabelEditPart, not the Label itself. And the
> > WireEditPart only has "Label".
> >
> > Thanks for any help.
> >
> > Sam
> >
> >
> > "Sam Cheung" <scheung@novarra.com> wrote in message
> > news:an3680$6ft$1@rogue.oti.com...
> > > Thanks again.
> > >
> > > In WireEditPart, I add a list which will be returned by
> > getModelChildren().
> > > And in the contructor of WireEditPart, I add a LogicLabel.
> > >
> > > When I try this, I got the following ClassClassException:
> > >
> > > Unhandled exception caught in event loop.
> > >
> > > Reason:
> > >
> > > Failed to execute runnable (java.lang.ClassCastException:
> > > org.eclipse.draw2d.geometry.Rectangle)
> > >
> > > *** Stack trace of contained exception ***
> > >
> > > Reason:
> > >
> > > org.eclipse.draw2d.geometry.Rectangle
> > >
> > > And in the refreshVisuals of other EditParts of the example, they just
> set
> > > color of the editPart. I don't see an example of setConstraints().
> > > And the SetConstraints command of the code just use setLocation()
> method.
> > >
> > > Thanks for your help again.
> > > Sam
> > >
> > > "Randy Hudson" <hudsonr@us.eye-bee-em.com> wrote in message
> > > news:an0bvr$l9j$1@rogue.oti.com...
> > > > > Sorry for keeping bothering you with this.
> > > > >
> > > > > But if I want my label to be editable, I can't just add an label
in
> > teh
> > > > > WireEditPart, I need to add a LogicLabelEditPart().
> > > >
> > > > Actually, you should never "add" an EditPart. It gets added
> > automatically
> > > > by refreshChildren() in AbstractEditPart. EditParts are kept in
sync
> > with
> > > > the corresponding model object that is returned in
getModelChildren().
> > > What
> > > > you need to do is make sure WireEditPart returns model children with
a
> > > > LogicLabel.
> > > >
> > > > > I can create the LogicLabelEditPart in the constructor of
> > WireEditPart,
> > > > but
> > > > > the setConstraint() of the layout manager of the connection only
> take
> > an
> > > > > IFigure, and LogicLabelEditPart() is not an IFigure.
> > > >
> > > > Look at how the Logic example sets constraints for "normal"
children.
> > It
> > > is
> > > > in refreshVisuals(). Do the same thing, except the constraint is a
> > > locator,
> > > > not a Rectangle.
> > > >
> > > > > So how can I add a LogicLabelEditPart (the editable label) to the
> > middle
> > > > of
> > > > > the wire?
> > > > >
> > > > > Thank you.
> > > > >
> > > > >
> > > > > "Randy Hudson" <hudsonr@us.eye-bee-em.com> wrote in message
> > > > > news:amv5q7$uvc$1@rogue.oti.com...
> > > > > >
> > > > > > "Sam Cheung" <scheung@novarra.com> wrote in message
> > > > > > news:amv5da$umc$1@rogue.oti.com...
> > > > > > > Actually, I want to add a LogicalLabelEdit in the middle of
the
> > > > > > > WireEditPart.
> > > > > > > You are correct that WireEditPart creates the Bendable wire
> > > > > > > (PolylineConnection) in method createFigure().
> > > > > > >
> > > > > > > But when I call getModelChildren(), it returns an empty list.
> How
> > > can
> > > > I
> > > > > > add
> > > > > >
> > > > > > You'd have to change the Wire model and WireEditPart for that.
It
> > > > sounds
> > > > > > like a simple change. You might want to add a label to Wires in
> the
> > > > > > constructor, since support label creation will take some extra
> > effort.
> > > > > >
> > > > > > > an LogicalLabelEdit in the middle of the WireEditPart? and
when
> > > users
> > > > > move
> > > > > > > the Wire, the logical label move along with it?
> > > > > >
> > > > > > Use a new ConnectionLocator(conn). Set that as the constraint
for
> > the
> > > > > > *LAYOUT*, not the Connection Router. A connection has two
objects
> > > that
> > > > do
> > > > > > two separate things. Routing comes first, then laying out of
> > > children.
> > > > > >
> > > > > > conn.getLayout().setConstraint(label, new
> ConnectionLocator(conn));
> > > > > >
> > > > > > >
> > > > > > > Thank you.
> > > > > > >
> > > > > > > "Randy Hudson" <hudsonr@us.eye-bee-em.com> wrote in message
> > > > > > > news:amtoh3$6qj$1@rogue.oti.com...
> > > > > > > > I don't understand the question. The ConnectionEditPart
> creates
> > > the
> > > > > > > > PolylineConnection. Not vice versa. You "node" EditPart
> should
> > > > > create
> > > > > > > > ConnectionEditParts. Put a breakpoint in the constructor
for
> > > > > > > > ConnectionEditPart.
> > > > > > > >
> > > > > > > > "Sam Cheung" <scheung@novarra.com> wrote in message
> > > > > > > > news:amsoeu$l63$1@rogue.oti.com...
> > > > > > > > > Thanks for your help. I want an editable label on the
> > > connection.
> > > > > > > > > How can I get the ConnectionEditPart from a polyline
> > connection.
> > > I
> > > > > > can't
> > > > > > > > > find such a method on the javadoc of polylineConnection.
> > > > > > > > >
> > > > > > > > > "Randy Hudson" <hudsonr@us.eye-bee-em.com> wrote in
message
> > > > > > > > > news:amsm5t$jie$1@rogue.oti.com...
> > > > > > > > > > Treat the ConnectionEditPart as a container. Containers
> > > return
> > > > > > > > > > getModelChildren(), which would then be used to create
an
> > > > EditPart
> > > > > > for
> > > > > > > > > each
> > > > > > > > > > label on the connection. If you want to interact with
the
> > > > labels,
> > > > > > you
> > > > > > > > > > should represent them with EditParts.
> > > > > > > > > >
> > > > > > > > > > If you just want to see a label on the connection, do
what
> > the
> > > > > > draw2d
> > > > > > > > > > example does. The ConnectionEdtiPart would place the
> label.
> > > > > > > > > >
> > > > > > > > > > "Sam Cheung" <scheung@novarra.com> wrote in message
> > > > > > > > > > news:amslr5$jb9$1@rogue.oti.com...
> > > > > > > > > > > Hi,
> > > > > > > > > > >
> > > > > > > > > > > In the Draw2D help, it has an example of adding a
Label
> > > > > (IFigure)
> > > > > > to
> > > > > > > a
> > > > > > > > > > > PolyLineConnection.
> > > > > > > > > > > <From the help >
> > > > > > > > > > >
> > > > > > > > > > > PolylineConnection conn = new PolylineConnection();
> > > > > > > > > > >
> > > > > > > > > > > Label label = new Label ("Midpoint");
> > > > > > > > > > > label.setOpaque(true);
> > > > > > > > > > >
label.setBackgroundColor(ColorConstants.buttonLightest);
> > > > > > > > > > > label.setBorder(new LineBorder());
> > > > > > > > > > > conn.add(label, new MidpointLocator (conn, 0));
> > > > > > > > > > >
> > > > > > > > > > > I would like to know how to add an edit Part (e.g.
> > > > > > > LogicLabelEditPart)
> > > > > > > > > to
> > > > > > > > > > a
> > > > > > > > > > > PolyLineConnection?
> > > > > > > > > > > LogicLabelEditPart is NOTan implementation of IFigure,
> but
> > > its
> > > > > > > > > > > createFigure() cretains a Label.
> > > > > > > > > > > I appreciate if someone can tell me how to add the
> > > > > > > logicLabelEditPart
> > > > > > > > to
> > > > > > > > > > the
> > > > > > > > > > > connection.
> > > > > > > > > > >
> > > > > > > > > > > Thanks.
> > > > > > > > > > > Sam
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > > >
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >
> >
> >
>
>
|
|
| |
Re: How to add edit part to a PolyLineConnection [message #24445 is a reply to message #22633] |
Sun, 06 October 2002 17:27  |
Eclipse User |
|
|
|
Originally posted by: sy_cheung2.yahoo.com
Randy,
Thanks again. I am now able to add a Logic Label in the middle of a
connection. However, that label does not respond to the mouse select event,
mouse drag event and mouse popup event (right-mouse click). It does respond
to mouse double-click event so that I can edit the label content.
Do you have any idea why this happens? I add the same logic label in other
part of a diagram, i can move, right mouse click that label.
Thank you.
"Randy Hudson" <hudsonr@us.eye-bee-em.com> wrote in message
news:anc7ki$v7s$1@rogue.oti.com...
>
> "Sam Cheung" <scheung@novarra.com> wrote in message
> news:anal23$dni$1@rogue.oti.com...
> >
> >
> > Thanks for the suggestion. I add the following code in refreshVisuals of
> the
> > LogicLabelEditPart, but I got an exception saying "Figure is not a
child".
> >
> > EditPart parent = getParent();
> >
> > if (parent instanceof WireEditPart) {
> >
> >
> > WireEditPart wire = (WireEditPart)parent;
> >
> >
> > // this should be LogicLabelEditPart, getFigure should return Label
> >
> > setLayoutConstraint(this, getFigure(), new ConnectionLocator
> > ((Connection)wire.getFigure()));
>
> Did you call this method on the parent (the wire)? I guess the method
isn't
> ideally named "setLayoutConstaintForChild", but if you think about it,
there
> would be no reason to pass this if you are calling the method on yourself.
>
> it should be wire.setLayoutConstraint(this, getFigure(), locator)
>
>
|
|
|
Goto Forum:
Current Time: Wed Jul 02 20:09:15 EDT 2025
Powered by FUDForum. Page generated in 0.05586 seconds
|