Search in sources :

Example 1 with IWorkbenchBrowserSupport

use of org.eclipse.ui.browser.IWorkbenchBrowserSupport 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 IWorkbenchBrowserSupport

use of org.eclipse.ui.browser.IWorkbenchBrowserSupport 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 IWorkbenchBrowserSupport

use of org.eclipse.ui.browser.IWorkbenchBrowserSupport in project archi by archimatetool.

the class CheckForNewVersionAction method run.

@Override
public void run() {
    try {
        URL url = new URL(versionFile);
        String newVersion = getOnlineVersion(url);
        // Get this app's main version number
        String thisVersion = System.getProperty(Application.APPLICATION_VERSIONID);
        if (StringUtils.compareVersionNumbers(newVersion, thisVersion) > 0) {
            boolean reply = MessageDialog.openQuestion(null, Messages.CheckForNewVersionAction_1, Messages.CheckForNewVersionAction_2 + " (" + newVersion + // $NON-NLS-1$ //$NON-NLS-2$
            "). " + Messages.CheckForNewVersionAction_3);
            if (reply) {
                IWorkbenchBrowserSupport support = PlatformUI.getWorkbench().getBrowserSupport();
                IWebBrowser browser = support.getExternalBrowser();
                if (browser != null) {
                    URL url2 = new URL(downloadPage);
                    browser.openURL(url2);
                }
            }
        } else {
            MessageDialog.openInformation(null, Messages.CheckForNewVersionAction_1, Messages.CheckForNewVersionAction_4);
        }
    } catch (MalformedURLException ex) {
        ex.printStackTrace();
    } catch (IOException ex) {
        ex.printStackTrace();
        showErrorMessage(Messages.CheckForNewVersionAction_5);
        return;
    } catch (PartInitException ex) {
        ex.printStackTrace();
    }
}
Also used : MalformedURLException(java.net.MalformedURLException) IWorkbenchBrowserSupport(org.eclipse.ui.browser.IWorkbenchBrowserSupport) IWebBrowser(org.eclipse.ui.browser.IWebBrowser) IOException(java.io.IOException) PartInitException(org.eclipse.ui.PartInitException) URL(java.net.URL)

Example 4 with IWorkbenchBrowserSupport

use of org.eclipse.ui.browser.IWorkbenchBrowserSupport in project archi by archimatetool.

the class HTMLUtils method openLinkInBrowser.

/**
 * Open a link in a Browser
 * @param href
 * @throws PartInitException
 * @throws MalformedURLException
 */
public static void openLinkInBrowser(String href) throws PartInitException, MalformedURLException {
    IWorkbenchBrowserSupport support = PlatformUI.getWorkbench().getBrowserSupport();
    IWebBrowser browser = support.getExternalBrowser();
    browser.openURL(new URL(urlEncodeForSpaces(href.toCharArray())));
}
Also used : IWorkbenchBrowserSupport(org.eclipse.ui.browser.IWorkbenchBrowserSupport) IWebBrowser(org.eclipse.ui.browser.IWebBrowser) URL(java.net.URL)

Example 5 with IWorkbenchBrowserSupport

use of org.eclipse.ui.browser.IWorkbenchBrowserSupport in project eclipse.platform.text by eclipse.

the class URLHyperlink method open.

@Override
public void open() {
    // Create the browser
    IWorkbenchBrowserSupport support = PlatformUI.getWorkbench().getBrowserSupport();
    IWebBrowser browser;
    try {
        browser = support.createBrowser(null);
    } catch (PartInitException e) {
        // $NON-NLS-1$
        EditorsPlugin.logErrorStatus("Could not create Web browser for URLHyperlink", e.getStatus());
        super.open();
        return;
    }
    try {
        browser.openURL(new URL(getURLString()));
    } catch (PartInitException e) {
        super.open();
    } catch (MalformedURLException e) {
        super.open();
    }
}
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

IWorkbenchBrowserSupport (org.eclipse.ui.browser.IWorkbenchBrowserSupport)35 URL (java.net.URL)29 IWebBrowser (org.eclipse.ui.browser.IWebBrowser)28 PartInitException (org.eclipse.ui.PartInitException)21 MalformedURLException (java.net.MalformedURLException)18 GridData (org.eclipse.swt.layout.GridData)7 GridLayout (org.eclipse.swt.layout.GridLayout)6 SelectionEvent (org.eclipse.swt.events.SelectionEvent)5 Button (org.eclipse.swt.widgets.Button)5 Composite (org.eclipse.swt.widgets.Composite)5 Label (org.eclipse.swt.widgets.Label)5 IOException (java.io.IOException)4 Status (org.eclipse.core.runtime.Status)4 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)4 File (java.io.File)3 CoreException (org.eclipse.core.runtime.CoreException)3 IStatus (org.eclipse.core.runtime.IStatus)3 HyperlinkEvent (org.eclipse.ui.forms.events.HyperlinkEvent)3 FormText (org.eclipse.ui.forms.widgets.FormText)3 Hyperlink (com.novocode.naf.swt.custom.Hyperlink)2