Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » Luna release: casting problem(Luna, casting, WorkbenchWindow, org.eclipse.jface.window.ApplicationWindow))
Luna release: casting problem [message #1237784] Thu, 30 January 2014 15:30 Go to next message
Pina giusy is currently offline Pina giusy
Messages: 8
Registered: October 2010
Junior Member
Hi,

I am working on project developed in Eclipse Helios, migrating from Eclipse 3.x to Eclipse 4 (in Luna release), one of problem is the following:


(java.lang.ClassCastException: org.eclipse.ui.internal.WorkbenchWindow cannot be cast to org.eclipse.jface.window.ApplicationWindow)
that is, the following casting:

...
((ApplicationWindow)PlatformUI.getWorkbench().getActiveWorkbenchWindow()).getShell()
...

arise the SWT exception:
org.eclipse.swt.SWTException: Failed to execute runnable (java.lang.ClassCastException: org.eclipse.ui.internal.WorkbenchWindow cannot be cast to org.eclipse.jface.window.ApplicationWindow).




Do you have a workaround or a solution for this problem.

Best regards,

pina

[Updated on: Thu, 30 January 2014 15:51]

Report message to a moderator

Re: Luna release: casting problem [message #1237785 is a reply to message #1237784] Thu, 30 January 2014 15:33 Go to previous messageGo to next message
Sopot Cela is currently offline Sopot Cela
Messages: 597
Registered: December 2010
Senior Member

Stack trace?
Re: Luna release: casting problem [message #1238113 is a reply to message #1237785] Fri, 31 January 2014 12:28 Go to previous messageGo to next message
Pina giusy is currently offline Pina giusy
Messages: 8
Registered: October 2010
Junior Member
Hi,

stack trace is:


org.eclipse.swt.SWTException: Failed to execute runnable (java.lang.ClassCastException: org.eclipse.ui.internal.WorkbenchWindow cannot be cast to org.eclipse.jface.window.ApplicationWindow)
at org.eclipse.swt.SWT.error(SWT.java:4419)
at org.eclipse.swt.SWT.error(SWT.java:4334)
at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:139)
at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:4145)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3762)
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:146)
at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:611)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:565)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150)
at it.unisa.coffeediscusser.Application.start(Application.java:42)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:109)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:80)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:372)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:226)
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)
Caused by: java.lang.ClassCastException: org.eclipse.ui.internal.WorkbenchWindow cannot be cast to org.eclipse.jface.window.ApplicationWindow
at xx.xxx.xx.ApplicationWorkbenchWindowAdvisor.applyTheme(ApplicationWorkbenchWindowAdvisor.java:125)
at it.unisa.coffeediscusser.ApplicationWorkbenchWindowAdvisor.postWindowOpenActions(ApplicationWorkbenchWindowAdvisor.java:242)
at it.unisa.coffeediscusser.ApplicationWorkbenchWindowAdvisor.access$0(ApplicationWorkbenchWindowAdvisor.java:158)
at it.unisa.coffeediscusser.ApplicationWorkbenchWindowAdvisor$1.run(ApplicationWorkbenchWindowAdvisor.java:105)
at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:136)
... 24 more


thanks,

Pina

[Updated on: Tue, 04 February 2014 21:47]

Report message to a moderator

Re: Luna release: casting problem [message #1244037 is a reply to message #1238113] Tue, 11 February 2014 20:40 Go to previous messageGo to next message
Eric Moffatt is currently offline Eric Moffatt
Messages: 118
Registered: July 2009
Senior Member
In Eclipse 4 we've moved away from using ApplicationWindow. If you can explain how you were using it perhaps I can point you towards a workaround...
Re: Luna release: casting problem [message #1386417 is a reply to message #1237784] Tue, 17 June 2014 12:48 Go to previous messageGo to next message
Ricardo Ferreira is currently offline Ricardo Ferreira
Messages: 6
Registered: April 2012
Junior Member
I have the same issue

CoolBarManager aCoolBarManager =((ApplicationWindow) view.getSite().getWorkbenchWindow()).getCoolBarManager();

This code works fine in Eclipse 3.x but after migrate to Eclipse 4 gives the exception

!MESSAGE Problems occurred when invoking code from plug-in: "org.eclipse.ui.workbench".
!STACK 0
java.lang.ClassCastException: org.eclipse.ui.internal.WorkbenchWindow cannot be cast to org.eclipse.jface.window.ApplicationWindow

Do you have a workaround ?
Re: Luna release: casting problem [message #1386613 is a reply to message #1386417] Wed, 18 June 2014 16:35 Go to previous messageGo to next message
Eric Moffatt is currently offline Eric Moffatt
Messages: 118
Registered: July 2009
Senior Member
There isn't likely to be a workaround for this...Again, what in particular do you need the cast for ?
Re: Luna release: casting problem [message #1386809 is a reply to message #1386613] Fri, 20 June 2014 17:06 Go to previous message
Eric Moffatt is currently offline Eric Moffatt
Messages: 118
Registered: July 2009
Senior Member

Ok, the new hack is to use the following:

ICoolBarManager aCoolBarManager =((WorkbenchWindow) view.getSite().getWorkbenchWindow()).getCoolBarManager2();

Specifically note two things; the result is an interface and the "2" in the get call. 'getCoolBarManager()' will return a non-functional stub so make use to use 'getCoolBarManager2().

Hopefully what you want to do can be done with the interface...*this* is why downcasting to internals is bad...Wink. If you are making additions then please consider switching over to using the org.eclipse.ui.menus extension point...

Previous Topic:Eclipse 4 RCP applications - Creating a Feature Product including all of its plugin dependencies
Next Topic:Listen to MPart close events
Goto Forum:
  


Current Time: Tue Sep 23 20:29:03 GMT 2014

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

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