Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Failed To Load HTML From Bundle Using Browser
Failed To Load HTML From Bundle Using Browser [message #486486] Thu, 17 September 2009 19:52 Go to next message
Eclipse UserFriend
Originally posted by: runzhou.li.gmail.com

Hi,

I'm doing something like below to open up html pages from the plugin bundle
using browser:

Bundle bundle = WidgetPlugin.getDefault().getBundle();
IPath path = new Path( "/test/index.html" );
URL url = FileLocator.find( bundle, path, null );
IWorkbenchBrowserSupport support =
PlatformUI.getWorkbench().getBrowserSupport();

try {
url = FileLocator.toFileURL( url );
IWebBrowser browser = support.createBrowser(
IWorkbenchBrowserSupport.AS_EDITOR, "testPage", null, null );

browser.openURL( url );
} catch( PartInitException e ) {
//
} catch( IOException e ) {
//
}

which works fine in dev environment, however in actual build, when I looked
into ./configuration/org.eclipse.osgi/bundles/xxx/1/test, there is only one
index.html while there are supposed to be other resources like js, css and
images.

So it appears to be very weird ugly page opened up in the actual build,
while in dev environment it works perfectly.

Please help, thank you in advance.

--
Runzhou Li
Re: Failed To Load HTML From Bundle Using Browser [message #486548 is a reply to message #486486] Fri, 18 September 2009 07:32 Go to previous messageGo to next message
Prakash G.R. is currently offline Prakash G.R.Friend
Messages: 621
Registered: July 2009
Senior Member
Runzhou Li wrote:
> which works fine in dev environment, however in actual build, when I
> looked into ./configuration/org.eclipse.osgi/bundles/xxx/1/test, there
> is only one index.html while there are supposed to be other resources
> like js, css and images.

Check the other resources in your build.properties. They might not have
been included.

- Prakash

Platform UI Team, IBM
http://blog.eclipse-tips.com
Re: Failed To Load HTML From Bundle Using Browser [message #486563 is a reply to message #486486] Fri, 18 September 2009 08:54 Go to previous messageGo to next message
Steffen Zschaler is currently offline Steffen ZschalerFriend
Messages: 228
Registered: July 2009
Senior Member
Hi,

Are you deploying your plugin as a Jar? In that case,
FileLocator.toFileURL will actually extract the indicated file from the
JAR file, but of course it won't know about any other related files.
Running your plugin from source (in what I assume is what you call the
'environment') doesn't have this issue, because the plugin is always
'deployed' as a folder and FileLocator.toFileURL just uses the files
that are there and does not do any copying.

I've had a few annoying experiences with this inconsistent behaviour in
the past, too, but have yet to find a completely satisfactory solution.

Cheers,

Steffen

Runzhou Li wrote:
> Hi,
>
> I'm doing something like below to open up html pages from the plugin
> bundle using browser:
>
> Bundle bundle = WidgetPlugin.getDefault().getBundle();
> IPath path = new Path( "/test/index.html" );
> URL url = FileLocator.find( bundle, path, null );
> IWorkbenchBrowserSupport support =
> PlatformUI.getWorkbench().getBrowserSupport();
>
> try {
> url = FileLocator.toFileURL( url );
> IWebBrowser browser = support.createBrowser(
> IWorkbenchBrowserSupport.AS_EDITOR, "testPage", null, null );
>
> browser.openURL( url );
> } catch( PartInitException e ) {
> //
> } catch( IOException e ) {
> //
> }
>
> which works fine in dev environment, however in actual build, when I
> looked into ./configuration/org.eclipse.osgi/bundles/xxx/1/test, there
> is only one index.html while there are supposed to be other resources
> like js, css and images.
>
> So it appears to be very weird ugly page opened up in the actual
> build, while in dev environment it works perfectly.
>
> Please help, thank you in advance.
>
> --
> Runzhou Li
Re: Failed To Load HTML From Bundle Using Browser [message #486734 is a reply to message #486563] Fri, 18 September 2009 20:30 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: runzhou.li.gmail.com

Yes Steffen. Your understanding to this issue has given me an okay
workaround.

The workaround is basically pass in another path

IPath path2 = new Path( "/test" );

And make that an url

URL url2 = FileLocator.find( bundle, path, null );

And then use toFileUrl(url2) just to extract the contents out, but not
really using it programmatically.

Hope some one can tell me there is a method that does just what I needed,
instead of this workaround that doesn't make perfect logical sense :)


"Steffen Zschaler" <szschaler@acm.org> 写入消息
news:h8vhre$pfi$1@build.eclipse.org...
> Hi,
>
> Are you deploying your plugin as a Jar? In that case,
> FileLocator.toFileURL will actually extract the indicated file from the
> JAR file, but of course it won't know about any other related files.
> Running your plugin from source (in what I assume is what you call the
> 'environment') doesn't have this issue, because the plugin is always
> 'deployed' as a folder and FileLocator.toFileURL just uses the files
> that are there and does not do any copying.
>
> I've had a few annoying experiences with this inconsistent behaviour in
> the past, too, but have yet to find a completely satisfactory solution.
>
> Cheers,
>
> Steffen
>
> Runzhou Li wrote:
>> Hi,
>>
>> I'm doing something like below to open up html pages from the plugin
>> bundle using browser:
>>
>> Bundle bundle = WidgetPlugin.getDefault().getBundle();
>> IPath path = new Path( "/test/index.html" );
>> URL url = FileLocator.find( bundle, path, null );
>> IWorkbenchBrowserSupport support =
>> PlatformUI.getWorkbench().getBrowserSupport();
>>
>> try {
>> url = FileLocator.toFileURL( url );
>> IWebBrowser browser = support.createBrowser(
>> IWorkbenchBrowserSupport.AS_EDITOR, "testPage", null, null );
>>
>> browser.openURL( url );
>> } catch( PartInitException e ) {
>> //
>> } catch( IOException e ) {
>> //
>> }
>>
>> which works fine in dev environment, however in actual build, when I
>> looked into ./configuration/org.eclipse.osgi/bundles/xxx/1/test, there
>> is only one index.html while there are supposed to be other resources
>> like js, css and images.
>>
>> So it appears to be very weird ugly page opened up in the actual
>> build, while in dev environment it works perfectly.
>>
>> Please help, thank you in advance.
>>
>> --
>> Runzhou Li
Re: Failed To Load HTML From Bundle Using Browser [message #486741 is a reply to message #486734] Fri, 18 September 2009 20:46 Go to previous messageGo to next message
Steffen Zschaler is currently offline Steffen ZschalerFriend
Messages: 228
Registered: July 2009
Senior Member
Glad you found a way to make this work. Actually, this does sound quite
sensible, as you are effectively asking FileLocator to extract the
complete directory. I wasn't aware it would do that, so thanks for
allowing me to learn something, too.

Steffen

Runzhou Li wrote:
> Yes Steffen. Your understanding to this issue has given me an okay
> workaround.
>
> The workaround is basically pass in another path
>
> IPath path2 = new Path( "/test" );
>
> And make that an url
>
> URL url2 = FileLocator.find( bundle, path, null );
>
> And then use toFileUrl(url2) just to extract the contents out, but not
> really using it programmatically.
>
> Hope some one can tell me there is a method that does just what I
> needed, instead of this workaround that doesn't make perfect logical
> sense :)
>
>
> "Steffen Zschaler" <szschaler@acm.org> 写入消息
> news:h8vhre$pfi$1@build.eclipse.org...
>> Hi,
>>
>> Are you deploying your plugin as a Jar? In that case,
>> FileLocator.toFileURL will actually extract the indicated file from the
>> JAR file, but of course it won't know about any other related files.
>> Running your plugin from source (in what I assume is what you call the
>> 'environment') doesn't have this issue, because the plugin is always
>> 'deployed' as a folder and FileLocator.toFileURL just uses the files
>> that are there and does not do any copying.
>>
>> I've had a few annoying experiences with this inconsistent behaviour in
>> the past, too, but have yet to find a completely satisfactory solution.
>>
>> Cheers,
>>
>> Steffen
>>
>> Runzhou Li wrote:
>>> Hi,
>>>
>>> I'm doing something like below to open up html pages from the plugin
>>> bundle using browser:
>>>
>>> Bundle bundle = WidgetPlugin.getDefault().getBundle();
>>> IPath path = new Path( "/test/index.html" );
>>> URL url = FileLocator.find( bundle, path, null );
>>> IWorkbenchBrowserSupport support =
>>> PlatformUI.getWorkbench().getBrowserSupport();
>>>
>>> try {
>>> url = FileLocator.toFileURL( url );
>>> IWebBrowser browser = support.createBrowser(
>>> IWorkbenchBrowserSupport.AS_EDITOR, "testPage", null, null );
>>>
>>> browser.openURL( url );
>>> } catch( PartInitException e ) {
>>> //
>>> } catch( IOException e ) {
>>> //
>>> }
>>>
>>> which works fine in dev environment, however in actual build, when I
>>> looked into ./configuration/org.eclipse.osgi/bundles/xxx/1/test, there
>>> is only one index.html while there are supposed to be other resources
>>> like js, css and images.
>>>
>>> So it appears to be very weird ugly page opened up in the actual
>>> build, while in dev environment it works perfectly.
>>>
>>> Please help, thank you in advance.
>>>
>>> --
>>> Runzhou Li
>
Re: Failed To Load HTML From Bundle Using Browser [message #486742 is a reply to message #486741] Fri, 18 September 2009 21:05 Go to previous message
Eclipse UserFriend
Originally posted by: runzhou.li.gmail.com

All about open source community helps ;p

Thank you and you're welcome.

"Steffen Zschaler" <szschaler@acm.org> 写入消息
news:h90rk3$750$1@build.eclipse.org...
> Glad you found a way to make this work. Actually, this does sound quite
> sensible, as you are effectively asking FileLocator to extract the
> complete directory. I wasn't aware it would do that, so thanks for
> allowing me to learn something, too.
>
> Steffen
>
> Runzhou Li wrote:
>> Yes Steffen. Your understanding to this issue has given me an okay
>> workaround.
>>
>> The workaround is basically pass in another path
>>
>> IPath path2 = new Path( "/test" );
>>
>> And make that an url
>>
>> URL url2 = FileLocator.find( bundle, path, null );
>>
>> And then use toFileUrl(url2) just to extract the contents out, but not
>> really using it programmatically.
>>
>> Hope some one can tell me there is a method that does just what I
>> needed, instead of this workaround that doesn't make perfect logical
>> sense :)
>>
>>
>> "Steffen Zschaler" <szschaler@acm.org> 写入消息
>> news:h8vhre$pfi$1@build.eclipse.org...
>>> Hi,
>>>
>>> Are you deploying your plugin as a Jar? In that case,
>>> FileLocator.toFileURL will actually extract the indicated file from the
>>> JAR file, but of course it won't know about any other related files.
>>> Running your plugin from source (in what I assume is what you call the
>>> 'environment') doesn't have this issue, because the plugin is always
>>> 'deployed' as a folder and FileLocator.toFileURL just uses the files
>>> that are there and does not do any copying.
>>>
>>> I've had a few annoying experiences with this inconsistent behaviour in
>>> the past, too, but have yet to find a completely satisfactory solution.
>>>
>>> Cheers,
>>>
>>> Steffen
>>>
>>> Runzhou Li wrote:
>>>> Hi,
>>>>
>>>> I'm doing something like below to open up html pages from the plugin
>>>> bundle using browser:
>>>>
>>>> Bundle bundle = WidgetPlugin.getDefault().getBundle();
>>>> IPath path = new Path( "/test/index.html" );
>>>> URL url = FileLocator.find( bundle, path, null );
>>>> IWorkbenchBrowserSupport support =
>>>> PlatformUI.getWorkbench().getBrowserSupport();
>>>>
>>>> try {
>>>> url = FileLocator.toFileURL( url );
>>>> IWebBrowser browser = support.createBrowser(
>>>> IWorkbenchBrowserSupport.AS_EDITOR, "testPage", null, null );
>>>>
>>>> browser.openURL( url );
>>>> } catch( PartInitException e ) {
>>>> //
>>>> } catch( IOException e ) {
>>>> //
>>>> }
>>>>
>>>> which works fine in dev environment, however in actual build, when I
>>>> looked into ./configuration/org.eclipse.osgi/bundles/xxx/1/test, there
>>>> is only one index.html while there are supposed to be other resources
>>>> like js, css and images.
>>>>
>>>> So it appears to be very weird ugly page opened up in the actual
>>>> build, while in dev environment it works perfectly.
>>>>
>>>> Please help, thank you in advance.
>>>>
>>>> --
>>>> Runzhou Li
>>
Previous Topic:java debug - breakpoint
Next Topic:Plugin to share icons and strings
Goto Forum:
  


Current Time: Thu Nov 27 03:14:08 GMT 2014

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

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