• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java ExternalDocumentationProvider类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.intellij.lang.documentation.ExternalDocumentationProvider的典型用法代码示例。如果您正苦于以下问题:Java ExternalDocumentationProvider类的具体用法?Java ExternalDocumentationProvider怎么用?Java ExternalDocumentationProvider使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ExternalDocumentationProvider类属于com.intellij.lang.documentation包,在下文中一共展示了ExternalDocumentationProvider类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: update

import com.intellij.lang.documentation.ExternalDocumentationProvider; //导入依赖的package包/类
@Override
public void update(AnActionEvent e) {
  final Presentation presentation = e.getPresentation();
  presentation.setEnabled(false);
  if (myElement != null) {
    final PsiElement element = myElement.getElement();
    final DocumentationProvider provider = DocumentationManager.getProviderFromElement(element);
    final PsiElement originalElement = DocumentationManager.getOriginalElement(element);
    if (provider instanceof ExternalDocumentationProvider) {
      presentation.setEnabled(element != null && ((ExternalDocumentationProvider)provider).hasDocumentationFor(element, originalElement));
    }
    else {
      final List<String> urls = provider.getUrlFor(element, originalElement);
      presentation.setEnabled(element != null && urls != null && !urls.isEmpty());
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:DocumentationComponent.java


示例2: update

import com.intellij.lang.documentation.ExternalDocumentationProvider; //导入依赖的package包/类
@Override
public void update(AnActionEvent event) {
  Presentation presentation = event.getPresentation();
  DataContext dataContext = event.getDataContext();
  Editor editor = CommonDataKeys.EDITOR.getData(dataContext);
  PsiElement element = getElement(dataContext, editor);
  final PsiElement originalElement = getOriginalElement(CommonDataKeys.PSI_FILE.getData(dataContext), editor);
  DocumentationManager.storeOriginalElement(CommonDataKeys.PROJECT.getData(dataContext), originalElement, element);
  final DocumentationProvider provider = DocumentationManager.getProviderFromElement(element);
  boolean enabled;
  if (provider instanceof ExternalDocumentationProvider) {
    final ExternalDocumentationProvider edProvider = (ExternalDocumentationProvider)provider;
    enabled = edProvider.hasDocumentationFor(element, originalElement) || edProvider.canPromptToConfigureDocumentation(element);
  }
  else {
    final List<String> urls = provider.getUrlFor(element, originalElement);
    enabled = urls != null && !urls.isEmpty();
  }
  if (editor != null) {
    presentation.setEnabled(enabled);
    if (ActionPlaces.isMainMenuOrActionSearch(event.getPlace())) {
      presentation.setVisible(true);
    }
    else {
      presentation.setVisible(enabled);
    }
  }
  else{
    presentation.setEnabled(enabled);
    presentation.setVisible(true);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:33,代码来源:ExternalJavaDocAction.java


示例3: doTestExternalDoc

import com.intellij.lang.documentation.ExternalDocumentationProvider; //导入依赖的package包/类
protected void doTestExternalDoc(String expectedPart) {
  final PsiElement originalElement = myFixture.getFile().findElementAt(
    myFixture.getEditor().getCaretModel().getOffset());
  final PsiElement docTargetElement = DocumentationManager.getInstance(getProject()).
    findTargetElement(myFixture.getEditor(), myFixture.getFile(), originalElement);
  final DocumentationProvider provider = DocumentationManager.getProviderFromElement(docTargetElement);
  final List<String> urls = provider.getUrlFor(docTargetElement, originalElement);
  final String doc = ((ExternalDocumentationProvider)provider).fetchExternalDocumentation(myFixture.getProject(), docTargetElement, urls);
  assertNotNull(doc);
  assertTrue("Can't find " + expectedPart + " in " + doc, doc.contains(expectedPart));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:AndroidDomTest.java


示例4: update

import com.intellij.lang.documentation.ExternalDocumentationProvider; //导入依赖的package包/类
@Override
public void update(AnActionEvent event) {
  Presentation presentation = event.getPresentation();
  DataContext dataContext = event.getDataContext();
  Editor editor = PlatformDataKeys.EDITOR.getData(dataContext);
  final PsiElement element = LangDataKeys.PSI_ELEMENT.getData(dataContext);
  final PsiElement originalElement = getOriginalElement(LangDataKeys.PSI_FILE.getData(dataContext), editor);
  DocumentationManager.storeOriginalElement(PlatformDataKeys.PROJECT.getData(dataContext), originalElement, element);
  final DocumentationProvider provider = DocumentationManager.getProviderFromElement(element);
  boolean enabled;
  if (provider instanceof ExternalDocumentationProvider) {
    final ExternalDocumentationProvider edProvider = (ExternalDocumentationProvider)provider;
    enabled = edProvider.hasDocumentationFor(element, originalElement) || edProvider.canPromptToConfigureDocumentation(element);
  }
  else {
    final List<String> urls = provider.getUrlFor(element, originalElement);
    enabled = urls != null && !urls.isEmpty();
  }
  if (editor != null) {
    presentation.setEnabled(enabled);
    if (event.getPlace().equals(ActionPlaces.MAIN_MENU)) {
      presentation.setVisible(true);
    }
    else {
      presentation.setVisible(enabled);
    }
  }
  else{
    presentation.setEnabled(enabled);
    presentation.setVisible(true);
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:33,代码来源:ExternalJavaDocAction.java


示例5: update

import com.intellij.lang.documentation.ExternalDocumentationProvider; //导入依赖的package包/类
@Override
public void update(AnActionEvent event) {
  Presentation presentation = event.getPresentation();
  DataContext dataContext = event.getDataContext();
  Editor editor = dataContext.getData(CommonDataKeys.EDITOR);
  PsiElement element = getElement(dataContext, editor);
  final PsiElement originalElement = getOriginalElement(dataContext.getData(CommonDataKeys.PSI_FILE), editor);
  DocumentationManager.storeOriginalElement(dataContext.getData(CommonDataKeys.PROJECT), originalElement, element);
  final DocumentationProvider provider = DocumentationManager.getProviderFromElement(element);
  boolean enabled;
  if (provider instanceof ExternalDocumentationProvider) {
    final ExternalDocumentationProvider edProvider = (ExternalDocumentationProvider)provider;
    enabled = edProvider.hasDocumentationFor(element, originalElement) || edProvider.canPromptToConfigureDocumentation(element);
  }
  else {
    final List<String> urls = provider.getUrlFor(element, originalElement);
    enabled = urls != null && !urls.isEmpty();
  }
  if (editor != null) {
    presentation.setEnabled(enabled);
    if (ActionPlaces.isMainMenuOrActionSearch(event.getPlace())) {
      presentation.setVisible(true);
    }
    else {
      presentation.setVisible(enabled);
    }
  }
  else{
    presentation.setEnabled(enabled);
    presentation.setVisible(true);
  }
}
 
开发者ID:consulo,项目名称:consulo,代码行数:33,代码来源:ExternalJavaDocAction.java


示例6: actionPerformed

import com.intellij.lang.documentation.ExternalDocumentationProvider; //导入依赖的package包/类
@Override
public void actionPerformed(AnActionEvent e) {
  DataContext dataContext = e.getDataContext();
  Project project = CommonDataKeys.PROJECT.getData(dataContext);
  if (project == null) {
    return;
  }

  Editor editor = CommonDataKeys.EDITOR.getData(dataContext);
  PsiElement element = getElement(dataContext, editor);
  if (element == null) {
    Messages.showMessageDialog(
      project,
      IdeBundle.message("message.please.select.element.for.javadoc"),
      IdeBundle.message("title.no.element.selected"),
      Messages.getErrorIcon()
    );
    return;
  }


  PsiFile context = CommonDataKeys.PSI_FILE.getData(dataContext);

  PsiElement originalElement = getOriginalElement(context, editor);
  DocumentationManager.storeOriginalElement(project, originalElement, element);
  final DocumentationProvider provider = DocumentationManager.getProviderFromElement(element);

  if (provider instanceof ExternalDocumentationHandler && ((ExternalDocumentationHandler)provider).handleExternal(element, originalElement)) {
    return;
  }

  final List<String> urls = provider.getUrlFor(element, originalElement);
  if (urls != null && !urls.isEmpty()) {
    showExternalJavadoc(urls, PlatformDataKeys.CONTEXT_COMPONENT.getData(dataContext));
  }
  else if (provider instanceof ExternalDocumentationProvider) {
    final ExternalDocumentationProvider externalDocumentationProvider = (ExternalDocumentationProvider)provider;
    if (externalDocumentationProvider.canPromptToConfigureDocumentation(element)) {
      externalDocumentationProvider.promptToConfigureDocumentation(element);
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:43,代码来源:ExternalJavaDocAction.java


示例7: actionPerformed

import com.intellij.lang.documentation.ExternalDocumentationProvider; //导入依赖的package包/类
@Override
public void actionPerformed(AnActionEvent e) {
  DataContext dataContext = e.getDataContext();
  Project project = PlatformDataKeys.PROJECT.getData(dataContext);
  if (project == null) {
    return;
  }

  PsiElement element = LangDataKeys.PSI_ELEMENT.getData(dataContext);
  if (element == null) {
    Messages.showMessageDialog(
      project,
      IdeBundle.message("message.please.select.element.for.javadoc"),
      IdeBundle.message("title.no.element.selected"),
      Messages.getErrorIcon()
    );
    return;
  }


  PsiFile context = LangDataKeys.PSI_FILE.getData(dataContext);
  Editor editor = PlatformDataKeys.EDITOR.getData(dataContext);
  PsiElement originalElement = getOriginalElement(context, editor);
  DocumentationManager.storeOriginalElement(project, originalElement, element);
  final DocumentationProvider provider = DocumentationManager.getProviderFromElement(element);

  if (provider instanceof ExternalDocumentationHandler && ((ExternalDocumentationHandler)provider).handleExternal(element, originalElement)) {
    return;
  }

  final List<String> urls = provider.getUrlFor(element, originalElement);
  if (urls != null && !urls.isEmpty()) {
    showExternalJavadoc(urls);
  }
  else if (provider instanceof ExternalDocumentationProvider) {
    final ExternalDocumentationProvider externalDocumentationProvider = (ExternalDocumentationProvider)provider;
    if (externalDocumentationProvider.canPromptToConfigureDocumentation(element)) {
      externalDocumentationProvider.promptToConfigureDocumentation(element);
    }
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:42,代码来源:ExternalJavaDocAction.java


示例8: showExternalJavadoc

import com.intellij.lang.documentation.ExternalDocumentationProvider; //导入依赖的package包/类
public static void showExternalJavadoc(PsiElement element, PsiElement originalElement, String docUrl, DataContext dataContext) {
  DocumentationProvider provider = DocumentationManager.getProviderFromElement(element);
  if (provider instanceof ExternalDocumentationHandler &&
      ((ExternalDocumentationHandler)provider).handleExternal(element, originalElement)) {
    return;
  }
  Project project = dataContext.getData(CommonDataKeys.PROJECT);
  final Component contextComponent = dataContext.getData(PlatformDataKeys.CONTEXT_COMPONENT);
  ApplicationManager.getApplication().executeOnPooledThread(() -> {
    List<String> urls;
    if (StringUtil.isEmptyOrSpaces(docUrl)) {
      urls = ReadAction.compute(() -> provider.getUrlFor(element, originalElement));
    }
    else {
      urls = Collections.singletonList(docUrl);
    }
    if (provider instanceof ExternalDocumentationProvider && urls != null && urls.size() > 1) {
      for (String url : urls) {
        List<String> thisUrlList = Collections.singletonList(url);
        String doc = ((ExternalDocumentationProvider)provider).fetchExternalDocumentation(project, element, thisUrlList);
        if (doc != null) {
          urls = thisUrlList;
          break;
        }
      }
    }
    final List<String> finalUrls = urls;
    ApplicationManager.getApplication().invokeLater(() -> {
      if (ContainerUtil.isEmpty(finalUrls)) {
        if (element != null && provider instanceof ExternalDocumentationProvider) {
          ExternalDocumentationProvider externalDocumentationProvider = (ExternalDocumentationProvider)provider;
          if (externalDocumentationProvider.canPromptToConfigureDocumentation(element)) {
            externalDocumentationProvider.promptToConfigureDocumentation(element);
          }
        }
      }
      else if (finalUrls.size() == 1) {
        BrowserUtil.browse(finalUrls.get(0));
      }
      else {
        JBPopupFactory.getInstance().createListPopup(new BaseListPopupStep<String>("Choose external documentation root",
                                                                                   ArrayUtil.toStringArray(finalUrls)) {
          @Override
          public PopupStep onChosen(final String selectedValue, final boolean finalChoice) {
            BrowserUtil.browse(selectedValue);
            return FINAL_CHOICE;
          }
        }).showInBestPositionFor(DataManager.getInstance().getDataContext(contextComponent));
      }
    }, ModalityState.NON_MODAL);
  });

}
 
开发者ID:consulo,项目名称:consulo,代码行数:54,代码来源:ExternalJavaDocAction.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java NodeModel类代码示例发布时间:2022-05-22
下一篇:
Java PrefixManager类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap