force only one type of connector for an EditPart [message #191318] |
Tue, 09 August 2005 21:27 |
Eclipse User |
|
|
|
Originally posted by: pbeagan.yahoo_nospam_.com
I have EditParts A and B. I have connectors A1 and B1. EditParts A can
only be connected together with A1 connectors. EditParts B can only be
connected together with B1 connectors.
How do I accomplished this rule?
It seems that in A's EditPolicy.getConnectionCreateCommand, I should
somehow be able to determine the type of connector in the
CreateConnectionRequest. I've tried request.getNewObjectType(), which
always returns 1. I've tried request.getNewObject(), which returns null.
Any ideas?
Thanks.
protected Command getConnectionCreateCommand(CreateConnectionRequest
request) {
Shape source = (Shape) getHost().getModel();
int style = ((Integer) request.getNewObjectType()).intValue();
ShapeConnectionCreateCommand cmd = new
ShapeConnectionCreateCommand(source, style);
request.setStartCommand(cmd);
return cmd;
}
|
|
|
Re: force only one type of connector for an EditPart [message #191327 is a reply to message #191318] |
Tue, 09 August 2005 21:49 |
Eclipse User |
|
|
|
Originally posted by: none.us.ibm.com
Those methods should work. It depends on the CreationFactory you configured
the tool with.
"Patrick Beagan" <pbeagan@yahoo_nospam_.com> wrote in message
news:ddb6qb$ruh$1@news.eclipse.org...
>I have EditParts A and B. I have connectors A1 and B1. EditParts A can
> only be connected together with A1 connectors. EditParts B can only be
> connected together with B1 connectors.
>
> How do I accomplished this rule?
>
> It seems that in A's EditPolicy.getConnectionCreateCommand, I should
> somehow be able to determine the type of connector in the
> CreateConnectionRequest. I've tried request.getNewObjectType(), which
> always returns 1. I've tried request.getNewObject(), which returns null.
> Any ideas?
>
> Thanks.
>
>
>
> protected Command getConnectionCreateCommand(CreateConnectionRequest
> request) {
>
>
> Shape source = (Shape) getHost().getModel();
> int style = ((Integer)
> request.getNewObjectType()).intValue();
> ShapeConnectionCreateCommand cmd = new
> ShapeConnectionCreateCommand(source, style);
> request.setStartCommand(cmd);
> return cmd;
>
> }
|
|
|
Re: force only one type of connector for an EditPart [message #191466 is a reply to message #191327] |
Wed, 10 August 2005 15:33 |
Eclipse User |
|
|
|
Originally posted by: pbeagan.yahoo_dontspamme_.com
That was it, in the tool's CreationFactory. Thanks again! It's really cool
when GEF starts to come together and make sense.
Randy Hudson wrote:
> Those methods should work. It depends on the CreationFactory you
> configured the tool with.
>
> "Patrick Beagan" <pbeagan@yahoo_nospam_.com> wrote in message
> news:ddb6qb$ruh$1@news.eclipse.org...
>>I have EditParts A and B. I have connectors A1 and B1. EditParts A can
>> only be connected together with A1 connectors. EditParts B can only be
>> connected together with B1 connectors.
>>
>> How do I accomplished this rule?
>>
>> It seems that in A's EditPolicy.getConnectionCreateCommand, I should
>> somehow be able to determine the type of connector in the
>> CreateConnectionRequest. I've tried request.getNewObjectType(), which
>> always returns 1. I've tried request.getNewObject(), which returns null.
>> Any ideas?
>>
>> Thanks.
>>
>>
>>
>> protected Command getConnectionCreateCommand(CreateConnectionRequest
>> request) {
>>
>>
>> Shape source = (Shape) getHost().getModel();
>> int style = ((Integer)
>> request.getNewObjectType()).intValue();
>> ShapeConnectionCreateCommand cmd = new
>> ShapeConnectionCreateCommand(source, style);
>> request.setStartCommand(cmd);
>> return cmd;
>>
>> }
|
|
|
Powered by
FUDForum. Page generated in 0.21098 seconds