|
|
|
|
Re: Changing a shape to another shape at run time [message #200959 is a reply to message #200473] |
Thu, 07 August 2008 03:12 |
Jevon Messages: 164 Registered: July 2009 |
Senior Member |
|
|
Hi David,
Sure, here are some snippets of code that I was using. In particular it
is some code to create an element, and then some similar code to delete
an element.
// we will combine all of these commands together
CompoundCommand cc = new CompoundCommand("A compound command");
// create a command to create an element
CreateViewRequest leftRequest =
CreateViewRequestFactory.getCreateShapeRequest(ThreeElementT ypes.LeftObject_1002,
part.getDiagramPreferencesHint());
ContainerEditPart mapEditPart = (ContainerEditPart) part.getParent();
Command createLeftCmd = mapEditPart.getCommand(leftRequest);
// add it to the compound command
cc.add(createLeftCmd);
// create a command to delete an element
DestroyElementRequest request2 = new
DestroyElementRequest(sublink.resolveSemanticElement(), false);
Command deleteLinkCmd = sublink.getCommand( new
EditCommandRequestWrapper(request2) );
cc.add(deleteLinkCmd);
// you can then execute the command
selectedElement.getDiagramEditDomain().getDiagramCommandStac k().execute(cc);
Hope this helps.
Jevon
David wrote:
> Hi Jevon,
> Many thanks for your help.
> I intend to replace a selected element with another without loosing the
> link to other elements. Now I can right-click on the element and then
> select another element to replace it, the problem now is this; the new
> element just sits on top of the selected element without replacing it.
> Im trying to include the "DestroyElementrequest" code you sent. Please,
> if you have more suggestions, they would be highly appreciated.
>
> Thanks
> David
>
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03311 seconds