Search in sources :

Example 6 with LocationListener

use of org.eclipse.swt.browser.LocationListener in project mylyn.docs by eclipse.

the class MarkupEditor method createSourceViewer.

@Override
protected ISourceViewer createSourceViewer(Composite parent, IVerticalRuler ruler, int styles) {
    sourceViewerConfiguration.initializeDefaultFonts();
    tabFolder = new CTabFolder(parent, SWT.BOTTOM);
    {
        sourceTab = new CTabItem(tabFolder, SWT.NONE);
        updateSourceTabLabel();
        viewer = new MarkupProjectionViewer(tabFolder, ruler, getOverviewRuler(), isOverviewRulerVisible(), styles | SWT.WRAP);
        sourceTab.setControl(((Viewer) viewer).getControl());
        tabFolder.setSelection(sourceTab);
    }
    try {
        previewTab = new CTabItem(tabFolder, SWT.NONE);
        previewTab.setText(Messages.MarkupEditor_preview);
        previewTab.setToolTipText(Messages.MarkupEditor_preview_tooltip);
        browser = new Browser(tabFolder, SWT.NONE);
        // bug 260479: open hyperlinks in a browser
        browser.addLocationListener(new LocationListener() {

            public void changed(LocationEvent event) {
                event.doit = false;
            }

            public void changing(LocationEvent event) {
                // if it looks like an absolute URL
                if (event.location.matches("([a-zA-Z]{3,8})://?.*")) {
                    // $NON-NLS-1$
                    // workaround for browser problem (bug 262043)
                    // $NON-NLS-1$
                    int idxOfSlashHash = event.location.indexOf("/#");
                    if (idxOfSlashHash != -1) {
                        // allow javascript-based scrolling to work
                        if (!event.location.startsWith("file:///#")) {
                            // $NON-NLS-1$
                            event.doit = false;
                        }
                        return;
                    }
                    // workaround end
                    event.doit = false;
                    try {
                        PlatformUI.getWorkbench().getBrowserSupport().createBrowser(// $NON-NLS-1$
                        "org.eclipse.ui.browser").openURL(new URL(event.location));
                    } catch (Exception e) {
                        new URLHyperlink(new Region(0, 1), event.location).open();
                    }
                }
            }
        });
        previewTab.setControl(browser);
    } catch (SWTError e) {
        // disable preview, the exception is probably due to the internal browser not being available
        if (previewTab != null) {
            previewTab.dispose();
            previewTab = null;
        }
        logPreviewTabUnavailable(e);
    }
    tabFolder.addSelectionListener(new SelectionListener() {

        public void widgetDefaultSelected(SelectionEvent selectionevent) {
            widgetSelected(selectionevent);
        }

        public void widgetSelected(SelectionEvent selectionevent) {
            if (isShowingPreview()) {
                updatePreview();
            }
        }
    });
    viewer.getTextWidget().addSelectionListener(new SelectionListener() {

        public void widgetDefaultSelected(SelectionEvent e) {
        }

        public void widgetSelected(SelectionEvent e) {
            updateOutlineSelection();
        }
    });
    viewer.getTextWidget().addKeyListener(new KeyAdapter() {

        @Override
        public void keyReleased(KeyEvent e) {
            if (isRelevantKeyCode(e.keyCode)) {
                updateOutlineSelection();
            }
        }

        private boolean isRelevantKeyCode(int keyCode) {
            // for some reason not all key presses result in a selection change
            switch(keyCode) {
                case SWT.ARROW_DOWN:
                case SWT.ARROW_LEFT:
                case SWT.ARROW_RIGHT:
                case SWT.ARROW_UP:
                case SWT.PAGE_DOWN:
                case SWT.PAGE_UP:
                    return true;
            }
            return false;
        }
    });
    viewer.getTextWidget().addMouseListener(new MouseAdapter() {

        @Override
        public void mouseUp(MouseEvent e) {
            updateOutlineSelection();
        }
    });
    IFocusService focusService = PlatformUI.getWorkbench().getService(IFocusService.class);
    if (focusService != null) {
        focusService.addFocusTracker(viewer.getTextWidget(), MarkupEditor.EDITOR_SOURCE_VIEWER);
    }
    viewer.getTextWidget().setData(MarkupLanguage.class.getName(), getMarkupLanguage());
    viewer.getTextWidget().setData(ISourceViewer.class.getName(), viewer);
    getSourceViewerDecorationSupport(viewer);
    updateDocument();
    if (preferencesListener == null) {
        preferencesListener = new IPropertyChangeListener() {

            public void propertyChange(PropertyChangeEvent event) {
                if (viewer.getTextWidget() == null || viewer.getTextWidget().isDisposed()) {
                    return;
                }
                if (isFontPreferenceChange(event)) {
                    viewer.getTextWidget().getDisplay().asyncExec(new Runnable() {

                        public void run() {
                            reloadPreferences();
                        }
                    });
                }
            }
        };
        WikiTextUiPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(preferencesListener);
    }
    return viewer;
}
Also used : CTabFolder(org.eclipse.swt.custom.CTabFolder) KeyAdapter(org.eclipse.swt.events.KeyAdapter) ProjectionViewer(org.eclipse.jface.text.source.projection.ProjectionViewer) ISourceViewer(org.eclipse.jface.text.source.ISourceViewer) Viewer(org.eclipse.jface.viewers.Viewer) IFocusService(org.eclipse.ui.swt.IFocusService) CTabItem(org.eclipse.swt.custom.CTabItem) URL(java.net.URL) KeyEvent(org.eclipse.swt.events.KeyEvent) URLHyperlink(org.eclipse.jface.text.hyperlink.URLHyperlink) LocationListener(org.eclipse.swt.browser.LocationListener) SelectionEvent(org.eclipse.swt.events.SelectionEvent) LocationEvent(org.eclipse.swt.browser.LocationEvent) SWTError(org.eclipse.swt.SWTError) IPropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener) PropertyChangeEvent(org.eclipse.jface.util.PropertyChangeEvent) MouseEvent(org.eclipse.swt.events.MouseEvent) MouseAdapter(org.eclipse.swt.events.MouseAdapter) CoreException(org.eclipse.core.runtime.CoreException) PartInitException(org.eclipse.ui.PartInitException) SWTException(org.eclipse.swt.SWTException) Point(org.eclipse.swt.graphics.Point) Region(org.eclipse.jface.text.Region) AbstractMarkupLanguage(org.eclipse.mylyn.wikitext.parser.markup.AbstractMarkupLanguage) MarkupLanguage(org.eclipse.mylyn.wikitext.parser.markup.MarkupLanguage) ISourceViewer(org.eclipse.jface.text.source.ISourceViewer) Browser(org.eclipse.swt.browser.Browser) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 7 with LocationListener

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

the class OverviewToolTip method createToolTipContentArea.

@Override
protected Composite createToolTipContentArea(Event event, final Composite parent) {
    Shell shell = parent.getShell();
    setData(Shell.class.getName(), shell);
    AbstractMarketplaceDiscoveryItem.setWidgetId(shell, DiscoveryItem.WIDGET_ID_OVERVIEW);
    GridLayoutFactory.fillDefaults().applyTo(parent);
    Color backgroundColor = parent.getDisplay().getSystemColor(SWT.COLOR_WHITE);
    final Composite container = new Composite(parent, SWT.NULL);
    container.setBackground(backgroundColor);
    boolean hasImage = false;
    if (overview.getScreenshot() != null) {
        hasImage = true;
    }
    final boolean addLearnMoreLink = browser != null && overview.getUrl() != null && overview.getUrl().length() > 0;
    final int borderWidth = 1;
    final int heightHint = SCREENSHOT_HEIGHT + (borderWidth * 2);
    final int widthHint = SCREENSHOT_WIDTH;
    final int containerWidthHintWithImage = 650;
    final int containerWidthHintWithoutImage = 500;
    GridDataFactory.fillDefaults().grab(true, true).hint(hasImage ? containerWidthHintWithImage : containerWidthHintWithoutImage, SWT.DEFAULT).applyTo(container);
    GridLayoutFactory.fillDefaults().numColumns((leftImage != null) ? 3 : 2).margins(5, 5).spacing(3, 0).applyTo(container);
    if (leftImage != null) {
        Label imageLabel = new Label(container, SWT.NONE);
        imageLabel.setImage(leftImage);
        imageLabel.setBackground(backgroundColor);
        int imageWidthHint = leftImage.getBounds().width + 5;
        GridDataFactory.fillDefaults().align(SWT.BEGINNING, SWT.BEGINNING).hint(imageWidthHint, SWT.DEFAULT).applyTo(imageLabel);
    }
    String summary = overview.getSummary();
    Composite summaryContainer = new Composite(container, SWT.NULL);
    summaryContainer.setBackground(backgroundColor);
    GridLayoutFactory.fillDefaults().applyTo(summaryContainer);
    GridDataFactory gridDataFactory = GridDataFactory.fillDefaults().grab(true, true).span(hasImage ? 1 : 2, 1);
    if (hasImage) {
        gridDataFactory.hint(widthHint, heightHint);
    }
    gridDataFactory.applyTo(summaryContainer);
    Browser summaryLabel = new Browser(summaryContainer, SWT.NULL);
    Font dialogFont = JFaceResources.getDialogFont();
    FontData[] fontData = dialogFont.getFontData();
    // $NON-NLS-1$
    String attr = "";
    // $NON-NLS-1$
    String fontSizeUnitOfMeasure = "pt";
    if (Platform.OS_MACOSX.equals(Platform.getOS())) {
        // $NON-NLS-1$
        fontSizeUnitOfMeasure = "px";
    } else if (Platform.OS_WIN32.equals(Platform.getOS())) {
        // $NON-NLS-1$
        attr = "overflow: auto; ";
    }
    String cssStyle = // $NON-NLS-1$ //$NON-NLS-2$
    "body, p, div, *  {" + attr + "font-family:\"" + fontData[0].getName() + "\",Arial,sans-serif !important;font-size:" + fontData[0].getHeight() + fontSizeUnitOfMeasure + // $NON-NLS-1$ //$NON-NLS-2$
    " !important;" + // $NON-NLS-1$
    "} body { margin: 0px; background-color: white;}";
    summaryLabel.setFont(dialogFont);
    String html = // $NON-NLS-1$//$NON-NLS-2$
    "<html><style>" + cssStyle + "</style><body>" + TextUtil.cleanInformalHtmlMarkup(summary) + // $NON-NLS-1$
    "</body></html>";
    summaryLabel.setText(html);
    summaryLabel.setBackground(backgroundColor);
    // instead of opening links in the tooltip, open a new browser window
    summaryLabel.addLocationListener(new LocationListener() {

        public void changing(LocationEvent event) {
            if (event.location.equals("about:blank")) {
                // $NON-NLS-1$
                return;
            }
            event.doit = false;
            OverviewToolTip.this.hide();
            WorkbenchUtil.openUrl(event.location, IWorkbenchBrowserSupport.AS_EXTERNAL);
        }

        public void changed(LocationEvent event) {
        }
    });
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).hint(SWT.DEFAULT, hasImage ? SWT.DEFAULT : SCREENSHOT_HEIGHT).applyTo(summaryLabel);
    if (hasImage) {
        final Composite imageContainer = new Composite(container, SWT.BORDER);
        GridLayoutFactory.fillDefaults().applyTo(imageContainer);
        GridDataFactory.fillDefaults().grab(false, false).align(SWT.CENTER, SWT.BEGINNING).hint(widthHint + (borderWidth * 2), heightHint).applyTo(imageContainer);
        Label imageLabel = new Label(imageContainer, SWT.NULL);
        GridDataFactory.fillDefaults().hint(widthHint, SCREENSHOT_HEIGHT).indent(borderWidth, borderWidth).applyTo(imageLabel);
        imageLabel.setBackground(backgroundColor);
        imageLabel.setSize(widthHint, SCREENSHOT_HEIGHT);
        provideImage(imageLabel, source, overview.getScreenshot());
        final Cursor handCursor = new Cursor(imageLabel.getDisplay(), SWT.CURSOR_HAND);
        imageLabel.setCursor(handCursor);
        imageLabel.addDisposeListener(new DisposeListener() {

            public void widgetDisposed(DisposeEvent e) {
                handCursor.dispose();
            }
        });
        imageLabel.addMouseListener(new MouseAdapter() {

            @Override
            public void mouseDown(MouseEvent e) {
                OverviewToolTip.this.hide();
                WorkbenchUtil.openUrl(overview.getScreenshot(), IWorkbenchBrowserSupport.AS_EXTERNAL);
            }
        });
        // creates a border
        imageContainer.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_DARK_GRAY));
    }
    if (addLearnMoreLink) {
        Link link = new Link(summaryContainer, SWT.NULL);
        AbstractMarketplaceDiscoveryItem.setWidgetId(link, DiscoveryItem.WIDGET_ID_LEARNMORE);
        GridDataFactory.fillDefaults().grab(false, false).align(SWT.BEGINNING, SWT.CENTER).applyTo(link);
        link.setText(Messages.OverviewToolTip_learnMoreLink);
        link.setBackground(backgroundColor);
        link.setToolTipText(NLS.bind(Messages.OverviewToolTip_openUrlInBrowser, overview.getUrl()));
        link.addSelectionListener(new SelectionListener() {

            public void widgetSelected(SelectionEvent e) {
                OverviewToolTip.this.hide();
                browser.openUrl(overview.getUrl());
            }

            public void widgetDefaultSelected(SelectionEvent e) {
                widgetSelected(e);
            }
        });
    }
    if (!hasImage) {
        // prevent overviews with no image from providing unlimited text.
        Point optimalSize = summaryContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
        if (optimalSize.y > (heightHint + 10)) {
            ((GridData) summaryContainer.getLayoutData()).heightHint = heightHint;
            container.layout(true);
        }
    }
    // hack: cause the tooltip to gain focus so that we can capture the escape key
    // this must be done async since the tooltip is not yet visible.
    Display.getCurrent().asyncExec(new Runnable() {

        public void run() {
            if (!parent.isDisposed()) {
                parent.setFocus();
            }
        }
    });
    return container;
}
Also used : DisposeListener(org.eclipse.swt.events.DisposeListener) Label(org.eclipse.swt.widgets.Label) Cursor(org.eclipse.swt.graphics.Cursor) DisposeEvent(org.eclipse.swt.events.DisposeEvent) Font(org.eclipse.swt.graphics.Font) Shell(org.eclipse.swt.widgets.Shell) LocationListener(org.eclipse.swt.browser.LocationListener) SelectionEvent(org.eclipse.swt.events.SelectionEvent) LocationEvent(org.eclipse.swt.browser.LocationEvent) MouseEvent(org.eclipse.swt.events.MouseEvent) Composite(org.eclipse.swt.widgets.Composite) Color(org.eclipse.swt.graphics.Color) FontData(org.eclipse.swt.graphics.FontData) MouseAdapter(org.eclipse.swt.events.MouseAdapter) Point(org.eclipse.swt.graphics.Point) Point(org.eclipse.swt.graphics.Point) GridDataFactory(org.eclipse.jface.layout.GridDataFactory) Link(org.eclipse.swt.widgets.Link) Browser(org.eclipse.swt.browser.Browser) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 8 with LocationListener

use of org.eclipse.swt.browser.LocationListener in project BiglyBT by BiglySoftware.

the class BrowserWrapperFake method setUrl.

@Override
public void setUrl(final String _url) {
    url = _url;
    Utils.execSWTThread(new Runnable() {

        @Override
        public void run() {
            String url_str = _url;
            int pos = url_str.indexOf('?');
            if (pos != -1) {
                url_str = url_str.substring(0, pos);
            }
            link_label.setText(url_str);
            browser.layout();
            for (LocationListener l : location_listeners) {
                try {
                    LocationEvent event = new LocationEvent(browser);
                    event.top = true;
                    event.location = _url;
                    l.changed(event);
                } catch (Throwable e) {
                    Debug.out(e);
                }
            }
            for (ProgressListener l : progress_listeners) {
                try {
                    ProgressEvent event = new ProgressEvent(browser);
                    l.completed(event);
                } catch (Throwable e) {
                    Debug.out(e);
                }
            }
            for (TitleListener l : title_listeners) {
                try {
                    TitleEvent event = new TitleEvent(browser);
                    event.title = "Browser Disabled";
                    l.changed(event);
                } catch (Throwable e) {
                    Debug.out(e);
                }
            }
        }
    });
}
Also used : TitleListener(org.eclipse.swt.browser.TitleListener) TitleEvent(org.eclipse.swt.browser.TitleEvent) ProgressListener(org.eclipse.swt.browser.ProgressListener) LocationListener(org.eclipse.swt.browser.LocationListener) ProgressEvent(org.eclipse.swt.browser.ProgressEvent) LocationEvent(org.eclipse.swt.browser.LocationEvent)

Example 9 with LocationListener

use of org.eclipse.swt.browser.LocationListener in project BiglyBT by BiglySoftware.

the class FullUpdateWindow method open.

public static void open(final String url, final UIFunctions.actionListener listener) {
    boolean ok = false;
    final boolean[] listener_informed = { false };
    try {
        if (current_shell != null && !current_shell.isDisposed()) {
            return;
        }
        final Shell parentShell = Utils.findAnyShell();
        final Shell shell = current_shell = ShellFactory.createShell(parentShell, SWT.BORDER | SWT.APPLICATION_MODAL | SWT.TITLE | SWT.RESIZE | SWT.DIALOG_TRIM);
        if (shell == null) {
            return;
        }
        shell.setLayout(new FillLayout());
        if (parentShell != null) {
            parentShell.setCursor(shell.getDisplay().getSystemCursor(SWT.CURSOR_WAIT));
        }
        shell.addDisposeListener(new DisposeListener() {

            @Override
            public void widgetDisposed(DisposeEvent e) {
                try {
                    if (parentShell != null) {
                        parentShell.setCursor(e.display.getSystemCursor(SWT.CURSOR_ARROW));
                    }
                    if (browserFunction != null && !browserFunction.isDisposed()) {
                        browserFunction.dispose();
                    }
                    current_shell = null;
                } finally {
                    if (!listener_informed[0]) {
                        try {
                            listener.actionComplete(false);
                        } catch (Throwable f) {
                            Debug.out(f);
                        }
                    }
                }
            }
        });
        BrowserWrapper browser = Utils.createSafeBrowser(shell, SWT.NONE);
        if (browser == null) {
            shell.dispose();
            return;
        }
        browser.addTitleListener(new TitleListener() {

            @Override
            public void changed(TitleEvent event) {
                if (shell.isDisposed()) {
                    return;
                }
                shell.setText(event.title);
            }
        });
        browser.addOpenWindowListener(new BrowserWrapper.OpenWindowListener() {

            @Override
            public void open(BrowserWrapper.WindowEvent event) {
                final BrowserWrapper subBrowser = Utils.createSafeBrowser(shell, SWT.NONE);
                if (subBrowser == null) {
                    return;
                }
                subBrowser.addLocationListener(new LocationListener() {

                    @Override
                    public void changed(LocationEvent arg0) {
                    }

                    @Override
                    public void changing(LocationEvent event) {
                        if (event.location == null || !event.location.startsWith("http")) {
                            return;
                        }
                        event.doit = false;
                        Utils.launch(event.location);
                        Utils.execSWTThreadLater(1000, new AERunnable() {

                            @Override
                            public void runSupport() {
                                subBrowser.dispose();
                            }
                        });
                    }
                });
                subBrowser.setBrowser(event);
            }
        });
        browserFunction = browser.addBrowserFunction("sendVuzeUpdateEvent", new BrowserWrapper.BrowserFunction() {

            private String last = null;

            @Override
            public Object function(Object[] arguments) {
                if (shell.isDisposed()) {
                    return null;
                }
                if (arguments == null) {
                    Debug.out("Invalid sendVuzeUpdateEvent null ");
                    return null;
                }
                if (arguments.length < 1) {
                    Debug.out("Invalid sendVuzeUpdateEvent length " + arguments.length + " not 1");
                    return null;
                }
                if (!(arguments[0] instanceof String)) {
                    Debug.out("Invalid sendVuzeUpdateEvent " + (arguments[0] == null ? "NULL" : arguments.getClass().getSimpleName()) + " not String");
                    return null;
                }
                String text = ((String) arguments[0]).toLowerCase();
                if (last != null && last.equals(text)) {
                    return null;
                }
                last = text;
                if (text.contains("page-loaded")) {
                    Utils.centreWindow(shell);
                    if (parentShell != null) {
                        parentShell.setCursor(shell.getDisplay().getSystemCursor(SWT.CURSOR_ARROW));
                    }
                    shell.open();
                } else if (text.startsWith("set-size")) {
                    String[] strings = text.split(" ");
                    if (strings.length > 2) {
                        try {
                            int w = Integer.parseInt(strings[1]);
                            int h = Integer.parseInt(strings[2]);
                            Rectangle computeTrim = shell.computeTrim(0, 0, w, h);
                            shell.setSize(computeTrim.width, computeTrim.height);
                        } catch (Exception ignored) {
                        }
                    }
                } else if (text.contains("decline") || text.contains("close")) {
                    Utils.execSWTThreadLater(0, new AERunnable() {

                        @Override
                        public void runSupport() {
                            shell.dispose();
                        }
                    });
                } else if (text.contains("accept")) {
                    Utils.execSWTThreadLater(0, new AERunnable() {

                        @Override
                        public void runSupport() {
                            listener_informed[0] = true;
                            try {
                                listener.actionComplete(true);
                            } catch (Throwable e) {
                                Debug.out(e);
                            }
                            shell.dispose();
                        }
                    });
                }
                return null;
            }
        });
        browser.addStatusTextListener(new StatusTextListener() {

            @Override
            public void changed(StatusTextEvent event) {
                if (browserFunction != null) {
                    browserFunction.function(new Object[] { event.text });
                }
            }
        });
        browser.addLocationListener(new LocationListener() {

            @Override
            public void changing(LocationEvent event) {
            }

            @Override
            public void changed(LocationEvent event) {
            }
        });
        String final_url = url + (url.indexOf('?') == -1 ? "?" : "&") + "locale=" + MessageText.getCurrentLocale().toString() + "&azv=" + Constants.BIGLYBT_VERSION;
        SimpleTimer.addEvent("fullupdate.pageload", SystemTime.getOffsetTime(5000), new TimerEventPerformer() {

            @Override
            public void perform(TimerEvent event) {
                Utils.execSWTThread(new AERunnable() {

                    @Override
                    public void runSupport() {
                        if (!shell.isDisposed()) {
                            shell.open();
                        }
                    }
                });
            }
        });
        browser.setUrl(final_url);
        if (browser.isFake()) {
            shell.setSize(400, 500);
            Utils.centreWindow(shell);
            browser.setUrl(Constants.URL_CLIENT_HOME);
            browser.setText("Update available, please go to www.biglybt.com to update.");
            shell.open();
        }
        ok = true;
    } finally {
        if (!ok) {
            try {
                listener.actionComplete(false);
            } catch (Throwable f) {
                Debug.out(f);
            }
        }
    }
}
Also used : DisposeListener(org.eclipse.swt.events.DisposeListener) TitleListener(org.eclipse.swt.browser.TitleListener) Rectangle(org.eclipse.swt.graphics.Rectangle) StatusTextListener(org.eclipse.swt.browser.StatusTextListener) DisposeEvent(org.eclipse.swt.events.DisposeEvent) StatusTextEvent(org.eclipse.swt.browser.StatusTextEvent) Shell(org.eclipse.swt.widgets.Shell) LocationListener(org.eclipse.swt.browser.LocationListener) BrowserWrapper(com.biglybt.ui.swt.BrowserWrapper) LocationEvent(org.eclipse.swt.browser.LocationEvent) FillLayout(org.eclipse.swt.layout.FillLayout) TitleEvent(org.eclipse.swt.browser.TitleEvent)

Example 10 with LocationListener

use of org.eclipse.swt.browser.LocationListener in project netxms-ocilib by stevemqeen.

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)

Aggregations

LocationEvent (org.eclipse.swt.browser.LocationEvent)29 LocationListener (org.eclipse.swt.browser.LocationListener)29 Browser (org.eclipse.swt.browser.Browser)18 ProgressEvent (org.eclipse.swt.browser.ProgressEvent)9 ProgressListener (org.eclipse.swt.browser.ProgressListener)9 FillLayout (org.eclipse.swt.layout.FillLayout)9 Shell (org.eclipse.swt.widgets.Shell)9 URL (java.net.URL)7 Display (org.eclipse.swt.widgets.Display)7 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)6 SWTException (org.eclipse.swt.SWTException)6 Test (org.junit.Test)6 StatusTextListener (org.eclipse.swt.browser.StatusTextListener)5 TitleListener (org.eclipse.swt.browser.TitleListener)5 Point (org.eclipse.swt.graphics.Point)5 MalformedURLException (java.net.MalformedURLException)4 OpenWindowListener (org.eclipse.swt.browser.OpenWindowListener)4 WindowEvent (org.eclipse.swt.browser.WindowEvent)4 MouseEvent (org.eclipse.swt.events.MouseEvent)4 IOException (java.io.IOException)3