Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Unhandled event loop exception Raison: org.eclipse.core.internal.resources.File
Unhandled event loop exception Raison: org.eclipse.core.internal.resources.File [message #297003] Fri, 06 January 2006 15:33 Go to next message
Eclipse UserFriend
Originally posted by: lacmene.yahoo.fr

Hi,

I`m building a plug-in to transform the contents of an selected file. I
generated the plugin with the pde.
I want to get the File (the selection) from the view (Vavigator or package
Explorer) in the runtime workbench by reading out the selection.

The following code snippets should demonstrate my problem:

if ((theSelection instanceof
IStructuredSelection)&&(!theSelection.isEmpty())){
Object segment= ((IStructuredSelection) theSelection).getFirstElement();
String Classname = segment.getClass().getName();
System.out.println(Classname );

File theFile = (File)segment;
System.out.println(theFile.getName());
System.out.println(theFile.getFileExtension());

....
}

I checked the Classtype with :
String Classname = segment.getClass().getName();
System.out.println(Classname );
and the result was "org.eclipse.core.internal.resources.File";
so I'm sure, that I do a correct cast.
I also try to cast the Object to IFile without any succes.

This is the console output:
Unhandled event loop exception
Reason:
org/eclipse/core/internal/resources/File


Has anyone an idea?

Thanx a lot for your help.

Laurette
Re: Unhandled event loop exception Raison: org.eclipse.core.internal.resources.File [message #297004 is a reply to message #297003] Fri, 06 January 2006 15:39 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: kwpeck.mersoft.com

Look in the .log file to get a better error message. The console just
tells you something went awry but the output in the .log file should
give you what really happened. Look a the very end of the file as it
could be quite large if you have run your application multiple times
without deleting the .log file.

Laurette Lacmene wrote:
> Hi,
>
> I`m building a plug-in to transform the contents of an selected file. I
> generated the plugin with the pde.
> I want to get the File (the selection) from the view (Vavigator or
> package Explorer) in the runtime workbench by reading out the selection.
>
> The following code snippets should demonstrate my problem:
>
> if ((theSelection instanceof
> IStructuredSelection)&&(!theSelection.isEmpty())){
> Object segment= ((IStructuredSelection)
> theSelection).getFirstElement();
> String Classname = segment.getClass().getName();
> System.out.println(Classname );
>
> File theFile = (File)segment; System.out.println(theFile.getName());
> System.out.println(theFile.getFileExtension());
> ....
> }
>
> I checked the Classtype with :
> String Classname = segment.getClass().getName();
> System.out.println(Classname );
> and the result was "org.eclipse.core.internal.resources.File"; so I'm
> sure, that I do a correct cast. I also try to cast the Object to IFile
> without any succes.
>
> This is the console output:
> Unhandled event loop exception
> Reason:
> org/eclipse/core/internal/resources/File
>
>
> Has anyone an idea?
> Thanx a lot for your help.
>
> Laurette
>
Re: Unhandled event loop exception Raison: org.eclipse.core.internal.resources.File [message #297013 is a reply to message #297004] Fri, 06 January 2006 16:09 Go to previous messageGo to next message
Darin Swanson is currently offline Darin SwansonFriend
Messages: 2386
Registered: July 2009
Senior Member
I would guess you have a ClassCastException as you are casting to
java.io.File instead of org.eclipse.core.internal.resources.File but this is
just a guess....

Check those imports and you really should cast to IFile anyways :-)

Darins
"Kevin Peck" <kwpeck@mersoft.com> wrote in message
news:dpm322$prl$1@utils.eclipse.org...
> Look in the .log file to get a better error message. The console just
> tells you something went awry but the output in the .log file should give
> you what really happened. Look a the very end of the file as it could be
> quite large if you have run your application multiple times without
> deleting the .log file.
>
> Laurette Lacmene wrote:
>> Hi,
>>
>> I`m building a plug-in to transform the contents of an selected file. I
>> generated the plugin with the pde.
>> I want to get the File (the selection) from the view (Vavigator or
>> package Explorer) in the runtime workbench by reading out the selection.
>>
>> The following code snippets should demonstrate my problem:
>>
>> if ((theSelection instanceof
>> IStructuredSelection)&&(!theSelection.isEmpty())){
>> Object segment= ((IStructuredSelection)
>> theSelection).getFirstElement();
>> String Classname = segment.getClass().getName();
>> System.out.println(Classname );
>> File theFile = (File)segment;
>> System.out.println(theFile.getName());
>> System.out.println(theFile.getFileExtension()); ....
>> }
>>
>> I checked the Classtype with :
>> String Classname = segment.getClass().getName();
>> System.out.println(Classname );
>> and the result was "org.eclipse.core.internal.resources.File"; so I'm
>> sure, that I do a correct cast. I also try to cast the Object to IFile
>> without any succes.
>>
>> This is the console output:
>> Unhandled event loop exception
>> Reason:
>> org/eclipse/core/internal/resources/File
>>
>>
>> Has anyone an idea?
>> Thanx a lot for your help.
>>
>> Laurette
>>
Re: Unhandled event loop exception Raison: org.eclipse.core.internal.resources.F [message #297028 is a reply to message #297004] Fri, 06 January 2006 17:23 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: lacmene.yahoo.fr

Hi Kevin,
Hier is the output from the .log file. It doesn't make sence because the
exception is raised exactly where i do the cast:
at
com.fokus.uml2__u2tp.actions.SampleAction.getThefile(SampleA ction.java:127)


!ENTRY org.eclipse.ui 4 4 2006-01-06 18:10:39.865
!MESSAGE Unhandled event loop exception

!ENTRY org.eclipse.ui 4 0 2006-01-06 18:10:39.865
!MESSAGE org.eclipse.core.internal.resources.File
!STACK 0

java.lang.ClassCastException: org.eclipse.core.internal.resources.File
at
com.fokus.uml2__u2tp.actions.SampleAction.getThefile(SampleA ction.java:127)
at com.fokus.uml2__u2tp.actions.SampleAction.run(SampleAction.j ava:69)
at
org.eclipse.ui.internal.PluginAction.runWithEvent(PluginActi on.java:246)
at
org.eclipse.ui.internal.WWinPluginAction.runWithEvent(WWinPl uginAction.java:223)
at
org.eclipse.jface.action.ActionContributionItem.handleWidget Selection(ActionContributionItem.java:538)
at
org.eclipse.jface.action.ActionContributionItem.access$2(Act ionContributionItem.java:488)
at
org.eclipse.jface.action.ActionContributionItem$6.handleEven t(ActionContributionItem.java:441)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java :66)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:843)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.ja va:3080)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :2713)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.jav a:1699)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1663)
at
org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Work bench.java:367)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.j ava:143)
at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplicatio n.java:103)
at
org.eclipse.core.internal.runtime.PlatformActivator$1.run(Pl atformActivator.java:226)
at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:376)
at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:163)
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.core.launcher.Main.invokeFramework(Main.java:334 )
at org.eclipse.core.launcher.Main.basicRun(Main.java:278)
at org.eclipse.core.launcher.Main.run(Main.java:973)
at org.eclipse.core.launcher.Main.main(Main.java:948)

thanx
Laurette
Re: Unhandled event loop exception Raison: org.eclipse.core.internal.resources.F [message #297032 is a reply to message #297013] Fri, 06 January 2006 17:40 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: lacmene.yahoo.fr

Hi Darin,
Thanx a lot for your suggestion, but i'm sure that i do the rigth import:
import org.eclipse.core.internal.resources.File;

I have also try to use IFile and the same exception was raised.

Laurette
Re: Unhandled event loop exception Raison: org.eclipse.core.internal.resources.File [message #297044 is a reply to message #297003] Fri, 06 January 2006 18:33 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

Are you sure your think is a org.eclipse.core.internal.resources.File?
When I use the following code and select a text file (not a java file),
I get the expected output and no class cast exception:

if (sel instanceof IStructuredSelection) {
IStructuredSelection ss = (IStructuredSelection) sel;
Object el[] = ss.toArray();
System.out.println(el[0].getClass().getName());
IFile file = (IFile) el[0];
System.out.println(file.getProject().getName());
}


org.eclipse.core.internal.resources.File
test.files

Later,
PW


Re: Unhandled event loop exception Raison: org.eclipse.core.internal.resources.File [message #297246 is a reply to message #297003] Tue, 10 January 2006 21:21 Go to previous message
Eclipse UserFriend
Originally posted by: john.eclipsefaq.org

You shouldn't be referencing org.eclipse.core.internal.resources.File.
Cast to the org.eclipse.core.resource.IFile interface instead.
--

Laurette Lacmene wrote:
> Hi,
>
> I`m building a plug-in to transform the contents of an selected file. I
> generated the plugin with the pde.
> I want to get the File (the selection) from the view (Vavigator or
> package Explorer) in the runtime workbench by reading out the selection.
>
> The following code snippets should demonstrate my problem:
>
> if ((theSelection instanceof
> IStructuredSelection)&&(!theSelection.isEmpty())){
> Object segment= ((IStructuredSelection)
> theSelection).getFirstElement();
> String Classname = segment.getClass().getName();
> System.out.println(Classname );
>
> File theFile = (File)segment; System.out.println(theFile.getName());
> System.out.println(theFile.getFileExtension());
> ....
> }
>
> I checked the Classtype with :
> String Classname = segment.getClass().getName();
> System.out.println(Classname );
> and the result was "org.eclipse.core.internal.resources.File"; so I'm
> sure, that I do a correct cast. I also try to cast the Object to IFile
> without any succes.
>
> This is the console output:
> Unhandled event loop exception
> Reason:
> org/eclipse/core/internal/resources/File
>
>
> Has anyone an idea?
> Thanx a lot for your help.
>
> Laurette
>
Previous Topic:PartitionScanner problem
Next Topic:Class Cast exception using equals method for domain object within a listviewer.
Goto Forum:
  


Current Time: Fri Oct 18 15:17:06 GMT 2024

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

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

Back to the top