Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » How to open a plugin resource inside the WebBrowser editor
How to open a plugin resource inside the WebBrowser editor [message #509863] Mon, 25 January 2010 15:56 Go to next message
Pierre Francis Roy is currently offline Pierre Francis Roy
Messages: 12
Registered: July 2009
Junior Member
Hi,

I've just learned how to embed the WebBrowser editor into my RCP application by using the org.eclipse.ui.browser.openBrowser command.

By specifying the url parameter the browser open and displays file:// and http:// url.

My RCP application have the following needs:

1) Open a resource located inside one of its plugin (mostly xml files located in a resource directory of the plugin)
2) Hide the navigation button and adress bar

Any idea how I can process with that?

My best regards
Pierre Francis
Re: How to open a plugin resource inside the WebBrowser editor [message #509924 is a reply to message #509863] Mon, 25 January 2010 14:10 Go to previous messageGo to next message
Paul Webster is currently offline Paul Webster
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

Pierre Francis Roy wrote:
> My RCP application have the following needs:
>
> 1) Open a resource located inside one of its plugin (mostly xml files
> located in a resource directory of the plugin)

You can use URLs like
platform:/plugin.id/icons/full/dlcl16/collapseall.gif with varying
degrees of success. See
http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse .platform.doc.isv/reference/misc/platform-scheme-uri.html


PW


--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse .platform.doc.isv/guide/workbench.htm


Re: How to open a plugin resource inside the WebBrowser editor [message #509934 is a reply to message #509924] Mon, 25 January 2010 19:40 Go to previous messageGo to next message
Pierre Francis Roy is currently offline Pierre Francis Roy
Messages: 12
Registered: July 2009
Junior Member
Hi Paul,

My url would look like this:
platform:/plugin/reports.browser/reports/cdcatalog.xml
or
platform:/resource/reports.browser/reports/cdcatalog.xml

I tried many variation and it doesn't work. It think because it's in URI form instead of the URL the web browser requires... What do you think?

Thank you
Pierre
Re: How to open a plugin resource inside the WebBrowser editor [message #509979 is a reply to message #509863] Mon, 25 January 2010 23:58 Go to previous messageGo to next message
Thomas Mauch is currently offline Thomas Mauch
Messages: 29
Registered: July 2009
Junior Member
Hi Pierre

Unfortunately I cannot help you, but I'm struggling with a similar problem. You write

Quote:
I've just learned how to embed the WebBrowser editor into my RCP application by using the org.eclipse.ui.browser.openBrowser command.


Where did you find any information about using the WebBrowser? I'm still looking but could not find anything real useful.

Could you share your findings with me?

Many thanks in advance,
Thomas
Re: How to open a plugin resource inside the WebBrowser editor [message #509980 is a reply to message #509979] Tue, 26 January 2010 00:06 Go to previous messageGo to next message
Pierre Francis Roy is currently offline Pierre Francis Roy
Messages: 12
Registered: July 2009
Junior Member
Dear Thomas,

I'm only part done with this component. In fact it is really easy to open a WebBrowser editor for an http or file url using the command provided by the plugin.

1) Add dependencie to org.eclipse.ui.browser to your plugin.xml
2) Add a command to a menu
3) Set the command id to org.eclipse.ui.browser.openBrowser
4) Add a parameter to your new command with name=url and value=http://www.yoursite.com.

Et voilĂ !!!

You can inspect the org.eclipse.ui.browser plugin for more comprehension by importing the plugin source into your workspace. I'm doing it more and more often to gain knowledge of good RCP programming practices.

1) Window / Show View / Plug-ins
2) Select org.eclipse.ui.browser
3) Import As / Source Project

Keep me inform if you find some stuff about plugin resource uri Wink.

Pierre
Re: How to open a plugin resource inside the WebBrowser editor [message #509983 is a reply to message #509980] Tue, 26 January 2010 00:25 Go to previous messageGo to next message
Thomas Mauch is currently offline Thomas Mauch
Messages: 29
Registered: July 2009
Junior Member
Thanks for your prompt reply.

Unfortunately this does not help me. What I try to do it to show a HTML page if some processing is done.

So I'm experimenting with WebBrowserEditor and WebBrowserEditorInput (both have discouraged access) to open the browser programmatically, but it does not work properly.

Any idea where I could find information about opening the browser programmatically?

The funny part: when I open the browser programmatically, I get no address bar, but I would like to have one!

Good luck with your problem.
Thomas
Re: How to open a plugin resource inside the WebBrowser editor [message #509985 is a reply to message #509983] Tue, 26 January 2010 00:47 Go to previous messageGo to next message
Pierre Francis Roy is currently offline Pierre Francis Roy
Messages: 12
Registered: July 2009
Junior Member
try {
IWorkbenchBrowserSupport browserSupport = PlatformUI.getWorkbench()
.getBrowserSupport();
IWebBrowser browser = browserSupport.createBrowser(
IWorkbenchBrowserSupport.LOCATION_BAR
| IWorkbenchBrowserSupport.NAVIGATION_BAR,
browserId, name, tooltip);
browser.openURL(url);
} catch (PartInitException ex) {
throw new ExecutionException("error opening browser", ex); //$NON-NLS-1$
}
Re: How to open a plugin resource inside the WebBrowser editor [message #510070 is a reply to message #509934] Tue, 26 January 2010 13:00 Go to previous messageGo to next message
Paul Webster is currently offline Paul Webster
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

Pierre Francis Roy wrote:
> I tried many variation and it doesn't work. It think because it's in URI
> form instead of the URL the web browser requires... What do you think?

My guess is because of the platform: ... somewhere down in equinox
registers a handler for the platform: scheme and voila, the Java URL
class can deal with it. But I missed the bit about the web browser,
which is usually embedded firefox or IE (which wouldn't know how to deal
with it).

One option would be to use org.eclipse.core.runtime.FileLocator to
return a "file:" compatible pointer to the files you want in your plugin.

PW


--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse .platform.doc.isv/guide/workbench.htm


Re: How to open a plugin resource inside the WebBrowser editor [message #510181 is a reply to message #510070] Tue, 26 January 2010 16:03 Go to previous message
Pierre Francis Roy is currently offline Pierre Francis Roy
Messages: 12
Registered: July 2009
Junior Member
Dear Paul,

As you proposed, I transformed my platform URL to a file URL using FileLocator (see code below). It works perfectly. The only things left to do is to give the browser tab a more interesting name than the full file path.

Thanks for your help
Pierre

private final static String REPORT_URI = "platform:/plugin/reports.browser/reports/cdcatalog.xml";

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
URL platformUrl;
try {
platformUrl = new URL(REPORT_URI);
URL fileUrl = FileLocator.toFileURL(platformUrl);
IWorkbenchBrowserSupport bs = PlatformUI.getWorkbench().getBrowserSupport();
IWebBrowser b = bs.createBrowser("report");
b.openURL(fileUrl);
} catch (IOException e) {
e.printStackTrace();
} catch (PartInitException e) {
e.printStackTrace();
}

return null;
}
Previous Topic:Accessing native libraries from fragments using JNI
Next Topic:How to generate RCP application programatically
Goto Forum:
  


Current Time: Thu Oct 30 15:58:43 GMT 2014

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

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