diff --git a/platform/lang-impl/src/com/intellij/ui/popup/PopupUpdateProcessor.java b/platform/lang-impl/src/com/intellij/ui/popup/PopupUpdateProcessor.java index cedb27689301..a6af606ec2d5 100644 --- a/platform/lang-impl/src/com/intellij/ui/popup/PopupUpdateProcessor.java +++ b/platform/lang-impl/src/com/intellij/ui/popup/PopupUpdateProcessor.java @@ -21,7 +21,6 @@ import com.intellij.codeInsight.documentation.DocumentationManager; import com.intellij.codeInsight.lookup.*; import com.intellij.ide.util.gotoByName.ChooseByNameBase; import com.intellij.openapi.project.Project; -import com.intellij.openapi.ui.popup.JBPopupAdapter; import com.intellij.openapi.ui.popup.LightweightWindowEvent; import com.intellij.openapi.wm.ex.WindowManagerEx; import com.intellij.psi.PsiElement; @@ -34,7 +33,7 @@ import java.awt.*; /** * @author yole */ -public abstract class PopupUpdateProcessor extends JBPopupAdapter { +public abstract class PopupUpdateProcessor extends PopupUpdateProcessorBase { private final Project myProject; @@ -43,8 +42,6 @@ public abstract class PopupUpdateProcessor extends JBPopupAdapter { } - public abstract void updatePopup(Object lookupItemObject); - public void beforeShown(final LightweightWindowEvent windowEvent) { final Lookup activeLookup = LookupManager.getInstance(myProject).getActiveLookup(); if (activeLookup != null) { diff --git a/platform/lang-impl/src/com/intellij/ui/JBListWithHintProvider.java b/platform/platform-api/src/com/intellij/ui/JBListWithHintProvider.java similarity index 90% rename from platform/lang-impl/src/com/intellij/ui/JBListWithHintProvider.java rename to platform/platform-api/src/com/intellij/ui/JBListWithHintProvider.java index ac7290b6374b..0a52f814e03e 100644 --- a/platform/lang-impl/src/com/intellij/ui/JBListWithHintProvider.java +++ b/platform/platform-api/src/com/intellij/ui/JBListWithHintProvider.java @@ -4,7 +4,8 @@ import com.intellij.openapi.ui.popup.JBPopup; import com.intellij.openapi.ui.popup.PopupChooserBuilder; import com.intellij.psi.PsiElement; import com.intellij.ui.components.JBList; -import com.intellij.ui.popup.PopupUpdateProcessor; +import com.intellij.ui.popup.PopupUpdateProcessorBase; +import org.jetbrains.annotations.Nullable; import javax.swing.*; import javax.swing.event.ListSelectionEvent; @@ -53,6 +54,7 @@ public abstract class JBListWithHintProvider extends JBList { }); } + @Nullable protected abstract PsiElement getPsiElementForHint(final Object selectedValue); public void registerHint(final JBPopup hint) { @@ -71,7 +73,7 @@ public abstract class JBListWithHintProvider extends JBList { public void updateHint(PsiElement element) { if (myHint == null || !myHint.isVisible()) return; - final PopupUpdateProcessor updateProcessor = myHint.getUserData(PopupUpdateProcessor.class); + final PopupUpdateProcessorBase updateProcessor = myHint.getUserData(PopupUpdateProcessorBase.class); if (updateProcessor != null) { updateProcessor.updatePopup(element); } diff --git a/platform/platform-api/src/com/intellij/ui/popup/PopupUpdateProcessorBase.java b/platform/platform-api/src/com/intellij/ui/popup/PopupUpdateProcessorBase.java new file mode 100644 index 000000000000..39ca27864d7c --- /dev/null +++ b/platform/platform-api/src/com/intellij/ui/popup/PopupUpdateProcessorBase.java @@ -0,0 +1,26 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.ui.popup; + +import com.intellij.openapi.ui.popup.JBPopupAdapter; + +/** + * User: anna + * Date: 12/19/12 + */ +public abstract class PopupUpdateProcessorBase extends JBPopupAdapter { + public abstract void updatePopup(Object lookupItemObject); +} diff --git a/platform/platform-impl/src/com/intellij/ui/popup/PopupDispatcher.java b/platform/platform-impl/src/com/intellij/ui/popup/PopupDispatcher.java index 9d3577eb5351..c40fd91db992 100644 --- a/platform/platform-impl/src/com/intellij/ui/popup/PopupDispatcher.java +++ b/platform/platform-impl/src/com/intellij/ui/popup/PopupDispatcher.java @@ -118,9 +118,7 @@ public class PopupDispatcher implements AWTEventListener, KeyEventDispatcher, Id if (ourShowingStep == null) { return false; } - ourShowingStep.dispatch(e); - - return true; + return ourShowingStep.dispatch(e); } public static void setShowing(WizardPopup aBaseWizardPopup) { diff --git a/platform/platform-impl/src/com/intellij/ui/popup/WizardPopup.java b/platform/platform-impl/src/com/intellij/ui/popup/WizardPopup.java index e53ab61a63ce..8c53143f14a5 100644 --- a/platform/platform-impl/src/com/intellij/ui/popup/WizardPopup.java +++ b/platform/platform-impl/src/com/intellij/ui/popup/WizardPopup.java @@ -331,27 +331,27 @@ public abstract class WizardPopup extends AbstractPopup implements ActionListene return myStep; } - public final void dispatch(KeyEvent event) { + public final boolean dispatch(KeyEvent event) { if (event.getID() != KeyEvent.KEY_PRESSED && event.getID() != KeyEvent.KEY_RELEASED) { - return; + return false; } if (event.getID() == KeyEvent.KEY_PRESSED) { final KeyStroke stroke = KeyStroke.getKeyStroke(event.getKeyCode(), event.getModifiers(), false); - if (proceedKeyEvent(event, stroke)) return; + if (proceedKeyEvent(event, stroke)) return false; } if (event.getID() == KeyEvent.KEY_RELEASED) { final KeyStroke stroke = KeyStroke.getKeyStroke(event.getKeyCode(), event.getModifiers(), true); - proceedKeyEvent(event, stroke); - return; + return proceedKeyEvent(event, stroke); } myMnemonicsSearch.process(event); mySpeedSearch.process(event); - if (event.isConsumed()) return; + if (event.isConsumed()) return true; process(event); + return event.isConsumed(); } private boolean proceedKeyEvent(KeyEvent event, KeyStroke stroke) { diff --git a/platform/platform-impl/src/com/intellij/ui/popup/list/ListPopupImpl.java b/platform/platform-impl/src/com/intellij/ui/popup/list/ListPopupImpl.java index 35e4a62af26c..4087b20de37d 100644 --- a/platform/platform-impl/src/com/intellij/ui/popup/list/ListPopupImpl.java +++ b/platform/platform-impl/src/com/intellij/ui/popup/list/ListPopupImpl.java @@ -24,11 +24,12 @@ import com.intellij.openapi.ui.popup.ListPopupStep; import com.intellij.openapi.ui.popup.MultiSelectionListPopupStep; import com.intellij.openapi.ui.popup.PopupStep; import com.intellij.openapi.util.text.StringUtil; +import com.intellij.psi.PsiElement; import com.intellij.psi.statistics.StatisticsInfo; import com.intellij.psi.statistics.StatisticsManager; +import com.intellij.ui.JBListWithHintProvider; import com.intellij.ui.ListScrollingUtil; import com.intellij.ui.SeparatorWithText; -import com.intellij.ui.components.JBList; import com.intellij.ui.popup.ClosableByLeftArrow; import com.intellij.ui.popup.WizardPopup; import com.intellij.util.ui.UIUtil; @@ -474,11 +475,16 @@ public class ListPopupImpl extends WizardPopup implements ListPopup { myIndexForShowingChild = aIndexForShowingChild; } - private class MyList extends JBList implements DataProvider{ + private class MyList extends JBListWithHintProvider implements DataProvider { public MyList() { super(myListModel); } + @Override + protected PsiElement getPsiElementForHint(Object selectedValue) { + return selectedValue instanceof PsiElement ? (PsiElement)selectedValue : null; + } + @Override public Dimension getPreferredScrollableViewportSize() { return new Dimension(super.getPreferredScrollableViewportSize().width, getPreferredSize().height);