Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 345351

Summary: CCE when trying to Copy via keyboard shortcut
Product: [Technology] EGit Reporter: DJ Houghton <dj.houghton>
Component: UIAssignee: Project Inbox <egit.ui-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: cyril.jaquier, daniel_megert, kathleen.e.sharp, Lars.Vogel, matthias.sohn, noopur_gupta, remy.suen, robin
Version: 3.3   
Target Milestone: 3.5   
Hardware: PC   
OS: Mac OS X - Carbon (unsup.)   
Whiteboard:

Description DJ Houghton CLA 2011-05-10 20:29:01 EDT
eclipse.buildId=I20110510-1040

With this build when I try and use Command-C to copy, I get the following error. The copy does seem to work ok. Using the Copy entry from the context menu works as well and does not produce the error.

!ENTRY org.eclipse.e4.ui.workbench 4 0 2011-05-10 20:24:34.320
!MESSAGE 
!STACK 0
org.eclipse.e4.core.di.InjectionException: java.lang.ClassCastException: org.eclipse.ui.internal.views.log.LogEntry cannot be cast to org.eclipse.egit.ui.internal.repository.tree.RepositoryTreeNode
	at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:63)
	at org.eclipse.e4.core.internal.di.InjectorImpl.invokeUsingClass(InjectorImpl.java:226)
	at org.eclipse.e4.core.internal.di.InjectorImpl.invoke(InjectorImpl.java:207)
	at org.eclipse.e4.core.contexts.ContextInjectionFactory.invoke(ContextInjectionFactory.java:123)
	at org.eclipse.e4.core.commands.internal.HandlerServiceImpl.executeHandler(HandlerServiceImpl.java:122)
	at org.eclipse.e4.ui.bindings.keys.KeyBindingDispatcher.executeCommand(KeyBindingDispatcher.java:266)
	at org.eclipse.e4.ui.bindings.keys.KeyBindingDispatcher.press(KeyBindingDispatcher.java:465)
	at org.eclipse.e4.ui.bindings.keys.KeyBindingDispatcher.processKeyEvent(KeyBindingDispatcher.java:515)
	at org.eclipse.e4.ui.bindings.keys.KeyBindingDispatcher.filterKeySequenceBindings(KeyBindingDispatcher.java:348)
	at org.eclipse.e4.ui.bindings.keys.KeyBindingDispatcher.access$0(KeyBindingDispatcher.java:294)
	at org.eclipse.e4.ui.bindings.keys.KeyBindingDispatcher$KeyDownFilter.handleEvent(KeyBindingDispatcher.java:76)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Display.filterEvent(Display.java:1069)
	at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4115)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1453)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1476)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1461)
	at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1490)
	at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1486)
	at org.eclipse.swt.widgets.Text.sendKeyEvent(Text.java:1516)
	at org.eclipse.swt.widgets.Control.doCommandBySelector(Control.java:1039)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:5547)
	at org.eclipse.swt.internal.cocoa.OS.objc_msgSendSuper(Native Method)
	at org.eclipse.swt.widgets.Widget.callSuper(Widget.java:220)
	at org.eclipse.swt.widgets.Widget.superKeyDown(Widget.java:1891)
	at org.eclipse.swt.widgets.Widget.keyDown(Widget.java:1076)
	at org.eclipse.swt.widgets.Control.keyDown(Control.java:2329)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:5457)
	at org.eclipse.swt.internal.cocoa.OS.objc_msgSendSuper(Native Method)
	at org.eclipse.swt.widgets.Widget.callSuper(Widget.java:220)
	at org.eclipse.swt.widgets.Widget.windowSendEvent(Widget.java:2084)
	at org.eclipse.swt.widgets.Shell.windowSendEvent(Shell.java:2248)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:5519)
	at org.eclipse.swt.internal.cocoa.OS.objc_msgSendSuper(Native Method)
	at org.eclipse.swt.widgets.Display.applicationSendEvent(Display.java:4973)
	at org.eclipse.swt.widgets.Display.applicationProc(Display.java:5122)
	at org.eclipse.swt.internal.cocoa.OS.objc_msgSend(Native Method)
	at org.eclipse.swt.internal.cocoa.NSApplication.sendEvent(NSApplication.java:128)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3598)
	at org.eclipse.jface.window.Window.runEventLoop(Window.java:825)
	at org.eclipse.jface.window.Window.open(Window.java:801)
	at org.eclipse.ui.internal.views.log.EventDetailsDialog.open(EventDetailsDialog.java:180)
	at org.eclipse.ui.internal.views.log.EventDetailsDialogAction.run(EventDetailsDialogAction.java:98)
	at org.eclipse.ui.internal.views.log.LogView$15.doubleClick(LogView.java:535)
	at org.eclipse.jface.viewers.StructuredViewer$1.run(StructuredViewer.java:845)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
	at org.eclipse.ui.internal.JFaceUtil$1.run(JFaceUtil.java:49)
	at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:175)
	at org.eclipse.jface.viewers.StructuredViewer.fireDoubleClick(StructuredViewer.java:843)
	at org.eclipse.jface.viewers.AbstractTreeViewer.handleDoubleSelect(AbstractTreeViewer.java:1462)
	at org.eclipse.jface.viewers.StructuredViewer$4.widgetDefaultSelected(StructuredViewer.java:1246)
	at org.eclipse.jface.util.OpenStrategy.fireDefaultSelectionEvent(OpenStrategy.java:249)
	at org.eclipse.jface.util.OpenStrategy.access$0(OpenStrategy.java:246)
	at org.eclipse.jface.util.OpenStrategy$1.handleEvent(OpenStrategy.java:307)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4116)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1453)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1476)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1461)
	at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:1266)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3962)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3601)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$7.run(PartRenderingEngine.java:893)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:809)
	at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:87)
	at org.eclipse.ui.internal.Workbench$3.run(Workbench.java:542)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:522)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:123)
	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:344)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:622)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:577)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1410)
Caused by: java.lang.ClassCastException: org.eclipse.ui.internal.views.log.LogEntry cannot be cast to org.eclipse.egit.ui.internal.repository.tree.RepositoryTreeNode
	at org.eclipse.egit.ui.internal.repository.tree.command.CopyPathCommand.execute(CopyPathCommand.java:28)
	at org.eclipse.ui.internal.handlers.HandlerProxy.execute(HandlerProxy.java:293)
	at org.eclipse.ui.internal.handlers.E4HandlerProxy.execute(E4HandlerProxy.java:58)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:56)
	... 82 more
Comment 1 DJ Houghton CLA 2011-05-10 20:39:45 EDT
Not sure if it is related but I'm also seeing this when I try and do a Command-V to paste.


!ENTRY org.eclipse.egit.ui 4 0 2011-05-10 20:29:25.125
!MESSAGE Clipboard content is not a directory path

(no stack trace)
Comment 2 Remy Suen CLA 2011-05-10 22:11:54 EDT
Likely the same problem as bug 344704.
Comment 3 Kat CLA 2012-09-22 15:02:22 EDT
I'm seeing this exception in a more recent build

eclipse.buildId=I20120608-1400
java.fullversion=JRE 1.6.0 IBM J9 2.4 Linux x86-32 jvmxi3260sr10fp1-20120202_101568 (JIT enabled, AOT enabled)
J9VM - 20120202_101568
JIT  - r9_20111107_21307ifx1
GC   - 20120202_AA
BootLoader constants: OS=linux, ARCH=x86, WS=gtk, NL=en_GB
Framework arguments:  -product org.eclipse.epp.package.rcp.product
Command-line arguments:  -os linux -ws gtk -arch x86 -product org.eclipse.epp.package.rcp.product

eGit version: 2.0.0.201206130900-r

org.eclipse.e4.core.di.InjectionException: java.lang.ClassCastException: org.eclipse.ui.internal.views.log.LogEntry incompatible with org.eclipse.egit.ui.internal.repository.tree.RepositoryTreeNode
	at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:63)
	at org.eclipse.e4.core.internal.di.InjectorImpl.invokeUsingClass(InjectorImpl.java:229)
	at org.eclipse.e4.core.internal.di.InjectorImpl.invoke(InjectorImpl.java:210)
	at org.eclipse.e4.core.contexts.ContextInjectionFactory.invoke(ContextInjectionFactory.java:131)
	at org.eclipse.e4.core.commands.internal.HandlerServiceImpl.executeHandler(HandlerServiceImpl.java:171)
	at org.eclipse.e4.ui.workbench.renderers.swt.HandledContributionItem.executeItem(HandledContributionItem.java:851)
	at org.eclipse.e4.ui.workbench.renderers.swt.HandledContributionItem.handleWidgetSelection(HandledContributionItem.java:744)
	at org.eclipse.e4.ui.workbench.renderers.swt.HandledContributionItem.access$7(HandledContributionItem.java:728)
	at org.eclipse.e4.ui.workbench.renderers.swt.HandledContributionItem$4.handleEvent(HandledContributionItem.java:667)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1276)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3554)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3179)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1022)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:916)
	at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:86)
	at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:585)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:540)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
	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:353)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:180)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:48)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:600)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:629)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:584)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1438)
Caused by: java.lang.ClassCastException: org.eclipse.ui.internal.views.log.LogEntry incompatible with org.eclipse.egit.ui.internal.repository.tree.RepositoryTreeNode
	at org.eclipse.egit.ui.internal.repository.tree.command.ConfigurePushCommand.execute(ConfigurePushCommand.java:27)
	at org.eclipse.ui.internal.handlers.HandlerProxy.execute(HandlerProxy.java:293)
	at org.eclipse.ui.internal.handlers.E4HandlerProxy.execute(E4HandlerProxy.java:76)
	at sun.reflect.GeneratedMethodAccessor44.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:600)
	at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:56)
	... 33 more
Comment 4 Paul Webster CLA 2012-09-24 08:00:06 EDT
(In reply to comment #3)
> I'm seeing this exception in a more recent build

Hi Kat, what were you doing when it generated this log?  Using the context menu, or tool item?

PW
Comment 5 Noopur Gupta CLA 2014-03-10 08:15:00 EDT
Eclipse SDK
Version: Luna (4.4)
Build id: I20140305-2000

Eclipse Git Team Provider	3.3.0.201403021825-r	org.eclipse.egit.feature.group	Eclipse EGit

Windows 7
-------------------------------------------------------------------------

- Download Eclipse and install EGit.
- Open Eclipse on a new workspace and close the Welcome screen.
- Press Ctrl+3 and type "clipboard".
- Press Ctrl+3 again to show all matches.
- Select "Copy Path to Clipboard (Ctrl+C)" and press Enter.

We get the following exception:
java.lang.ArrayIndexOutOfBoundsException: 0
	at java.util.Arrays$ArrayList.get(Arrays.java:2866)
	at org.eclipse.egit.ui.internal.repository.tree.command.CopyPathCommand.execute(CopyPathCommand.java:28)
	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.GeneratedMethodAccessor26.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:601)
	at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:56)
	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.ui.internal.handlers.LegacyHandlerService.executeCommand(LegacyHandlerService.java:420)
	at org.eclipse.ui.internal.quickaccess.CommandElement.execute(CommandElement.java:69)
	at org.eclipse.ui.internal.quickaccess.SearchField$2.handleElementSelected(SearchField.java:173)
	at org.eclipse.ui.internal.quickaccess.QuickAccessContents.handleSelection(QuickAccessContents.java:461)
	at org.eclipse.ui.internal.quickaccess.QuickAccessContents.access$0(QuickAccessContents.java:451)
	at org.eclipse.ui.internal.quickaccess.QuickAccessContents$1.keyPressed(QuickAccessContents.java:495)
	at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:167)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4353)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1061)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1085)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1070)
	at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1112)
	at org.eclipse.swt.widgets.Text.sendKeyEvent(Text.java:1726)
	at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1108)
	at org.eclipse.swt.widgets.Widget.wmChar(Widget.java:1529)
	at org.eclipse.swt.widgets.Control.WM_CHAR(Control.java:4722)
	at org.eclipse.swt.widgets.Text.WM_CHAR(Text.java:2611)
	at org.eclipse.swt.widgets.Control.windowProc(Control.java:4610)
	at org.eclipse.swt.widgets.Text.windowProc(Text.java:2597)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:5020)
	at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method)
	at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:2549)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3759)
	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:601)
	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)

-------------------------------------------------------------------------

- Press Ctrl+3 and select "Copy Path to Clipboard (Ctrl+C)" from Previous choices and press Enter.

We get the following exception:

java.lang.ClassCastException: org.eclipse.ui.internal.views.log.LogEntry cannot be cast to org.eclipse.egit.ui.internal.repository.tree.RepositoryTreeNode
	at org.eclipse.egit.ui.internal.repository.tree.command.CopyPathCommand.execute(CopyPathCommand.java:28)
	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.GeneratedMethodAccessor26.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:601)
	at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:56)
	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.ui.internal.handlers.LegacyHandlerService.executeCommand(LegacyHandlerService.java:420)
	at org.eclipse.ui.internal.quickaccess.CommandElement.execute(CommandElement.java:69)
	at org.eclipse.ui.internal.quickaccess.SearchField$2.handleElementSelected(SearchField.java:173)
	at org.eclipse.ui.internal.quickaccess.QuickAccessContents.handleSelection(QuickAccessContents.java:461)
	at org.eclipse.ui.internal.quickaccess.QuickAccessContents.access$0(QuickAccessContents.java:451)
	at org.eclipse.ui.internal.quickaccess.QuickAccessContents$1.keyPressed(QuickAccessContents.java:495)
	at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:167)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4353)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1061)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1085)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1070)
	at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1112)
	at org.eclipse.swt.widgets.Text.sendKeyEvent(Text.java:1726)
	at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1108)
	at org.eclipse.swt.widgets.Widget.wmChar(Widget.java:1529)
	at org.eclipse.swt.widgets.Control.WM_CHAR(Control.java:4722)
	at org.eclipse.swt.widgets.Text.WM_CHAR(Text.java:2611)
	at org.eclipse.swt.widgets.Control.windowProc(Control.java:4610)
	at org.eclipse.swt.widgets.Text.windowProc(Text.java:2597)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:5020)
	at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method)
	at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:2549)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3759)
	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:601)
	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)
Comment 6 Paul Webster CLA 2014-03-10 09:24:07 EDT
EGit, can you point us to the definition for the command and handler (and possibly keybinding) for comment #5 ?

PW
Comment 7 Matthias Sohn CLA 2014-03-17 16:45:25 EDT
(In reply to Paul Webster from comment #6)
> EGit, can you point us to the definition for the command and handler (and
> possibly keybinding) for comment #5 ?

commands declaration in org.eclipse.egit.ui's plugin.xml

<command
  categoryId="org.eclipse.egit.ui.commandCategory"
  defaultHandler="org.eclipse.egit.ui.internal.repository.tree.command.CopyPathCommand"
  id="org.eclipse.egit.ui.RepositoriesViewCopyPath"
  name="%CopyPathCommand">

key binding definition

   <extension
      point="org.eclipse.ui.bindings">
      <key
            commandId="org.eclipse.egit.ui.RepositoriesViewCopyPath"
            contextId="org.eclipse.egit.ui.RepositoriesView"
            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
            sequence="M1+C">
      </key>
...

contribution for the context menu of the repositories view

      <menuContribution
            locationURI="popup:org.eclipse.egit.ui.RepositoriesView?after=repo-6">
         <command
               commandId="org.eclipse.egit.ui.RepositoriesViewCopyPath"
               label="%RepoViewCopyPath.label"
               style="push">
            <visibleWhen
                  checkEnabled="false">
               <and>
                  <count
                        value="1">
                  </count>
                  <iterate>
                     <or>
                        <instanceof
                              value="org.eclipse.egit.ui.internal.repository.tree.RepositoryNode">
                        </instanceof>
                        <instanceof
                              value="org.eclipse.egit.ui.internal.repository.tree.FileNode">
                        </instanceof>
                        <instanceof
                              value="org.eclipse.egit.ui.internal.repository.tree.FolderNode">
                        </instanceof>
                        <and>
                           <instanceof
                                 value="org.eclipse.egit.ui.internal.repository.tree.WorkingDirNode">
                           </instanceof>
                           <not>
                              <test
                                    property="GitRepository.isBare">
                              </test>
                           </not>
                        </and>
                     </or>
                  </iterate>
               </and>
            </visibleWhen>
         </command>
Comment 8 Paul Webster CLA 2014-03-28 10:57:21 EDT
(In reply to Matthias Sohn from comment #7)

Thanks Matthias

> (In reply to Paul Webster from comment #6)
> > EGit, can you point us to the definition for the command and handler (and
> > possibly keybinding) for comment #5 ?
> 
> commands declaration in org.eclipse.egit.ui's plugin.xml
> 
> <command
>   categoryId="org.eclipse.egit.ui.commandCategory"
>  
> defaultHandler="org.eclipse.egit.ui.internal.repository.tree.command.
> CopyPathCommand"
>   id="org.eclipse.egit.ui.RepositoriesViewCopyPath"
>   name="%CopyPathCommand">


This is the problem.  The command has a default handler, which means that handler is active all of the time.


For the AIOOBE
ava.lang.IndexOutOfBoundsException: Index: 0
	at java.util.Collections$EmptyList.get(Collections.java:3212)
	at org.eclipse.egit.ui.internal.repository.tree.command.CopyPathCommand.execute(CopyPathCommand.java:28)


Line 28 does a getSelectedNodes(event).get(0); which fails on the empty list.

For the CCE:
java.lang.ClassCastException: org.eclipse.jdt.internal.core.JavaProject cannot be cast to org.eclipse.egit.ui.internal.repository.tree.RepositoryTreeNode
	at org.eclipse.egit.ui.internal.repository.tree.command.CopyPathCommand.execute(CopyPathCommand.java:28)

RepositoryTreeNode node = getSelectedNodes(event).get(0);

getSelectedNodes(*) just does a structuredSelection.toList(), so if you have a selection in the package explorer, you'll get a CCE.

Possible options to fix it:

1) move the handlers into o.e.ui.handlers EP and make the handler active when the selection is valid.

2)  move the handlers into o.e.ui.handlers EP and make the handler enabled when the selection is valid

To do either 1 or 2, you can take the visibleWhen definition contents and move it into org.eclipse.core.expressions.definitions so it can be re-used.

3) try the checks in the setEnabled(*) call.

4) just protect the execute, either in the execute, getSelectedNodes, or both so that you get empty lists when the selection type isn't correct.

PW
Comment 9 Paul Webster CLA 2014-03-28 10:59:18 EDT
(In reply to Paul Webster from comment #8)
> > <command
> >   categoryId="org.eclipse.egit.ui.commandCategory"
> >  
> > defaultHandler="org.eclipse.egit.ui.internal.repository.tree.command.
> > CopyPathCommand"
> >   id="org.eclipse.egit.ui.RepositoriesViewCopyPath"
> >   name="%CopyPathCommand">
> 
> 

I was reproducing both scenarios using CTRL+3
Comment 10 Paul Webster CLA 2014-05-05 15:14:20 EDT
*** Bug 434141 has been marked as a duplicate of this bug. ***
Comment 11 Cyril Jaquier CLA 2014-06-26 07:21:36 EDT
I also see this after upgrading to Luna (4.4.0.I20140606-1215):

java.lang.IndexOutOfBoundsException: Index: 0
	at java.util.Collections$EmptyList.get(Collections.java:3212)
	at org.eclipse.egit.ui.internal.repository.tree.command.CopyPathCommand.execute(CopyPathCommand.java:28)
	at org.eclipse.ui.internal.handlers.HandlerProxy.execute(HandlerProxy.java:294)
	at org.eclipse.ui.internal.handlers.E4HandlerProxy.execute(E4HandlerProxy.java:90)
	at sun.reflect.GeneratedMethodAccessor36.invoke(Unknown Source)
	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:55)
	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:149)
	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:210)
	at org.eclipse.ui.internal.handlers.LegacyHandlerService.executeCommandInContext(LegacyHandlerService.java:396)
	at org.eclipse.ui.internal.quickaccess.CommandElement.execute(CommandElement.java:54)
	at org.eclipse.ui.internal.quickaccess.QuickAccessDialog$1$1$1.run(QuickAccessDialog.java:218)
	at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
	at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:136)
	at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:3806)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3444)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1151)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1032)
	at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:148)
	at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:636)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:579)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:135)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:382)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:236)
	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:1465)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1438)
Comment 12 Robin Stocker CLA 2014-06-28 01:38:51 EDT
(In reply to Paul Webster from comment #8)
> Possible options to fix it:
> 
> 1) move the handlers into o.e.ui.handlers EP and make the handler active
> when the selection is valid.

Thanks Paul. Proposed fix: https://git.eclipse.org/r/29153
Comment 13 Matthias Sohn CLA 2014-06-30 10:51:35 EDT
merged as b29b039274f6280537c6d5aa04d0c7b6a7863631