use of com.intellij.codeInsight.documentation.DocumentationComponent in project intellij-community by JetBrains.
the class ShowJavadoc method actionPerformed.
@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(() -> {
JBPopup hint = JBPopupFactory.getInstance().createComponentPopupBuilder(component, component).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(() -> {
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();
}
}
use of com.intellij.codeInsight.documentation.DocumentationComponent in project android by JetBrains.
the class ShowCustomIssueExplanationFix method apply.
@Override
public void apply(@NotNull PsiElement startElement, @NotNull PsiElement endElement, @NotNull AndroidQuickfixContexts.Context context) {
Project project = myElement.getProject();
DocumentationManager manager = DocumentationManager.getInstance(project);
DocumentationComponent component = new DocumentationComponent(manager);
component.setText("<html>" + myIssue.getExplanation(TextFormat.HTML) + "</html>", myElement, false);
JBPopup popup = JBPopupFactory.getInstance().createComponentPopupBuilder(component, component).setDimensionServiceKey(project, DocumentationManager.JAVADOC_LOCATION_AND_SIZE, false).setResizable(true).setMovable(true).setRequestFocus(true).createPopup();
component.setHint(popup);
if (context.getType() == AndroidQuickfixContexts.EditorContext.TYPE) {
popup.showInBestPositionFor(((AndroidQuickfixContexts.EditorContext) context).getEditor());
} else {
popup.showCenteredInCurrentWindow(project);
}
Disposer.dispose(component);
}
use of com.intellij.codeInsight.documentation.DocumentationComponent in project android by JetBrains.
the class ShowJavadocAction method actionPerformed.
@Override
public void actionPerformed(ActionEvent e) {
EditedStyleItem item = myCurrentItem;
if (item == null) {
return;
}
Project project = myContext.getProject();
DocumentationManager documentationManager = DocumentationManager.getInstance(project);
final DocumentationComponent docComponent = new DocumentationComponent(documentationManager);
String tooltip = ThemeEditorUtils.generateToolTipText(item.getSelectedValue(), myContext.getCurrentContextModule(), myContext.getConfiguration());
// images will not work unless we pass a valid PsiElement {@link DocumentationComponent#myImageProvider}
docComponent.setText(tooltip, new FakePsiElement() {
@Override
public boolean isValid() {
// this needs to return true for the DocumentationComponent to accept this PsiElement {@link DocumentationComponent#setData(PsiElement, String, boolean, String, String)}
return true;
}
@NotNull
@Override
public Project getProject() {
// superclass implementation throws an exception
return myContext.getProject();
}
@Override
public PsiElement getParent() {
return null;
}
@Override
public PsiFile getContainingFile() {
// superclass implementation throws an exception
return null;
}
}, 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));
}
use of com.intellij.codeInsight.documentation.DocumentationComponent in project intellij-community by JetBrains.
the class ShowJavadocAction method actionPerformed.
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(() -> {
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();
});
}
Aggregations