Skip to main content



      Home
Home » Eclipse Projects » Eclipse Platform » How to reference a documentation plug-in's HTML in the browser widget?
How to reference a documentation plug-in's HTML in the browser widget? [message #326536] Sun, 23 March 2008 01:54 Go to next message
Eclipse UserFriend
Hi,

Basically I have HTML content displayed by an IInformationControl, such
as the BrowserInformationControl, which is implemented to use the SWT
Browser widget to display HTML content.

How would I specify via the href tag in my HTML content to reference a
documentation plug-in's HTML content.

I tried the below format, but does not help.

<a href="/com.acme.doc.plugin_id/html/index.html">go to acme's doc
plug-in content</a>

That does not seem to work.

Thanks for any tips!
Re: How to reference a documentation plug-in's HTML in the browser widget? [message #326551 is a reply to message #326536] Tue, 25 March 2008 01:34 Go to previous messageGo to next message
Eclipse UserFriend
AL wrote:
> Hi,
>
> Basically I have HTML content displayed by an IInformationControl, such
> as the BrowserInformationControl, which is implemented to use the SWT
> Browser widget to display HTML content.
>
> How would I specify via the href tag in my HTML content to reference a
> documentation plug-in's HTML content?
>
> I tried the below format, but does not help.
>
> <a href="/com.acme.doc.plugin_id/html/index.html">go to acme's doc
> plug-in content</a>
>
> That does not seem to work.
>
> Thanks for any tips!

An example of the above is from cheatsheet. Below is a snippets from
cheatsheet that reference a documentation plug-in's HTML content via the
href tag.

<?xml version="1.0" encoding="UTF-8" ?>
<cheatsheet title="Simple Java Application">
<intro href="/org.eclipse.ui.cheatsheets.doc/tasks/tcheatst.htm">
<description>
hello.
</description>
</intro>
Re: How to reference a documentation plug-in's HTML in the browser widget? [message #326552 is a reply to message #326536] Tue, 25 March 2008 02:01 Go to previous messageGo to next message
Eclipse UserFriend
AL wrote:
> Hi,
>
> Basically I have HTML content displayed by an IInformationControl, such
> as the BrowserInformationControl, which is implemented to use the SWT
> Browser widget to display HTML content.
>
> How would I specify via the href tag in my HTML content to reference a
> documentation plug-in's HTML content.
>
> I tried the below format, but does not help.
>
> <a href="/com.acme.doc.plugin_id/html/index.html">go to acme's doc
> plug-in content</a>
>
> That does not seem to work.
>
> Thanks for any tips!

I think I've figured out how to do this. Get my documentation's
plug-in's bundle via
Activator.getInstance().getBundle().getEntry("html-path"). This returns
a java.net.URL. I should then able to resolve it to an absolute path.

The one requirement is that the documentation plug-in, when deployed,
must be deployed with the unpack="true", which is specified in the
feature.xml.

Any other way to do this?

Thanks.
Re: How to reference a documentation plug-in's HTML in the browser widget? [message #326567 is a reply to message #326552] Tue, 25 March 2008 08:38 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: merks.ca.ibm.com

AL,

I think you could use FileLocator.toFileURL which I think will unpack
the plugin if necessary. Of course it's best to use the URL directly if
at all possible, i.e, get the input stream from the URL directly...


AL wrote:
> AL wrote:
>> Hi,
>>
>> Basically I have HTML content displayed by an IInformationControl,
>> such as the BrowserInformationControl, which is implemented to use
>> the SWT Browser widget to display HTML content.
>>
>> How would I specify via the href tag in my HTML content to reference
>> a documentation plug-in's HTML content.
>>
>> I tried the below format, but does not help.
>>
>> <a href="/com.acme.doc.plugin_id/html/index.html">go to acme's doc
>> plug-in content</a>
>>
>> That does not seem to work.
>>
>> Thanks for any tips!
>
> I think I've figured out how to do this. Get my documentation's
> plug-in's bundle via
> Activator.getInstance().getBundle().getEntry("html-path"). This
> returns a java.net.URL. I should then able to resolve it to an
> absolute path.
>
> The one requirement is that the documentation plug-in, when deployed,
> must be deployed with the unpack="true", which is specified in the
> feature.xml.
>
> Any other way to do this?
>
> Thanks.
Re: How to reference a documentation plug-in's HTML in the browser widget? [message #326581 is a reply to message #326567] Tue, 25 March 2008 13:04 Go to previous messageGo to next message
Eclipse UserFriend
Ed Merks wrote:
> AL,
>
> I think you could use FileLocator.toFileURL which I think will unpack
> the plugin if necessary. Of course it's best to use the URL directly if
> at all possible, i.e, get the input stream from the URL directly...
>

Thanks for tip, but I am still a bit not clear. The HTML stuff I want
to display in my IInformationControl has an href to the documentation
plug-in's HTML content, for example, the TOC content. So, basically, I
need the href to have the correct path put in the href at runtime. I am
not attempting to read the content, just referencing it.

Not sure if I need FileLocator.

So, if my documentation plug-in is deployed as a JAR file, where would
FileLocator.toFileURL unpack the stuff at runtime? It would be probably
bad to unpack every time I need to locate something that had already
been unpacked already.

Anyway, I ended up doing the below to get the path to my plug-in--with
one caveat and that is requiring the doc plug-in to have "unpack=true".
"Activator" is my doc plug-in.

String slocation = Activator.getDefault().getStateLocation().toOSString();
int index = slocation.indexOf(':'); //$NON-NLS-1$
String location = Activator.getDefault().getBundle().getLocation();
location = location.substring(location.indexOf('/'),
location.length());
if (index > 0) {
location = slocation.substring(0, index + 1) + location;
}
>
> AL wrote:
>> AL wrote:
>>> Hi,
>>>
>>> Basically I have HTML content displayed by an IInformationControl,
>>> such as the BrowserInformationControl, which is implemented to use
>>> the SWT Browser widget to display HTML content.
>>>
>>> How would I specify via the href tag in my HTML content to reference
>>> a documentation plug-in's HTML content.
>>>
>>> I tried the below format, but does not help.
>>>
>>> <a href="/com.acme.doc.plugin_id/html/index.html">go to acme's doc
>>> plug-in content</a>
>>>
>>> That does not seem to work.
>>>
>>> Thanks for any tips!
>>
>> I think I've figured out how to do this. Get my documentation's
>> plug-in's bundle via
>> Activator.getInstance().getBundle().getEntry("html-path"). This
>> returns a java.net.URL. I should then able to resolve it to an
>> absolute path.
>>
>> The one requirement is that the documentation plug-in, when deployed,
>> must be deployed with the unpack="true", which is specified in the
>> feature.xml.
>>
>> Any other way to do this?
>>
>> Thanks.
Re: How to reference a documentation plug-in's HTML in the browser widget? [message #326584 is a reply to message #326581] Tue, 25 March 2008 14:16 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: merks.ca.ibm.com

AL,

I think it would unpack the whole plugin. You could use
platform:/plugin/<plugin-ID>/<path in plugin> to refer to it that way;
the platform: protocol is a real live registered URL handler when
running in Eclipse...


AL wrote:
> Ed Merks wrote:
>> AL,
>>
>> I think you could use FileLocator.toFileURL which I think will unpack
>> the plugin if necessary. Of course it's best to use the URL directly
>> if at all possible, i.e, get the input stream from the URL directly...
>>
>
> Thanks for tip, but I am still a bit not clear. The HTML stuff I want
> to display in my IInformationControl has an href to the documentation
> plug-in's HTML content, for example, the TOC content. So, basically,
> I need the href to have the correct path put in the href at runtime.
> I am not attempting to read the content, just referencing it.
>
> Not sure if I need FileLocator.
>
> So, if my documentation plug-in is deployed as a JAR file, where would
> FileLocator.toFileURL unpack the stuff at runtime? It would be
> probably bad to unpack every time I need to locate something that had
> already been unpacked already.
>
> Anyway, I ended up doing the below to get the path to my plug-in--with
> one caveat and that is requiring the doc plug-in to have
> "unpack=true". "Activator" is my doc plug-in.
>
> String slocation =
> Activator.getDefault().getStateLocation().toOSString();
> int index = slocation.indexOf(':'); //$NON-NLS-1$
> String location = Activator.getDefault().getBundle().getLocation();
> location = location.substring(location.indexOf('/'),
> location.length());
> if (index > 0) {
> location = slocation.substring(0, index + 1) + location;
> }
>>
>> AL wrote:
>>> AL wrote:
>>>> Hi,
>>>>
>>>> Basically I have HTML content displayed by an IInformationControl,
>>>> such as the BrowserInformationControl, which is implemented to use
>>>> the SWT Browser widget to display HTML content.
>>>>
>>>> How would I specify via the href tag in my HTML content to
>>>> reference a documentation plug-in's HTML content.
>>>>
>>>> I tried the below format, but does not help.
>>>>
>>>> <a href="/com.acme.doc.plugin_id/html/index.html">go to acme's doc
>>>> plug-in content</a>
>>>>
>>>> That does not seem to work.
>>>>
>>>> Thanks for any tips!
>>>
>>> I think I've figured out how to do this. Get my documentation's
>>> plug-in's bundle via
>>> Activator.getInstance().getBundle().getEntry("html-path"). This
>>> returns a java.net.URL. I should then able to resolve it to an
>>> absolute path.
>>>
>>> The one requirement is that the documentation plug-in, when
>>> deployed, must be deployed with the unpack="true", which is
>>> specified in the feature.xml.
>>>
>>> Any other way to do this?
>>>
>>> Thanks.
Re: How to reference a documentation plug-in's HTML in the browser widget? [message #326587 is a reply to message #326584] Tue, 25 March 2008 14:24 Go to previous messageGo to next message
Eclipse UserFriend
Ed Merks wrote:
> AL,
>
> I think it would unpack the whole plugin. You could use
> platform:/plugin/<plugin-ID>/<path in plugin> to refer to it that way;
> the platform: protocol is a real live registered URL handler when
> running in Eclipse...
>

Thanks, just to be clear. I put "platform:/plugin/<plugin-ID>/<path to
HTML file>" in my href tag? Or I am passing this in to FileLocator,
which, looking at the code, takes Bundle and IPath?
Re: How to reference a documentation plug-in's HTML in the browser widget? [message #326588 is a reply to message #326587] Tue, 25 March 2008 14:58 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: merks.ca.ibm.com

AL,

I think you could use this directly in your href tag. I think the file
locator would handle it too. The advantage of the former is that the
plugin shouldn't need to be unzipped and the value doesn't change
depending on the installed location of the plugin...


AL wrote:
> Ed Merks wrote:
>> AL,
>>
>> I think it would unpack the whole plugin. You could use
>> platform:/plugin/<plugin-ID>/<path in plugin> to refer to it that
>> way; the platform: protocol is a real live registered URL handler
>> when running in Eclipse...
>>
>
> Thanks, just to be clear. I put "platform:/plugin/<plugin-ID>/<path
> to HTML file>" in my href tag? Or I am passing this in to
> FileLocator, which, looking at the code, takes Bundle and IPath?
Re: How to reference a documentation plug-in's HTML in the browser widget? [message #326591 is a reply to message #326588] Tue, 25 March 2008 16:36 Go to previous messageGo to next message
Eclipse UserFriend
Ed Merks wrote:
> AL,
>
> I think you could use this directly in your href tag. I think the file
> locator would handle it too. The advantage of the former is that the
> plugin shouldn't need to be unzipped and the value doesn't change
> depending on the installed location of the plugin...
>

Hi,

Tried it out to use form "platform:/plugin/<plugin-ID>/<path in plugin>"
directly in the href tag. It does not work.

If you have any more tips, greatly appreciate it. Thanks.

>
> AL wrote:
>> Ed Merks wrote:
>>> AL,
>>>
>>> I think it would unpack the whole plugin. You could use
>>> platform:/plugin/<plugin-ID>/<path in plugin> to refer to it that
>>> way; the platform: protocol is a real live registered URL handler
>>> when running in Eclipse...
>>>
>>
>> Thanks, just to be clear. I put "platform:/plugin/<plugin-ID>/<path
>> to HTML file>" in my href tag? Or I am passing this in to
>> FileLocator, which, looking at the code, takes Bundle and IPath?
Re: How to reference a documentation plug-in's HTML in the browser widget? [message #326592 is a reply to message #326591] Tue, 25 March 2008 16:47 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: merks.ca.ibm.com

AL,

You're actually running this within an Eclipse process? You're sure you
have the path right? If you create a URL for your path and open a
stream, does that work? The information in
http://lmap.blogspot.com/2008/03/platform-scheme-uri.html should be
accurate...


AL wrote:
> Ed Merks wrote:
>> AL,
>>
>> I think you could use this directly in your href tag. I think the
>> file locator would handle it too. The advantage of the former is
>> that the plugin shouldn't need to be unzipped and the value doesn't
>> change depending on the installed location of the plugin...
>>
>
> Hi,
>
> Tried it out to use form "platform:/plugin/<plugin-ID>/<path in
> plugin>" directly in the href tag. It does not work.
>
> If you have any more tips, greatly appreciate it. Thanks.
>
>>
>> AL wrote:
>>> Ed Merks wrote:
>>>> AL,
>>>>
>>>> I think it would unpack the whole plugin. You could use
>>>> platform:/plugin/<plugin-ID>/<path in plugin> to refer to it that
>>>> way; the platform: protocol is a real live registered URL handler
>>>> when running in Eclipse...
>>>>
>>>
>>> Thanks, just to be clear. I put "platform:/plugin/<plugin-ID>/<path
>>> to HTML file>" in my href tag? Or I am passing this in to
>>> FileLocator, which, looking at the code, takes Bundle and IPath?
Re: How to reference a documentation plug-in's HTML in the browser widget? [message #326594 is a reply to message #326592] Tue, 25 March 2008 17:07 Go to previous messageGo to next message
Eclipse UserFriend
Ed Merks wrote:
> AL,
>
> You're actually running this within an Eclipse process?

Yes.

> You're sure you have the path right?

Yes. I System.out.println() it out to verify.

If you create a URL for your path and open a
> stream, does that work?

Have not tried opening the stream.

The information in
> http://lmap.blogspot.com/2008/03/platform-scheme-uri.html should be
> accurate...

Read the above article. Can't seem to find the URI that has the
createPlatformPluginURI() method, when doing an open-type in the java
editor. Can't find also CommonPlugin as mentioned in the above article. :-(

>
Re: How to reference a documentation plug-in's HTML in the browser widget? [message #326595 is a reply to message #326594] Tue, 25 March 2008 17:10 Go to previous messageGo to next message
Eclipse UserFriend
AL wrote:
> Ed Merks wrote:
>> AL,
>>
>> You're actually running this within an Eclipse process?
>
> Yes.
>
>> You're sure you have the path right?
>
> Yes. I System.out.println() it out to verify.
>
> If you create a URL for your path and open a
>> stream, does that work?
>
> Have not tried opening the stream.
>
> The information in
>> http://lmap.blogspot.com/2008/03/platform-scheme-uri.html should be
>> accurate...
>
> Read the above article. Can't seem to find the URI that has the
> createPlatformPluginURI() method, when doing an open-type in the java
> editor. Can't find also CommonPlugin as mentioned in the above article.
> :-(
>

Oops the URI object mentioned in the article is from EMF, but I am not
using EMF at the moment :-(

Class URI java.lang.Object
extended by org.eclipse.emf.common.util.URI

>>
Re: How to reference a documentation plug-in's HTML in the browser widget? [message #326596 is a reply to message #326594] Tue, 25 March 2008 17:11 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: merks.ca.ibm.com

AL,

The article is a little EMF centric so it's
org.eclipse.emf.common.util.URI. But you should be able to use the
string to construct a URL and if you've got the right URL, you should be
able to open a stream on that URL.


AL wrote:
> Ed Merks wrote:
>> AL,
>>
>> You're actually running this within an Eclipse process?
>
> Yes.
>
>> You're sure you have the path right?
>
> Yes. I System.out.println() it out to verify.
>
> If you create a URL for your path and open a
>> stream, does that work?
>
> Have not tried opening the stream.
>
> The information in
>> http://lmap.blogspot.com/2008/03/platform-scheme-uri.html should be
>> accurate...
>
> Read the above article. Can't seem to find the URI that has the
> createPlatformPluginURI() method, when doing an open-type in the java
> editor. Can't find also CommonPlugin as mentioned in the above
> article. :-(
>
>>
Re: How to reference a documentation plug-in's HTML in the browser widget? [message #326597 is a reply to message #326595] Tue, 25 March 2008 17:12 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: merks.ca.ibm.com

AL,

Yes, but you should be able to do all this without EMF. new
URL("platform:/plugin/<plugin-id>/plugin.xml").openStream() for example...

AL wrote:
> AL wrote:
>> Ed Merks wrote:
>>> AL,
>>>
>>> You're actually running this within an Eclipse process?
>>
>> Yes.
>>
>>> You're sure you have the path right?
>>
>> Yes. I System.out.println() it out to verify.
>>
>> If you create a URL for your path and open a
>>> stream, does that work?
>>
>> Have not tried opening the stream.
>>
>> The information in
>>> http://lmap.blogspot.com/2008/03/platform-scheme-uri.html should be
>>> accurate...
>>
>> Read the above article. Can't seem to find the URI that has the
>> createPlatformPluginURI() method, when doing an open-type in the java
>> editor. Can't find also CommonPlugin as mentioned in the above
>> article. :-(
>>
>
> Oops the URI object mentioned in the article is from EMF, but I am not
> using EMF at the moment :-(
>
> Class URI java.lang.Object
> extended by org.eclipse.emf.common.util.URI
>
>>>
Re: How to reference a documentation plug-in's HTML in the browser widget? [message #326598 is a reply to message #326597] Tue, 25 March 2008 17:32 Go to previous message
Eclipse UserFriend
Ed Merks wrote:
> AL,
>
> Yes, but you should be able to do all this without EMF. new
> URL("platform:/plugin/<plugin-id>/plugin.xml").openStream() for example...
>

Ok, the openstream does not cause any exception, but the href still does
not work with platform URI format. It wants an absolute path, and
currently my using Bundle.getLocateState() and Bundle.getLocation() does
the trick. I tested on Linux and Windows. It works fine, although I
like the URI approach better.

Thanks.
Previous Topic:How to switch VM in preferences to another jdk installation?
Next Topic:Can two Eclipse installations coexist on a hard disc?
Goto Forum:
  


Current Time: Wed May 07 15:32:17 EDT 2025

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

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

Back to the top