예제 #1
0
  protected void openBrowser(ISonarResource sonarResource) {
    IWorkbenchBrowserSupport browserSupport =
        SonarUiPlugin.getDefault().getWorkbench().getBrowserSupport();
    ProjectProperties properties = ProjectProperties.getInstance(sonarResource.getProject());
    try {
      String url = new SonarUrls().resourceUrl(sonarResource);

      URL consoleURL = new URL(url);
      if (browserSupport.isInternalWebBrowserAvailable()) {
        browserSupport.createBrowser("id" + properties.getUrl().hashCode()).openURL(consoleURL);
      } else {
        browserSupport.getExternalBrowser().openURL(consoleURL);
      }
    } catch (Exception e) {
      LoggerFactory.getLogger(getClass()).error(e.getMessage(), e);
    }
  }
예제 #2
0
  /**
   * Open a URL in a browser.
   *
   * @param url
   * @param internal In case true, the system will try to open the internal browser if it's
   *     available.
   * @param style the Browser's style, in case an internal browser is requested.
   * @return A boolean value indicating a successful operations or not.
   */
  public static boolean openInBroswer(URL url, boolean internal, int style) {
    IWorkbench workbench = PlatformUI.getWorkbench();
    if (workbench != null) {
      IWorkbenchBrowserSupport support = PlatformUI.getWorkbench().getBrowserSupport();
      try {
        if (internal && support.isInternalWebBrowserAvailable()) {

          support.createBrowser(style, INTERNAL_HELP_BROWSER_ID, null, null).openURL(url);

        } else {
          support.getExternalBrowser().openURL(url);
        }
      } catch (PartInitException e) {
        IdeLog.logError(UIPlugin.getDefault(), "Error opening the help", e); // $NON-NLS-1$
        return false;
      }
      return true;
    }
    return false;
  }