is it possible for one palette entry to correspond to multiple EObjects? [message #79645] |
Tue, 21 November 2006 21:31 |
Eclipse User |
|
|
|
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 |
Eclipse User |
|
|
|
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
|
|
|
|
Powered by
FUDForum. Page generated in 0.03403 seconds