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  |
Eclipse User |
|
|
|
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 #326567 is a reply to message #326552] |
Tue, 25 March 2008 08:38   |
Eclipse User |
|
|
|
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   |
Eclipse User |
|
|
|
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   |
Eclipse User |
|
|
|
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 #326592 is a reply to message #326591] |
Tue, 25 March 2008 16:47   |
Eclipse User |
|
|
|
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 #326598 is a reply to message #326597] |
Tue, 25 March 2008 17:32  |
Eclipse User |
|
|
|
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.
|
|
|
Goto Forum:
Current Time: Wed May 07 15:32:17 EDT 2025
Powered by FUDForum. Page generated in 0.05144 seconds
|