Search in sources :

Example 16 with LocationEvent

use of org.eclipse.swt.browser.LocationEvent in project netxms by netxms.

the class BrowserView method createPartControl.

/* (non-Javadoc)
	 * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
	 */
@Override
public void createPartControl(Composite parent) {
    browser = new Browser(parent, SWT.NONE);
    browser.addLocationListener(new LocationListener() {

        @Override
        public void changing(LocationEvent event) {
            setPartName(String.format(Messages.get().BrowserView_PartName_Changing, event.location));
            actionStop.setEnabled(true);
        }

        @Override
        public void changed(LocationEvent event) {
            setPartName(String.format(Messages.get().BrowserView_PartName_Changed, getTitle(browser.getText(), event.location)));
            actionStop.setEnabled(false);
        }
    });
    createActions();
    contributeToActionBars();
}
Also used : LocationListener(org.eclipse.swt.browser.LocationListener) LocationEvent(org.eclipse.swt.browser.LocationEvent) Browser(org.eclipse.swt.browser.Browser)

Example 17 with LocationEvent

use of org.eclipse.swt.browser.LocationEvent in project core by jcryptool.

the class BrowserView method createPartControl.

@Override
public void createPartControl(Composite parent) {
    GridLayout gridLayout = new GridLayout();
    gridLayout.verticalSpacing = 2;
    parent.setLayout(gridLayout);
    controls = new Controls(parent, SWT.NONE, this);
    GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, false);
    gridData.heightHint = 28;
    controls.setLayoutData(gridData);
    browser = new Browser(parent, SWT.NONE);
    browser.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    browser.setUrl(BROWSER_HOME);
    browser.addLocationListener(new LocationListener() {

        public void changed(LocationEvent event) {
            history.put(browser.getUrl(), browser.getUrl());
            controls.getUrlField().setItems(history.values().toArray(new String[0]));
            controls.getUrlField().setText(browser.getUrl());
            controls.getBackButton().setEnabled(browser.isBackEnabled());
            controls.getForwardButton().setEnabled(browser.isForwardEnabled());
            controls.animateReloadButton(false);
        }

        public void changing(LocationEvent event) {
            controls.animateReloadButton(true);
        }
    });
    browser.addStatusTextListener(new StatusTextListener() {

        public void changed(StatusTextEvent event) {
            status.setText(event.text);
        }
    });
    status = new Text(parent, SWT.BORDER | SWT.READ_ONLY | SWT.SINGLE);
    status.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
    PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, // $NON-NLS-1$
    "org.jcryptool.webbrowser.webBrowserView");
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) LocationListener(org.eclipse.swt.browser.LocationListener) GridData(org.eclipse.swt.layout.GridData) StatusTextListener(org.eclipse.swt.browser.StatusTextListener) Text(org.eclipse.swt.widgets.Text) StatusTextEvent(org.eclipse.swt.browser.StatusTextEvent) LocationEvent(org.eclipse.swt.browser.LocationEvent) Browser(org.eclipse.swt.browser.Browser)

Aggregations

LocationEvent (org.eclipse.swt.browser.LocationEvent)17 LocationListener (org.eclipse.swt.browser.LocationListener)12 Browser (org.eclipse.swt.browser.Browser)11 LocationAdapter (org.eclipse.swt.browser.LocationAdapter)6 URL (java.net.URL)4 SWTException (org.eclipse.swt.SWTException)4 ProgressEvent (org.eclipse.swt.browser.ProgressEvent)4 ProgressListener (org.eclipse.swt.browser.ProgressListener)4 Point (org.eclipse.swt.graphics.Point)4 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)3 SWTError (org.eclipse.swt.SWTError)3 Composite (org.eclipse.swt.widgets.Composite)3 Test (org.junit.Test)3 MalformedURLException (java.net.MalformedURLException)2 OpenWindowListener (org.eclipse.swt.browser.OpenWindowListener)2 TitleListener (org.eclipse.swt.browser.TitleListener)2 WindowEvent (org.eclipse.swt.browser.WindowEvent)2 MouseAdapter (org.eclipse.swt.events.MouseAdapter)2 MouseEvent (org.eclipse.swt.events.MouseEvent)2 SelectionEvent (org.eclipse.swt.events.SelectionEvent)2