Search in sources :

Example 31 with ProgressListener

use of org.eclipse.swt.browser.ProgressListener in project eclipse.platform.swt by eclipse-platform.

the class Bug510183_javadocHang method main.

public static void main(String[] args) {
    Display display = new Display();
    final Shell shell = new Shell(display);
    shell.setLayout(new FillLayout());
    Button button = new Button(shell, SWT.PUSH);
    final Browser browser = new Browser(shell, SWT.NONE);
    button.setText("Click to increase count.");
    button.addMouseListener(new MouseListener() {

        @Override
        public void mouseUp(MouseEvent e) {
        }

        @Override
        public void mouseDown(MouseEvent e) {
            shell.setText("Count: " + count++);
        }

        @Override
        public void mouseDoubleClick(MouseEvent e) {
        }
    });
    browser.setText("<html><title>Snippet</title><body><a href=\"https://eclipse.org/\">Eclipse.org  Disposing on link change causes hang</a></body></html>");
    browser.addProgressListener(new ProgressListener() {

        @Override
        public void completed(ProgressEvent event) {
            browser.addLocationListener(new LocationListener() {

                @Override
                public void changing(LocationEvent event) {
                    browser.dispose();
                // System.out.println("KILLING OF THE BROWSER");
                // 
                // String value = (String)widget.browser.evaluate("return 'hello'");
                // System.out.println("Returned: " + value);
                // 
                // String script = "document.body.style.backgroundColor = 'red'";
                // widget.browser.execute(script);
                }

                @Override
                public void changed(LocationEvent event) {
                }
            });
        }

        @Override
        public void changed(ProgressEvent event) {
        }
    });
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    display.dispose();
}
Also used : Shell(org.eclipse.swt.widgets.Shell) MouseListener(org.eclipse.swt.events.MouseListener) MouseEvent(org.eclipse.swt.events.MouseEvent) ProgressListener(org.eclipse.swt.browser.ProgressListener) Button(org.eclipse.swt.widgets.Button) LocationListener(org.eclipse.swt.browser.LocationListener) FillLayout(org.eclipse.swt.layout.FillLayout) ProgressEvent(org.eclipse.swt.browser.ProgressEvent) LocationEvent(org.eclipse.swt.browser.LocationEvent) Display(org.eclipse.swt.widgets.Display) Browser(org.eclipse.swt.browser.Browser)

Example 32 with ProgressListener

use of org.eclipse.swt.browser.ProgressListener in project eclipse.platform.swt by eclipse-platform.

the class Bug509615_auto_LocationChangeListener method main.

public static void main(String[] args) {
    Display display = new Display();
    final Shell shell = new Shell(display);
    shell.setLayout(new FillLayout());
    final Browser browser = new Browser(shell, SWT.NONE);
    browser.addLocationListener(new LocationListener() {

        @Override
        public void changing(LocationEvent event) {
            System.out.println("Changing ....");
            browser.evaluate("return 123");
        }

        @Override
        public void changed(LocationEvent event) {
            System.out.println("Changed !!!!");
            browser.evaluate("return 123");
        }
    });
    browser.addProgressListener(new ProgressListener() {

        @Override
        public void completed(ProgressEvent event) {
            System.out.println("Progress Completed !!!! ");
        }

        @Override
        public void changed(ProgressEvent event) {
            System.out.println("Progress Changing ....");
        }
    });
    browser.setText("Hello world");
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    display.dispose();
}
Also used : Shell(org.eclipse.swt.widgets.Shell) ProgressListener(org.eclipse.swt.browser.ProgressListener) LocationListener(org.eclipse.swt.browser.LocationListener) FillLayout(org.eclipse.swt.layout.FillLayout) ProgressEvent(org.eclipse.swt.browser.ProgressEvent) LocationEvent(org.eclipse.swt.browser.LocationEvent) Display(org.eclipse.swt.widgets.Display) Browser(org.eclipse.swt.browser.Browser)

Aggregations

ProgressEvent (org.eclipse.swt.browser.ProgressEvent)32 ProgressListener (org.eclipse.swt.browser.ProgressListener)32 Browser (org.eclipse.swt.browser.Browser)22 FillLayout (org.eclipse.swt.layout.FillLayout)14 Display (org.eclipse.swt.widgets.Display)13 Shell (org.eclipse.swt.widgets.Shell)13 LocationListener (org.eclipse.swt.browser.LocationListener)11 LocationEvent (org.eclipse.swt.browser.LocationEvent)10 GridLayout (org.eclipse.swt.layout.GridLayout)8 Composite (org.eclipse.swt.widgets.Composite)8 IOException (java.io.IOException)6 Test (org.junit.Test)6 SWT (org.eclipse.swt.SWT)5 TitleListener (org.eclipse.swt.browser.TitleListener)5 WindowEvent (org.eclipse.swt.browser.WindowEvent)5 Point (org.eclipse.swt.graphics.Point)5 MalformedURLException (java.net.MalformedURLException)4 SWTError (org.eclipse.swt.SWTError)4 BrowserFunction (org.eclipse.swt.browser.BrowserFunction)4 CloseWindowListener (org.eclipse.swt.browser.CloseWindowListener)4