use of com.intellij.psi.impl.FakePsiElement 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));
}
Aggregations