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

Bug 315362

Summary: [Tooling] ClassCastException in WorkbenchModel Editor in 3.x host mode
Product: [Eclipse Project] Platform Reporter: Simon Chemouil <eclipse>
Component: UIAssignee: Thomas Schindl <tom.schindl>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: tom.schindl
Version: 3.7   
Target Milestone: 4.1   
Hardware: PC   
OS: Linux   
Whiteboard:
Attachments:
Description Flags
Git patch fixes the exception
none
Improved fix, now adds the ISelection to the context instead of dropping it tom.schindl: iplog+

Description Simon Chemouil CLA 2010-06-02 05:35:03 EDT
Build Identifier: I20100531-1900

Get this exception:

java.lang.ClassCastException: org.eclipse.jface.text.TextSelection cannot be cast to org.eclipse.jface.viewers.IStructuredSelection
	at org.eclipse.e4.tools.emf.editor3x.compat.IEclipseContextServiceFactory$1.selectionChanged(IEclipseContextServiceFactory.java:67)
	at org.eclipse.ui.internal.AbstractSelectionService.fireSelection(AbstractSelectionService.java:156)
	at org.eclipse.ui.internal.AbstractSelectionService$1.selectionChanged(AbstractSelectionService.java:62)
	at org.eclipse.jface.viewers.Viewer$2.run(Viewer.java:162)
	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.Viewer.fireSelectionChanged(Viewer.java:160)
	at org.eclipse.jface.text.TextViewer.fireSelectionChanged(TextViewer.java:2728)
	at org.eclipse.jface.text.TextViewer.selectionChanged(TextViewer.java:2707)
	at org.eclipse.jface.text.TextViewer.setSelectedRange(TextViewer.java:2392)
	at org.eclipse.jdt.internal.ui.javaeditor.JavaEditor.setSelection(JavaEditor.java:

In IEclipseContextServiceFactory line 67, the selection is cast to IStructuredSelection without checking its type. Turns out it's not always a IStructuredSelection.

Also, when all the Workbench Model Editor parts are closed, the behavior goes on. Maybe the selection listener could be removed in some conditions (currently, the IEclipseContextServiceFactory is an internal class(!) so it can consider only the current bundle is using it).



Reproducible: Always

Steps to Reproduce:
1. Open Workbenchmodel editor in 3.6
2. Open Error Log
3. Select Console view
Comment 1 Simon Chemouil CLA 2010-06-02 05:36:46 EDT
Created attachment 170766 [details]
Git patch fixes the exception

Here's a simple patch that prevent the exception from happening.
Comment 2 Simon Chemouil CLA 2010-06-02 06:31:32 EDT
Created attachment 170772 [details]
Improved fix, now adds the ISelection to the context instead of dropping it
Comment 3 Thomas Schindl CLA 2010-06-02 07:28:29 EDT
fix released to head - thanks