delete an element from model [message #1015896] |
Mon, 04 March 2013 03:27  |
Eclipse User |
|
|
|
Hi,
I'm quiet new to GFM and I have some problems
How could I delete an element from the data model?
I get the element by the way below:
URI fileUri = URI.createFileURI(modelFilePath);
ResourceSet resourceSet = new ResourceSetImpl();
Resource resource = resourceSet.getResource(fileUri, true);
EList<EObject> eList = resource.getContents();
EObject eObject = eList.get(0);
Model fmToolModel = (Model)eObject;
xxElement x = fmToolModel.get...
what is the best way to delete the element and the links with it?
Deleting only the x while not deleting the links may cause errors that the file could not open.
Giving me the code is what i expected...
Thanks~
|
|
|
|
|
|
|
|
|
|
|
Re: delete an element from model [message #1015962 is a reply to message #1015954] |
Mon, 04 March 2013 07:30  |
Eclipse User |
|
|
|
Hi,Andreas
The code finally executed wihout any error.However it does not gose as i wished.
Here gose my code:
ResourceSet resourceSet = new ResourceSetImpl();
TransactionalEditingDomain domainx = TransactionalEditingDomain.Factory.INSTANCE.createEditingDomain(resourceSet);
Resource res = domainx.loadResource(fileUri.path());
xxxImpl toDelete = (xxxImpl)((xxxModelImpl)res.getContents().get(0)).getXXX().get(0);
IOperationHistory history = OperationHistoryFactory.getOperationHistory();
DestroyElementRequest desRequest = new DestroyElementRequest(toDelete, true);
history.execute(new DestroyElementCommand(desRequest), new NullProgressMonitor(), null);
The code delete the element indeed,while the edgs goes still. it causes the problem that i can not open the file any more.
What should I do ,Could you please give a helping hand?
[Updated on: Mon, 04 March 2013 10:40] by Moderator
|
|
|
Powered by
FUDForum. Page generated in 0.04421 seconds