Programmatically deleting a node [message #140025] |
Wed, 27 June 2007 10:00 |
Eclipse User |
|
|
|
Originally posted by: frank.henard.accenture.com
I am trying to implement something called "pins". A pin is simply a
side-affixed child node of it's parent node.
I am trying to make it so that when the user adds a pin to a node or
deletes it from the node, our plugins will also add and delete pins to and
from other nodes.
I have written the code that will add a pin to a node when the user adds a
pin to another node. I simply add the semantic object and thanks to gmf
magic, the view is also added.
<code>
myNode.getInputPins().add(newInputPin);
</code>
However, I am having trouble deleting that same pin. When the user
deletes a view from the diagram I would like to delete a completely
different view and its corresponding semantic object.
The closest that I got to this working was when I implemented the
getDestroyElementCommand in the SemanticEditPolicy. I am removing the pin
semantic element from the collection in its parent, but the view is not
disappearing. See code below:
<code>
/**
* @generated
*/
public class InputPinItemSemanticEditPolicy extends
XXXBaseItemSemanticEditPolicy {
/**
* @not-generated
*/
protected Command getDestroyElementCommand(final DestroyElementRequest
req) {
return getMSLWrapper(new DestroyElementCommand(req) {
@Override
protected CommandResult doExecuteWithResult(IProgressMonitor monitor,
IAdaptable info) throws ExecutionException {
xxx
myNode.getInputPins().remove(inputPinToDelete);
xxx
}
xxxx
</code>
Can anybody tell me how to get the view to disappear when I delete the
semantic element, or is there a different way to go about this?
|
|
|
Powered by
FUDForum. Page generated in 0.05393 seconds