Search in sources :

Example 91 with Browser

use of org.eclipse.swt.browser.Browser in project erlide_eclipse by erlang.

the class EdocView method internalCreatePartControl.

/*
     * @see AbstractInfoView#internalCreatePartControl(Composite)
     */
@Override
protected void internalCreatePartControl(final Composite parent) {
    try {
        fBrowser = new Browser(parent, SWT.NONE);
        locationListener = new HandleEdocLinksLocationListener(this);
        fBrowser.addLocationListener(locationListener);
    } catch (final SWTError er) {
        ErlLogger.warn(er);
    }
    initStyleSheet();
    getViewSite().setSelectionProvider(new SelectionProvider(getControl()));
}
Also used : SWTError(org.eclipse.swt.SWTError) HandleEdocLinksLocationListener(org.erlide.ui.internal.information.HandleEdocLinksLocationListener) ISelectionProvider(org.eclipse.jface.viewers.ISelectionProvider) Browser(org.eclipse.swt.browser.Browser)

Example 92 with Browser

use of org.eclipse.swt.browser.Browser in project eclipse-integration-commons by spring-projects.

the class StsBrowserEditor method createPartControl.

/*
	 * (non-Javadoc)
	 *
	 * @see
	 * org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets
	 * .Composite)
	 */
@Override
public void createPartControl(Composite parent) {
    parent.setLayout(new FillLayout());
    browserViewer = new StsBrowserViewer(parent, hasToolbar() ? StsBrowserViewer.BUTTON_BAR | StsBrowserViewer.LOCATION_BAR : SWT.NONE);
    final Browser browser = browserViewer.getBrowser();
    if (getEditorInput() instanceof WebBrowserEditorInput) {
        homeUrl = ((WebBrowserEditorInput) getEditorInput()).getURL().toString();
        browserViewer.setVisible(true);
    }
    if (homeUrl != null) {
        browserViewer.setHomeUrl(homeUrl);
        browserViewer.setURL(homeUrl);
    } else {
        browser.setText("<h1>URL not set</h1>" + "<p>Url should be provided via the setInitializationData method</p>");
    }
    if (getName() == null) {
        browser.addTitleListener(new TitleListener() {

            @Override
            public void changed(TitleEvent event) {
                String newValue = event.title;
                setName(newValue);
                setPartName(newValue);
            }
        });
    }
    browser.addProgressListener(new ProgressAdapter() {

        @Override
        public void completed(ProgressEvent event) {
            StsBrowserViewer browserViewer = getBrowserViewer();
            if (browserViewer != null) {
                if (browserManager == null) {
                    browserManager = new StsBrowserManager();
                }
                browserManager.setClient(browserViewer.getBrowser());
                if (getEditorInput() instanceof WebBrowserEditorInput) {
                    String url = browserViewer.getURL();
                    try {
                        setInput(new WebBrowserEditorInput(new URL(url), SWT.NONE, url));
                    } catch (MalformedURLException e) {
                        throw new RuntimeException(e);
                    }
                }
            }
        }
    });
}
Also used : TitleListener(org.eclipse.swt.browser.TitleListener) MalformedURLException(java.net.MalformedURLException) FillLayout(org.eclipse.swt.layout.FillLayout) ProgressEvent(org.eclipse.swt.browser.ProgressEvent) URL(java.net.URL) TitleEvent(org.eclipse.swt.browser.TitleEvent) WebBrowserEditorInput(org.eclipse.ui.internal.browser.WebBrowserEditorInput) ProgressAdapter(org.eclipse.swt.browser.ProgressAdapter) Browser(org.eclipse.swt.browser.Browser)

Example 93 with Browser

use of org.eclipse.swt.browser.Browser in project webtools.servertools by eclipse.

the class BrowserViewer method init.

/**
 * (non-Javadoc)
 * @see ContentViewer#init(Composite)
 */
public void init(Composite parent) {
    browser = new Browser(parent, SWT.NONE);
    browser.addListener(SWT.MenuDetect, new Listener() {

        public void handleEvent(Event event) {
            event.doit = false;
        }
    });
}
Also used : Listener(org.eclipse.swt.widgets.Listener) Event(org.eclipse.swt.widgets.Event) Browser(org.eclipse.swt.browser.Browser)

Example 94 with Browser

use of org.eclipse.swt.browser.Browser in project epp.mpc by eclipse.

the class MarketplaceWizard method hookLocationListener.

private boolean hookLocationListener(IWebBrowser webBrowser) {
    try {
        // $NON-NLS-1$
        Field partField = findField(webBrowser.getClass(), "part", IWorkbenchPart.class);
        if (partField != null) {
            partField.setAccessible(true);
            IWorkbenchPart part = (IWorkbenchPart) partField.get(webBrowser);
            if (part != null) {
                // $NON-NLS-1$
                Field browserViewerField = findField(part.getClass(), "webBrowser", null);
                if (browserViewerField != null) {
                    browserViewerField.setAccessible(true);
                    Object browserViewer = browserViewerField.get(part);
                    if (browserViewer != null) {
                        // $NON-NLS-1$
                        Field browserField = findField(browserViewer.getClass(), "browser", Browser.class);
                        if (browserField != null) {
                            browserField.setAccessible(true);
                            Browser browser = (Browser) browserField.get(browserViewer);
                            if (browser != null) {
                                // only hook the listener once
                                if (browser.getData(MarketplaceBrowserIntegration.class.getName()) == null) {
                                    if (browserListener == null) {
                                        browserListener = new MarketplaceBrowserIntegration();
                                    }
                                    browser.setData(MarketplaceBrowserIntegration.class.getName(), browserListener);
                                    // hook in listeners
                                    browser.addLocationListener(browserListener);
                                    browser.addOpenWindowListener(browserListener);
                                }
                                return true;
                            }
                        }
                    }
                }
            }
        }
    } catch (Throwable t) {
    // ignore
    }
    return false;
}
Also used : Field(java.lang.reflect.Field) IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) IWebBrowser(org.eclipse.ui.browser.IWebBrowser) Browser(org.eclipse.swt.browser.Browser)

Example 95 with Browser

use of org.eclipse.swt.browser.Browser in project epp.mpc by eclipse.

the class AbstractMarketplaceDiscoveryItem method computeBrowserAvailable.

private synchronized boolean computeBrowserAvailable(Composite composite) {
    if (browserAvailable == null) {
        // SWTError is thrown if not available.
        try {
            Browser browser = new Browser(composite, SWT.NULL);
            browser.dispose();
            browserAvailable = true;
        } catch (SWTError e) {
            browserAvailable = false;
        }
    }
    return browserAvailable;
}
Also used : SWTError(org.eclipse.swt.SWTError) Browser(org.eclipse.swt.browser.Browser)

Aggregations

Browser (org.eclipse.swt.browser.Browser)117 Shell (org.eclipse.swt.widgets.Shell)40 FillLayout (org.eclipse.swt.layout.FillLayout)29 Composite (org.eclipse.swt.widgets.Composite)29 Display (org.eclipse.swt.widgets.Display)29 GridData (org.eclipse.swt.layout.GridData)28 Test (org.junit.Test)26 GridLayout (org.eclipse.swt.layout.GridLayout)20 LocationEvent (org.eclipse.swt.browser.LocationEvent)18 ProgressEvent (org.eclipse.swt.browser.ProgressEvent)18 Point (org.eclipse.swt.graphics.Point)18 IOException (java.io.IOException)16 SWTError (org.eclipse.swt.SWTError)16 BrowserFunction (org.eclipse.swt.browser.BrowserFunction)14 WindowEvent (org.eclipse.swt.browser.WindowEvent)14 Label (org.eclipse.swt.widgets.Label)14 URL (java.net.URL)13 LocationAdapter (org.eclipse.swt.browser.LocationAdapter)13 LocationListener (org.eclipse.swt.browser.LocationListener)13 ProgressAdapter (org.eclipse.swt.browser.ProgressAdapter)13