Community
Participate
Working Groups
For the IBrowserRidget we need API to intercept and prevent URL changes. This should be possible using SWTs LocationListener / LocationEvent. The proposed API will be based on that, but toolkit independent.
Committing 1st implementation. Example Snippet: browserRidget.addLocationListener(new ILocationListener() { public boolean locationChanging(final LocationEvent event) { System.out.println(event); final String msg = String.format("Go to:\n\n'%s' ?", event.getLocation()); return MessageDialog.openQuestion(shell, "Confirm Change", msg); } }); Technical notes: - The listener cannot prevent _some_ changes. For example: clicks that trigger javascripts (dom changes) or that open urls with <a href="" target="_blank"> do not fire events and therefore cannot be caught - Per design - changing the URL via API calls (i.e. setUrl(...), setText(...)) does not fire events or notify the listener. This is constintent with SWT patterns, to avoid endless listener-event-listener loops. - Per design - rebinding the ridget to another browser widget does not notify the listeners. (though this could be discussed)
Notes: - added LocationEvent.isAllowed() flag - this can be used to check if another listener has already vetoed the change. - added ILocationListener.locationChanged() to receive notification of successful url changes - this is equivalent to browserRidget.addPropertyListener(IBrowserRidget.PROPERTY_URL, lsnr); Resolved.