Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » is it possible for one palette entry to correspond to multiple EObjects?
is it possible for one palette entry to correspond to multiple EObjects? [message #79645] Tue, 21 November 2006 21:31 Go to next message
Eclipse UserFriend
Originally posted by: liam.morley.baesystems.com

I have a particular edge which is also a node. When I drag this out from the
palette, I want it to respond as a connection tool. When I complete the
connection, I want 3 eobjects to be created:
1. a FROM edge from the source
2. a TO edge to the target
3. a node in the middle.

I want to be able to do this because I'll need to connect things to the
node.

I was looking at specialization types, and it looks appropriate, but I'm
still a bit hazy- is that right?

Liam
Re: is it possible for one palette entry to correspond to multiple EObjects? [message #79661 is a reply to message #79645] Wed, 22 November 2006 01:17 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: vcciubot.uwaterloo.ca

After the connection tool handles the gesture from the user, it sends a
request to the destination edit part of the connection the user tries to
create.

This request is handled by the GraphicalNodeEditPolicy installed on that
edit part. This method, does the actual work:

protected Command getConnectionAndRelationshipCompleteCommand()

It returns a composite command: one is commands that creates the view, and
the other is one creating the model element.

You can return an arbitrary semantic command, that does the work you need,
creating an intermediate node and joined by connections to the source and
target indicated by the user.

Rely on you canonical policy to create the necessary views for these
elements, like I do below (I comment out the command that creates the view)

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 Tue, 21 Nov 2006 16:31:44 -0500, Liam Morley wrote:

> I have a particular edge which is also a node. When I drag this out from the
> palette, I want it to respond as a connection tool. When I complete the
> connection, I want 3 eobjects to be created:
> 1. a FROM edge from the source by Seweryn Niemiec
2006-11-21

> 2. a TO edge to the target
> 3. a node in the middle.
>
> I want to be able to do this because I'll need to connect things to the
> node.
>
> I was looking at specialization types, and it looks appropriate, but I'm
> still a bit hazy- is that right?
>
> Liam
Re: is it possible for one palette entry to correspond to multiple EObjects? [message #79817 is a reply to message #79645] Wed, 22 November 2006 09:35 Go to previous message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Liam,

The easiest way to achieve this functionality is to modify your domain model
and add two “transient volatile derived” features one to the source of the
link, another – to the link itself. In this situation EMF will generate empty
getter/setter methods for these features which you have to implement. You
can traverse source/end objects of the link in these methods and put creation
of corresponding nodes (Are they ports BTW?) into these methods. As a result
you should not modify code generated by GMF, will be able to correctly describe
link in terms of GMF mapping model and get CanonicalEditPolicy/InitDiagramFileAction
working correctly.

If you can not modify your domain model (you are using some standard one
and would like to stay with it) you should follow the suggestions from Vlad
with an addition – CanonicalEditPolicy/InitDiagramFileAction should be modified
appropriately.

-----------------
Alex Shatalin
Previous Topic:planned maintenance releases?
Next Topic:reconcile graphical/tooling
Goto Forum:
  


Current Time: Sat Nov 23 02:54:05 GMT 2024

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

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

Back to the top