[EMF / GMF / UML] Modify model element cause diagram corrupted [message #632228] |
Tue, 12 October 2010 08:22 |
Arnaud Dieumegard Messages: 29 Registered: June 2010 |
Junior Member |
|
|
Hi all,
I have done many search to find if someone have the same problem than me and I have found some clues but nothing work so I post here.
I use Helios Build id: 20100617-1415
And Papyrus MDT 0.7.0.v201007251735
I'm creating a plugin to populate an UML model from a database. So I have a parser getting elements from the database.
When I try to populate my model, I need to compare the existing elements with the new element and replace/add/delete acccording to the result.
I have an action to launch the population of the diagram. In this action I have a WorkspaceModifyOperation.
In the WorkspaceModifyOperation, I have a RecordingCommand in witch I make my modifications on the model.
These modifications are DeleteCommands and RemoveCommands. I use the uml2 methods to create my new elements.
When my modifications are done I save the modified diagram (and so the model) and when I reopen it, I have an error:
First: Is this a good way to modify a model (I mean is it good to do Commands inside commands ?
Quote: | !MESSAGE org.eclipse.uml2.uml.internal.impl.ClassImpl cannot be cast to org.eclipse.uml2.uml.Operation
!STACK 0
java.lang.ClassCastException: org.eclipse.uml2.uml.internal.impl.ClassImpl cannot be cast to org.eclipse.uml2.uml.Operation
|
It seems that this error is close to this one: https://bugs.eclipse.org/bugs/show_bug.cgi?id=319240
But I do not find the way to solve the issue.
Operation op = getOperationToModify();
EditingDomain dom = AdapterFactoryEditingDomain.getEditingDomainFor(op);
Command commDeleteOP = RemoveCommand.create(dom, op);
Command commDeleteParams = DeleteCommand.create(dom, op.getOwnedParameters());
tmp = (Class) op.getOwner();
domain.getCommandStack().execute(commDeleteParams);
domain.getCommandStack().execute(commDeleteOP);
op = ((Class)tmp).createOwnedOperation(actionName, tmpParamName, tmpParamType);
Second: This is how I manage my modification, is this good or is there a problem ?
Thanks for your help.
|
|
|
Re: [EMF / GMF / UML] Modify model element cause diagram corrupted [message #632283 is a reply to message #632228] |
Tue, 12 October 2010 12:33 |
Ed Merks Messages: 33217 Registered: July 2009 |
Senior Member |
|
|
Arnaud,
Comments below.
Arnaud Dieumegard wrote:
> Hi all,
>
> I have done many search to find if someone have the same problem than
> me and I have found some clues but nothing work so I post here.
>
> I use Helios Build id: 20100617-1415
> And Papyrus MDT 0.7.0.v201007251735
>
> I'm creating a plugin to populate an UML model from a database. So I
> have a parser getting elements from the database.
> When I try to populate my model, I need to compare the existing
> elements with the new element and replace/add/delete acccording to the
> result.
>
> I have an action to launch the population of the diagram. In this
> action I have a WorkspaceModifyOperation.
> In the WorkspaceModifyOperation, I have a RecordingCommand in witch I
> make my modifications on the model.
Normally if you have a recording command you'd not make the fine grained
changes also with commands; you'd modify the model directly.
>
>
> These modifications are DeleteCommands and RemoveCommands. I use the
> uml2 methods to create my new elements.
> When my modifications are done I save the modified diagram (and so the
> model) and when I reopen it, I have an error:
> First: Is this a good way to modify a model (I mean is it good to do
> Commands inside commands ?
>
>
> Quote:
>> !MESSAGE org.eclipse.uml2.uml.internal.impl.ClassImpl cannot be cast
>> to org.eclipse.uml2.uml.Operation
>> !STACK 0
>> java.lang.ClassCastException:
>> org.eclipse.uml2.uml.internal.impl.ClassImpl cannot be cast to
>> org.eclipse.uml2.uml.Operation
>
>
> It seems that this error is close to this one:
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=319240
It might be, but it would be a big help to show the full stack trace and
if it's an issue with Papyrus on the stack, it's best to ask on their
newsgroup.
>
> But I do not find the way to solve the issue.
>
>
> Operation op = getOperationToModify();
> EditingDomain dom = AdapterFactoryEditingDomain.getEditingDomainFor(op);
> Command commDeleteOP = RemoveCommand.create(dom, op);
> Command commDeleteParams = DeleteCommand.create(dom,
> op.getOwnedParameters());
>
> tmp = (Class) op.getOwner();
> domain.getCommandStack().execute(commDeleteParams);
> domain.getCommandStack().execute(commDeleteOP);
> op = ((Class)tmp).createOwnedOperation(actionName, tmpParamName,
> tmpParamType);
>
>
> Second: This is how I manage my modification, is this good or is there
> a problem ?
>
> Thanks for your help.
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
|
Powered by
FUDForum. Page generated in 0.03459 seconds