Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » FilteredTree: ClassCastException: FilteredTree cannot be cast to org.eclipse.swt.widgets.Tree
FilteredTree: ClassCastException: FilteredTree cannot be cast to org.eclipse.swt.widgets.Tree [message #1051313] Sun, 28 April 2013 15:32 Go to next message
KW is currently offline KW
Messages: 12
Registered: July 2009
Junior Member
Hi all,

I am trying to switch from TreeViewer to a FilteredTree :

old:
final Tree tree = treeViewer.getTree();


new:
final PatternFilter patternFilter = new PatternFilter();
final FilteredTree filter =
new FilteredTree(compositeViewer, SWT.MULTI |
SWT.H_SCROLL | SWT.V_SCROLL, patternFilter, true);
treeViewer = filter.getViewer();

With the FilteredTree I get the exception given below.

Any idea what I am doing wrong?

Thanks!
Kris


org.eclipse.e4.core.di.InjectionException: java.lang.ClassCastException:
org.eclipse.e4.ui.workbench.swt.internal.copy.FilteredTree cannot be
cast to org.eclipse.swt.widgets.Tree
at
org.eclipse.e4.core.internal.di.ConstructorRequestor.execute(ConstructorRequestor.java:53)
at
org.eclipse.e4.core.internal.di.InjectorImpl.internalMake(InjectorImpl.java:319)
at org.eclipse.e4.core.internal.di.InjectorImpl.make(InjectorImpl.java:242)
at
org.eclipse.e4.core.contexts.ContextInjectionFactory.make(ContextInjectionFactory.java:161)
at
org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.createFromBundle(ReflectionContributionFactory.java:102)
at
org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.doCreate(ReflectionContributionFactory.java:71)
at
org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.create(ReflectionContributionFactory.java:53)
at
org.eclipse.e4.ui.workbench.renderers.swt.ContributedPartRenderer.createWidget(ContributedPartRenderer.java:141)
at
org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.createWidget(PartRenderingEngine.java:892)
at
org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:627)
at
org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:729)
at
org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.access$2(PartRenderingEngine.java:700)
at
org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$7.run(PartRenderingEngine.java:694)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at
org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.createGui(PartRenderingEngine.java:679)
at
org.eclipse.e4.ui.workbench.renderers.swt.StackRenderer.showTab(StackRenderer.java:1115)
at
org.eclipse.e4.ui.workbench.renderers.swt.LazyStackRenderer$1.handleEvent(LazyStackRenderer.java:67)
at
org.eclipse.e4.ui.services.internal.events.UIEventHandler$1.run(UIEventHandler.java:41)
at org.eclipse.swt.widgets.Synchronizer.syncExec(Synchronizer.java:180)
at org.eclipse.swt.widgets.Display.syncExec(Display.java:4605)
at
org.eclipse.e4.ui.internal.workbench.swt.E4Application$1.syncExec(E4Application.java:187)
at
org.eclipse.e4.ui.services.internal.events.UIEventHandler.handleEvent(UIEventHandler.java:38)
at
org.eclipse.equinox.internal.event.EventHandlerWrapper.handleEvent(EventHandlerWrapper.java:197)
at
org.eclipse.equinox.internal.event.EventHandlerTracker.dispatchEvent(EventHandlerTracker.java:197)
at
org.eclipse.equinox.internal.event.EventHandlerTracker.dispatchEvent(EventHandlerTracker.java:1)
at
org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)
at
org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:148)
at
org.eclipse.equinox.internal.event.EventAdminImpl.dispatchEvent(EventAdminImpl.java:135)
at
org.eclipse.equinox.internal.event.EventAdminImpl.sendEvent(EventAdminImpl.java:78)
at
org.eclipse.equinox.internal.event.EventComponent.sendEvent(EventComponent.java:39)
at
org.eclipse.e4.ui.services.internal.events.EventBroker.send(EventBroker.java:80)
at
org.eclipse.e4.ui.internal.workbench.UIEventPublisher.notifyChanged(UIEventPublisher.java:58)
at
org.eclipse.emf.common.notify.impl.BasicNotifierImpl.eNotify(BasicNotifierImpl.java:374)
at
org.eclipse.e4.ui.model.application.ui.impl.ElementContainerImpl.setSelectedElement(ElementContainerImpl.java:171)
at
org.eclipse.e4.ui.internal.workbench.ModelServiceImpl.showElementInWindow(ModelServiceImpl.java:418)
at
org.eclipse.e4.ui.internal.workbench.ModelServiceImpl.bringToTop(ModelServiceImpl.java:385)
at
org.eclipse.e4.ui.internal.workbench.PartServiceImpl.delegateBringToTop(PartServiceImpl.java:591)
at
org.eclipse.e4.ui.internal.workbench.PartServiceImpl.activate(PartServiceImpl.java:564)
at
org.eclipse.e4.ui.internal.workbench.PartServiceImpl.activate(PartServiceImpl.java:534)
at
org.eclipse.e4.ui.internal.workbench.PartServiceImpl.activate(PartServiceImpl.java:523)
at
org.eclipse.e4.ui.internal.workbench.PartServiceImpl.showPart(PartServiceImpl.java:990)
at
com.taskman.ui.rcp.part.navigation.NavigationPart$9.doubleClick(NavigationPart.java:322)
at
org.eclipse.jface.viewers.StructuredViewer$1.run(StructuredViewer.java:845)
at org.eclipse.jface.util.SafeRunnable$1.run(SafeRunnable.java:128)
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:1477)
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:4134)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1458)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1481)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1466)
at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:1271)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3980)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3619)
at
org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1045)
at
org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at
org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:940)
at
org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:86)
at
org.eclipse.e4.ui.internal.workbench.swt.E4Application.start(E4Application.java:150)
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: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:629)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:584)
at org.eclipse.equinox.launcher.Main.run(Main.java:1438)
at org.eclipse.equinox.launcher.Main.main(Main.java:1414)
Caused by: java.lang.ClassCastException:
org.eclipse.e4.ui.workbench.swt.internal.copy.FilteredTree cannot be
cast to org.eclipse.swt.widgets.Tree
at
org.eclipse.jface.layout.TreeColumnLayout.getColumnCount(TreeColumnLayout.java:82)
at
org.eclipse.jface.layout.AbstractColumnLayout.computeTableTreeSize(AbstractColumnLayout.java:114)
at
org.eclipse.jface.layout.AbstractColumnLayout.computeSize(AbstractColumnLayout.java:229)
at org.eclipse.swt.widgets.Composite.computeSize(Composite.java:236)
at org.eclipse.swt.layout.GridData.computeSize(GridData.java:491)
at org.eclipse.swt.layout.GridLayout.layout(GridLayout.java:218)
at org.eclipse.swt.layout.GridLayout.computeSize(GridLayout.java:163)
at org.eclipse.swt.widgets.Composite.computeSize(Composite.java:236)
at org.eclipse.swt.widgets.Control.computeSize(Control.java:873)
at
com.taskman.ui.rcp.part.project.details.ProjectDetailsPart.<init>(ProjectDetailsPart.java:350)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at
org.eclipse.e4.core.internal.di.ConstructorRequestor.execute(ConstructorRequestor.java:44)
... 76 more
Re: FilteredTree: ClassCastException: FilteredTree cannot be cast to org.eclipse.swt.widgets.Tree [message #1051361 is a reply to message #1051313] Sun, 28 April 2013 17:10 Go to previous message
KW is currently offline KW
Messages: 12
Registered: July 2009
Junior Member
Sorry, had a copy-paste error in my previous post:

the "old" section is:
treeViewer = new TreeViewer(compositeViewer, SWT.BORDER);


Addionally - in both cases (old and new) the compositeViewer as parent
composite is created like this:

final Composite compositeViewer = new Composite(containerRoot, SWT.NONE);
final GridData gd_compositeViewer = new GridData(SWT.FILL, SWT.FILL,
true, true, 3, 1);

gd_compositeViewer.heightHint = 129;
compositeViewer.setLayoutData(gd_compositeViewer);
compositeViewer.setLayout(new TreeColumnLayout());

Regards
Kris




Am 28.04.13 17:32, schrieb KW:
> Hi all,
>
> I am trying to switch from TreeViewer to a FilteredTree :
>
> old:
> final Tree tree = treeViewer.getTree();
>
>
> new:
> final PatternFilter patternFilter = new PatternFilter();
> final FilteredTree filter =
> new FilteredTree(compositeViewer, SWT.MULTI |
> SWT.H_SCROLL | SWT.V_SCROLL, patternFilter, true);
> treeViewer = filter.getViewer();
>
> With the FilteredTree I get the exception given below.
>
> Any idea what I am doing wrong?
>
> Thanks!
> Kris
>
>
> org.eclipse.e4.core.di.InjectionException: java.lang.ClassCastException:
> org.eclipse.e4.ui.workbench.swt.internal.copy.FilteredTree cannot be
> cast to org.eclipse.swt.widgets.Tree
> at
> org.eclipse.e4.core.internal.di.ConstructorRequestor.execute(ConstructorRequestor.java:53)
>
> at
> org.eclipse.e4.core.internal.di.InjectorImpl.internalMake(InjectorImpl.java:319)
>
> at
> org.eclipse.e4.core.internal.di.InjectorImpl.make(InjectorImpl.java:242)
> at
> org.eclipse.e4.core.contexts.ContextInjectionFactory.make(ContextInjectionFactory.java:161)
>
> at
> org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.createFromBundle(ReflectionContributionFactory.java:102)
>
> at
> org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.doCreate(ReflectionContributionFactory.java:71)
>
> at
> org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.create(ReflectionContributionFactory.java:53)
>
> at
> org.eclipse.e4.ui.workbench.renderers.swt.ContributedPartRenderer.createWidget(ContributedPartRenderer.java:141)
>
> at
> org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.createWidget(PartRenderingEngine.java:892)
>
> at
> org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:627)
>
> at
> org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:729)
>
> at
> org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.access$2(PartRenderingEngine.java:700)
>
> at
> org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$7.run(PartRenderingEngine.java:694)
>
> at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
> at
> org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.createGui(PartRenderingEngine.java:679)
>
> at
> org.eclipse.e4.ui.workbench.renderers.swt.StackRenderer.showTab(StackRenderer.java:1115)
>
> at
> org.eclipse.e4.ui.workbench.renderers.swt.LazyStackRenderer$1.handleEvent(LazyStackRenderer.java:67)
>
> at
> org.eclipse.e4.ui.services.internal.events.UIEventHandler$1.run(UIEventHandler.java:41)
>
> at
> org.eclipse.swt.widgets.Synchronizer.syncExec(Synchronizer.java:180)
> at org.eclipse.swt.widgets.Display.syncExec(Display.java:4605)
> at
> org.eclipse.e4.ui.internal.workbench.swt.E4Application$1.syncExec(E4Application.java:187)
>
> at
> org.eclipse.e4.ui.services.internal.events.UIEventHandler.handleEvent(UIEventHandler.java:38)
>
> at
> org.eclipse.equinox.internal.event.EventHandlerWrapper.handleEvent(EventHandlerWrapper.java:197)
>
> at
> org.eclipse.equinox.internal.event.EventHandlerTracker.dispatchEvent(EventHandlerTracker.java:197)
>
> at
> org.eclipse.equinox.internal.event.EventHandlerTracker.dispatchEvent(EventHandlerTracker.java:1)
>
> at
> org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)
>
> at
> org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:148)
>
> at
> org.eclipse.equinox.internal.event.EventAdminImpl.dispatchEvent(EventAdminImpl.java:135)
>
> at
> org.eclipse.equinox.internal.event.EventAdminImpl.sendEvent(EventAdminImpl.java:78)
>
> at
> org.eclipse.equinox.internal.event.EventComponent.sendEvent(EventComponent.java:39)
>
> at
> org.eclipse.e4.ui.services.internal.events.EventBroker.send(EventBroker.java:80)
>
> at
> org.eclipse.e4.ui.internal.workbench.UIEventPublisher.notifyChanged(UIEventPublisher.java:58)
>
> at
> org.eclipse.emf.common.notify.impl.BasicNotifierImpl.eNotify(BasicNotifierImpl.java:374)
>
> at
> org.eclipse.e4.ui.model.application.ui.impl.ElementContainerImpl.setSelectedElement(ElementContainerImpl.java:171)
>
> at
> org.eclipse.e4.ui.internal.workbench.ModelServiceImpl.showElementInWindow(ModelServiceImpl.java:418)
>
> at
> org.eclipse.e4.ui.internal.workbench.ModelServiceImpl.bringToTop(ModelServiceImpl.java:385)
>
> at
> org.eclipse.e4.ui.internal.workbench.PartServiceImpl.delegateBringToTop(PartServiceImpl.java:591)
>
> at
> org.eclipse.e4.ui.internal.workbench.PartServiceImpl.activate(PartServiceImpl.java:564)
>
> at
> org.eclipse.e4.ui.internal.workbench.PartServiceImpl.activate(PartServiceImpl.java:534)
>
> at
> org.eclipse.e4.ui.internal.workbench.PartServiceImpl.activate(PartServiceImpl.java:523)
>
> at
> org.eclipse.e4.ui.internal.workbench.PartServiceImpl.showPart(PartServiceImpl.java:990)
>
> at
> com.taskman.ui.rcp.part.navigation.NavigationPart$9.doubleClick(NavigationPart.java:322)
>
> at
> org.eclipse.jface.viewers.StructuredViewer$1.run(StructuredViewer.java:845)
> at org.eclipse.jface.util.SafeRunnable$1.run(SafeRunnable.java:128)
> 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:1477)
>
> 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:4134)
> at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1458)
> at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1481)
> at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1466)
> at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:1271)
> at
> org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3980)
> at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3619)
> at
> org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1045)
>
> at
> org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
>
> at
> org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:940)
>
> at
> org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:86)
>
> at
> org.eclipse.e4.ui.internal.workbench.swt.E4Application.start(E4Application.java:150)
>
> 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: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:629)
> at org.eclipse.equinox.launcher.Main.basicRun(Main.java:584)
> at org.eclipse.equinox.launcher.Main.run(Main.java:1438)
> at org.eclipse.equinox.launcher.Main.main(Main.java:1414)
> Caused by: java.lang.ClassCastException:
> org.eclipse.e4.ui.workbench.swt.internal.copy.FilteredTree cannot be
> cast to org.eclipse.swt.widgets.Tree
> at
> org.eclipse.jface.layout.TreeColumnLayout.getColumnCount(TreeColumnLayout.java:82)
>
> at
> org.eclipse.jface.layout.AbstractColumnLayout.computeTableTreeSize(AbstractColumnLayout.java:114)
>
> at
> org.eclipse.jface.layout.AbstractColumnLayout.computeSize(AbstractColumnLayout.java:229)
>
> at org.eclipse.swt.widgets.Composite.computeSize(Composite.java:236)
> at org.eclipse.swt.layout.GridData.computeSize(GridData.java:491)
> at org.eclipse.swt.layout.GridLayout.layout(GridLayout.java:218)
> at org.eclipse.swt.layout.GridLayout.computeSize(GridLayout.java:163)
> at org.eclipse.swt.widgets.Composite.computeSize(Composite.java:236)
> at org.eclipse.swt.widgets.Control.computeSize(Control.java:873)
> at
> com.taskman.ui.rcp.part.project.details.ProjectDetailsPart.<init>(ProjectDetailsPart.java:350)
>
> at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
> Method)
> at
> sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
>
> at
> sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
>
> at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
> at
> org.eclipse.e4.core.internal.di.ConstructorRequestor.execute(ConstructorRequestor.java:44)
>
> ... 76 more
Previous Topic:org.eclipse.ui.activities conflict?
Next Topic:Eclipse Drag and Drop - ViewPart to CommonNavigator
Goto Forum:
  


Current Time: Sat Oct 25 00:49:35 GMT 2014

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

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