Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 338602 - IBrowserRidget - API to intercept and prevent URL changes
Summary: IBrowserRidget - API to intercept and prevent URL changes
Status: RESOLVED FIXED
Alias: None
Product: Riena
Classification: RT
Component: ridget (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows Vista
: P3 normal (vote)
Target Milestone: 3.0.0   Edit
Assignee: Elias Volanakis CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-03-01 18:31 EST by Elias Volanakis CLA
Modified: 2011-03-07 20:11 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Elias Volanakis CLA 2011-03-01 18:31:41 EST
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.
Comment 1 Elias Volanakis CLA 2011-03-01 18:36:03 EST
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)
Comment 2 Elias Volanakis CLA 2011-03-07 20:11:40 EST
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.