Search in sources :

Example 71 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 72 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)

Example 73 with Browser

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

the class BrowserTab method createExampleWidgets.

/**
 * Creates the "Example" widgets.
 */
@Override
void createExampleWidgets() {
    /* Compute the widget style */
    int style = getDefaultStyle();
    if (borderButton.getSelection())
        style |= SWT.BORDER;
    if (webKitButton.getSelection())
        style |= SWT.WEBKIT;
    /* Create the example widgets */
    try {
        browser = new Browser(browserGroup, style);
    } catch (SWTError e) {
        // Probably missing browser
        try {
            browser = new Browser(browserGroup, style & ~(SWT.WEBKIT));
        } catch (SWTError e2) {
            // Unsupported platform
            errorMessage = e.getMessage();
            return;
        }
        MessageBox dialog = new MessageBox(shell, SWT.ICON_WARNING | SWT.OK);
        String resourceString = "WebKitNotFound";
        dialog.setMessage(ControlExample.getResourceString(resourceString, e.getMessage()));
        dialog.open();
    }
    if (lastUrl != null) {
        browser.setUrl(lastUrl);
    } else if (lastText != null) {
        browser.setText(lastText);
    } else {
        StringBuilder sb = new StringBuilder(300);
        try (InputStream htmlStream = ControlExample.class.getResourceAsStream("browser-content.html");
            BufferedReader br = new BufferedReader(new InputStreamReader(htmlStream))) {
            int read = 0;
            while ((read = br.read()) != -1) sb.append((char) read);
        } catch (IOException e) {
            log(e.getMessage());
        }
        String text = sb.toString();
        browser.setText(text);
    }
    lastText = lastUrl = null;
}
Also used : SWTError(org.eclipse.swt.SWTError) InputStreamReader(java.io.InputStreamReader) InputStream(java.io.InputStream) BufferedReader(java.io.BufferedReader) IOException(java.io.IOException) Browser(org.eclipse.swt.browser.Browser) MessageBox(org.eclipse.swt.widgets.MessageBox)

Example 74 with Browser

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

the class Bug497705_BrowserDragDetect method main.

public static void main(String[] args) {
    Display display = new Display();
    final Shell shell = new Shell(display);
    shell.setLayout(new FillLayout());
    final Browser b = new Browser(shell, SWT.BORDER);
    b.setText("TEXT");
    final Label label2 = new Label(shell, SWT.BORDER);
    // doesn't seem to have an effect.
    setDrag(b);
    setDrop(label2);
    shell.setSize(200, 200);
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    display.dispose();
}
Also used : Shell(org.eclipse.swt.widgets.Shell) Label(org.eclipse.swt.widgets.Label) FillLayout(org.eclipse.swt.layout.FillLayout) Display(org.eclipse.swt.widgets.Display) Browser(org.eclipse.swt.browser.Browser)

Example 75 with Browser

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

the class Test_org_eclipse_swt_browser_Browser method test_LocationListener_adapter_closeShell.

@Test
public void test_LocationListener_adapter_closeShell() {
    Display display = Display.getCurrent();
    Shell shell = new Shell(display);
    Browser browser = new Browser(shell, SWT.NONE);
    LocationAdapter adapter = new LocationAdapter() {
    };
    // shouldn't throw
    browser.addLocationListener(adapter);
    shell.close();
}
Also used : Shell(org.eclipse.swt.widgets.Shell) LocationAdapter(org.eclipse.swt.browser.LocationAdapter) Display(org.eclipse.swt.widgets.Display) Browser(org.eclipse.swt.browser.Browser) Test(org.junit.Test)

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