Search in sources :

Example 11 with Browser

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

the class CubridNoticeInfoEditorPart method createPartControl.

/**
	 * Create the editor content
	 *
	 * @param parent the parent composite
	 */
public void createPartControl(Composite parent) {
    Composite composite = new Composite(parent, SWT.None);
    GridLayout layout = new GridLayout();
    composite.setLayout(layout);
    try {
        Button ignoreButton = new Button(composite, SWT.CHECK);
        ignoreButton.setText(Messages.cubridNoticeIgnoreButtonLbl);
        ignoreButton.addSelectionListener(new SelectionAdapter() {

            public void widgetSelected(SelectionEvent event) {
                String ignore = PersistUtils.getPreferenceValue(CommonUIPlugin.PLUGIN_ID, CubridNoticeUtil.IGNORE_NOTICE);
                if (StringUtil.isEmpty(ignore)) {
                    ignore = index;
                } else {
                    ignore = ignore + "," + index;
                }
                PersistUtils.setPreferenceValue(CommonUIPlugin.PLUGIN_ID, CubridNoticeUtil.IGNORE_NOTICE, ignore);
                getSite().getWorkbenchWindow().getActivePage().closeEditor(editor, false);
            }
        });
        Browser browser = new Browser(composite, SWT.NONE);
        browser.setUrl(noticeURL);
        browser.setLayoutData(new GridData(GridData.FILL_BOTH));
    } catch (Exception e) {
        Label label = new Label(parent, SWT.NONE);
        IWorkbenchBrowserSupport support = PlatformUI.getWorkbench().getBrowserSupport();
        try {
            IWebBrowser browser = support.getExternalBrowser();
            browser.openURL(new URL(CommonUITool.urlEncodeForSpaces(noticeURL.toCharArray())));
        } catch (Exception browserEx) {
            LOGGER.error(browserEx.getMessage(), browserEx);
            label.setText(Messages.errCannotOpenExternalBrowser);
            return;
        }
        label.setText(Messages.errCannotOpenInternalBrowser);
    }
}
Also used : Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) IWebBrowser(org.eclipse.ui.browser.IWebBrowser) PartInitException(org.eclipse.ui.PartInitException) URL(java.net.URL) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) SelectionEvent(org.eclipse.swt.events.SelectionEvent) GridData(org.eclipse.swt.layout.GridData) IWorkbenchBrowserSupport(org.eclipse.ui.browser.IWorkbenchBrowserSupport) IWebBrowser(org.eclipse.ui.browser.IWebBrowser) Browser(org.eclipse.swt.browser.Browser)

Example 12 with Browser

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

the class JPMBrowserView method createPartControl.

@Override
public void createPartControl(Composite parent) {
    StackLayout stack = new StackLayout();
    parent.setLayout(stack);
    JpmPreferences prefs = new JpmPreferences();
    if (prefs.getBrowserSelection() == JpmPreferences.PREF_BROWSER_EXTERNAL) {
        external = true;
        Composite composite = new Composite(parent, SWT.NONE);
        composite.setLayout(new GridLayout(2, false));
        new Label(composite, SWT.NONE).setText("JPM is configured to open in an external browser.");
        Hyperlink linkToPrefs = new Hyperlink(composite, SWT.NONE);
        linkToPrefs.setText("Open Preference Page");
        linkToPrefs.setUnderlined(true);
        linkToPrefs.addHyperlinkListener(new HyperlinkAdapter() {

            @Override
            public void linkActivated(HyperlinkEvent e) {
                PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn(getViewSite().getShell(), "bndtools.prefPages.jpm", new String[] { "bndtools.prefPages.jpm" }, null);
                dialog.open();
            }
        });
        //            linkToPrefs.setLayoutData(new GridData(SWT.FILL, SWT.BOTTOM, true, false));
        stack.topControl = composite;
    } else {
        if (prefs.getBrowserSelection() == JpmPreferences.PREF_BROWSER_PLATFORM_DEFAULT) {
            browser = new Browser(parent, SWT.NONE);
            stack.topControl = browser;
        } else if (prefs.getBrowserSelection() == JpmPreferences.PREF_BROWSER_WEBKIT) {
            browser = new Browser(parent, SWT.WEBKIT);
            stack.topControl = browser;
        } else if (prefs.getBrowserSelection() == JpmPreferences.PREF_BROWSER_MOZILLA) {
            browser = new Browser(parent, SWT.MOZILLA);
            stack.topControl = browser;
        }
        createActions();
        // Prevent navigation away from JPM4J.org, and redirect from HTTP back to HTTPS
        browser.addLocationListener(new LocationAdapter() {

            @Override
            public void changing(LocationEvent event) {
                setContentDescription(event.location);
            /*
                     *
                    if (event.location.startsWith(HTTPS_URL))
                        return;
                    if (event.location.startsWith(HTTP_URL))
                        event.location = event.location.replaceFirst(HTTP_URL, HTTP_URL);
                    else
                        event.doit = false;
                     */
            }
        });
    }
    selectionService = getViewSite().getWorkbenchWindow().getSelectionService();
    selectionService.addSelectionListener(this);
    handleWorkbenchSelection(selectionService.getSelection());
}
Also used : HyperlinkEvent(org.eclipse.ui.forms.events.HyperlinkEvent) Composite(org.eclipse.swt.widgets.Composite) JpmPreferences(bndtools.preferences.JpmPreferences) LocationAdapter(org.eclipse.swt.browser.LocationAdapter) Label(org.eclipse.swt.widgets.Label) GridLayout(org.eclipse.swt.layout.GridLayout) PreferenceDialog(org.eclipse.jface.preference.PreferenceDialog) StackLayout(org.eclipse.swt.custom.StackLayout) LocationEvent(org.eclipse.swt.browser.LocationEvent) Hyperlink(org.eclipse.ui.forms.widgets.Hyperlink) HyperlinkAdapter(org.eclipse.ui.forms.events.HyperlinkAdapter) Browser(org.eclipse.swt.browser.Browser)

Example 13 with Browser

use of org.eclipse.swt.browser.Browser in project translationstudio8 by heartsome.

the class HtmlBrowserEditor method createPartControl.

@Override
public void createPartControl(Composite parent) {
    GridLayoutFactory.fillDefaults().numColumns(1).applyTo(parent);
    parent.setLayoutData(new GridData(GridData.FILL_BOTH));
    cmp = new Composite(parent, SWT.BORDER);
    GridLayoutFactory.fillDefaults().numColumns(1).applyTo(cmp);
    GridDataFactory.fillDefaults().grab(true, true).applyTo(cmp);
    browser = new Browser(cmp, SWT.NONE);
    browser.setLayoutData(new GridData(GridData.FILL_BOTH));
    browser.setUrl(htmlUrl);
    browser.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseDown(MouseEvent e) {
            getSite().getPart().setFocus();
            super.mouseDown(e);
        }
    });
}
Also used : MouseEvent(org.eclipse.swt.events.MouseEvent) Composite(org.eclipse.swt.widgets.Composite) GridData(org.eclipse.swt.layout.GridData) MouseAdapter(org.eclipse.swt.events.MouseAdapter) Browser(org.eclipse.swt.browser.Browser)

Example 14 with Browser

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

the class NoticeDialog method createDialogArea.

protected Control createDialogArea(Composite parent) {
    Composite parentComp = (Composite) super.createDialogArea(parent);
    {
        GridLayout tLayout = new GridLayout();
        tLayout.marginHeight = 0;
        tLayout.marginWidth = 0;
        tLayout.verticalSpacing = 0;
        tLayout.horizontalSpacing = 0;
        parentComp.setLayout(tLayout);
        parentComp.setLayoutData(new GridData(GridData.FILL_BOTH));
    }
    try {
        Browser browser = new Browser(parentComp, SWT.NONE);
        browser.setSize(500, 400);
        {
            GridLayout tLayout = new GridLayout();
            tLayout.marginHeight = 0;
            tLayout.marginWidth = 0;
            tLayout.verticalSpacing = 0;
            tLayout.horizontalSpacing = 0;
            browser.setLayout(tLayout);
            browser.setLayoutData(new GridData(GridData.FILL_BOTH));
        }
        browser.setUrl(url);
    } catch (Exception e) {
    }
    return parent;
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) GridData(org.eclipse.swt.layout.GridData) Browser(org.eclipse.swt.browser.Browser)

Example 15 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)

Aggregations

Browser (org.eclipse.swt.browser.Browser)19 GridData (org.eclipse.swt.layout.GridData)10 Composite (org.eclipse.swt.widgets.Composite)10 GridLayout (org.eclipse.swt.layout.GridLayout)7 Label (org.eclipse.swt.widgets.Label)5 IOException (java.io.IOException)4 URL (java.net.URL)4 LocationEvent (org.eclipse.swt.browser.LocationEvent)4 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)4 SelectionEvent (org.eclipse.swt.events.SelectionEvent)4 Button (org.eclipse.swt.widgets.Button)4 FillLayout (org.eclipse.swt.layout.FillLayout)3 Text (org.eclipse.swt.widgets.Text)3 PartInitException (org.eclipse.ui.PartInitException)3 LocationAdapter (org.eclipse.swt.browser.LocationAdapter)2 LocationListener (org.eclipse.swt.browser.LocationListener)2 IWebBrowser (org.eclipse.ui.browser.IWebBrowser)2 IWorkbenchBrowserSupport (org.eclipse.ui.browser.IWorkbenchBrowserSupport)2 JpmPreferences (bndtools.preferences.JpmPreferences)1 HttpResponse (com.microsoft.azure.hdinsight.sdk.common.HttpResponse)1