Skip to main content



      Home
Home » Eclipse Projects » Eclipse Platform » Is it possible to get events from "browser support"
Is it possible to get events from "browser support" [message #327685] Mon, 28 April 2008 23:45 Go to next message
Eclipse UserFriend
Hi,
what I want to do is to react to certain URLs being clicked in the
internal browser, and ideally take an alternative action "inside
Eclipse" when user clicks on these links.

I am currently using the workbench browser support, and my guess is that
it is very difficult to hook actions that take place in the browser.

After looking at the source (but I can't say I figured out how the
pieces fit together), it seems like the SWT Browser has support for
adding listeners to location. But nothing like this is available on the
IWebBrowser interface returned from IWorkbenchBrowserSupport.

Somehow listening must take place, since the Eclipse status bar at the
bottom shows URLs.

It also seems possible to react to events, as an "Eclipse menu" with
"back, and some more actions" is displayed on a right mouse click in the
browser window.

How can I hook into these mechanisms?

If I can't turn clicks into something useful right away, I can perhaps
listen to other things, and pop additional information in a side view.

Grateful for for any ideas or pointers.
Regards
- henrik
Re: Is it possible to get events from "browser support" [message #327689 is a reply to message #327685] Tue, 29 April 2008 00:40 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: zx.us.ibm.com

How about this...

1) extend org.eclipse.ui.browserSupport extension point
2) extend AbstractWorkbenchBrowserSupport in extension point and mark as
deafult
3) in createBrowser()... create your own custom browser...?
4) Browser.addLocationListener(...)

I had an idea of something like this in a blog awhile ago...
http://mea-bloga.blogspot.com/2006/10/what-eclipse-can-learn -from-firefox.html

I think that should work... is there a reason you just need to use the
Eclipse Browser view?

Cheers,

~ Chris
Re: Is it possible to get events from "browser support" [message #327692 is a reply to message #327685] Tue, 29 April 2008 03:14 Go to previous messageGo to next message
Eclipse UserFriend
You have full control. Eclipse is the best platform for embedding Firefox
(XulRunner).

You need xpcom.jar the Java bindings for XPCOM, the internal object model
of Xulrunner, and xulrunner for your platform.

You have to create the browser with the SWT.MOZILLA style, and get access
to the browser internals through:

(nsIWebBrowser)browser.getWebBrowser();

For some features you should use another entry point, the service manager.
Here is an example of how to access the coookies through the service
manager:

nsICookieManager cookieManager = (nsICookieManager)
Mozilla.getInstance().getServiceManager()
getServiceByContractID("@mozilla.org/cookiemanager;1",
nsICookieManager.NS_ICOOKIEMANAGER_IID);

Look at xulplanet.com for further info.

---------------------------------

In addition you have a lot of control for embedding IE as Eclipse support
COM, the underlying used object model. There is an example of this
(download the platform examples).

------------------------------------

Also you have generic browser support, like location events:

browser.addLocationListener(new LocationListener() {
public void changed(LocationEvent event) {
.....
}

public void changing(LocationEvent event) {
.....
}
});


Henrik Lindberg wrote:

> Hi,
> what I want to do is to react to certain URLs being clicked in the
> internal browser, and ideally take an alternative action "inside
> Eclipse" when user clicks on these links.

> I am currently using the workbench browser support, and my guess is that
> it is very difficult to hook actions that take place in the browser.

> After looking at the source (but I can't say I figured out how the
> pieces fit together), it seems like the SWT Browser has support for
> adding listeners to location. But nothing like this is available on the
> IWebBrowser interface returned from IWorkbenchBrowserSupport.

> Somehow listening must take place, since the Eclipse status bar at the
> bottom shows URLs.

> It also seems possible to react to events, as an "Eclipse menu" with
> "back, and some more actions" is displayed on a right mouse click in the
> browser window.

> How can I hook into these mechanisms?

> If I can't turn clicks into something useful right away, I can perhaps
> listen to other things, and pop additional information in a side view.

> Grateful for for any ideas or pointers.
> Regards
> - henrik
Re: Is it possible to get events from "browser support" [message #327712 is a reply to message #327685] Tue, 29 April 2008 09:49 Go to previous messageGo to next message
Eclipse UserFriend
Unfortunately I don't know this level too well, but surely there's a way to
get hold of the underlying Browser object that is being used, no? (anyone?).
If there really isn't a way then the IWebBrowserSupport path may not be the
right one for embedding a Browser that you want to have this amount of
control over. Once you have a Browser instance by some means then listeners
can be added to it like in
http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/org. eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet128 .java .

Grant


"Henrik Lindberg" <henrik.lindberg@cloudsmith.com> wrote in message
news:fv65ld$2mk$1@build.eclipse.org...
> Hi,
> what I want to do is to react to certain URLs being clicked in the
> internal browser, and ideally take an alternative action "inside
> Eclipse" when user clicks on these links.
>
> I am currently using the workbench browser support, and my guess is that
> it is very difficult to hook actions that take place in the browser.
>
> After looking at the source (but I can't say I figured out how the
> pieces fit together), it seems like the SWT Browser has support for
> adding listeners to location. But nothing like this is available on the
> IWebBrowser interface returned from IWorkbenchBrowserSupport.
>
> Somehow listening must take place, since the Eclipse status bar at the
> bottom shows URLs.
>
> It also seems possible to react to events, as an "Eclipse menu" with
> "back, and some more actions" is displayed on a right mouse click in the
> browser window.
>
> How can I hook into these mechanisms?
>
> If I can't turn clicks into something useful right away, I can perhaps
> listen to other things, and pop additional information in a side view.
>
> Grateful for for any ideas or pointers.
> Regards
> - henrik
Re: Is it possible to get events from "browser support" [message #327737 is a reply to message #327685] Tue, 29 April 2008 17:01 Go to previous message
Eclipse UserFriend
Thanks everyone for very useful input. I ended up using the SWT Browser
directly thus being able to add a listener. It enables me to rewrite
URLs and add a request parameter to pages that normally show applets but
now can delegate the job to my plugin in the IDE directly.

I should not have to do this if it was possible to detect that the user
agent is embedded in Eclipse. Wrote an issue on that:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=229289


Regards
- henrik
Previous Topic:Ganymede Splashscreen
Next Topic:Programatically close a ViewPart
Goto Forum:
  


Current Time: Thu May 08 19:42:11 EDT 2025

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

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

Back to the top