本文整理汇总了Java中com.intellij.codeInsight.documentation.DocumentationManager.getInstance方法的典型用法代码示例。如果您正苦于以下问题:Java DocumentationManager.getInstance方法的具体用法?Java DocumentationManager.getInstance怎么用?Java DocumentationManager.getInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.codeInsight.documentation.DocumentationManager
的用法示例。
在下文中一共展示了DocumentationManager.getInstance方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getDocumentationText
import com.intellij.codeInsight.documentation.DocumentationManager; //导入方法依赖的package包/类
public static String getDocumentationText(@NotNull PsiFile psiFile, int caretPosition) throws InterruptedException {
Project project = psiFile.getProject();
Document document = PsiDocumentManager.getInstance(project).getDocument(psiFile);
assertNotNull(document);
Editor editor = EditorFactory.getInstance().createEditor(document, project);
try {
if (caretPosition >= 0) {
editor.getCaretModel().moveToOffset(caretPosition);
}
DocumentationManager documentationManager = DocumentationManager.getInstance(project);
MockDocumentationComponent documentationComponent = new MockDocumentationComponent(documentationManager);
try {
documentationManager.setDocumentationComponent(documentationComponent);
documentationManager.showJavaDocInfo(editor, psiFile, false);
waitTillDone(documentationManager.getLastAction());
return documentationComponent.getText();
}
finally {
JBPopup hint = documentationComponent.getHint();
if (hint != null) Disposer.dispose(hint);
Disposer.dispose(documentationComponent);
}
}
finally {
EditorFactory.getInstance().releaseEditor(editor);
}
}
示例2: doActionPerformed
import com.intellij.codeInsight.documentation.DocumentationManager; //导入方法依赖的package包/类
@Override
protected void doActionPerformed(@NotNull DataContext context, @NotNull PsiElement docAnchor, @NotNull PsiElement originalElement) {
Project project = CommonDataKeys.PROJECT.getData(context);
if (project == null) {
return;
}
DocumentationManager docManager = DocumentationManager.getInstance(project);
docManager.setAllowContentUpdateFromContext(false);
docManager.showJavaDocInfoAtToolWindow(docAnchor, originalElement);
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:ShowQuickDocAtPinnedWindowFromTooltipAction.java
示例3: showHint
import com.intellij.codeInsight.documentation.DocumentationManager; //导入方法依赖的package包/类
public static void showHint(Project project) {
Course course = StudyTaskManager.getInstance(project).getCourse();
if (course == null) {
return;
}
StudyState studyState = new StudyState(StudyUtils.getSelectedStudyEditor(project));
if (!studyState.isValid()) {
return;
}
PsiFile file = PsiManager.getInstance(project).findFile(studyState.getVirtualFile());
final Editor editor = studyState.getEditor();
LogicalPosition pos = editor.getCaretModel().getLogicalPosition();
AnswerPlaceholder answerPlaceholder = studyState.getTaskFile().getAnswerPlaceholder(editor.getDocument(), pos);
if (file == null) {
return;
}
String hintText = ourWarningMessage;
if (answerPlaceholder != null) {
String hint = answerPlaceholder.getHint();
hintText = hint.isEmpty() ? HINT_NOT_AVAILABLE : hint;
}
int offset = editor.getDocument().getLineStartOffset(pos.line) + pos.column;
PsiElement element = file.findElementAt(offset);
DocumentationManager documentationManager = DocumentationManager.getInstance(project);
DocumentationComponent component = new DocumentationComponent(documentationManager);
component.setData(element != null ? element : file, element != null ? hintText : ourWarningMessage, true, null);
showHintPopUp(project, editor, component);
}
示例4: actionPerformed
import com.intellij.codeInsight.documentation.DocumentationManager; //导入方法依赖的package包/类
@Override
public void actionPerformed(AnActionEvent e) {
int selectedRow = myAttributesTable.getSelectedRow();
int selectedColumn = myAttributesTable.getSelectedColumn();
Object selectedItem = myAttributesTable.getValueAt(selectedRow, selectedColumn);
if (selectedItem == null || !(selectedItem instanceof EditedStyleItem)) {
// We can not display javadoc for this item.
return;
}
EditedStyleItem item = (EditedStyleItem)selectedItem;
Project project = e.getProject();
DocumentationManager documentationManager = DocumentationManager.getInstance(project);
final DocumentationComponent docComponent = new DocumentationComponent(documentationManager);
String tooltip = ThemeEditorUtils.generateToolTipText(item.getItemResourceValue(), myContext.getCurrentThemeModule(), myContext.getConfiguration());
docComponent.setText(tooltip, e.getData(CommonDataKeys.PSI_FILE), true);
JBPopup hint = JBPopupFactory.getInstance().createComponentPopupBuilder(docComponent, docComponent).setProject(project)
.setDimensionServiceKey(project, DocumentationManager.JAVADOC_LOCATION_AND_SIZE, false).setResizable(true).setMovable(true)
.setRequestFocus(true).setTitle(item.getName()).setCancelCallback(new Computable<Boolean>() {
@Override
public Boolean compute() {
Disposer.dispose(docComponent);
return Boolean.TRUE;
}
}).createPopup();
docComponent.setHint(hint);
Disposer.register(hint, docComponent);
hint.show(new RelativePoint(myAttributesTable.getParent(), ORIGIN));
}
示例5: doActionPerformed
import com.intellij.codeInsight.documentation.DocumentationManager; //导入方法依赖的package包/类
@Override
protected void doActionPerformed(@NotNull DataContext context, @NotNull PsiElement docAnchor, @NotNull PsiElement originalElement) {
Project project = PlatformDataKeys.PROJECT.getData(context);
if (project == null) {
return;
}
DocumentationManager docManager = DocumentationManager.getInstance(project);
docManager.setAllowContentUpdateFromContext(false);
docManager.showJavaDocInfoAtToolWindow(docAnchor, originalElement);
}
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:12,代码来源:ShowQuickDocAtPinnedWindowFromTooltipAction.java
示例6: doActionPerformed
import com.intellij.codeInsight.documentation.DocumentationManager; //导入方法依赖的package包/类
@Override
protected void doActionPerformed(@Nonnull DataContext context, @Nonnull PsiElement docAnchor, @Nonnull PsiElement originalElement) {
Project project = context.getData(CommonDataKeys.PROJECT);
if (project == null) {
return;
}
DocumentationManager docManager = DocumentationManager.getInstance(project);
docManager.setAllowContentUpdateFromContext(false);
docManager.showJavaDocInfoAtToolWindow(docAnchor, originalElement);
}
示例7: actionPerformed
import com.intellij.codeInsight.documentation.DocumentationManager; //导入方法依赖的package包/类
public void actionPerformed(final AnActionEvent e) {
final PropertyInspectorTable inspector = PropertyInspectorTable.DATA_KEY.getData(e.getDataContext());
final IntrospectedProperty introspectedProperty = inspector.getSelectedIntrospectedProperty();
final PsiClass aClass = inspector.getComponentClass();
final PsiMethod getter = PropertyUtil.findPropertyGetter(aClass, introspectedProperty.getName(), false, true);
LOG.assertTrue(getter != null);
final PsiMethod setter = PropertyUtil.findPropertySetter(aClass, introspectedProperty.getName(), false, true);
LOG.assertTrue(setter != null);
final DocumentationManager documentationManager = DocumentationManager.getInstance(aClass.getProject());
final DocumentationComponent component1 = new DocumentationComponent(documentationManager);
final DocumentationComponent component2 = new DocumentationComponent(documentationManager);
final Disposable disposable = Disposer.newDisposable();
final TabbedPaneWrapper tabbedPane = new TabbedPaneWrapper(disposable);
tabbedPane.addTab(UIDesignerBundle.message("tab.getter"), component1);
tabbedPane.addTab(UIDesignerBundle.message("tab.setter"), component2);
documentationManager.fetchDocInfo(getter, component1);
documentationManager.queueFetchDocInfo(setter, component2).doWhenProcessed(new Runnable() {
public void run() {
final JBPopup hint =
JBPopupFactory.getInstance().createComponentPopupBuilder(tabbedPane.getComponent(), component1)
.setDimensionServiceKey(aClass.getProject(), DocumentationManager.JAVADOC_LOCATION_AND_SIZE, false)
.setResizable(true)
.setMovable(true)
.setRequestFocus(true)
.setTitle(UIDesignerBundle.message("property.javadoc.title", introspectedProperty.getName()))
.createPopup();
component1.setHint(hint);
component2.setHint(hint);
Disposer.register(hint, component1);
Disposer.register(hint, component2);
Disposer.register(hint, disposable);
hint.show(new RelativePoint(inspector, new Point(0,0)));
//component1.requestFocus();
}
});
}
示例8: actionPerformed
import com.intellij.codeInsight.documentation.DocumentationManager; //导入方法依赖的package包/类
@Override
public void actionPerformed(AnActionEvent e) {
final Project project = e.getProject();
if (project == null) {
return;
}
DocumentationManager documentationManager = DocumentationManager.getInstance(project);
final DocumentationComponent component = new DocumentationComponent(documentationManager);
final Property property = myTable.getSelectionProperty();
if (property == null) {
return;
}
PsiElement javadocElement = property.getJavadocElement();
ActionCallback callback;
if (javadocElement == null) {
callback = new ActionCallback();
component.setText(property.getJavadocText(), null, true);
}
else {
callback = documentationManager.queueFetchDocInfo(javadocElement, component);
}
callback.doWhenProcessed(new Runnable() {
public void run() {
JBPopup hint =
JBPopupFactory.getInstance().createComponentPopupBuilder(component, component)
.setRequestFocusCondition(project, NotLookupOrSearchCondition.INSTANCE)
.setProject(project)
.setDimensionServiceKey(project, DocumentationManager.JAVADOC_LOCATION_AND_SIZE, false)
.setResizable(true)
.setMovable(true)
.setRequestFocus(true)
.setTitle(DesignerBundle.message("designer.properties.javadoc.title", property.getName()))
.setCancelCallback(new Computable<Boolean>() {
@Override
public Boolean compute() {
Disposer.dispose(component);
return Boolean.TRUE;
}
})
.createPopup();
component.setHint(hint);
Disposer.register(hint, component);
hint.show(new RelativePoint(myTable.getParent(), new Point(0, 0)));
}
});
if (javadocElement == null) {
callback.setDone();
}
}
示例9: actionPerformed
import com.intellij.codeInsight.documentation.DocumentationManager; //导入方法依赖的package包/类
@Override
public void actionPerformed(AnActionEvent e) {
final Project project = e.getProject();
if (project == null) {
return;
}
DocumentationManager documentationManager = DocumentationManager.getInstance(project);
final DocumentationComponent component = new DocumentationComponent(documentationManager);
final Property property = myTable.getSelectionProperty();
if (property == null) {
return;
}
PsiElement javadocElement = property.getJavadocElement();
ActionCallback callback;
if (javadocElement == null) {
callback = new ActionCallback();
component.setText(property.getJavadocText(), null, true);
}
else {
callback = documentationManager.queueFetchDocInfo(javadocElement, component);
}
callback.doWhenProcessed(new Runnable() {
public void run() {
JBPopup hint =
JBPopupFactory.getInstance().createComponentPopupBuilder(component, component)
.setRequestFocusCondition(project, NotLookupOrSearchCondition.INSTANCE)
.setProject(project)
.setDimensionServiceKey(project, DocumentationManager.JAVADOC_LOCATION_AND_SIZE, false)
.setResizable(true)
.setMovable(true)
.setRequestFocus(true)
.setTitle(CordovaDesignerBundle.message("designer.properties.javadoc.title", property.getName()))
.setCancelCallback(new Computable<Boolean>() {
@Override
public Boolean compute() {
Disposer.dispose(component);
return Boolean.TRUE;
}
})
.createPopup();
component.setHint(hint);
Disposer.register(hint, component);
hint.show(new RelativePoint(myTable.getParent(), new Point(0, 0)));
}
});
if (javadocElement == null) {
callback.setDone();
}
}
示例10: actionPerformed
import com.intellij.codeInsight.documentation.DocumentationManager; //导入方法依赖的package包/类
@RequiredDispatchThread
@Override
public void actionPerformed(@NotNull final AnActionEvent e)
{
final PropertyInspectorTable inspector = e.getData(PropertyInspectorTable.DATA_KEY);
final IntrospectedProperty introspectedProperty = inspector.getSelectedIntrospectedProperty();
final PsiClass aClass = inspector.getComponentClass();
final PsiMethod getter = PropertyUtil.findPropertyGetter(aClass, introspectedProperty.getName(), false, true);
LOG.assertTrue(getter != null);
final PsiMethod setter = PropertyUtil.findPropertySetter(aClass, introspectedProperty.getName(), false, true);
LOG.assertTrue(setter != null);
final DocumentationManager documentationManager = DocumentationManager.getInstance(aClass.getProject());
final DocumentationComponent component1 = new DocumentationComponent(documentationManager);
final DocumentationComponent component2 = new DocumentationComponent(documentationManager);
final Disposable disposable = Disposer.newDisposable();
final TabbedPaneWrapper tabbedPane = new TabbedPaneWrapper(disposable);
tabbedPane.addTab(UIDesignerBundle.message("tab.getter"), component1);
tabbedPane.addTab(UIDesignerBundle.message("tab.setter"), component2);
documentationManager.fetchDocInfo(getter, component1);
documentationManager.queueFetchDocInfo(setter, component2).doWhenProcessed(new Runnable()
{
@Override
public void run()
{
final JBPopup hint = JBPopupFactory.getInstance().createComponentPopupBuilder(tabbedPane.getComponent(), component1).setDimensionServiceKey(aClass.getProject(), DocumentationManager
.JAVADOC_LOCATION_AND_SIZE, false).setResizable(true).setMovable(true).setRequestFocus(true).setTitle(UIDesignerBundle.message("property.javadoc.title", introspectedProperty
.getName())).createPopup();
component1.setHint(hint);
component2.setHint(hint);
Disposer.register(hint, component1);
Disposer.register(hint, component2);
Disposer.register(hint, disposable);
hint.show(new RelativePoint(inspector, new Point(0, 0)));
//component1.requestFocus();
}
});
}