当前位置: 首页>>代码示例>>Java>>正文


Java BrowserUtil.browse方法代码示例

本文整理汇总了Java中com.intellij.ide.BrowserUtil.browse方法的典型用法代码示例。如果您正苦于以下问题:Java BrowserUtil.browse方法的具体用法?Java BrowserUtil.browse怎么用?Java BrowserUtil.browse使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.ide.BrowserUtil的用法示例。


在下文中一共展示了BrowserUtil.browse方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: openInBrowser

import com.intellij.ide.BrowserUtil; //导入方法依赖的package包/类
protected static void openInBrowser(Project project, GitRepository repository, String revisionHash) {
  String url = GithubUtil.findGithubRemoteUrl(repository);
  if (url == null) {
    GithubUtil.LOG.info(String.format("Repository is not under GitHub. Root: %s, Remotes: %s", repository.getRoot(),
                                         GitUtil.getPrintableRemotes(repository.getRemotes())));
    return;
  }
  GithubFullPath userAndRepository = GithubUrlUtil.getUserAndRepositoryFromRemoteUrl(url);
  if (userAndRepository == null) {
    GithubNotifications
      .showError(project, GithubOpenInBrowserAction.CANNOT_OPEN_IN_BROWSER, "Cannot extract info about repository: " + url);
    return;
  }

  String githubUrl = GithubUrlUtil.getGithubHost() + '/' + userAndRepository.getUser() + '/'
                     + userAndRepository.getRepository() + "/commit/" + revisionHash;
  BrowserUtil.browse(githubUrl);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:GithubShowCommitInBrowserAction.java

示例2: execute

import com.intellij.ide.BrowserUtil; //导入方法依赖的package包/类
@Override
protected void execute(final @NotNull SingleItemActionContext actionContext) {
    final ServerContext context = actionContext.getServerContext();

    // check for null values (it's ok if the server item is null because the URL redirects to the general page in that case
    if (context != null && context.getTeamProjectReference() != null && actionContext.getItem() != null) {
        final URI urlToBrowseTo = UrlHelper.getTfvcAnnotateURI(context.getUri().toString(),
                context.getTeamProjectReference().getName(), actionContext.getItem().getServerItem());
        logger.info("Browsing to url " + urlToBrowseTo.getPath());
        BrowserUtil.browse(urlToBrowseTo);
    } else {
        final String issue = context == null ? "context is null" : context.getTeamProjectReference() == null ? "team project is null" : "getItem is null";
        logger.warn("Couldn't create annotate url: " + issue);
        Messages.showErrorDialog(actionContext.getProject(), TfPluginBundle.message(TfPluginBundle.KEY_ACTIONS_ANNOTATE_ERROR_MSG),
                TfPluginBundle.message(TfPluginBundle.KEY_ACTIONS_ANNOTATE_ERROR_TITLE));
    }
}
 
开发者ID:Microsoft,项目名称:vso-intellij,代码行数:18,代码来源:AnnotateAction.java

示例3: doActionPerformed

import com.intellij.ide.BrowserUtil; //导入方法依赖的package包/类
@Override
public void doActionPerformed(@NotNull final AnActionEvent anActionEvent) {
    final Project project = anActionEvent.getRequiredData(CommonDataKeys.PROJECT);
    final VcsFullCommitDetails commit = anActionEvent.getRequiredData(VcsLogDataKeys.VCS_LOG).getSelectedDetails().get(0);

    final GitRepository gitRepository = GitUtil.getRepositoryManager(project).getRepositoryForRoot(commit.getRoot());
    final GitRemote remote = TfGitHelper.getTfGitRemote(gitRepository);

    // guard for null so findbugs doesn't complain
    if (remote == null) {
        return;
    }

    final String remoteUrl = remote.getFirstUrl();
    if (remoteUrl == null) {
        return;
    }

    final URI urlToBrowseTo = UrlHelper.getCommitURI(remoteUrl, commit.getId().toString());
    logger.info("Browsing to url " + urlToBrowseTo.getPath());
    BrowserUtil.browse(urlToBrowseTo);
}
 
开发者ID:Microsoft,项目名称:vso-intellij,代码行数:23,代码来源:OpenCommitInBrowserAction.java

示例4: testExecute_Success

import com.intellij.ide.BrowserUtil; //导入方法依赖的package包/类
@Test
public void testExecute_Success() {
    ArgumentCaptor<URI> argCapture = ArgumentCaptor.forClass(URI.class);
    when(mockTeamProjectReference.getName()).thenReturn("TeamName");
    when(mockItemInfo.getServerItem()).thenReturn("$/path/to/file.txt");
    when(mockServerContext.getTeamProjectReference()).thenReturn(mockTeamProjectReference);
    when(mockActionContext.getServerContext()).thenReturn(mockServerContext);
    when(mockActionContext.getItem()).thenReturn(mockItemInfo);
    annotateAction.execute(mockActionContext);

    verifyStatic(times(0));
    Messages.showErrorDialog(any(Project.class), anyString(), anyString());
    verifyStatic(times(1));
    BrowserUtil.browse(argCapture.capture());
    assertEquals(serverURI.toString() +
                    "TeamName/_versionControl/?path=%24%2Fpath%2Fto%2Ffile.txt&_a=contents&annotate=true&hideComments=true",
            argCapture.getValue().toString());
}
 
开发者ID:Microsoft,项目名称:vso-intellij,代码行数:19,代码来源:AnnotateActionTest.java

示例5: launchExternalLink

import com.intellij.ide.BrowserUtil; //导入方法依赖的package包/类
public static void launchExternalLink(@NotNull final Project project, @NotNull final String href) {
    if (PathInfo.isExternal(href)) {
        BrowserUtil.browse(href);
    } else if (href.startsWith("file://")) {
        try {
            URL target = new URL(href);
            VirtualFileSystem virtualFileSystem = VirtualFileManager.getInstance().getFileSystem(target.getProtocol());
            final VirtualFile virtualFile = virtualFileSystem == null ? null : virtualFileSystem.findFileByPath(target.getFile());
            // open local file
            if (virtualFile != null) {
                ApplicationManager.getApplication().invokeLater(new Runnable() {
                    @Override
                    public void run() {
                        FileEditorManager.getInstance(project).openFile(virtualFile, true, true);
                        // TODO: see if we can resolve the #hashSuffix in the file
                        //logger.info("got hash suffixed href: " + href + "#" + hashSuffix);
                    }
                });
            }
        } catch (MalformedURLException ignored) {
        }
    }
}
 
开发者ID:vsch,项目名称:idea-multimarkdown,代码行数:24,代码来源:MultiMarkdownPathResolver.java

示例6: hyperlinkUpdate

import com.intellij.ide.BrowserUtil; //导入方法依赖的package包/类
public void hyperlinkUpdate(HyperlinkEvent e) {
  if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
    JEditorPane pane = (JEditorPane)e.getSource();
    if (e instanceof HTMLFrameHyperlinkEvent) {
      HTMLFrameHyperlinkEvent evt = (HTMLFrameHyperlinkEvent)e;
      HTMLDocument doc = (HTMLDocument)pane.getDocument();
      doc.processHTMLFrameHyperlinkEvent(evt);
    }
    else {
      URL url = e.getURL();
      if (url != null) {
        BrowserUtil.browse(url);
      }
    }
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:17,代码来源:PluginManagerMain.java

示例7: actionPerformed

import com.intellij.ide.BrowserUtil; //导入方法依赖的package包/类
public void actionPerformed(AnActionEvent e) {
  DataContext dataContext = e.getDataContext();
  CopyProvider provider = e.getData(PlatformDataKeys.COPY_PROVIDER);
  if (provider == null) {
    return;
  }
  provider.performCopy(dataContext);
  Transferable contents = CopyPasteManager.getInstance().getContents();
  String string;
  try {
    string = contents == null? null : (String)contents.getTransferData(DataFlavor.stringFlavor);
  }
  catch (Exception ex) {
    return;
  }
  if (StringUtil.isNotEmpty(string)) {
    BrowserUtil.browse("http://www.google.com/search?q="+ URLEncoder.encode(string));
  }
}
 
开发者ID:consulo,项目名称:consulo,代码行数:20,代码来源:SearchWebAction.java

示例8: hyperlinkUpdate

import com.intellij.ide.BrowserUtil; //导入方法依赖的package包/类
@Override
public void hyperlinkUpdate(HyperlinkEvent e) {
  if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
    JEditorPane pane = (JEditorPane)e.getSource();
    if (e instanceof HTMLFrameHyperlinkEvent) {
      HTMLFrameHyperlinkEvent evt = (HTMLFrameHyperlinkEvent)e;
      HTMLDocument doc = (HTMLDocument)pane.getDocument();
      doc.processHTMLFrameHyperlinkEvent(evt);
    }
    else {
      URL url = e.getURL();
      if (url != null) {
        BrowserUtil.browse(url);
      }
    }
  }
}
 
开发者ID:consulo,项目名称:consulo,代码行数:18,代码来源:PluginManagerMain.java

示例9: actionPerformed

import com.intellij.ide.BrowserUtil; //导入方法依赖的package包/类
public void actionPerformed(AnActionEvent var1) {
    DataContext var2 = var1.getDataContext();
    CopyProvider var3 = (CopyProvider) PlatformDataKeys.COPY_PROVIDER.getData(var2);
    if (var3 != null) {
        var3.performCopy(var2);
        String var4 = (String) CopyPasteManager.getInstance().getContents(DataFlavor.stringFlavor);
        if (StringUtil.isNotEmpty(var4)) {
            BrowserUtil.browse("https://translate.google.com/#en/zh-CN/" + URLEncoder.encode(var4));
        }
    }
}
 
开发者ID:kookob,项目名称:mybatis-log-plugin,代码行数:12,代码来源:GoogleTranslateAction.java

示例10: actionPerformed

import com.intellij.ide.BrowserUtil; //导入方法依赖的package包/类
public void actionPerformed(AnActionEvent var1) {
    DataContext var2 = var1.getDataContext();
    CopyProvider var3 = (CopyProvider) PlatformDataKeys.COPY_PROVIDER.getData(var2);
    if (var3 != null) {
        var3.performCopy(var2);
        String var4 = (String) CopyPasteManager.getInstance().getContents(DataFlavor.stringFlavor);
        if (StringUtil.isNotEmpty(var4)) {
            BrowserUtil.browse("https://www.baidu.com/s?wd=" + URLEncoder.encode(var4));
        }
    }
}
 
开发者ID:kookob,项目名称:mybatis-log-plugin,代码行数:12,代码来源:BaiduSearchAction.java

示例11: updateStatus

import com.intellij.ide.BrowserUtil; //导入方法依赖的package包/类
/**
 * Post on twitter media and text from panel
 * @param panel shown to user and used to provide data to post 
 */
public static void updateStatus(StudyTwitterUtils.TwitterDialogPanel panel, Twitter twitter) throws IOException, TwitterException {
  StatusUpdate update = new StatusUpdate(panel.getMessage());
  InputStream e = panel.getMediaSource();
  if (e != null) {
    File imageFile = FileUtil.createTempFile("twitter_media", panel.getMediaExtension());
    FileUtil.copy(e, new FileOutputStream(imageFile));
    update.media(imageFile);
  }

  twitter.updateStatus(update);
  BrowserUtil.browse("https://twitter.com/");
}
 
开发者ID:medvector,项目名称:educational-plugin,代码行数:17,代码来源:StudyTwitterUtils.java

示例12: doAuthorize

import com.intellij.ide.BrowserUtil; //导入方法依赖的package包/类
public static void doAuthorize(@NotNull Runnable externalRedirectUrlHandler) {
  String redirectUrl = getOAuthRedirectUrl();
  String link = createOAuthLink(redirectUrl);
  BrowserUtil.browse(link);
  if (!redirectUrl.startsWith("http://localhost")) {
    externalRedirectUrlHandler.run();
  }
}
 
开发者ID:medvector,项目名称:educational-plugin,代码行数:9,代码来源:EduStepicConnector.java

示例13: actionPerformed

import com.intellij.ide.BrowserUtil; //导入方法依赖的package包/类
@Override
public void actionPerformed(final AnActionEvent e) {
  try {
    if (new File(PLUGIN_URL).isFile()) {
      BrowserUtil.browse(PLUGIN_URL);
    }
    else {
      BrowserUtil.browse(PLUGIN_WEBSITE);
    }
  }
  catch(IllegalStateException ex) {
    // ignore
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:DevelopPluginsAction.java

示例14: linkActivated

import com.intellij.ide.BrowserUtil; //导入方法依赖的package包/类
@SuppressWarnings({"HardCodedStringLiteral"})
protected void linkActivated(URL u){
  String url=u.toExternalForm();
  if(url.startsWith("http") || url.startsWith("ftp")){
    BrowserUtil.browse(url);
  } else{
    super.linkActivated(u);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:IdeaHelpContentViewUI.java

示例15: createCenterPanel

import com.intellij.ide.BrowserUtil; //导入方法依赖的package包/类
@Override
protected JComponent createCenterPanel() {
  JLabel description = new JBLabel(
    "<html>You are about to commit CRLF line separators to the Git repository.<br/>" +
    "It is recommended to set core.autocrlf Git attribute to <code>" + RECOMMENDED_VALUE +
    "</code> to avoid line separator issues.</html>");

  JLabel additionalDescription = new JBLabel(
    "<html>Fix and Commit: <code>git config --global core.autocrlf " + RECOMMENDED_VALUE + "</code> will be called,<br/>" +
    "Commit as Is: the config value won't be set.</html>", UIUtil.ComponentStyle.SMALL);

  JLabel readMore = new LinkLabel("Read more", null, new LinkListener() {
    @Override
    public void linkSelected(LinkLabel aSource, Object aLinkData) {
      BrowserUtil.browse("https://help.github.com/articles/dealing-with-line-endings");
    }
  });

  JLabel icon = new JLabel(UIUtil.getWarningIcon(), SwingConstants.LEFT);
  myDontWarn = new JBCheckBox("Don't warn again");
  myDontWarn.setMnemonic('w');

  JPanel rootPanel = new JPanel(new GridBagLayout());
  GridBag g = new GridBag()
    .setDefaultInsets(new Insets(0, 6, DEFAULT_VGAP, DEFAULT_HGAP))
    .setDefaultAnchor(GridBagConstraints.LINE_START)
    .setDefaultFill(GridBagConstraints.HORIZONTAL);

  rootPanel.add(icon, g.nextLine().next().coverColumn(4));
  rootPanel.add(description, g.next());
  rootPanel.add(readMore, g.nextLine().next().next());
  rootPanel.add(additionalDescription, g.nextLine().next().next().pady(DEFAULT_HGAP));
  rootPanel.add(myDontWarn,  g.nextLine().next().next().insets(0, 0, 0, 0));

  return rootPanel;

}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:38,代码来源:GitCrlfDialog.java


注:本文中的com.intellij.ide.BrowserUtil.browse方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。