private void createUI_10_SearchInternal(final Composite parent) { try { _browser = new Browser(parent, SWT.NONE); GridDataFactory.fillDefaults().grab(true, true).applyTo(_browser); } catch (final SWTError e) { StatusUtil.showStatus("Could not instantiate Browser: " + e.getMessage(), e);//$NON-NLS-1$ return; } _browser.addLocationListener(new LocationAdapter() { @Override public void changing(final LocationEvent event) { SearchMgr.onBrowserLocation(event); } }); }
private void onBrowser_LocationChanging(final LocationEvent event) { final String location = event.location; final String[] locationParts = location.split(HREF_TOKEN); if (locationParts.length > 1) { // finalize loading of the browser page and then start the action _browser.getDisplay().asyncExec(new Runnable() { @Override public void run() { onBrowser_LocationChanging_Runnable(locationParts); } }); } // prevent to load a new url if (location.equals(PAGE_ABOUT_BLANK) == false) { // about:blank is the initial page event.doit = false; } }
private void openBrowserInEditor(LocationEvent event) { URL url; try { url = new URL(event.location); } catch (MalformedURLException ignored) { return; } IWorkbenchBrowserSupport support = PlatformUI.getWorkbench().getBrowserSupport(); try { IWebBrowser newBrowser = support.createBrowser(browserId); browserId = newBrowser.getId(); newBrowser.openURL(url); return; } catch (PartInitException e) { FindbugsPlugin.getDefault().logException(e, "Can't open external browser"); } }
@Override public void createPartControl(Composite parent){ browser = new Browser(parent, SWT.NONE); browser.addLocationListener(new LocationAdapter() { @Override public void changed(LocationEvent arg0){ String text = getText(arg0.location); System.out.println(text); } }); // browser.setUrl("http://ch.oddb.org"); browser.setUrl("http://santesuisse.oddb.org/"); }
protected URI initURI(LocationEvent event){ String loc= event.location; if ("about:blank".equals(loc)) { //$NON-NLS-1$ /* * Using the Browser.setText API triggers a location change to "about:blank". * remove this code once https://bugs.eclipse.org/bugs/show_bug.cgi?id=130314 is fixed */ //input set with setText handler.handleTextSet(); return null; } event.doit= false; if (loc.startsWith("about:")) { //$NON-NLS-1$ // Relative links should be handled via head > base tag. // If no base is available, links just won't work. return null; } URI uri; try { uri= new URI(loc); } catch (URISyntaxException e) { // try it with a file (workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=237903 ): File file= new File(loc); if (! file.exists()) { log.warn("Could not handle location"+loc, e); return null; } uri= file.toURI(); } return uri; }
public SwtInterceptingBrowser(final Browser browser, final Display display, final Shell shell) { this.browser = browser; this.display = display; this.browser.addLocationListener(new LocationAdapter() { @Override public void changing(LocationEvent locationEvent) { super.changing(locationEvent); final String newValue = locationEvent.location; lock.lock(); try { if (redirectUriString != null && newValue != null && newValue.startsWith(redirectUriString)) { // Do not load this new location, as we are only interested in the authorization code locationEvent.doit = false; response = UserAgentImpl.extractResponseFromRedirectUri(newValue); responseReceived.signal(); } } finally { lock.unlock(); } } }); shell.addListener(SWT.Close, new Listener() { @Override public void handleEvent(Event event) { lock.lock(); try { response = "error=cancelled&error_description=The browser window was closed by the user."; responseReceived.signal(); } finally { lock.unlock(); } } }); }
/** * Fire event */ private void fireLocationEvent(){ LocationEvent event = new LocationEvent(root); event.location = this.location; for (LocationListener listener : listeners) { listener.changed(event); } }
/** * Fires an on location change event. * * @param swtEvent * @return true, if a veto occurred */ private boolean fireOnLocationChange(final LocationEvent swtEvent) { if (locationListeners.size() > 0) { final IBrowserLocationEvent event = new BrowserLocationEvent(swtEvent); final VetoHolder vetoHolder = new VetoHolder(); for (final IBrowserLocationListener listener : new LinkedList<IBrowserLocationListener>(locationListeners)) { listener.onLocationChange(event, vetoHolder); if (vetoHolder.hasVeto()) { return true; } } } return false; }
private void fireLocationChanged(final LocationEvent swtEvent) { if (locationListeners.size() > 0) { final IBrowserLocationEvent event = new BrowserLocationEvent(swtEvent); for (final IBrowserLocationListener listener : new LinkedList<IBrowserLocationListener>(locationListeners)) { listener.locationChanged(event); } } }
@Override public void changing(LocationEvent event) { EPlanElement node = getTargetNode(event); if (node != null) { selectTemporalNode(node); } event.doit = false; }
/** * Utility function to look up the target for a given hyperlink event. * Relies on the unique id for the target being put into the href of * the hyperlink. As a backup, checks the link label as a print name. * @param e * @return the temporal node targeted by the hyperlink, if any */ private EPlanElement getTargetNode(LocationEvent e) { EPlanElement node = null; String href = e.location; if (href != null) { String uniqueId = PlanPrinter.getUniqueIdFromHref(href); node = identifiableRegistry.getIdentifiable(EPlanElement.class, uniqueId); } if (node == null) { String printName = e.location; node = getNodeByPrintName(plan, printName); } return node; }
@Override public void createPartControl(Composite parent){ browser = new Browser(parent, SWT.NONE); browser.addLocationListener(new LocationAdapter() { @Override public void changed(LocationEvent arg0){ String text = browser.getText(); // System.out.println(text); } }); browser.setUrl("http://www.compendium.ch/search/de"); //$NON-NLS-1$ }
/** * Sets the location to text control when web browser changes site. * Sets the browser enable when it has changed. * @see org.eclipse.swt.browser.LocationListener#changed(org.eclipse.swt.browser.LocationEvent) * @param event event. */ public void changed(LocationEvent event) { if (event.top) { String url = event.location; locationText.setText(url); locationText.redraw(); } getButton(IDialogConstants.OK_ID).setEnabled(true); }
public void changed(LocationEvent event) { tx_addr.setText(mozillaBrowser.getUrl()); }
@Override public void changed(LocationEvent arg0) { getCookies(); }
@Override public void changing(LocationEvent event) { String loc = event.location; if ("about:blank".equals(loc)) { //$NON-NLS-1$ /* * Using the Browser.setText API triggers a location change to * "about:blank". XXX: remove this code once * https://bugs.eclipse.org/bugs/show_bug.cgi?id=130314 is fixed */ // input set with setText handleTextSet(); return; } event.doit = false; if (loc.startsWith(TERN_FILE_PROTOCOL)) { //$NON-NLS-1$ handleTernFileLink(loc); return; } if (loc.startsWith(TERN_DEFINITION_PROTOCOL)) { //$NON-NLS-1$ handleTernDefinitionLink(loc); return; } if (loc.startsWith("about:")) { //$NON-NLS-1$ // Relative links should be handled via head > base tag. // If no base is available, links just won't work. return; } if (loc.startsWith(HTTP_PROTOCOL)) { //$NON-NLS-1$ try { handleHttpLink(new URL(loc), event.display); return; } catch (MalformedURLException e) { } } }
BrowserLocationEvent(final LocationEvent locationEvent) { this.locationEvent = locationEvent; this.location = locationEvent.location; this.isTopFrameLocation = locationEvent.top; }
@Override public void changing(final LocationEvent event) { if (fireOnLocationChange(event)) { event.doit = false; } }
@Override public void changed(final LocationEvent event) { fireLocationChanged(event); }
@Override public void changed(LocationEvent event) { // don't care }
public void changed(LocationEvent arg0) { getCookies(); }
public void changed( LocationEvent event ) { // TODO Auto-generated method stub }
public void changing( LocationEvent event ) { if ( event.location.startsWith( "birt://" ) ) //$NON-NLS-1$ { try { String urlstr = URLDecoder.decode( event.location, "UTF-8" ); //$NON-NLS-1$ urlstr = urlstr.substring( urlstr.indexOf( "?" ) + 1 ); //$NON-NLS-1$ StringTokenizer st = new StringTokenizer( urlstr, "&" ); //$NON-NLS-1$ final Map options = new HashMap( ); while ( st.hasMoreTokens( ) ) { String option = st.nextToken( ); int index = option.indexOf( "=" ); //$NON-NLS-1$ if ( index > 0 ) { options.put( option.substring( 0, index ), URLDecoder.decode( option.substring( index + 1, option.length( ) ), "UTF-8" ) ); //$NON-NLS-1$ } else { options.put( option, "" ); //$NON-NLS-1$ } } event.doit = false; Display.getCurrent( ).asyncExec( new Runnable( ) { public void run( ) { viewer.setReportDesignFile( (String) options.get( "__report" ) ); //$NON-NLS-1$ viewer.setParamValues( options ); viewer.setCurrentPage( 1 ); viewer.render( ); } } ); } catch ( UnsupportedEncodingException e ) { } } }
@Override public void changed(LocationEvent event) {}
public void onAddressChange(CefBrowser browser, String url) { LocationEvent locevent = new LocationEvent(webkitbrowser); locevent.location = url; webkitbrowser.notifyListeners(locevent); }
static void onBrowserLocation(final LocationEvent event) { final String location = event.location; if (hrefAction(location)) { // keep current page when an action is performed, OTHERWISE the current page will disappear or is replaced :-( event.doit = false; } }
@Override public void changing(LocationEvent arg0) { }
public void changing(LocationEvent arg0) { }
/** * Sets the browser disable when it is changing. * @see org.eclipse.swt.browser.LocationListener#changing(org.eclipse.swt.browser.LocationEvent) * @param event event. */ public void changing(LocationEvent event) { getButton(IDialogConstants.OK_ID).setEnabled(false); }
public void changing(LocationEvent event) { }