|
Re: Duplicate lines inside a container [message #59687 is a reply to message #59640] |
Thu, 05 October 2006 18:01 |
Eclipse User |
|
|
|
Originally posted by: vcciubot.uwaterloo.ca
Edges are created in two ways:
1) by the GraphicalNodeEditPolicy - that's when you use the connection
tool and drag with the mouse
2) by a CanonicalConnectionEditPolicy that listens to the model and syncs
it with the notational model
So very likely, a CanonicalConnectionEditPolicy is not turned off when it
should be. This happens when the connections are owned by a model element
that's not either the source, target or immediate container of the source
and target of the connection.
So you can either change the ownership of connections in your model, or
subclass GraphicalNodeEditPolicy and install that new editpolicy on the
edit parts that act as ends to the connection:
Here's an example (look for //cc.compose( new CommandProxy(viewCommand) );)
public class B2GraphicalNodeEditPolicy extends GraphicalNodeEditPolicy {
/**
* Gets the command to complete the creation of a new connection and
* relationship.
* <p>
* We override because we return a command that operates on the semantic model only.
*
* @param request
* @return Command
*/
protected Command getConnectionAndRelationshipCompleteCommand(
CreateConnectionViewAndElementRequest request) {
// get the element descriptor
CreateElementRequestAdapter requestAdapter = request
.getConnectionViewAndElementDescriptor().getCreateElementReq uestAdapter();
// get the semantic request
CreateRelationshipRequest createElementRequest = (CreateRelationshipRequest) requestAdapter
.getAdapter(CreateRelationshipRequest.class);
createElementRequest.setPrompt(!request.isUISupressed());
// complete the semantic request by filling in the source and
// destination
INodeEditPart targetEP = getConnectionCompleteEditPart(request);
View sourceView = (View)request.getSourceEditPart().getModel();
View targetView = (View)targetEP.getModel();
// resolve the source
EObject source = ViewUtil.resolveSemanticElement(sourceView);
if (source == null) {
source = sourceView;
}
createElementRequest.setSource(source);
// resolve the target
EObject target = ViewUtil.resolveSemanticElement(targetView);
if (target == null) {
target = targetView;
}
createElementRequest.setTarget(target);
// get the create element request based on the elementdescriptor's
// request
Command createElementCommand = /* targetEP
.getCommand(new EditCommandRequestWrapper(
(CreateRelationshipRequest) requestAdapter
.getAdapter(CreateRelationshipRequest.class), request.getExtendedData()));*/
new ICommandProxy (new CreateSegmentsCommand((End) source, (End) target));
// create the create semantic element wrapper command
if (null == createElementCommand)
return null;
SemanticCreateCommand semanticCommand = new SemanticCreateCommand(
requestAdapter, createElementCommand);
// get the view command
Command viewCommand = getConnectionCompleteCommand(request);
if (null == viewCommand)
return null;
// form the compound command and return
CompositeCommand cc = new CompositeCommand(semanticCommand.getLabel());
cc.compose( semanticCommand );
//cc.compose( new CommandProxy(viewCommand) );
return new ICommandProxy(cc);
}
}
On Thu, 05 Oct 2006 15:44:23 +0000, Jon Cooke wrote:
> Hello, I have a couple of queries with the GMF.
>
> I have created a GMF project that has one container node two core nodes
> and a link. The two main nodes can exist inside and outside the container.
> So far I have created the ecore model, the gmfgraph, gmftool and gmfmap
> and generated the other config files and the application.
>
> I'm getting some strange behaviour.
>
> The first is: I cannot drag new main nodes into the container but I can
> create them inside from the pop-up menu!
>
> The second is: when I create a link outside the container between two
> nodes all is fine I can drag the nodes inside the container and when try
> to link them from inside I get two links. Has anybody come across either
> of these problems before?
>
> I can publish the files here if required.
>
> Any help is greatly appreciated!
>
> Thanks
>
> Jon
|
|
|
|
Re: Duplicate lines inside a container [message #82450 is a reply to message #59687] |
Mon, 04 December 2006 12:29 |
Eclipse User |
|
|
|
Originally posted by: julias.frb.br
Hi Vlad, i couldnt put your pasted code to work.
I have a XXXGraphicalNodeEditPolicy and i couldnt understand the
// get the create element request based on the elementdescriptor's
// request
can you past the imports too? or maybe a more detailed code (if possible)?
thank you so much!
Vlad Ciubotariu wrote:
> Edges are created in two ways:
>
> 1) by the GraphicalNodeEditPolicy - that's when you use the connection
> tool and drag with the mouse
> 2) by a CanonicalConnectionEditPolicy that listens to the model and syncs
> it with the notational model
>
> So very likely, a CanonicalConnectionEditPolicy is not turned off when it
> should be. This happens when the connections are owned by a model element
> that's not either the source, target or immediate container of the source
> and target of the connection.
>
> So you can either change the ownership of connections in your model, or
> subclass GraphicalNodeEditPolicy and install that new editpolicy on the
> edit parts that act as ends to the connection:
>
> Here's an example (look for //cc.compose( new CommandProxy(viewCommand) );)
>
> public class B2GraphicalNodeEditPolicy extends GraphicalNodeEditPolicy {
> /**
> * Gets the command to complete the creation of a new connection and
> * relationship.
> * <p>
> * We override because we return a command that operates on the semantic model only.
> *
> * @param request
> * @return Command
> */
> protected Command getConnectionAndRelationshipCompleteCommand(
> CreateConnectionViewAndElementRequest request) {
> // get the element descriptor
> CreateElementRequestAdapter requestAdapter = request
> .getConnectionViewAndElementDescriptor().getCreateElementReq uestAdapter();
> // get the semantic request
> CreateRelationshipRequest createElementRequest = (CreateRelationshipRequest) requestAdapter
> .getAdapter(CreateRelationshipRequest.class);
>
> createElementRequest.setPrompt(!request.isUISupressed());
>
> // complete the semantic request by filling in the source and
> // destination
> INodeEditPart targetEP = getConnectionCompleteEditPart(request);
> View sourceView = (View)request.getSourceEditPart().getModel();
> View targetView = (View)targetEP.getModel();
>
> // resolve the source
> EObject source = ViewUtil.resolveSemanticElement(sourceView);
> if (source == null) {
> source = sourceView;
> }
> createElementRequest.setSource(source);
>
> // resolve the target
> EObject target = ViewUtil.resolveSemanticElement(targetView);
> if (target == null) {
> target = targetView;
> }
> createElementRequest.setTarget(target);
>
> // get the create element request based on the elementdescriptor's
> // request
> Command createElementCommand = /* targetEP
> .getCommand(new EditCommandRequestWrapper(
> (CreateRelationshipRequest) requestAdapter
> .getAdapter(CreateRelationshipRequest.class), request.getExtendedData()));*/
> new ICommandProxy (new CreateSegmentsCommand((End) source, (End) target));
>
> // create the create semantic element wrapper command
> if (null == createElementCommand)
> return null;
>
> SemanticCreateCommand semanticCommand = new SemanticCreateCommand(
> requestAdapter, createElementCommand);
> // get the view command
> Command viewCommand = getConnectionCompleteCommand(request);
> if (null == viewCommand)
> return null;
> // form the compound command and return
> CompositeCommand cc = new CompositeCommand(semanticCommand.getLabel());
> cc.compose( semanticCommand );
> //cc.compose( new CommandProxy(viewCommand) );
> return new ICommandProxy(cc);
> }
> }
>
>
>
>
>
> On Thu, 05 Oct 2006 15:44:23 +0000, Jon Cooke wrote:
>
>> Hello, I have a couple of queries with the GMF.
>>
>> I have created a GMF project that has one container node two core nodes
>> and a link. The two main nodes can exist inside and outside the container.
>> So far I have created the ecore model, the gmfgraph, gmftool and gmfmap
>> and generated the other config files and the application.
>>
>> I'm getting some strange behaviour.
>>
>> The first is: I cannot drag new main nodes into the container but I can
>> create them inside from the pop-up menu!
>>
>> The second is: when I create a link outside the container between two
>> nodes all is fine I can drag the nodes inside the container and when try
>> to link them from inside I get two links. Has anybody come across either
>> of these problems before?
>>
>> I can publish the files here if required.
>>
>> Any help is greatly appreciated!
>>
>> Thanks
>>
>> Jon
>
|
|
|
Re: Duplicate lines inside a container [message #82465 is a reply to message #82450] |
Mon, 04 December 2006 13:11 |
Eclipse User |
|
|
|
Originally posted by: julias.frb.br
I mean, i cant found CreateSegmentsCommand, and neither i can find out
what type is the End (source and target parameters)
please help me
Julia Sartori wrote:
> Hi Vlad, i couldnt put your pasted code to work.
> I have a XXXGraphicalNodeEditPolicy and i couldnt understand the
>
> // get the create element request based on the elementdescriptor's
> // request
>
>
> can you past the imports too? or maybe a more detailed code (if possible)?
>
> thank you so much!
>
>
>
> Vlad Ciubotariu wrote:
>> Edges are created in two ways:
>>
>> 1) by the GraphicalNodeEditPolicy - that's when you use the connection
>> tool and drag with the mouse
>> 2) by a CanonicalConnectionEditPolicy that listens to the model and syncs
>> it with the notational model
>>
>> So very likely, a CanonicalConnectionEditPolicy is not turned off when it
>> should be. This happens when the connections are owned by a model element
>> that's not either the source, target or immediate container of the source
>> and target of the connection.
>>
>> So you can either change the ownership of connections in your model, or
>> subclass GraphicalNodeEditPolicy and install that new editpolicy on the
>> edit parts that act as ends to the connection:
>>
>> Here's an example (look for //cc.compose( new
>> CommandProxy(viewCommand) );)
>>
>> public class B2GraphicalNodeEditPolicy extends GraphicalNodeEditPolicy {
>> /**
>> * Gets the command to complete the creation of a new connection and
>> * relationship.
>> * <p>
>> * We override because we return a command that operates on the
>> semantic model only.
>> * * @param request
>> * @return Command
>> */
>> protected Command getConnectionAndRelationshipCompleteCommand(
>> CreateConnectionViewAndElementRequest request) {
>> // get the element descriptor
>> CreateElementRequestAdapter requestAdapter = request
>>
>> .getConnectionViewAndElementDescriptor().getCreateElementReq uestAdapter();
>>
>> // get the semantic request
>> CreateRelationshipRequest createElementRequest =
>> (CreateRelationshipRequest) requestAdapter
>> .getAdapter(CreateRelationshipRequest.class);
>>
>> createElementRequest.setPrompt(!request.isUISupressed());
>>
>> // complete the semantic request by filling in the source and
>> // destination
>> INodeEditPart targetEP = getConnectionCompleteEditPart(request);
>> View sourceView = (View)request.getSourceEditPart().getModel();
>> View targetView = (View)targetEP.getModel();
>>
>> // resolve the source
>> EObject source = ViewUtil.resolveSemanticElement(sourceView);
>> if (source == null) {
>> source = sourceView;
>> }
>> createElementRequest.setSource(source);
>>
>> // resolve the target
>> EObject target = ViewUtil.resolveSemanticElement(targetView);
>> if (target == null) {
>> target = targetView;
>> }
>> createElementRequest.setTarget(target);
>>
>> // get the create element request based on the
>> elementdescriptor's
>> // request
>> Command createElementCommand = /* targetEP
>> .getCommand(new EditCommandRequestWrapper(
>> (CreateRelationshipRequest) requestAdapter
>>
>> .getAdapter(CreateRelationshipRequest.class),
>> request.getExtendedData()));*/
>> new ICommandProxy (new CreateSegmentsCommand((End) source,
>> (End) target));
>>
>> // create the create semantic element wrapper command
>> if (null == createElementCommand)
>> return null;
>>
>> SemanticCreateCommand semanticCommand = new
>> SemanticCreateCommand(
>> requestAdapter, createElementCommand);
>> // get the view command
>> Command viewCommand = getConnectionCompleteCommand(request);
>> if (null == viewCommand)
>> return null;
>> // form the compound command and return
>> CompositeCommand cc = new
>> CompositeCommand(semanticCommand.getLabel());
>> cc.compose( semanticCommand );
>> //cc.compose( new CommandProxy(viewCommand) );
>> return new ICommandProxy(cc);
>> }
>> }
>>
>>
>>
>>
>>
>> On Thu, 05 Oct 2006 15:44:23 +0000, Jon Cooke wrote:
>>
>>> Hello, I have a couple of queries with the GMF.
>>> I have created a GMF project that has one container node two core
>>> nodes and a link. The two main nodes can exist inside and outside the
>>> container. So far I have created the ecore model, the gmfgraph,
>>> gmftool and gmfmap and generated the other config files and the
>>> application.
>>>
>>> I'm getting some strange behaviour.
>>>
>>> The first is: I cannot drag new main nodes into the container but I
>>> can create them inside from the pop-up menu!
>>>
>>> The second is: when I create a link outside the container between two
>>> nodes all is fine I can drag the nodes inside the container and when
>>> try to link them from inside I get two links. Has anybody come across
>>> either of these problems before?
>>> I can publish the files here if required.
>>>
>>> Any help is greatly appreciated!
>>>
>>> Thanks
>>>
>>> Jon
>>
|
|
|
Powered by
FUDForum. Page generated in 0.03068 seconds