Search in sources :

Example 31 with Browser

use of org.eclipse.swt.browser.Browser in project eclipse.platform.swt by eclipse.

the class TextEditor method handleMouseUp.

void handleMouseUp(Event event) {
    if (link != null) {
        int offset = styledText.getCaretOffset();
        StyleRange range = offset > 0 ? styledText.getStyleRangeAtOffset(offset - 1) : null;
        if (range != null) {
            if (link == range.data) {
                Shell dialog = new Shell(shell);
                dialog.setLayout(new FillLayout());
                // $NON-NLS-1$
                dialog.setText(getResourceString("Browser"));
                Browser browser = new Browser(dialog, SWT.NONE);
                browser.setUrl(link);
                dialog.open();
            }
        }
    }
}
Also used : Shell(org.eclipse.swt.widgets.Shell) StyleRange(org.eclipse.swt.custom.StyleRange) FillLayout(org.eclipse.swt.layout.FillLayout) Point(org.eclipse.swt.graphics.Point) Browser(org.eclipse.swt.browser.Browser)

Example 32 with Browser

use of org.eclipse.swt.browser.Browser in project eclipse.platform.swt by eclipse.

the class BrowserTab method createTabFolderPage.

/**
 * Creates the tab folder page.
 *
 * @param tabFolder org.eclipse.swt.widgets.TabFolder
 * @return the new page for the tab folder
 */
@Override
Composite createTabFolderPage(final TabFolder tabFolder) {
    super.createTabFolderPage(tabFolder);
    /*
		 * Add a resize listener to the tabFolderPage so that
		 * if the user types into the example widget to change
		 * its preferred size, and then resizes the shell, we
		 * recalculate the preferred size correctly.
		 */
    tabFolderPage.addControlListener(ControlListener.controlResizedAdapter(e -> setExampleWidgetSize()));
    /*
		 * Add a selection listener to the tabFolder to bring up a
		 * dialog if this platform does not support the Browser.
		 */
    tabFolder.addSelectionListener(widgetSelectedAdapter(e -> {
        if (errorMessage != null && tabFolder.getSelection()[0].getText().equals(getTabText())) {
            MessageBox dialog = new MessageBox(shell, SWT.ICON_WARNING | SWT.OK);
            dialog.setMessage(ControlExample.getResourceString("BrowserNotFound", errorMessage));
            dialog.open();
        }
    }));
    return tabFolderPage;
}
Also used : Browser(org.eclipse.swt.browser.Browser) TabFolder(org.eclipse.swt.widgets.TabFolder) Button(org.eclipse.swt.widgets.Button) IOException(java.io.IOException) ProgressListener(org.eclipse.swt.browser.ProgressListener) ControlListener(org.eclipse.swt.events.ControlListener) InputStreamReader(java.io.InputStreamReader) Group(org.eclipse.swt.widgets.Group) SWTError(org.eclipse.swt.SWTError) SelectionListener.widgetSelectedAdapter(org.eclipse.swt.events.SelectionListener.widgetSelectedAdapter) ProgressEvent(org.eclipse.swt.browser.ProgressEvent) Composite(org.eclipse.swt.widgets.Composite) SWT(org.eclipse.swt.SWT) WindowEvent(org.eclipse.swt.browser.WindowEvent) MessageBox(org.eclipse.swt.widgets.MessageBox) LocationListener(org.eclipse.swt.browser.LocationListener) LocationEvent(org.eclipse.swt.browser.LocationEvent) BufferedReader(java.io.BufferedReader) GridData(org.eclipse.swt.layout.GridData) Widget(org.eclipse.swt.widgets.Widget) VisibilityWindowListener(org.eclipse.swt.browser.VisibilityWindowListener) InputStream(java.io.InputStream) GridLayout(org.eclipse.swt.layout.GridLayout) MessageBox(org.eclipse.swt.widgets.MessageBox)

Example 33 with Browser

use of org.eclipse.swt.browser.Browser in project eclipse.platform.swt by eclipse.

the class BrowserDemoView method createPartControl.

@Override
public void createPartControl(Composite parent) {
    this.parent = parent;
    parent.setLayout(new FillLayout());
    try {
        Browser browser = new Browser(parent, SWT.NONE);
        browser.dispose();
    } catch (SWTError e) {
        Text text = new Text(parent, SWT.MULTI | SWT.READ_ONLY);
        text.setText("Browser widget cannot be instantiated. The exact error is:\r\n" + e);
        text.requestLayout();
        return;
    }
    TabFolder folder = new TabFolder(parent, SWT.NONE);
    TabItem item = new TabItem(folder, SWT.NONE);
    new PawnTab(item);
    item = new TabItem(folder, SWT.NONE);
    new EditorTab(item);
}
Also used : SWTError(org.eclipse.swt.SWTError) TabItem(org.eclipse.swt.widgets.TabItem) TabFolder(org.eclipse.swt.widgets.TabFolder) Text(org.eclipse.swt.widgets.Text) FillLayout(org.eclipse.swt.layout.FillLayout) Browser(org.eclipse.swt.browser.Browser)

Example 34 with Browser

use of org.eclipse.swt.browser.Browser in project cubrid-manager by CUBRID.

the class CubridNewInfoEditorPart method createPartControl.

/**
	 * Create the editor content
	 *
	 * @param parent the parent composite
	 */
public void createPartControl(Composite parent) {
    String url = Platform.getNL().equals("ko_KR") ? CHECK_NEW_INFO_URL_KO : CHECK_NEW_INFO_URL_EN;
    try {
        Browser browser = new Browser(parent, SWT.NONE);
        browser.setUrl(url);
    } catch (Exception e) {
        LOGGER.error(e.getMessage(), e);
        Label label = new Label(parent, SWT.NONE);
        IWorkbenchBrowserSupport support = PlatformUI.getWorkbench().getBrowserSupport();
        try {
            IWebBrowser browser = support.getExternalBrowser();
            browser.openURL(new URL(CommonUITool.urlEncodeForSpaces(url.toCharArray())));
        } catch (Exception browserEx) {
            LOGGER.warn(browserEx.getMessage(), browserEx);
            label.setText(Messages.errCannotOpenExternalBrowser);
            return;
        }
        label.setText(Messages.errCannotOpenInternalBrowser);
    }
}
Also used : Label(org.eclipse.swt.widgets.Label) IWorkbenchBrowserSupport(org.eclipse.ui.browser.IWorkbenchBrowserSupport) IWebBrowser(org.eclipse.ui.browser.IWebBrowser) PartInitException(org.eclipse.ui.PartInitException) URL(java.net.URL) Browser(org.eclipse.swt.browser.Browser) IWebBrowser(org.eclipse.ui.browser.IWebBrowser)

Example 35 with Browser

use of org.eclipse.swt.browser.Browser in project cubrid-manager by CUBRID.

the class NewFeatureEditorPart method createPartControl.

public void createPartControl(Composite parent) {
    GridLayout layout = new GridLayout();
    layout.numColumns = 1;
    layout.marginBottom = 0;
    layout.marginTop = 0;
    layout.marginLeft = 0;
    layout.marginRight = 0;
    parent.setLayout(layout);
    browser = new Browser(parent, SWT.None);
    browser.setLayoutData(CommonUITool.createGridData(GridData.FILL_BOTH, 1, 1, -1, -1));
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Browser(org.eclipse.swt.browser.Browser)

Aggregations

Browser (org.eclipse.swt.browser.Browser)62 Shell (org.eclipse.swt.widgets.Shell)26 Display (org.eclipse.swt.widgets.Display)25 Test (org.junit.Test)22 FillLayout (org.eclipse.swt.layout.FillLayout)19 GridData (org.eclipse.swt.layout.GridData)16 IOException (java.io.IOException)13 ProgressEvent (org.eclipse.swt.browser.ProgressEvent)13 Composite (org.eclipse.swt.widgets.Composite)13 BrowserFunction (org.eclipse.swt.browser.BrowserFunction)12 LocationEvent (org.eclipse.swt.browser.LocationEvent)12 URL (java.net.URL)11 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)11 ProgressListener (org.eclipse.swt.browser.ProgressListener)11 WindowEvent (org.eclipse.swt.browser.WindowEvent)11 GridLayout (org.eclipse.swt.layout.GridLayout)11 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)10 LocationAdapter (org.eclipse.swt.browser.LocationAdapter)10 LocationListener (org.eclipse.swt.browser.LocationListener)10 ProgressAdapter (org.eclipse.swt.browser.ProgressAdapter)10