Bug 430701 - [Copy & Paste] Ctrl+C on a class in a diagram throws NPE
Summary: [Copy & Paste] Ctrl+C on a class in a diagram throws NPE
Status: RESOLVED FIXED
Alias: None
Product: Papyrus
Classification: Modeling
Component: Core (show other bugs)
Version: 1.0.0   Edit
Hardware: PC Linux
: P2 major (vote)
Target Milestone: M7   Edit
Assignee: Christian Damus CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 290261
  Show dependency tree
 
Reported: 2014-03-19 10:15 EDT by Ronan Bar CLA
Modified: 2014-03-24 04:50 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ronan Bar CLA 2014-03-19 10:15:08 EDT
Pressing Ctrl+C on a class in a diagrams gets me the following in the Error Log:

org.eclipse.e4.core.di.InjectionException: java.lang.NullPointerException
	at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:63)
	at org.eclipse.e4.core.internal.di.InjectorImpl.invokeUsingClass(InjectorImpl.java:247)
	at org.eclipse.e4.core.internal.di.InjectorImpl.invoke(InjectorImpl.java:229)
	at org.eclipse.e4.core.contexts.ContextInjectionFactory.invoke(ContextInjectionFactory.java:132)
	at org.eclipse.e4.core.commands.internal.HandlerServiceHandler.execute(HandlerServiceHandler.java:153)
	at org.eclipse.core.commands.Command.executeWithChecks(Command.java:499)
	at org.eclipse.core.commands.ParameterizedCommand.executeWithChecks(ParameterizedCommand.java:508)
	at org.eclipse.e4.core.commands.internal.HandlerServiceImpl.executeHandler(HandlerServiceImpl.java:222)
	at org.eclipse.e4.ui.bindings.keys.KeyBindingDispatcher.executeCommand(KeyBindingDispatcher.java:285)
	at org.eclipse.e4.ui.bindings.keys.KeyBindingDispatcher.press(KeyBindingDispatcher.java:505)
	at org.eclipse.e4.ui.bindings.keys.KeyBindingDispatcher.processKeyEvent(KeyBindingDispatcher.java:556)
	at org.eclipse.e4.ui.bindings.keys.KeyBindingDispatcher.filterKeySequenceBindings(KeyBindingDispatcher.java:377)
	at org.eclipse.e4.ui.bindings.keys.KeyBindingDispatcher.access$0(KeyBindingDispatcher.java:323)
	at org.eclipse.e4.ui.bindings.keys.KeyBindingDispatcher$KeyDownFilter.handleEvent(KeyBindingDispatcher.java:85)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Display.filterEvent(Display.java:1569)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1387)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1412)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1397)
	at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1424)
	at org.eclipse.swt.widgets.Widget.gtk_key_press_event(Widget.java:824)
	at org.eclipse.swt.widgets.Control.gtk_key_press_event(Control.java:3266)
	at org.eclipse.swt.widgets.Composite.gtk_key_press_event(Composite.java:777)
	at org.eclipse.swt.widgets.Widget.windowProc(Widget.java:2088)
	at org.eclipse.swt.widgets.Control.windowProc(Control.java:5498)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:4639)
	at org.eclipse.swt.internal.gtk.OS._gtk_main_do_event(Native Method)
	at org.eclipse.swt.internal.gtk.OS.gtk_main_do_event(OS.java:8715)
	at org.eclipse.swt.widgets.Display.eventProc(Display.java:1248)
	at org.eclipse.swt.internal.gtk.OS._g_main_context_iteration(Native Method)
	at org.eclipse.swt.internal.gtk.OS.g_main_context_iteration(OS.java:2284)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3391)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1122)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1006)
	at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:147)
	at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:630)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:574)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:125)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:133)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:103)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:378)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:232)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:648)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:603)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1462)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1438)
Caused by: java.lang.NullPointerException
	at org.eclipse.gmf.runtime.diagram.ui.render.clipboard.AWTClipboardHelper.copyToClipboard(AWTClipboardHelper.java:139)
	at org.eclipse.gmf.runtime.diagram.ui.render.internal.commands.CopyImageCommand.doExecuteWithResult(CopyImageCommand.java:151)
	at org.eclipse.gmf.runtime.common.core.command.AbstractCommand.execute(AbstractCommand.java:134)
	at org.eclipse.papyrus.commands.wrappers.GMFtoGEFCommandWrapper.execute(GMFtoGEFCommandWrapper.java:95)
	at org.eclipse.gef.commands.CompoundCommand.execute(CompoundCommand.java:111)
	at org.eclipse.papyrus.commands.wrappers.GEFtoEMFCommandWrapper.execute(GEFtoEMFCommandWrapper.java:86)
	at org.eclipse.emf.workspace.EMFCommandOperation.doExecute(EMFCommandOperation.java:119)
	at org.eclipse.emf.workspace.AbstractEMFOperation.execute(AbstractEMFOperation.java:150)
	at org.eclipse.core.commands.operations.DefaultOperationHistory.execute(DefaultOperationHistory.java:513)
	at org.eclipse.papyrus.commands.CheckedOperationHistory.execute(CheckedOperationHistory.java:184)
	at org.eclipse.papyrus.commands.NotifyingWorkspaceCommandStack.doExecute(NotifyingWorkspaceCommandStack.java:253)
	at org.eclipse.emf.transaction.impl.AbstractTransactionalCommandStack.execute(AbstractTransactionalCommandStack.java:165)
	at org.eclipse.emf.transaction.impl.AbstractTransactionalCommandStack.execute(AbstractTransactionalCommandStack.java:219)
	at org.eclipse.papyrus.commands.NestingNotifyingWorkspaceCommandStack.execute(NestingNotifyingWorkspaceCommandStack.java:130)
	at org.eclipse.papyrus.infra.gmfdiag.menu.handlers.AbstractGraphicalCommandHandler.execute(AbstractGraphicalCommandHandler.java:74)
	at org.eclipse.ui.internal.handlers.HandlerProxy.execute(HandlerProxy.java:290)
	at org.eclipse.ui.internal.handlers.E4HandlerProxy.execute(E4HandlerProxy.java:90)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:56)
	... 53 more
Comment 1 Ronan Bar CLA 2014-03-20 12:09:44 EDT
Note I only see this on Linux.
Comment 2 Ronan Bar CLA 2014-03-20 12:12:33 EDT
This also occurs on windows under a different scenario:

1) Create a constraint on a Class diagram
2) Copy it using ctrl+c
3) Click somewhere else on the diagram
4) Ctrl+V and you get a NPE
Comment 3 Christian Damus CLA 2014-03-20 12:17:23 EDT
(In reply to Ronan B from comment #1)
> Note I only see this on Linux.

I see this on Mac when attempting to copy a class shape on a class diagram.
Comment 4 Christian Damus CLA 2014-03-20 15:06:28 EDT
This has an affinity with the work I did for bug 430648.
Comment 5 Christian Damus CLA 2014-03-20 16:00:17 EDT
Commit 689ca46 fixes the NPE on copy in the diagram.

The NPE was caused by an attempt to execute a GMF CopyImageCommand, which only works on Windows because the AWTClipboardHelper is only supported on that platform.  So, now we don't chain the CopyImageCommand to the semantic copy command if it isn't executable (which it only is on Windows).

Moreover, these various copy commands need to be marked as non-dirtying so that executing them on the command-stack doesn't cause the editor to become dirty (as in bug 430648).  So, an INonDirtying interface is introduced as a marker for GMF and GEF commands that are non-dirtying (analogous to EMF's AbstractCommand::NonDirtying).  The various command wrappers for interactions between different command-stack systems are extended with non-dirtying variants and also non-dirtying compounds of each flavour.

So, on Windows, Ctrl+C on a diagram shape now produces a non-dirtying compound of semantic and image copy commands and on other platforms it produces just the non-dirtying semantic copy command.

The NPE on paste is an unrelated issue, specific to an edit-helper advice extending the *move* (?) of a Constraint in a Namespace.  This is spun off as bug 430832.