Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[mdt-papyrus.dev] Problem using CommandStack and Commands

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.
Then, I need to compare the existing elements with the new element and replace/add/delete acccording to the result.

I have an IWorkbenchWindowActionDelegate 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.

Is this a good way to modify a model (I mean is it good to do Commands inside commands ?

When I try my plugin, the modifications are done, I save the modified diagram (and so the model) and when I reopen it, I have an error:

!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 it.
Here is a part of my code:
//Get the org.eclipse.uml2.uml.operation
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);
This is how I manage my modification, is this good or is there a problem ?

I tried to find some Papyrus MDT Cookbook but on the svn, it's an old version.
I also find this: http://wiki.eclipse.org/Papyrus_Developer_Guide/Editing_Domains_and_Commands but it's for Papyrus (old version)
Is there a new version of the second document ?

Thanks for your help.
Arnaud

Back to the top