Skip to main content



      Home
Home » Eclipse Projects » GEF » Prevent users from reconnecting a connection to a component
Prevent users from reconnecting a connection to a component [message #37583] Wed, 30 October 2002 11:26 Go to next message
Eclipse UserFriend
Originally posted by: sy_cheung2.yahoo.com

Hi,

I would like to know how I can prevent users from reconnecting an existing
connection to a component?

I return NULL in the getTargetConnectionAnchor() method of the component so
that user can NOT draw a connection connecting the the component. But user
can still reconnect an *existing* connection to that component. I would like
to know
what else I need to do so that users can *not* do that as well.

So user can not draw any connection to that component either using the
creation tool or re-connecting an existing connection to that new component.

Thank you.
Re: Prevent users from reconnecting a connection to a component [message #37728 is a reply to message #37583] Wed, 30 October 2002 13:33 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: hudsonr.us.eye-bee-em.com

LabelEditPart in Logic example does not support connections. Notice how it
also does not have any Node*EditPolicies either.

"Sam Cheung" <sy_cheung2@yahoo.com> wrote in message
news:apoved$835$1@rogue.oti.com...
> Hi,
>
> I would like to know how I can prevent users from reconnecting an existing
> connection to a component?
>
> I return NULL in the getTargetConnectionAnchor() method of the component
so
> that user can NOT draw a connection connecting the the component. But
user
> can still reconnect an *existing* connection to that component. I would
like
> to know
> what else I need to do so that users can *not* do that as well.
>
> So user can not draw any connection to that component either using the
> creation tool or re-connecting an existing connection to that new
component.
>
> Thank you.
>
>
Re: Prevent users from reconnecting a connection to a component [message #37766 is a reply to message #37728] Wed, 30 October 2002 13:41 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: sy_cheung2.yahoo.com

Thanks Randy,
But i want that component to allow incoming connection only, not outgoing
connection.

So I can't follow the LabelEditPart (which does not allow *ANY* connection),
can I?

"Randy Hudson" <hudsonr@us.eye-bee-em.com> wrote in message
news:app703$d3h$1@rogue.oti.com...
> LabelEditPart in Logic example does not support connections. Notice how
it
> also does not have any Node*EditPolicies either.
>
> "Sam Cheung" <sy_cheung2@yahoo.com> wrote in message
> news:apoved$835$1@rogue.oti.com...
> > Hi,
> >
> > I would like to know how I can prevent users from reconnecting an
existing
> > connection to a component?
> >
> > I return NULL in the getTargetConnectionAnchor() method of the component
> so
> > that user can NOT draw a connection connecting the the component. But
> user
> > can still reconnect an *existing* connection to that component. I would
> like
> > to know
> > what else I need to do so that users can *not* do that as well.
> >
> > So user can not draw any connection to that component either using the
> > creation tool or re-connecting an existing connection to that new
> component.
> >
> > Thank you.
> >
> >
>
>
Re: Prevent users from reconnecting a connection to a component [message #37822 is a reply to message #37766] Wed, 30 October 2002 15:51 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: hudsonr.us.eye-bee-em.com

OK. You would do this in your component's GraphicalNodeEditPolicy.
Override getTargetEditPart(Request) to return NULL if the Request is a
REQ_RECONNECT_SOURCE, or REQ_CONNECTION_START.


"Sam Cheung" <sy_cheung2@yahoo.com> wrote in message
news:app7c4$dbs$1@rogue.oti.com...
> Thanks Randy,
> But i want that component to allow incoming connection only, not outgoing
> connection.
>
> So I can't follow the LabelEditPart (which does not allow *ANY*
connection),
> can I?
>
> "Randy Hudson" <hudsonr@us.eye-bee-em.com> wrote in message
> news:app703$d3h$1@rogue.oti.com...
> > LabelEditPart in Logic example does not support connections. Notice how
> it
> > also does not have any Node*EditPolicies either.
> >
> > "Sam Cheung" <sy_cheung2@yahoo.com> wrote in message
> > news:apoved$835$1@rogue.oti.com...
> > > Hi,
> > >
> > > I would like to know how I can prevent users from reconnecting an
> existing
> > > connection to a component?
> > >
> > > I return NULL in the getTargetConnectionAnchor() method of the
component
> > so
> > > that user can NOT draw a connection connecting the the component. But
> > user
> > > can still reconnect an *existing* connection to that component. I
would
> > like
> > > to know
> > > what else I need to do so that users can *not* do that as well.
> > >
> > > So user can not draw any connection to that component either using the
> > > creation tool or re-connecting an existing connection to that new
> > component.
> > >
> > > Thank you.
> > >
> > >
> >
> >
>
>
Re: Prevent users from reconnecting a connection to a component [message #38052 is a reply to message #37822] Thu, 31 October 2002 03:47 Go to previous messageGo to next message
Eclipse UserFriend
i believe i did something like that in graphicalnodeeditpolicy, in one parts
policy, create returns null, which means you can not start a connection from
this part, in other part, complete returns null, which means you can not
complete a connection on it...

protected Command getConnectionCompleteCommand(CreateConnectionRequest
request)

{

return null;

}

protected Command getConnectionCreateCommand(CreateConnectionRequest
request)

{

ConnectionCommand command = new ConnectionCommand();

command.setWire(new Wire());

command.setSource(getModel());

ConnectionAnchor ctor = getPart().getSourceConnectionAnchor(request);

command.setSourceTerminal(getPart().mapConnectionAnchorToTer minal(ctor));

request.setStartCommand(command);

return command;

}



"Randy Hudson" <hudsonr@us.eye-bee-em.com> wrote in message
news:appf3g$imq$1@rogue.oti.com...
> OK. You would do this in your component's GraphicalNodeEditPolicy.
> Override getTargetEditPart(Request) to return NULL if the Request is a
> REQ_RECONNECT_SOURCE, or REQ_CONNECTION_START.
>
>
> "Sam Cheung" <sy_cheung2@yahoo.com> wrote in message
> news:app7c4$dbs$1@rogue.oti.com...
> > Thanks Randy,
> > But i want that component to allow incoming connection only, not
outgoing
> > connection.
> >
> > So I can't follow the LabelEditPart (which does not allow *ANY*
> connection),
> > can I?
> >
> > "Randy Hudson" <hudsonr@us.eye-bee-em.com> wrote in message
> > news:app703$d3h$1@rogue.oti.com...
> > > LabelEditPart in Logic example does not support connections. Notice
how
> > it
> > > also does not have any Node*EditPolicies either.
> > >
> > > "Sam Cheung" <sy_cheung2@yahoo.com> wrote in message
> > > news:apoved$835$1@rogue.oti.com...
> > > > Hi,
> > > >
> > > > I would like to know how I can prevent users from reconnecting an
> > existing
> > > > connection to a component?
> > > >
> > > > I return NULL in the getTargetConnectionAnchor() method of the
> component
> > > so
> > > > that user can NOT draw a connection connecting the the component.
But
> > > user
> > > > can still reconnect an *existing* connection to that component. I
> would
> > > like
> > > > to know
> > > > what else I need to do so that users can *not* do that as well.
> > > >
> > > > So user can not draw any connection to that component either using
the
> > > > creation tool or re-connecting an existing connection to that new
> > > component.
> > > >
> > > > Thank you.
> > > >
> > > >
> > >
> > >
> >
> >
>
>
Re: Prevent users from reconnecting a connection to a component [message #38246 is a reply to message #38052] Thu, 31 October 2002 08:49 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: hudsonr.us.eye-bee-em.com

You will need to handle reconnecting as well. Command
getReconnectIForgetTheRest(Request)
Also, NULL does not guarantee that the operation is prevented. You should
return an UnexecutableCommand

Either way works. In Ozgur's case, the Node is targeted, and it rejects the
connection. In my case, the node is not target, and whatever is under the
node is targeted. This gives good results if the part under the node is the
"Diagram", which doesn't support connections. If you have additional
containers in your application that are also nodes (like Logic Circuits),
then maybe this isn't ideal. To get a feel for this, drop a Label inside a
Circuit, and try to create a connection to the Label. The Circuit is
targeted.

"Ozgur Kurt" <ozgurkurt@hotmail.com> wrote in message
news:apqotu$6s8$1@rogue.oti.com...
> i believe i did something like that in graphicalnodeeditpolicy, in one
parts
> policy, create returns null, which means you can not start a connection
from
> this part, in other part, complete returns null, which means you can not
> complete a connection on it...
>
> protected Command getConnectionCompleteCommand(CreateConnectionRequest
> request)
>
> {
>
> return null;
>
> }
>
> protected Command getConnectionCreateCommand(CreateConnectionRequest
> request)
>
> {
>
> ConnectionCommand command = new ConnectionCommand();
>
> command.setWire(new Wire());
>
> command.setSource(getModel());
>
> ConnectionAnchor ctor = getPart().getSourceConnectionAnchor(request);
>
> command.setSourceTerminal(getPart().mapConnectionAnchorToTer minal(ctor));
>
> request.setStartCommand(command);
>
> return command;
>
> }
>
>
>
> "Randy Hudson" <hudsonr@us.eye-bee-em.com> wrote in message
> news:appf3g$imq$1@rogue.oti.com...
> > OK. You would do this in your component's GraphicalNodeEditPolicy.
> > Override getTargetEditPart(Request) to return NULL if the Request is a
> > REQ_RECONNECT_SOURCE, or REQ_CONNECTION_START.
> >
> >
> > "Sam Cheung" <sy_cheung2@yahoo.com> wrote in message
> > news:app7c4$dbs$1@rogue.oti.com...
> > > Thanks Randy,
> > > But i want that component to allow incoming connection only, not
> outgoing
> > > connection.
> > >
> > > So I can't follow the LabelEditPart (which does not allow *ANY*
> > connection),
> > > can I?
> > >
> > > "Randy Hudson" <hudsonr@us.eye-bee-em.com> wrote in message
> > > news:app703$d3h$1@rogue.oti.com...
> > > > LabelEditPart in Logic example does not support connections. Notice
> how
> > > it
> > > > also does not have any Node*EditPolicies either.
> > > >
> > > > "Sam Cheung" <sy_cheung2@yahoo.com> wrote in message
> > > > news:apoved$835$1@rogue.oti.com...
> > > > > Hi,
> > > > >
> > > > > I would like to know how I can prevent users from reconnecting an
> > > existing
> > > > > connection to a component?
> > > > >
> > > > > I return NULL in the getTargetConnectionAnchor() method of the
> > component
> > > > so
> > > > > that user can NOT draw a connection connecting the the component.
> But
> > > > user
> > > > > can still reconnect an *existing* connection to that component. I
> > would
> > > > like
> > > > > to know
> > > > > what else I need to do so that users can *not* do that as well.
> > > > >
> > > > > So user can not draw any connection to that component either using
> the
> > > > > creation tool or re-connecting an existing connection to that new
> > > > component.
> > > > >
> > > > > Thank you.
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >
> >
> >
>
>
Re: Prevent users from reconnecting a connection to a component [message #38343 is a reply to message #38246] Thu, 31 October 2002 10:13 Go to previous message
Eclipse UserFriend
thanx Randy, should i return this UnexecutableCommand for every request to a
command that shouldn't be ran?



"Randy Hudson" <hudsonr@us.eye-bee-em.com> wrote in message
news:apran4$h6k$1@rogue.oti.com...
> You will need to handle reconnecting as well. Command
> getReconnectIForgetTheRest(Request)
> Also, NULL does not guarantee that the operation is prevented. You should
> return an UnexecutableCommand
>
> Either way works. In Ozgur's case, the Node is targeted, and it rejects
the
> connection. In my case, the node is not target, and whatever is under the
> node is targeted. This gives good results if the part under the node is
the
> "Diagram", which doesn't support connections. If you have additional
> containers in your application that are also nodes (like Logic Circuits),
> then maybe this isn't ideal. To get a feel for this, drop a Label inside
a
> Circuit, and try to create a connection to the Label. The Circuit is
> targeted.
>
> "Ozgur Kurt" <ozgurkurt@hotmail.com> wrote in message
> news:apqotu$6s8$1@rogue.oti.com...
> > i believe i did something like that in graphicalnodeeditpolicy, in one
> parts
> > policy, create returns null, which means you can not start a connection
> from
> > this part, in other part, complete returns null, which means you can not
> > complete a connection on it...
> >
> > protected Command getConnectionCompleteCommand(CreateConnectionRequest
> > request)
> >
> > {
> >
> > return null;
> >
> > }
> >
> > protected Command getConnectionCreateCommand(CreateConnectionRequest
> > request)
> >
> > {
> >
> > ConnectionCommand command = new ConnectionCommand();
> >
> > command.setWire(new Wire());
> >
> > command.setSource(getModel());
> >
> > ConnectionAnchor ctor = getPart().getSourceConnectionAnchor(request);
> >
> >
command.setSourceTerminal(getPart().mapConnectionAnchorToTer minal(ctor));
> >
> > request.setStartCommand(command);
> >
> > return command;
> >
> > }
> >
> >
> >
> > "Randy Hudson" <hudsonr@us.eye-bee-em.com> wrote in message
> > news:appf3g$imq$1@rogue.oti.com...
> > > OK. You would do this in your component's GraphicalNodeEditPolicy.
> > > Override getTargetEditPart(Request) to return NULL if the Request is a
> > > REQ_RECONNECT_SOURCE, or REQ_CONNECTION_START.
> > >
> > >
> > > "Sam Cheung" <sy_cheung2@yahoo.com> wrote in message
> > > news:app7c4$dbs$1@rogue.oti.com...
> > > > Thanks Randy,
> > > > But i want that component to allow incoming connection only, not
> > outgoing
> > > > connection.
> > > >
> > > > So I can't follow the LabelEditPart (which does not allow *ANY*
> > > connection),
> > > > can I?
> > > >
> > > > "Randy Hudson" <hudsonr@us.eye-bee-em.com> wrote in message
> > > > news:app703$d3h$1@rogue.oti.com...
> > > > > LabelEditPart in Logic example does not support connections.
Notice
> > how
> > > > it
> > > > > also does not have any Node*EditPolicies either.
> > > > >
> > > > > "Sam Cheung" <sy_cheung2@yahoo.com> wrote in message
> > > > > news:apoved$835$1@rogue.oti.com...
> > > > > > Hi,
> > > > > >
> > > > > > I would like to know how I can prevent users from reconnecting
an
> > > > existing
> > > > > > connection to a component?
> > > > > >
> > > > > > I return NULL in the getTargetConnectionAnchor() method of the
> > > component
> > > > > so
> > > > > > that user can NOT draw a connection connecting the the
component.
> > But
> > > > > user
> > > > > > can still reconnect an *existing* connection to that component.
I
> > > would
> > > > > like
> > > > > > to know
> > > > > > what else I need to do so that users can *not* do that as well.
> > > > > >
> > > > > > So user can not draw any connection to that component either
using
> > the
> > > > > > creation tool or re-connecting an existing connection to that
new
> > > > > component.
> > > > > >
> > > > > > Thank you.
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >
> >
> >
>
>
Previous Topic:Problems in creating connections
Next Topic:Change the Color of a Container Figure
Goto Forum:
  


Current Time: Mon May 05 09:18:36 EDT 2025

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

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

Back to the top