Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7904737
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T10:12:48+00:00 2026-06-03T10:12:48+00:00

For my eclipse plugin I want to track every URL that is opened with

  • 0

For my eclipse plugin I want to track every URL that is opened with the internal (and if possible also external) Eclipse browser.

So far I use

org.eclipse.swt.browser.Browser;

and

addLocationListener(...)

But I would prefer that it works also for the internal Eclipse browser. How can I achieve that?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T10:12:51+00:00Added an answer on June 3, 2026 at 10:12 am

    One possible solution for the Eclipse Internal Browser would be to create an eclipse plugin that registers an IStartup extension. In your earlyStartup() method you would register an IPartListener on the workbenchPage. Then when the internal browser part is created, you will receive a callback with a reference to the WebBrowserEditor (or WebBrowserView). Since there is no direct API you will have to hack a bit and use reflection to grab the internal SWT Browser instance. Once you have that, you can add your location listener.

    Sometimes during early startup there is no active Workbench window yet so you have to loop through all existing workbench windows (usually just one) and each of their workbench pages to add part listeners also.

    Here is the snippet of code for the earlyStartup() routine. Note that I have omitted any cleanup of listeners during dispose for windows/pages so that still needs to be done.

    //Add this code to an IStartup.earlyStartup() method
    final IPartListener partListener = new IPartListener() {
        @Override
        public void partOpened(IWorkbenchPart part) {
            if (part instanceof WebBrowserEditor)
            {
                WebBrowserEditor editor = (WebBrowserEditor) part;
    
                try {
                    Field webBrowser = editor.getClass().getDeclaredField("webBrowser");
                    webBrowser.setAccessible(true);
                    BrowserViewer viewer = (BrowserViewer)webBrowser.get(editor);
    
                    Field browser = viewer.getClass().getDeclaredField("browser");
                    browser.setAccessible(true);
                    Browser swtBrowser = (Browser) browser.get(viewer);
    
                    swtBrowser.addLocationListener(new LocationListener() {
                        @Override
                        public void changed(LocationEvent event) {
                            System.out.println(event.location);
                        }
                    });
                } catch (Exception e) {
                }
            }
            else if (part instanceof WebBrowserView)
            {
                WebBrowserView view = (WebBrowserView) part;
    
                try {
                    Field webBrowser = editor.getClass().getDeclaredField("viewer");
                    webBrowser.setAccessible(true);
                    BrowserViewer viewer = (BrowserViewer)webBrowser.get(view);
    
                    Field browser = viewer.getClass().getDeclaredField("browser");
                    browser.setAccessible(true);
                    Browser swtBrowser = (Browser) browser.get(viewer);
    
                    swtBrowser.addLocationListener(new LocationListener() {
                        @Override
                        public void changed(LocationEvent event) {
                            System.out.println(event.location);
                        }
                    });
                } catch (Exception e) {
                }
            }
        }
        ...
    };
    
    final IPageListener pageListener = new IPageListener() {
        @Override
        public void pageOpened(IWorkbenchPage page) {
            page.addPartListener(partListener);
        }
        ...
    };
    
    final IWindowListener windowListener = new IWindowListener() {
        @Override
        public void windowOpened(IWorkbenchWindow window) {
            window.addPageListener(pageListener);
        }
        ...
    };
    
    
    IWorkbenchWindow activeWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    
    if (activeWindow != null)
    {
        IWorkbenchPage activePage = activeWindow.getActivePage();
    
        if (activePage != null)
        {
            activePage.addPartListener(partListener);
        }
        else
        {
            activeWindow.addPageListener(pageListener);
        }
    }
    else
    {
        for (IWorkbenchWindow window : PlatformUI.getWorkbench().getWorkbenchWindows())
        {
            for (IWorkbenchPage page : window.getPages()) {
                page.addPartListener(partListener);
            }
            window.addPageListener(pageListener);
        }
    
        PlatformUI.getWorkbench().addWindowListener(windowListener);
    }       
    

    One last detail about this code snippet is that it requires a dependency on the org.eclipse.ui.browser plugin to have access to the WebBrowserEditor class.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to use autocomplete for jQuery in Eclipse. The Aptana Plugin is installed:
I want to use the Eclipse plugin Subclipse on Snow Leopard. I installed Eclipse
I have maven eclipse plugin and I want to use a jar file in
I've created an eclipse plugin with a UI that I want to dock by
I have an Eclipse plugin that makes use of several keybindings (Alt-G x, Alt-G
I have a handler in an Eclipse plugin (developed on Indigo) that I want
From my Eclipse plugin, I want to execute a command and show the results
We're using Eclipse (with the eGit plugin) and I want to host a repo
I am using eclipse with the maven 2 plugin. I want to add the
I am using Eclipse Helios (3.6). I want to use Mercurial for version management

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.