summaryrefslogtreecommitdiff
path: root/platform/platform-api/src/com/intellij/ui/JBListWithHintProvider.java
diff options
context:
space:
mode:
Diffstat (limited to 'platform/platform-api/src/com/intellij/ui/JBListWithHintProvider.java')
-rw-r--r--platform/platform-api/src/com/intellij/ui/JBListWithHintProvider.java64
1 files changed, 22 insertions, 42 deletions
diff --git a/platform/platform-api/src/com/intellij/ui/JBListWithHintProvider.java b/platform/platform-api/src/com/intellij/ui/JBListWithHintProvider.java
index 5ef516210e0d..f859421bbbee 100644
--- a/platform/platform-api/src/com/intellij/ui/JBListWithHintProvider.java
+++ b/platform/platform-api/src/com/intellij/ui/JBListWithHintProvider.java
@@ -18,79 +18,59 @@ package com.intellij.ui;
import com.intellij.openapi.ui.popup.JBPopup;
import com.intellij.psi.PsiElement;
import com.intellij.ui.components.JBList;
-import com.intellij.ui.popup.PopupUpdateProcessorBase;
+import com.intellij.ui.popup.HintUpdateSupply;
+import com.intellij.util.ObjectUtils;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
-import javax.swing.event.ListSelectionEvent;
-import javax.swing.event.ListSelectionListener;
import java.util.Collection;
/**
* @author pegov
+ * @deprecated
+ * @see com.intellij.ui.popup.HintUpdateSupply
*/
public abstract class JBListWithHintProvider extends JBList {
- private JBPopup myHint;
+ {
+ new HintUpdateSupply(this) {
+ @Override
+ protected PsiElement getPsiElementForHint(Object selectedValue) {
+ return JBListWithHintProvider.this.getPsiElementForHint(selectedValue);
+ }
+ };
+ }
public JBListWithHintProvider() {
- addSelectionListener();
}
public JBListWithHintProvider(ListModel dataModel) {
super(dataModel);
- addSelectionListener();
}
public JBListWithHintProvider(Object... listData) {
super(listData);
- addSelectionListener();
}
public JBListWithHintProvider(Collection items) {
super(items);
- addSelectionListener();
}
- private void addSelectionListener() {
- addListSelectionListener(new ListSelectionListener() {
- @Override
- public void valueChanged(final ListSelectionEvent e) {
- if (getClientProperty(ListUtil.SELECTED_BY_MOUSE_EVENT) != Boolean.TRUE) {
- final Object[] selectedValues = ((JList)e.getSource()).getSelectedValues();
- if (selectedValues.length != 1) return;
-
- final PsiElement element = getPsiElementForHint(selectedValues[0]);
- if (element != null && element.isValid()) {
- updateHint(element);
- }
- }
- }
- });
- }
-
@Nullable
protected abstract PsiElement getPsiElementForHint(final Object selectedValue);
- public void registerHint(final JBPopup hint) {
- hideHint();
- myHint = hint;
+ @Deprecated
+ public void registerHint(JBPopup hint) {
+ ObjectUtils.assertNotNull(HintUpdateSupply.getSupply(this)).registerHint(hint);
}
-
- public void hideHint() {
- if (myHint != null && myHint.isVisible()) {
- myHint.cancel();
- }
- myHint = null;
+ @Deprecated
+ public void hideHint() {
+ ObjectUtils.assertNotNull(HintUpdateSupply.getSupply(this)).hideHint();
}
-
- public void updateHint(PsiElement element) {
- if (myHint == null || !myHint.isVisible()) return;
- final PopupUpdateProcessorBase updateProcessor = myHint.getUserData(PopupUpdateProcessorBase.class);
- if (updateProcessor != null) {
- updateProcessor.updatePopup(element);
- }
+ @Deprecated
+ public void updateHint(PsiElement element) {
+ ObjectUtils.assertNotNull(HintUpdateSupply.getSupply(this)).updateHint(element);
}
-
+
}