Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » UML2 » [EMF / GMF / UML] Modify model element cause diagram corrupted
[EMF / GMF / UML] Modify model element cause diagram corrupted [message #632228] Tue, 12 October 2010 08:22 Go to next message
Arnaud Dieumegard is currently offline Arnaud DieumegardFriend
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 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
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/
Re: [EMF / GMF / UML] Modify model element cause diagram corrupted [message #632289 is a reply to message #632283] Tue, 12 October 2010 13:17 Go to previous message
Arnaud Dieumegard is currently offline Arnaud DieumegardFriend
Messages: 29
Registered: June 2010
Junior Member
Hi,

It apears that it's a Papyrus related error:

Quote:
!ENTRY org.eclipse.emf.transaction 4 45 2010-10-12 15:05:51.735
!MESSAGE Uncaught exception during post-commit listener notifications
!STACK 0
java.lang.ClassCastException: org.eclipse.uml2.uml.internal.impl.ClassImpl cannot be cast to org.eclipse.uml2.uml.Operation
at org.eclipse.papyrus.diagram.common.helper.OperationLabelHelp er.getUMLElement(OperationLabelHelper.java:129)
at org.eclipse.papyrus.diagram.common.helper.OperationLabelHelp er.getUMLElement(OperationLabelHelper.java:1)
at org.eclipse.papyrus.diagram.common.helper.StereotypedElement LabelHelper.stereotypesToDisplay(StereotypedElementLabelHelp er.java:232)
at org.eclipse.papyrus.diagram.common.helper.StereotypedElement LabelHelper.labelToDisplay(StereotypedElementLabelHelper.jav a:361)
at org.eclipse.papyrus.diagram.common.helper.StereotypedElement LabelHelper.refreshEditPartDisplay(StereotypedElementLabelHe lper.java:351)
at org.eclipse.papyrus.diagram.clazz.custom.policies.OperationL abelEditPolicy.refreshDisplay(OperationLabelEditPolicy.java: 397)
at org.eclipse.papyrus.diagram.common.editpolicies.AbstractMask ManagedEditPolicy.refresh(AbstractMaskManagedEditPolicy.java :90)
at org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPa rt$3.run(GraphicalEditPart.java:858)
at org.eclipse.emf.transaction.impl.TransactionalEditingDomainI mpl.runExclusive(TransactionalEditingDomainImpl.java:328)
at org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPa rt.refresh(GraphicalEditPart.java:851)
at org.eclipse.gef.editparts.AbstractEditPart.addNotify(Abstrac tEditPart.java:252)
at org.eclipse.gef.editparts.AbstractGraphicalEditPart.addNotif y(AbstractGraphicalEditPart.java:223)
at org.eclipse.gef.editparts.AbstractEditPart.addChild(Abstract EditPart.java:211)
at org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPa rt.addChild(GraphicalEditPart.java:1319)
at org.eclipse.gef.editparts.AbstractEditPart.refreshChildren(A bstractEditPart.java:771)
at org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPa rt.refreshChild(GraphicalEditPart.java:1232)
at org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPa rt.handleMajorSemanticChange(GraphicalEditPart.java:1258)
at org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPa rt.handleNotificationEvent(GraphicalEditPart.java:1477)
at org.eclipse.papyrus.diagram.clazz.edit.parts.Operation3EditP art.handleNotificationEvent(Operation3EditPart.java:734)
at org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPa rt.notifyChanged(GraphicalEditPart.java:1438)
at org.eclipse.gmf.runtime.diagram.core.listener.DiagramEventBr oker.fireNotification(DiagramEventBroker.java:500)
at org.eclipse.gmf.runtime.diagram.core.listener.DiagramEventBr oker.resourceSetChanged(DiagramEventBroker.java:395)
at org.eclipse.gmf.runtime.diagram.ui.DiagramEventBrokerThreadS afe.resourceSetChanged(DiagramEventBrokerThreadSafe.java:73)
at org.eclipse.emf.transaction.impl.TransactionalEditingDomainI mpl$1.run(TransactionalEditingDomainImpl.java:781)
at org.eclipse.emf.transaction.impl.TransactionalEditingDomainI mpl.runExclusive(TransactionalEditingDomainImpl.java:328)
at org.eclipse.emf.transaction.impl.TransactionalEditingDomainI mpl.postcommit(TransactionalEditingDomainImpl.java:771)
at org.eclipse.emf.transaction.impl.TransactionalEditingDomainI mpl.deactivate(TransactionalEditingDomainImpl.java:543)
at org.eclipse.emf.transaction.impl.TransactionImpl.close(Trans actionImpl.java:712)
at org.eclipse.emf.transaction.impl.TransactionImpl.commit(Tran sactionImpl.java:474)
at org.eclipse.emf.workspace.AbstractEMFOperation.execute(Abstr actEMFOperation.java:155)
at org.eclipse.core.commands.operations.DefaultOperationHistory .execute(DefaultOperationHistory.java:511)
at org.eclipse.emf.workspace.impl.WorkspaceCommandStackImpl.doE xecute(WorkspaceCommandStackImpl.java:208)
at org.eclipse.emf.transaction.impl.AbstractTransactionalComman dStack.execute(AbstractTransactionalCommandStack.java:165)
at org.eclipse.emf.transaction.impl.AbstractTransactionalComman dStack.execute(AbstractTransactionalCommandStack.java:219)
at com.continental.limasrelated.actions.GetADDContentAction$1.e xecute(GetADDContentAction.java:101)
at org.eclipse.ui.actions.WorkspaceModifyOperation$1.run(Worksp aceModifyOperation.java:106)
at org.eclipse.core.internal.resources.Workspace.run(Workspace. java:1975)
at org.eclipse.ui.actions.WorkspaceModifyOperation.run(Workspac eModifyOperation.java:118)
at org.eclipse.jface.operation.ModalContext.runInCurrentThread( ModalContext.java:464)
at org.eclipse.jface.operation.ModalContext.run(ModalContext.ja va:372)
at org.eclipse.jface.dialogs.ProgressMonitorDialog.run(Progress MonitorDialog.java:507)
at org.eclipse.ui.internal.progress.ProgressMonitorJobsDialog.r un(ProgressMonitorJobsDialog.java:275)
at org.eclipse.ui.internal.progress.ProgressManager.run(Progres sManager.java:1162)
at com.continental.limasrelated.actions.GetADDContentAction.run (GetADDContentAction.java:57)
at org.eclipse.ui.internal.PluginAction.runWithEvent(PluginActi on.java:251)
at org.eclipse.ui.internal.WWinPluginAction.runWithEvent(WWinPl uginAction.java:229)
at org.eclipse.jface.action.ActionContributionItem.handleWidget Selection(ActionContributionItem.java:584)
at org.eclipse.jface.action.ActionContributionItem.access$2(Act ionContributionItem.java:501)
at org.eclipse.jface.action.ActionContributionItem$5.handleEven t(ActionContributionItem.java:411)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java :84)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.ja va:4066)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :3657)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.jav a:2629)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2593)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:24 27)
at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:670)
at org.eclipse.core.databinding.observable.Realm.runWithDefault (Realm.java:332)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Work bench.java:663)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.j ava:149)
at org.eclipse.ui.internal.ide.application.IDEApplication.start (IDEApplication.java:115)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(Eclips eAppHandle.java:196)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .runApplication(EclipseAppLauncher.java:110)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .start(EclipseAppLauncher.java:79)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:369)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:179)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java: 619)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:574)
at org.eclipse.equinox.launcher.Main.run(Main.java:1407)
at org.eclipse.equinox.launcher.Main.main(Main.java:1383)


I will post on their news group.
Thanks for your answer.

Arnaud
Previous Topic:HOW to register UML resources?
Next Topic:Re: UML Testing Profile
Goto Forum:
  


Current Time: Fri Mar 29 11:09:51 GMT 2024

Powered by FUDForum. Page generated in 0.01644 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top