1 /*******************************************************************************
2 * Copyright (c) 2003, 2017 IBM Corporation and others.
4 * This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License 2.0
6 * which accompanies this distribution, and is available at
7 * https://www.eclipse.org/legal/epl-2.0/
9 * SPDX-License-Identifier: EPL-2.0
12 * IBM Corporation - initial API and implementation
13 *******************************************************************************/
14 package org.eclipse.swt.browser;
16 import java.util.function.*;
18 import org.eclipse.swt.internal.*;
21 * This listener interface may be implemented in order to receive
22 * a {@link LocationEvent} notification when a {@link Browser}
23 * navigates to a different URL.
25 * @see Browser#addLocationListener(LocationListener)
26 * @see Browser#removeLocationListener(LocationListener)
27 * @see LocationAdapter
31 public interface LocationListener extends SWTEventListener {
34 * This method is called when the current location is about to be changed.
36 * <p>The following fields in the <code>LocationEvent</code> apply:</p>
38 * <li>(in) location the location to be loaded
39 * <li>(in) widget the <code>Browser</code> whose location is changing
40 * <li>(in/out) doit can be set to <code>false</code> to prevent the location
44 * @param event the <code>LocationEvent</code> that specifies the location
45 * to be loaded by a <code>Browser</code>
49 public void changing(LocationEvent event);
52 * This method is called when the current location is changed.
54 * <p>The following fields in the <code>LocationEvent</code> apply:</p>
56 * <li>(in) location the current location
57 * <li>(in) top <code>true</code> if the location opens in the top frame or
58 * <code>false</code> otherwise
59 * <li>(in) widget the <code>Browser</code> whose location has changed
62 * @param event the <code>LocationEvent</code> that specifies the new
63 * location of a <code>Browser</code>
67 public void changed(LocationEvent event);
70 * Static helper method to create a <code>LocationListener</code> for the
71 * {@link #changing(LocationEvent e)}) method, given a lambda expression or a method reference.
73 * @param c the consumer of the event
74 * @return LocationListener
77 public static LocationListener changingAdapter(Consumer<LocationEvent> c) {
78 return new LocationAdapter() {
80 public void changing(LocationEvent e) {
87 * Static helper method to create a <code>LocationListener</code> for the
88 * {@link #changed(LocationEvent e)}) method, given a lambda expression or a method reference.
90 * @param c the consumer of the event
91 * @return LocationListener
94 public static LocationListener changedAdapter(Consumer<LocationEvent> c) {
95 return new LocationAdapter() {
97 public void changed(LocationEvent e) {