browser.addProgressListener (new ProgressAdapter () {
@SuppressWarnings("unused")
public void completed (ProgressEvent event) {
nsIWebBrowser webBrowser = (nsIWebBrowser)browser.getWebBrowser ();
nsIDOMWindow domWindow = webBrowser.getContentDOMWindow ();
nsIDOMEventTarget target = (nsIDOMEventTarget)domWindow.queryInterface (nsIDOMEventTarget.NS_IDOMEVENTTARGET_IID);
nsIDOMEventListener listener = new nsIDOMEventListener () {
public nsISupports queryInterface (String uuid) {
if (uuid.equals (nsIDOMEventListener.NS_IDOMEVENTLISTENER_IID) ||
uuid.equals (nsIDOMEventListener.NS_ISUPPORTS_IID)) {
return this;
}
return null;
}
public void handleEvent (nsIDOMEvent event2) {
Menu menu = browser.getMenu();
if(menu != null) menu.dispose();
try {
BrowserMenu browserMenu = (BrowserMenu)clazz.newInstance();
browser.setMenu(browserMenu.createMenu(browser, event2));
} catch (Exception e) {
ClientLog.getInstance().setMessage(browser.getShell(), e);
}
}
};
target.addEventListener ("contextmenu", listener, false);
}
});
return browser;
}