Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Browser local html with ESWT
Browser local html with ESWT [message #638059] Tue, 09 November 2010 19:21 Go to next message
Felipe is currently offline FelipeFriend
Messages: 1
Registered: November 2010
Junior Member
Hello,

I'm doing an app to Nokia devices using ESWT. In order to create the app help, I created a html file with the help instructions and use the Browser class to open it.

        try {
            browser = new Browser(getShell(), SWT.NONE);
        } catch (SWTError e) {
            e.printStackTrace();
        }

        if (browser != null) {
            StringBuffer buf = new StringBuffer();
            try {
                InputStream inputStreamTxt = null;
                inputStreamTxt = this.getClass().getResourceAsStream("/help/index_test.html");

                int c;
                while ((c = inputStreamTxt.read()) != -1) {
                    buf.append((char) c);
                }
                inputStreamTxt.close();

            } catch (IOException e) {
                e.printStackTrace();
            }

            browser.setText(buf.toString());
        }


When I open the help screen at the phone app, I renders the HTML, but doesn't load the images. I already tryed all kinds of paths.

  <p><img src="figure-1.jpg" alt="alt text"/></p>


  <p><img src="/figure-1.jpg" alt="alt text"/></p>


  <p><img src="./figure-1.jpg" alt="alt text"/></p>


Please help me.
Re: Browser local html with ESWT [message #638262 is a reply to message #638059] Wed, 10 November 2010 15:01 Go to previous message
Grant Gayed is currently offline Grant GayedFriend
Messages: 2150
Registered: July 2009
Senior Member
Hi,

When Browser content is set via setText() it does not have a base directory
for resolving relative links. I assume that you're using setText() instead
of setUrl() because your .html file and its images are contained within your
plugin's .jar. Assuming so, you should determine the location that your
plug-in's files have been auto-extracted to by eclipse and then setUrl() to
the .html. For an example of determing where a file has been auto-extracted
to see the code snippet that's part of
http://www.eclipse.org/swt/faq.php#specifyxulrunner .

If I've made an incorrect assumption then please follow up here.

Grant


<felipelcoutinho@gmail.com> wrote in message
news:ibc6p6$oad$1@news.eclipse.org...
> Hello,
>
> I'm doing an app to Nokia devices using ESWT. In order to create the app
> help, I created a html file with the help instructions and use the Browser
> class to open it.
>
>
> try {
> browser = new Browser(getShell(), SWT.NONE);
> } catch (SWTError e) {
> e.printStackTrace();
> }
>
> if (browser != null) {
> StringBuffer buf = new StringBuffer();
> try {
> InputStream inputStreamTxt = null;
> inputStreamTxt =
> this.getClass().getResourceAsStream("/help/index_test.html");
>
> int c;
> while ((c = inputStreamTxt.read()) != -1) {
> buf.append((char) c);
> }
> inputStreamTxt.close();
>
> } catch (IOException e) {
> e.printStackTrace();
> }
>
> browser.setText(buf.toString());
> }
>
>
> When I open the help screen at the phone app, I renders the HTML, but
> doesn't load the images. I already tryed all kinds of paths.
>
>
> <p><img src="figure-1.jpg" alt="alt text"/></p>
>
>
>
> <p><img src="/figure-1.jpg" alt="alt text"/></p>
>
>
>
> <p><img src="./figure-1.jpg" alt="alt text"/></p>
>
>
> Please help me.
Previous Topic:GTK 2.22.0 (Ubuntu 10.10) Eclipse 3.5.2 performance problem
Next Topic:enabling mouse wheel scroll in .Xdefaults
Goto Forum:
  


Current Time: Wed Apr 24 16:01:59 GMT 2024

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

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

Back to the top