Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » Copy And Paste of graphical Elements(copy & paste in graphical editors on the graphical model-elements)
Copy And Paste of graphical Elements [message #1071572] Sat, 20 July 2013 13:51 Go to next message
Rahul Dev Mishra is currently offline Rahul Dev MishraFriend
Messages: 8
Registered: July 2013
Location: Bangalore, India
Junior Member
Hi All,

I have implemented the Copy and Paste functionality on the Graphical editor.
Now the new copied element comes up fine on the editor. However any manipulation I do on this new element gets reflected on the other element from where this new element was copied.

The reason I think is because I have copied only the graphical pictogram element and not the underlying business element.

It would be really helpful if anybody can point me in the right direction in resolving this issue i.e. copying of business model element.

Thanks & Regards,
Rahul
Re: Copy And Paste of graphical Elements [message #1072395 is a reply to message #1071572] Mon, 22 July 2013 17:09 Go to previous messageGo to next message
Rahul Dev Mishra is currently offline Rahul Dev MishraFriend
Messages: 8
Registered: July 2013
Location: Bangalore, India
Junior Member
Hi Everyone,

The above mentioned issue is resolved and the graphical elements are getting copied perfectly. However just after the paste action completes I get an error as shown below:
Quote:
Caused by: java.lang.IllegalArgumentException: An EditPart has to be selectable (isSelectable() == true) in order to get selected.
at org.eclipse.core.runtime.Assert.isLegal(Assert.java:63)
at org.eclipse.gef.editparts.AbstractEditPart.setSelected(AbstractEditPart.java:1060)
at org.eclipse.gef.SelectionManager.appendSelection(SelectionManager.java:81)
at org.eclipse.gef.ui.parts.AbstractEditPartViewer.appendSelection(AbstractEditPartViewer.java:190)
at org.eclipse.graphiti.ui.internal.editor.GraphitiScrollingGraphicalViewer.appendSelection(GraphitiScrollingGraphicalViewer.java:138)
at org.eclipse.gef.ui.parts.AbstractEditPartViewer.select(AbstractEditPartViewer.java:599)
at org.eclipse.graphiti.ui.internal.editor.GraphitiScrollingGraphicalViewer.select(GraphitiScrollingGraphicalViewer.java:45)
at com.sap.ndb.studio.view.ui.editors.ViewEditor.select(ViewEditor.java:347)
at com.sap.ndb.studio.view.ui.graphiti.features.PasteCustomFeature$1.run(PasteCustomFeature.java:93)
at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:135)


Could anybody please let me know why this is happening ?

Thanks & Regards,
Rahul Dev Mishra
Re: Copy And Paste of graphical Elements [message #1073277 is a reply to message #1072395] Wed, 24 July 2013 12:58 Go to previous messageGo to next message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1635
Registered: July 2009
Location: Walldorf, Germany
Senior Member
Rahul,

do you trigger a select of the new shape in your paste feature? If yes, that
might come to early (the GEF edit part is set up on refresh after your
feature finished). You might try to schedule the select to happen
asynchronously after the feature.

Michael
Re: Copy And Paste of graphical Elements [message #1077141 is a reply to message #1071572] Thu, 01 August 2013 09:41 Go to previous messageGo to next message
Rahul Dev Mishra is currently offline Rahul Dev MishraFriend
Messages: 8
Registered: July 2013
Location: Bangalore, India
Junior Member
Hi Michael,

Thanks a lot for the solution. That did the trick.

Thanks,
Rahul
Re: Copy And Paste of graphical Elements [message #1096636 is a reply to message #1077141] Wed, 28 August 2013 17:06 Go to previous messageGo to next message
Rahul Dev Mishra is currently offline Rahul Dev MishraFriend
Messages: 8
Registered: July 2013
Location: Bangalore, India
Junior Member
Hello All,

Now I have got another issue.

I copy a graphical element from an editor and paste it in another editor. Now when I do that I receive IllegalStateException.

Quote:
!MESSAGE GFCommandStack.execute(Command) java.lang.IllegalStateException: Cannot modify resource set without a write transaction
!STACK 0
java.lang.IllegalStateException: Cannot modify resource set without a write transaction
at org.eclipse.emf.transaction.impl.TransactionChangeRecorder.assertWriting(TransactionChangeRecorder.java:348)
at org.eclipse.emf.transaction.impl.TransactionChangeRecorder.appendNotification(TransactionChangeRecorder.java:302)
at org.eclipse.emf.transaction.impl.TransactionChangeRecorder.processObjectNotification(TransactionChangeRecorder.java:284)
at org.eclipse.emf.transaction.impl.TransactionChangeRecorder.notifyChanged(TransactionChangeRecorder.java:240)
at org.eclipse.emf.common.notify.impl.BasicNotifierImpl.eNotify(BasicNotifierImpl.java:374)
at com.sap.ndb.studio.view.model.view.impl.ViewNodeImpl.setLayout(ViewNodeImpl.java:263)
at com.sap.ndb.studio.view.model.view.impl.ViewNodeImpl.eUnset(ViewNodeImpl.java:424)
at com.sap.ndb.studio.view.model.view.impl.ProjectionImpl.eUnset(ProjectionImpl.java:163)
at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eUnset(BasicEObjectImpl.java:1154)
at org.eclipse.emf.ecore.change.impl.FeatureChangeImpl.process(FeatureChangeImpl.java:544)
at org.eclipse.emf.ecore.change.impl.FeatureChangeImpl.apply(FeatureChangeImpl.java:518)
at org.eclipse.emf.ecore.change.impl.FeatureChangeImpl.apply(FeatureChangeImpl.java:493)
at org.eclipse.emf.ecore.change.impl.ChangeDescriptionImpl.apply(ChangeDescriptionImpl.java:300)
at org.eclipse.emf.transaction.util.CompositeChangeDescription.apply(CompositeChangeDescription.java:104)
at org.eclipse.emf.transaction.impl.TransactionImpl.doRollback(TransactionImpl.java:570)
at org.eclipse.emf.transaction.impl.TransactionImpl.rollback(TransactionImpl.java:547)
at org.eclipse.emf.workspace.AbstractEMFOperation.rollback(AbstractEMFOperation.java:630)
at org.eclipse.emf.workspace.AbstractEMFOperation.execute(AbstractEMFOperation.java:187)
at org.eclipse.core.commands.operations.DefaultOperationHistory.execute(DefaultOperationHistory.java:513)
at org.eclipse.emf.workspace.impl.WorkspaceCommandStackImpl.doExecute(WorkspaceCommandStackImpl.java:208)
at org.eclipse.emf.transaction.impl.AbstractTransactionalCommandStack.execute(AbstractTransactionalCommandStack.java:165)
at org.eclipse.graphiti.ui.internal.editor.GFCommandStack.execute(GFCommandStack.java:138)
at org.eclipse.graphiti.ui.internal.action.CustomAction.executeOnCommandStack(CustomAction.java:65)
at org.eclipse.graphiti.ui.internal.action.CustomAction.run(CustomAction.java:60)
at org.eclipse.jface.action.Action.runWithEvent(Action.java:499)
at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:584)
at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:501)
at org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java:411)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1057)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4170)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3759)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1113)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:997)
at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:138)
at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:610)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:567)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150)
at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:124)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.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(EclipseStarter.java:354)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:181)
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:636)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:591)
at org.eclipse.equinox.launcher.Main.run(Main.java:1450)
at org.eclipse.equinox.launcher.Main.main(Main.java:1426)


However if I paste the graphical element in the same editor, then without any exception the paste action is successful. However pasting the graphical element in some other editor throws an exception as shown above.

Also the paste action happens within a TransactionalEditingDomain.

Could you please let me know where am I going wrong ?

Thanks & Regards,
Rahul

[Updated on: Wed, 28 August 2013 17:07]

Report message to a moderator

Re: Copy And Paste of graphical Elements [message #1097061 is a reply to message #1096636] Thu, 29 August 2013 07:20 Go to previous message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1635
Registered: July 2009
Location: Walldorf, Germany
Senior Member
Rahul,

it seems you try to trigger a Graphiti custom action / custom feature from
somewhere (I can't see in the stack trace, there seems to be an asynchronous
trigger). That call is done directly and changes the EMF model; Graphiti
uses EMF Transactions and that framework requires all model modifications to
happen inside a transaction. Try wrapping your call into somthing like this:

TransactionalEditingDomain ted = TransactionUtil.getEditingDomain(diagram);
ted.getCommandStack().execute(new RecordingCommand(editingDomain) {

@Override
protected void doExecute() {
<your call here>
}
});

Michael
Previous Topic:Help with tutorial
Next Topic:Zoom
Goto Forum:
  


Current Time: Wed Nov 26 07:57:19 GMT 2014

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

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