Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 315362 - [Tooling] ClassCastException in WorkbenchModel Editor in 3.x host mode
Summary: [Tooling] ClassCastException in WorkbenchModel Editor in 3.x host mode
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.7   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: 4.1   Edit
Assignee: Thomas Schindl CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-06-02 05:35 EDT by Simon Chemouil CLA
Modified: 2011-05-17 16:23 EDT (History)
1 user (show)

See Also:


Attachments
Git patch fixes the exception (1.14 KB, patch)
2010-06-02 05:36 EDT, Simon Chemouil CLA
no flags Details | Diff
Improved fix, now adds the ISelection to the context instead of dropping it (1.58 KB, patch)
2010-06-02 06:31 EDT, Simon Chemouil CLA
tom.schindl: iplog+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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