Search in sources :

Example 1 with IWebBrowser

use of org.eclipse.ui.browser.IWebBrowser 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 2 with IWebBrowser

use of org.eclipse.ui.browser.IWebBrowser in project cubrid-manager by CUBRID.

the class CubridProjectSiteAction method run.

public void run() {
    String url = CommonUITool.urlEncodeForSpaces(Messages.msgCubridProjectSiteUrl);
    try {
        IWorkbenchBrowserSupport support = PlatformUI.getWorkbench().getBrowserSupport();
        IWebBrowser browser = support.getExternalBrowser();
        browser.openURL(new URL(url));
    } catch (PartInitException e) {
        LOGGER.error("Can not initialize web browser on the application.", e);
    } catch (MalformedURLException e) {
        LOGGER.error("The url {} is invalid.", url, e);
    }
}
Also used : MalformedURLException(java.net.MalformedURLException) IWorkbenchBrowserSupport(org.eclipse.ui.browser.IWorkbenchBrowserSupport) IWebBrowser(org.eclipse.ui.browser.IWebBrowser) PartInitException(org.eclipse.ui.PartInitException) URL(java.net.URL)

Example 3 with IWebBrowser

use of org.eclipse.ui.browser.IWebBrowser in project cubrid-manager by CUBRID.

the class ProductInfoDialog method openLink.

/**
	 * Open a link
	 * 
	 * @param href the href string
	 */
protected void openLink(String href) {
    // format the href for an html file (file:///<filename.html>
    // required for Mac only.
    String hrefUrl = href;
    if (href.startsWith("file:")) {
        //$NON-NLS-1$
        hrefUrl = href.substring(5);
        while (hrefUrl.startsWith("/")) {
            //$NON-NLS-1$
            hrefUrl = hrefUrl.substring(1);
        }
        //$NON-NLS-1$
        hrefUrl = "file:///" + hrefUrl;
    }
    IWorkbenchBrowserSupport support = PlatformUI.getWorkbench().getBrowserSupport();
    try {
        IWebBrowser browser = support.getExternalBrowser();
        browser.openURL(new URL(urlEncodeForSpaces(hrefUrl.toCharArray())));
    } catch (MalformedURLException e) {
        LOGGER.info(e.getMessage(), e);
    } catch (PartInitException e) {
        LOGGER.info(e.getMessage(), e);
    }
}
Also used : MalformedURLException(java.net.MalformedURLException) IWorkbenchBrowserSupport(org.eclipse.ui.browser.IWorkbenchBrowserSupport) IWebBrowser(org.eclipse.ui.browser.IWebBrowser) PartInitException(org.eclipse.ui.PartInitException) URL(java.net.URL)

Example 4 with IWebBrowser

use of org.eclipse.ui.browser.IWebBrowser in project cubrid-manager by CUBRID.

the class CubridOnlineForumAction method run.

public void run() {
    String url = CommonUITool.urlEncodeForSpaces(Messages.msgCubridOnlineForumUrl);
    try {
        IWorkbenchBrowserSupport support = PlatformUI.getWorkbench().getBrowserSupport();
        IWebBrowser browser = support.getExternalBrowser();
        browser.openURL(new URL(url));
    } catch (PartInitException e) {
        LOGGER.error("Can not initialize web browser on the application.", e);
    } catch (MalformedURLException e) {
        LOGGER.error("The url {} is invalid.", url, e);
    }
}
Also used : MalformedURLException(java.net.MalformedURLException) IWorkbenchBrowserSupport(org.eclipse.ui.browser.IWorkbenchBrowserSupport) IWebBrowser(org.eclipse.ui.browser.IWebBrowser) PartInitException(org.eclipse.ui.PartInitException) URL(java.net.URL)

Example 5 with IWebBrowser

use of org.eclipse.ui.browser.IWebBrowser in project cubrid-manager by CUBRID.

the class HelpDocumentAction method run.

public void run() {
    String url = CommonUITool.urlEncodeForSpaces(Messages.msgCubridHelpSiteUrl);
    try {
        IWorkbenchBrowserSupport support = PlatformUI.getWorkbench().getBrowserSupport();
        IWebBrowser browser = support.getExternalBrowser();
        browser.openURL(new URL(url));
    } catch (PartInitException e) {
        LOGGER.error("Can not initialize web browser on the application.", e);
    } catch (MalformedURLException e) {
        LOGGER.error("The url {} is invalid.", url, e);
    }
}
Also used : MalformedURLException(java.net.MalformedURLException) IWorkbenchBrowserSupport(org.eclipse.ui.browser.IWorkbenchBrowserSupport) IWebBrowser(org.eclipse.ui.browser.IWebBrowser) PartInitException(org.eclipse.ui.PartInitException) URL(java.net.URL)

Aggregations

IWebBrowser (org.eclipse.ui.browser.IWebBrowser)11 IWorkbenchBrowserSupport (org.eclipse.ui.browser.IWorkbenchBrowserSupport)11 URL (java.net.URL)10 PartInitException (org.eclipse.ui.PartInitException)8 MalformedURLException (java.net.MalformedURLException)6 GridData (org.eclipse.swt.layout.GridData)4 GridLayout (org.eclipse.swt.layout.GridLayout)4 SelectionEvent (org.eclipse.swt.events.SelectionEvent)3 Button (org.eclipse.swt.widgets.Button)3 Composite (org.eclipse.swt.widgets.Composite)3 Label (org.eclipse.swt.widgets.Label)3 Hyperlink (com.novocode.naf.swt.custom.Hyperlink)2 Browser (org.eclipse.swt.browser.Browser)2 MouseEvent (org.eclipse.swt.events.MouseEvent)2 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)2 HyperlinkEvent (org.eclipse.ui.forms.events.HyperlinkEvent)2 FormText (org.eclipse.ui.forms.widgets.FormText)2 ConfigElementLabelProvider (org.bndtools.core.ui.ConfigElementLabelProvider)1 CategorisedPrioritisedConfigurationElementTreeContentProvider (org.bndtools.utils.eclipse.CategorisedPrioritisedConfigurationElementTreeContentProvider)1 IConfigurationElement (org.eclipse.core.runtime.IConfigurationElement)1