Skip to main content



      Home
Home » Eclipse Projects » GEF » Connection end labels + feedback
Connection end labels + feedback [message #133352] Thu, 20 May 2004 19:07 Go to next message
Eclipse UserFriend
I have labels on the end of my connections which can be moved about. I'd
like to provide functionality such that when the label is selected a line
is drawn to the connection end it belongs. This line is removed when the
label loses focus.

My first guess at doing this was to implement a policy of type
SELECTION_FEEDBACK_ROLE on the editpart of the labels. But the problem
with this is that it only has access to the label's editPart figure and
can only add graphics within its bounds. It seems that I need to add a
new figure, is it necessary to add a new editpart or is it possible to add
the new figure to the label's editpart? Perhaps there is a better
approach to doing this?

Thanks.

James
Re: Connection end labels + feedback [message #133366 is a reply to message #133352] Thu, 20 May 2004 20:13 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: rlemaigr.ulb.ac.be

Hello,

Maybe I'm wrong but I think usualy feedbacks are displayed as figures in=
=

the feedback layer, not as children of the figure of an EditPart.
Displaying feedback figures in the feedback layer allows you to ensure =

that they are on top of everything else and thus visible, and you are no=
t =

limited by the bounding box of the figure of the host editpart like in =

your case.

I think you should extend SelectionEditPolicy. This EditPolicy listens t=
o =

changes in the selection state of its host EditPart and calls appropriat=
e =

methods when this selection state changes. In addition to that, extendin=
g =

itself GraphicalEditPolicy, SelectionEditPolicy gives you two methods to=
=

easily add and remove feedback figures from the feedback layer =

(addFeedback(IFigure) and removeFeedback(IFigure)).

For an example of how to add and remove feedback in the feedback layer y=
ou =

could look at the class NonResizableEditPolicy wich shows source feedbac=
k =

when you move the host editpart.

I hope this has helped you,

r=E9gis

On Thu, 20 May 2004 23:07:23 +0000 (UTC), James Willans =

<jwillans@cs.york.ac.uk> wrote:

> I have labels on the end of my connections which can be moved about. =
I'd
> like to provide functionality such that when the label is selected a l=
ine
> is drawn to the connection end it belongs. This line is removed when =
the
> label loses focus.
>
> My first guess at doing this was to implement a policy of type
> SELECTION_FEEDBACK_ROLE on the editpart of the labels. But the proble=
m
> with this is that it only has access to the label's editPart figure an=
d
> can only add graphics within its bounds. It seems that I need to add =
a
> new figure, is it necessary to add a new editpart or is it possible to=
=

> add
> the new figure to the label's editpart? Perhaps there is a better
> approach to doing this?
>
> Thanks.
>
> James
>



-- =

Using Opera's revolutionary e-mail client: http://www.opera.com/m2/
Re: Connection end labels + feedback [message #133433 is a reply to message #133366] Fri, 21 May 2004 07:02 Go to previous messageGo to next message
Eclipse UserFriend
Regis,

Thanks for your comprehensive reply - this helped a lot. In the first
instance I went down the route that you indicated implementing a type of
SelectionEditPolicy. Although this worked, the feedback was displayed
when I first selected the figure and hidden when it was unselected, the
feedback was out of date if I selected the label then moved it about.
Instead, I then extended my NonResizableEditPolicy (which handles the
movement of the connection labels) and used showChangeBoundsFeedback which
updates the feedback as the label is moved about. However an issue with
this is that you cannot just select the label in order to see its owning
connection end (you need to move it about). I guess I could add the
feedback using the SelectionEditPolicy and try and get a handle on it in
the NonResizableEditPolicy in order to move it about (potentially by
making the IFigure static). Do you have any better suggestion?

Thanks again,

James


rlemaigr@ulb.ac.be wrote:

> Hello,

> Maybe I'm wrong but I think usualy feedbacks are displayed as figures in
> the feedback layer, not as children of the figure of an EditPart.
> Displaying feedback figures in the feedback layer allows you to ensure
> that they are on top of everything else and thus visible, and you are not
> limited by the bounding box of the figure of the host editpart like in
> your case.

> I think you should extend SelectionEditPolicy. This EditPolicy listens to
> changes in the selection state of its host EditPart and calls appropriate
> methods when this selection state changes. In addition to that, extending
> itself GraphicalEditPolicy, SelectionEditPolicy gives you two methods to
> easily add and remove feedback figures from the feedback layer
> (addFeedback(IFigure) and removeFeedback(IFigure)).

> For an example of how to add and remove feedback in the feedback layer you
> could look at the class NonResizableEditPolicy wich shows source feedback
> when you move the host editpart.

> I hope this has helped you,

> régis

> On Thu, 20 May 2004 23:07:23 +0000 (UTC), James Willans
> <jwillans@cs.york.ac.uk> wrote:

> > I have labels on the end of my connections which can be moved about. I'd
> > like to provide functionality such that when the label is selected a line
> > is drawn to the connection end it belongs. This line is removed when the
> > label loses focus.
> >
> > My first guess at doing this was to implement a policy of type
> > SELECTION_FEEDBACK_ROLE on the editpart of the labels. But the problem
> > with this is that it only has access to the label's editPart figure and
> > can only add graphics within its bounds. It seems that I need to add a
> > new figure, is it necessary to add a new editpart or is it possible to
> > add
> > the new figure to the label's editpart? Perhaps there is a better
> > approach to doing this?
> >
> > Thanks.
> >
> > James
> >
Re: Connection end labels + feedback [message #133461 is a reply to message #133433] Fri, 21 May 2004 09:48 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: rlemaigr.ulb.ac.be

Oops, sorry I put you in a wrong direction with my idea of extending =

SelectionEditPolicy...I had forgotten that your label already had a =

NonResizableEditPolicy...I think the way you've chosen is better, =

extending your NonResizableEditPolicy is the good way to do that.

I think you could do something like that:
You could extend the methods that show and erase the selection feedback =
to =

show and erase your own feedback by writing your own code then calling =

super.xxx(). Then, you could do things in such a way that the feedback =

figure updates itself when the label moves. I think it is simple to do =

that: you could use a PolylineConnection as feedback figure. =

PolylineConnections use ConnectionAnchors to automaticaly update =

themselves when their ends move. You just have to choose the right type =
of =

ConnectionAnchors (draw2d provides different kinds of such =

ConnectionAnchor, in your case a ChopboxAnchor could be the best for the=
=

label side of the line and maybe for the other side of the line too) , a=
nd =

associate the connections anchor with the Figures at the ends of the =

PolylineConnection. A very fast way to learn to do that is to look at on=
e =

of the examples wich comes with the documentation of the draw2d library.=


Let me know if it has worked or if you have found another solution...

r=E9gis


On Fri, 21 May 2004 11:02:24 +0000 (UTC), James Willans =

<jwillans@cs.york.ac.uk> wrote:

> Regis,
>
> Thanks for your comprehensive reply - this helped a lot. In the first=

> instance I went down the route that you indicated implementing a type =
of
> SelectionEditPolicy. Although this worked, the feedback was displayed=

> when I first selected the figure and hidden when it was unselected, th=
e
> feedback was out of date if I selected the label then moved it about.
> Instead, I then extended my NonResizableEditPolicy (which handles the
> movement of the connection labels) and used showChangeBoundsFeedback =

> which
> updates the feedback as the label is moved about. However an issue wi=
th
> this is that you cannot just select the label in order to see its owni=
ng
> connection end (you need to move it about). I guess I could add the
> feedback using the SelectionEditPolicy and try and get a handle on it =
in
> the NonResizableEditPolicy in order to move it about (potentially by
> making the IFigure static). Do you have any better suggestion?
>
> Thanks again,
>
> James
>
>
> rlemaigr@ulb.ac.be wrote:
>
>> Hello,
>
>> Maybe I'm wrong but I think usualy feedbacks are displayed as figures=
in
>> the feedback layer, not as children of the figure of an EditPart.
>> Displaying feedback figures in the feedback layer allows you to ensur=
e
>> that they are on top of everything else and thus visible, and you are=
=

>> not
>> limited by the bounding box of the figure of the host editpart like i=
n
>> your case.
>
>> I think you should extend SelectionEditPolicy. This EditPolicy listen=
s =

>> to
>> changes in the selection state of its host EditPart and calls =

>> appropriate
>> methods when this selection state changes. In addition to that, =

>> extending
>> itself GraphicalEditPolicy, SelectionEditPolicy gives you two methods=
to
>> easily add and remove feedback figures from the feedback layer
>> (addFeedback(IFigure) and removeFeedback(IFigure)).
>
>> For an example of how to add and remove feedback in the feedback laye=
r =

>> you
>> could look at the class NonResizableEditPolicy wich shows source =

>> feedback
>> when you move the host editpart.
>
>> I hope this has helped you,
>
>> r=E9gis
>
>> On Thu, 20 May 2004 23:07:23 +0000 (UTC), James Willans
>> <jwillans@cs.york.ac.uk> wrote:
>
>> > I have labels on the end of my connections which can be moved about=
.. =

>> I'd
>> > like to provide functionality such that when the label is selected =
a =

>> line
>> > is drawn to the connection end it belongs. This line is removed wh=
en =

>> the
>> > label loses focus.
>> >
>> > My first guess at doing this was to implement a policy of type
>> > SELECTION_FEEDBACK_ROLE on the editpart of the labels. But the =

>> problem
>> > with this is that it only has access to the label's editPart figure=
=

>> and
>> > can only add graphics within its bounds. It seems that I need to a=
dd =

>> a
>> > new figure, is it necessary to add a new editpart or is it possible=
to
>> > add
>> > the new figure to the label's editpart? Perhaps there is a better
>> > approach to doing this?
>> >
>> > Thanks.
>> >
>> > James
>> >
>
>
>
>
>



-- =

Using Opera's revolutionary e-mail client: http://www.opera.com/m2/
Re: Connection end labels + feedback [message #134233 is a reply to message #133461] Tue, 25 May 2004 17:02 Go to previous message
Eclipse UserFriend
Originally posted by: none.us.ibm.com

If you use anchors which are properly implemented, the feedback line will
update as a result of the anchors firing that they moved. Or, you could
keep setting new anchors every time the label moves

This is the correct way to do it, since you need to also be concerned with
undo/redo of a selected label, which does not call show feedback.


<rlemaigr@ulb.ac.be> wrote in message
news:opr8crahu3xn9g2u@xn--pcrgis-dva.mshome.net...
Oops, sorry I put you in a wrong direction with my idea of extending
SelectionEditPolicy...I had forgotten that your label already had a
NonResizableEditPolicy...I think the way you've chosen is better,
extending your NonResizableEditPolicy is the good way to do that.

I think you could do something like that:
You could extend the methods that show and erase the selection feedback to
show and erase your own feedback by writing your own code then calling
super.xxx(). Then, you could do things in such a way that the feedback
figure updates itself when the label moves. I think it is simple to do
that: you could use a PolylineConnection as feedback figure.
PolylineConnections use ConnectionAnchors to automaticaly update
themselves when their ends move. You just have to choose the right type of
ConnectionAnchors (draw2d provides different kinds of such
ConnectionAnchor, in your case a ChopboxAnchor could be the best for the
label side of the line and maybe for the other side of the line too) , and
associate the connections anchor with the Figures at the ends of the
PolylineConnection. A very fast way to learn to do that is to look at one
of the examples wich comes with the documentation of the draw2d library.

Let me know if it has worked or if you have found another solution...

r
Previous Topic:Problems with Thumbnail
Next Topic:control which items can be parents for new items 'clicked' rather than dragged from the palette
Goto Forum:
  


Current Time: Sat May 10 16:01:53 EDT 2025

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

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

Back to the top