IDEA-66333 Quick documentation lookup on mouse hover

Don't overwrite documentation for the element under cursor by documentation for the element under caret
This commit is contained in:
Denis.Zhdanov
2012-07-05 13:09:21 +04:00
parent 9ff53a0814
commit 6ab806079d
3 changed files with 29 additions and 7 deletions
@@ -150,7 +150,7 @@ public abstract class DockablePopupManager<T extends JComponent & Disposable> {
if (myAutoUpdateRequest == null) {
myAutoUpdateRequest = new Runnable() {
public void run() {
if (myProject.isDisposed()) return;
if (!myAutoUpdateDocumentation || myProject.isDisposed()) return;
AsyncResult<DataContext> asyncResult = DataManager.getInstance().getDataContextFromFocus();
DataContext dataContext = asyncResult.getResult();
@@ -175,6 +175,10 @@ public class DocumentationManager extends DockablePopupManager<DocumentationComp
return myToolWindow != null;
}
public void setAllowContentUpdateFromContext(boolean allow) {
myAutoUpdateDocumentation = allow;
}
/**
* Asks to show quick doc for the target element.
*
@@ -211,6 +211,7 @@ public class QuickDocOnMouseOverManager {
{
return;
}
allowUpdateFromContext(false);
closeQuickDocIfPossible();
myActiveElements.put(editor, targetElementUnderMouse);
myDelayedQuickDocInfo = new DelayedQuickDocInfo(documentationManager, editor, targetElementUnderMouse, elementUnderMouse);
@@ -221,12 +222,7 @@ public class QuickDocOnMouseOverManager {
private void closeQuickDocIfPossible() {
myAlarm.cancelAllRequests();
WeakReference<DocumentationManager> ref = myDocumentationManager;
if (ref == null) {
return;
}
DocumentationManager docManager = ref.get();
DocumentationManager docManager = getDocManager();
if (docManager == null) {
return;
}
@@ -240,6 +236,27 @@ public class QuickDocOnMouseOverManager {
myDocumentationManager = null;
}
private void allowUpdateFromContext(boolean allow) {
DocumentationManager documentationManager = getDocManager();
if (documentationManager != null) {
documentationManager.setAllowContentUpdateFromContext(allow);
}
}
@Nullable
private DocumentationManager getDocManager() {
WeakReference<DocumentationManager> ref = myDocumentationManager;
if (ref == null) {
return null;
}
DocumentationManager docManager = ref.get();
if (docManager == null) {
return null;
}
return docManager;
}
private static class DelayedQuickDocInfo {
@NotNull public final DocumentationManager docManager;
@@ -333,6 +350,7 @@ public class QuickDocOnMouseOverManager {
private class MyCaretListener implements CaretListener {
@Override
public void caretPositionChanged(CaretEvent e) {
allowUpdateFromContext(true);
closeQuickDocIfPossible();
}
}