Skip to main content



      Home
Home » Eclipse Projects » Remote Application Platform (RAP) » File-Array from Workspace folder
File-Array from Workspace folder [message #86070] Mon, 05 May 2008 14:07 Go to next message
Eclipse UserFriend
Hi, I have a rather strange question..
I have a folder in my workspace, which contains some images. What I need
is a File-Array for these images. Inside my RCP, the following Snippet
does what I want:
URL url = FileLocator.toFileURL(bundle.getEntry("images"));
File f = new File(url.getFile());
File[] list = f.listFiles();

This doesnt work in RAP, I expect the problem to be the File located
absolute within the Filesystem, rather as a relative path, which may be
not allowed??
Can someone give me a snippet of how this works, I spent nearly half day
to this and now itŽs enough:-)
I know how it works for a single File, but not for this use case with a
directory containing files. For sure this is easy to solve, but I really
donŽt get the 3-lines at the moment.

Thanks for your help!
Re: File-Array from Workspace folder [message #86115 is a reply to message #86070] Tue, 06 May 2008 03:12 Go to previous messageGo to next message
Eclipse UserFriend
Hi again!
any idea to this? IŽm a bit under pressure to get this working:)

Thanks in advance!!

Martin
Re: File-Array from Workspace folder [message #86177 is a reply to message #86070] Tue, 06 May 2008 04:20 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: fappel.innoopract.com

Hi,

what does bundle.getEntry( "images" ) return?


Ciao
Frank

-----Ursprüngliche Nachricht-----
Von: Martin [mailto:mdilger@splitshade.de]
Bereitgestellt: Montag, 5. Mai 2008 20:08
Bereitgestellt in: eclipse.technology.rap
Unterhaltung: File-Array from Workspace folder
Betreff: File-Array from Workspace folder


Hi, I have a rather strange question..
I have a folder in my workspace, which contains some images. What I need
is a File-Array for these images. Inside my RCP, the following Snippet
does what I want:
URL url = FileLocator.toFileURL(bundle.getEntry("images"));
File f = new File(url.getFile());
File[] list = f.listFiles();

This doesnt work in RAP, I expect the problem to be the File located
absolute within the Filesystem, rather as a relative path, which may be
not allowed??
Can someone give me a snippet of how this works, I spent nearly half day
to this and now itŽs enough:-) I know how it works for a single File,
but not for this use case with a directory containing files. For sure
this is easy to solve, but I really donŽt get the 3-lines at the moment.

Thanks for your help!
Re: File-Array from Workspace folder [message #86207 is a reply to message #86177] Tue, 06 May 2008 05:30 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

this gives me the URL to this folder. This works if this is a File, and I
can open it with openStream(). But as this is a Folder, this doesnŽt work
for me.
Re: File-Array from Workspace folder [message #86454 is a reply to message #86207] Wed, 07 May 2008 14:30 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

IŽm quite sure there is a bug somewhere, the following snippet works:
Image im = Graphics.getImage("someNameForMyFile", new
FileInputStream(myFile));

Using Graphics.getImage(myFile) does not work and I get a "Invalid
Image..." Exception.

In my opinion both cases should work.
Re: File-Array from Workspace folder [message #86468 is a reply to message #86207] Wed, 07 May 2008 14:35 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

IŽm quite sure there is a bug somewhere, the following snippet works:
Image im = Graphics.getImage("someNameForMyFile", new
FileInputStream(myFile));

Using Graphics.getImage(myFile) does not work and I get a "Invalid
Image..." Exception. The File definitely exists and is on the classpath.

In my opinion both cases should work.
Re: File-Array from Workspace folder [message #86546 is a reply to message #86070] Thu, 08 May 2008 03:46 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: evolanakis.innoopract.com

Martin,

just a wild guess -- have you tried the class
org.eclipse.core.runtime.FileLocator in the org.eclipse.equinox.common
bundle ?

If I remember correctly, the method #toFileUrl() converts an bundle://
url to a file:// url, which can then be used with a File object. I've
used that in the past.

Alternatively, maybe #findEntries(...) is helpful, but I'm not too sure.

Let me know if this helped.

Regards,
Elias.


Martin wrote:
> Hi, I have a rather strange question..
> I have a folder in my workspace, which contains some images. What I need
> is a File-Array for these images. Inside my RCP, the following Snippet
> does what I want:
> URL url = FileLocator.toFileURL(bundle.getEntry("images"));
> File f = new File(url.getFile());
> File[] list = f.listFiles();
>
> This doesnt work in RAP, I expect the problem to be the File located
> absolute within the Filesystem, rather as a relative path, which may be
> not allowed??
> Can someone give me a snippet of how this works, I spent nearly half day
> to this and now itŽs enough:-)
> I know how it works for a single File, but not for this use case with a
> directory containing files. For sure this is easy to solve, but I really
> donŽt get the 3-lines at the moment.
>
> Thanks for your help!
>
Re: File-Array from Workspace folder [message #86560 is a reply to message #86546] Thu, 08 May 2008 03:47 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: evolanakis.innoopract.com

Oops, sorry - I see you are already using file locator...

Elias.


Elias Volanakis wrote:
> Martin,
>
> just a wild guess -- have you tried the class
> org.eclipse.core.runtime.FileLocator in the org.eclipse.equinox.common
> bundle ?
>
> If I remember correctly, the method #toFileUrl() converts an bundle://
> url to a file:// url, which can then be used with a File object. I've
> used that in the past.
>
> Alternatively, maybe #findEntries(...) is helpful, but I'm not too sure.
>
> Let me know if this helped.
>
> Regards,
> Elias.
>
>
> Martin wrote:
>> Hi, I have a rather strange question..
>> I have a folder in my workspace, which contains some images. What I
>> need is a File-Array for these images. Inside my RCP, the following
>> Snippet does what I want:
>> URL url = FileLocator.toFileURL(bundle.getEntry("images"));
>> File f = new File(url.getFile());
>> File[] list = f.listFiles();
>>
>> This doesnt work in RAP, I expect the problem to be the File located
>> absolute within the Filesystem, rather as a relative path, which may
>> be not allowed??
>> Can someone give me a snippet of how this works, I spent nearly half
>> day to this and now itŽs enough:-)
>> I know how it works for a single File, but not for this use case with
>> a directory containing files. For sure this is easy to solve, but I
>> really donŽt get the 3-lines at the moment.
>>
>> Thanks for your help!
>>
Re: File-Array from Workspace folder [message #86574 is a reply to message #86560] Thu, 08 May 2008 05:08 Go to previous messageGo to next message
Eclipse UserFriend
Hi Elias,
yes! thats exactly the Point, FileLocator works perfectly in
RCP-Environment, but strange enough does not in RAP, IŽll examine that in
the next days and do a Bug-Report if necessary.

Martin
Re: File-Array from Workspace folder [message #86603 is a reply to message #86468] Thu, 08 May 2008 05:48 Go to previous message
Eclipse UserFriend
Originally posted by: fappel.innoopract.com

Hi,

I'm not sure what you're really intend to do. But if you want to load a
image from the bundle you may try
AbstractUIPlugin#imageDescriptorFromPlugin(String,String).

Opening an inputstream on a folder fails of course. But you can retrieve
the file handle to the folder from the URL and retrieve the children
from it. Each child that is not a directory can then be opened using a
FileInputStream.


Ciao
Frank

-----Ursprüngliche Nachricht-----
Von: Martin [mailto:mdilger@splitshade.de]
Bereitgestellt: Mittwoch, 7. Mai 2008 20:36
Bereitgestellt in: eclipse.technology.rap
Unterhaltung: File-Array from Workspace folder
Betreff: Re: File-Array from Workspace folder


Hi,

IŽm quite sure there is a bug somewhere, the following snippet works:
Image im = Graphics.getImage("someNameForMyFile", new
FileInputStream(myFile));

Using Graphics.getImage(myFile) does not work and I get a "Invalid
Image..." Exception. The File definitely exists and is on the classpath.

In my opinion both cases should work.
Previous Topic:MessageBox?
Next Topic:Is RAP useabe by disabled people (barrierefrei)
Goto Forum:
  


Current Time: Sat Aug 30 13:22:59 EDT 2025

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

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

Back to the top