Having 2 types of connections [message #69974] |
Thu, 13 March 2003 14:59 |
Eclipse User |
|
|
|
Originally posted by: m.spork.NOSPAMtpg.com.au
Hi,
I want to be able to create 2 different types of connections within
the one diagram - these 2 different types of connections connect
different node types - so I don't want a connection of one type to try
to anchor itself to the wrong type of node (even though it may have a
GRAPHICAL_NODE_ROLE with a NodeEditPolicy).
The particular application is a sort of hybrid StateChart diagram
where I want to represent control flow links as well as data-flow
links. The controlflow is between States - the data flow will be
between input and output "parameters" that are nested within those
States.
I have the control flow links working (modelled on the Wire
connections in Logic example). Now I want to add a new "data-flow
link" tool to the tool pallette such that I can create data-flow
links.
I started implementing this by creating a new ParameterNodeEditPolicy
that creates a new type of connection command for data links - I
attach this policy to ParameterEditPart (based on NodeEditPart code in
Logic example).
My next step was to create a new connection tool on the pallette just
for data links.
But before I did this I wanted to check the effect of the new edit
policy on existing code - and it has created a problem when trying to
create the old control flow link (that was working fine previsously).
It seems that when I point the existing control-flow connection tool
at a Parameter (that is nested in a State) it tries to invoke the
(newly created) ParameterNodeEditPolicy - I want the control-flow
connection tool to ignore the child Parameter and just connect to the
underlying State. Before I installed the new ParameterNodeEditPolicy
on the ParameterEditPart it worked exactly this way. Now to anchor a
control-flow link to the State I have to click on an area of the state
that is not covered by a Parameter node.
Is there I way that I can have a connection tool that is selective in
the ConnectionEditPolicies it invokes? - so I want my control flow
connection tool to ignore Parameters with their
ParameterNodeEditPolicys - and I want my data-link connection tool to
ignore States with their StateNodeEditPolicys.
Any help would be much appreciated.
Thanks
Murray
|
|
|
Re: Having 2 types of connections [message #70014 is a reply to message #69974] |
Thu, 13 March 2003 15:30 |
Eclipse User |
|
|
|
Originally posted by: none.us.ibm.com
This is a multi-part message in MIME format.
------=_NextPart_000_0010_01C2E94B.8D37F970
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
> Hi,
>=20
> I want to be able to create 2 different types of connections within
> the one diagram - these 2 different types of connections connect
> different node types - so I don't want a connection of one type to try
> to anchor itself to the wrong type of node (even though it may have a
> GRAPHICAL_NODE_ROLE with a NodeEditPolicy).
To prevent the wrong nodes from being targeted your would override =
GraphcialNodeEditPolicy.getTArgetEditPART:
/**
* Returns the <i>host</i> for the appropriate <code>Requests</code>. =
Returns
* <code>null</code> otherwise.
* @see org.eclipse.gef.EditPolicy#getTargetEditPart(Request)
*/
public EditPart getTargetEditPart(Request request) {
if (REQ_CONNECTION_START.equals(request.getType())
|| REQ_CONNECTION_END.equals(request.getType())
{
CreateConnectionRequest create =3D =
(CreateConnectionRequest)request;
if (create.getNewObjectType() !=3D /*do some check here*/)
return null; //Therefore, don't target this editpart
return getHost();
}
if (REQ_RECONNECT_SOURCE.equals(request.getType())
|| REQ_RECONNECT_TARGET.equals(request.getType()))
{
ReconnectRequest reconnect =3D (ReconnectRequest)request;
Object model =3D reconnect.getConnectionEditPart().getModel();
if (/* perform some check on the model */)
return getHost(); //passes check
else
return null; //fails check
}
return null;
}
>=20
> I have the control flow links working (modelled on the Wire
> connections in Logic example). Now I want to add a new "data-flow
> link" tool to the tool pallette such that I can create data-flow
> links.
>=20
> I started implementing this by creating a new ParameterNodeEditPolicy
> that creates a new type of connection command for data links - I
> attach this policy to ParameterEditPart (based on NodeEditPart code in
> Logic example).
>=20
> My next step was to create a new connection tool on the pallette just
> for data links.
I don't think this is necessary. The CreationFactory on the default =
ConnecitonCreationTool can be configured with the object type, so you =
will be able to distinguish the two types of connections this way.
> But before I did this I wanted to check the effect of the new edit
> policy on existing code - and it has created a problem when trying to
> create the old control flow link (that was working fine previsously).
>=20
> It seems that when I point the existing control-flow connection tool
> at a Parameter (that is nested in a State) it tries to invoke the
> (newly created) ParameterNodeEditPolicy - I want the control-flow
> connection tool to ignore the child Parameter and just connect to the
> underlying State. Before I installed the new ParameterNodeEditPolicy
This is solved in the code above. It will fix your targeting issues.
------=_NextPart_000_0010_01C2E94B.8D37F970
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2600.0" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY>
<DIV><FONT face=3DArial size=3D2>> Hi,<BR>> <BR>> I want to be =
able to=20
create 2 different types of connections within<BR>> the one diagram - =
these 2=20
different types of connections connect<BR>> different node types - so =
I don't=20
want a connection of one type to try<BR>> to anchor itself to the =
wrong type=20
of node (even though it may have a<BR>> GRAPHICAL_NODE_ROLE with a=20
NodeEditPolicy).</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>To prevent the wrong nodes from being =
targeted your=20
would override GraphcialNodeEditPolicy.getTArgetEditPART:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2></FONT><FONT color=3D#3f5fbf size=3D2>
<P>/**<BR></FONT><FONT color=3D#3f5fbf size=3D2>*</FONT><FONT size=3D2> =
</FONT><FONT=20
color=3D#3f5fbf size=3D2>Returns</FONT><FONT size=3D2> </FONT><FONT =
color=3D#3f5fbf=20
size=3D2>the</FONT><FONT size=3D2> </FONT><FONT color=3D#7f7f9f=20
size=3D2><i></FONT><FONT color=3D#3f5fbf size=3D2>host</FONT><FONT =
color=3D#7f7f9f=20
size=3D2></i></FONT><FONT size=3D2> </FONT><FONT color=3D#3f5fbf=20
size=3D2>for</FONT><FONT size=3D2> </FONT><FONT color=3D#3f5fbf =
size=3D2>the</FONT><FONT=20
size=3D2> </FONT><FONT color=3D#3f5fbf size=3D2>appropriate</FONT><FONT =
size=3D2>=20
</FONT><FONT color=3D#7f7f9f size=3D2><code></FONT><FONT =
color=3D#3f5fbf=20
size=3D2>Requests</FONT><FONT color=3D#7f7f9f =
size=3D2></code></FONT><FONT=20
color=3D#3f5fbf size=3D2>.</FONT><FONT size=3D2> </FONT><FONT =
color=3D#3f5fbf=20
size=3D2>Returns<BR></FONT><FONT color=3D#3f5fbf size=3D2>*</FONT><FONT =
size=3D2>=20
</FONT><FONT color=3D#7f7f9f size=3D2><code></FONT><FONT =
color=3D#3f5fbf=20
size=3D2>null</FONT><FONT color=3D#7f7f9f =
size=3D2></code></FONT><FONT size=3D2>=20
</FONT><FONT color=3D#3f5fbf size=3D2>otherwise.<BR></FONT><FONT =
color=3D#3f5fbf=20
size=3D2>*</FONT><FONT size=3D2> </FONT><B><FONT color=3D#7f9fbf=20
size=3D2>@see</B></FONT><FONT size=3D2> </FONT><FONT color=3D#3f5fbf=20
size=3D2>org.eclipse.gef.EditPolicy#getTargetEditPart(Request) <BR></FONT>=
<FONT=20
color=3D#3f5fbf size=3D2>*/</P></FONT><B><FONT color=3D#7f0055 size=3D2>
<P>public</B></FONT><FONT size=3D2> EditPart getTargetEditPart(Request =
request)=20
{<BR></FONT><B><FONT color=3D#7f0055 size=3D2> =
if</B></FONT><FONT=20
size=3D2> =
(REQ_CONNECTION_START.equals(request.getType())<BR> =20
||=20
REQ_CONNECTION_END.equals(request.getType())<BR> =20
{<BR> CreateConnectionRequest =
create =3D=20
(CreateConnectionRequest)request;<BR></FONT><B><FONT color=3D#7f0055=20
size=3D2> if</B></FONT><FONT =
size=3D2>=20
(create.getNewObjectType() !=3D </FONT><FONT color=3D#3f7f5f =
size=3D2>/*do some check=20
here*/</FONT><FONT size=3D2>)<BR></FONT><B><FONT color=3D#7f0055=20
size=3D2> =20
return</B></FONT><FONT size=3D2> </FONT><B><FONT color=3D#7f0055=20
size=3D2>null</B></FONT><FONT size=3D2>; </FONT><FONT color=3D#3f7f5f=20
size=3D2>//Therefore, don't target this editpart<BR></FONT><B><FONT =
color=3D#7f0055=20
size=3D2> return</B></FONT><FONT =
size=3D2>=20
getHost();<BR> }<BR></FONT><FONT =
size=3D2></FONT><B><FONT=20
color=3D#7f0055 size=3D2> if</B></FONT><FONT size=3D2> =
(REQ_RECONNECT_SOURCE.equals(request.getType())<BR> =20
||=20
REQ_RECONNECT_TARGET.equals(request.getType()))<BR> =20
{<BR> ReconnectRequest reconnect =
=3D=20
(ReconnectRequest)request;<BR> =
Object=20
model =3D =
reconnect.getConnectionEditPart().getModel();<BR></FONT><B ><FONT=20
color=3D#7f0055 size=3D2> =
if</B></FONT><FONT=20
size=3D2> (</FONT><FONT color=3D#3f7f5f size=3D2>/* perform some check =
on the model=20
*/</FONT><FONT size=3D2>)<BR></FONT><B><FONT color=3D#7f0055=20
size=3D2> =20
return</B></FONT><FONT size=3D2> getHost(); //passes =
check<BR></FONT><B><FONT=20
color=3D#7f0055 size=3D2> =20
else<BR></B></FONT><B><FONT color=3D#7f0055 size=3D2> =20
return</B></FONT><FONT size=3D2>=20
</FONT><B><FONT color=3D#7f0055 size=3D2>null</B></FONT><FONT size=3D2>; =
//fails=20
check<BR> }<BR></FONT><B><FONT color=3D#7f0055=20
size=3D2> return</B></FONT><FONT size=3D2> =
</FONT><B><FONT=20
color=3D#7f0055 size=3D2>null</B></FONT><FONT =
size=3D2>;<BR>}</P></FONT></DIV>
<DIV><BR><FONT face=3DArial size=3D2><BR>> <BR>> I have the =
control flow links=20
working (modelled on the Wire<BR>> connections in Logic example). Now =
I want=20
to add a new "data-flow<BR>> link" tool to the tool pallette such =
that I can=20
create data-flow<BR>> links.<BR>> <BR>> I started =
implementing=20
this by creating a new ParameterNodeEditPolicy<BR>> that creates a =
new type=20
of connection command for data links - I<BR>> attach this policy to=20
ParameterEditPart (based on NodeEditPart code in<BR>> Logic =
example).<BR>>=20
<BR>> My next step was to create a new connection tool on the =
pallette=20
just<BR>> for data links.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>I don't think this is necessary. =
The=20
CreationFactory on the default ConnecitonCreationTool can be configured =
with the=20
object type, so you will be able to distinguish the two types of =
connections=20
this way.</DIV>
<DIV><BR>> But before I did this I wanted to check the effect of the =
new=20
edit<BR>> policy on existing code - and it has created a problem when =
trying=20
to<BR>> create the old control flow link (that was working fine=20
previsously).<BR>> <BR>> It seems that when I point the existing=20
control-flow connection tool<BR>> at a Parameter (that is nested in a =
State)=20
it tries to invoke the<BR>> (newly created) ParameterNodeEditPolicy - =
I want=20
the control-flow<BR>> connection tool to ignore the child Parameter =
and just=20
connect to the<BR>> underlying State. Before I installed the new=20
ParameterNodeEditPolicy</DIV>
<DIV> </DIV>
<DIV>This is solved in the code above. It will fix your targeting=20
issues.</DIV>
<DIV></FONT> </DIV></BODY></HTML>
------=_NextPart_000_0010_01C2E94B.8D37F970--
|
|
|
Re: Having 2 types of connections [message #70150 is a reply to message #70014] |
Thu, 13 March 2003 19:50 |
Eclipse User |
|
|
|
Originally posted by: m.spork.NOSPAMtpg.com.au
On Thu, 13 Mar 2003 10:30:22 -0500, "Randy Hudson" <none@us.ibm.com>
wrote:
>> I want to be able to create 2 different types of connections within
>> the one diagram - these 2 different types of connections connect
>> different node types - so I don't want a connection of one type to try
>> to anchor itself to the wrong type of node (even though it may have a
>> GRAPHICAL_NODE_ROLE with a NodeEditPolicy).
[...]
>I don't think this is necessary. The CreationFactory on the default ConnecitonCreationTool can be configured with the object type, so you will be able to distinguish the two types of connections this way.
Hi Randy,
Thanks for that. It appears to be mainly working now but I have a bug
with my data-links (control-flow links now working perfectly)
When I try to create a source for the data-flow link by clicking on
one of the Parameter objects with the connection tool - it doesn't
seem to want to connect properly - I get the proper connection icon
(as if it has connected to the source anchor properly) but the
connection line doesn't appear - or sometimes it does appear but it is
in a weird position in the top left hand corner of the workbench and
not connected to the Parameter object.
Just wondering if you might have any suggestions where I might look to
track this bug down - I've been looking for several hours to no avail.
Murray
|
|
|
Re: Having 2 types of connections [message #70170 is a reply to message #70150] |
Thu, 13 March 2003 21:05 |
Eclipse User |
|
|
|
Originally posted by: m.spork.NOSPAMtpg.com.au
On Fri, 14 Mar 2003 05:50:02 +1000, Murray Spork
<m.spork@NOSPAMtpg.com.au> wrote:
[...]
>When I try to create a source for the data-flow link by clicking on
>one of the Parameter objects with the connection tool - it doesn't
>seem to want to connect properly - I get the proper connection icon
>(as if it has connected to the source anchor properly) but the
>connection line doesn't appear - or sometimes it does appear but it is
>in a weird position in the top left hand corner of the workbench and
>not connected to the Parameter object.
>
>Just wondering if you might have any suggestions where I might look to
>track this bug down - I've been looking for several hours to no avail.
Found it - my ParameterEditPart needed to implement NodeEditPart
|
|
|
Powered by
FUDForum. Page generated in 0.04773 seconds