[platform]: ability to switch off statistics in listPopup autoselection

* (IDEA-166730) Switch off statistics for BranchPopup;
This commit is contained in:
Nadya Zabrodina
2017-01-18 16:02:00 +03:00
parent e2175e5239
commit dc177357f6
2 changed files with 29 additions and 14 deletions
@@ -146,6 +146,11 @@ public class BranchActionGroupPopup extends FlatSpeedSearchPopup {
ScrollingUtil.ensureSelectionExists(getList());
}
@Override
protected boolean shouldUseStatistics() {
return false;
}
protected boolean shouldBeShowing(@NotNull AnAction action) {
if (!super.shouldBeShowing(action)) return false;
if (getSpeedSearch().isHoldingFilter()) return !(action instanceof MoreAction);
@@ -156,6 +156,10 @@ public class ListPopupImpl extends WizardPopup implements ListPopup {
return false;
}
protected boolean shouldUseStatistics() {
return true;
}
private boolean autoSelectUsingStatistics() {
final String filter = getSpeedSearch().getFilter();
if (!StringUtil.isEmpty(filter)) {
@@ -405,11 +409,13 @@ public class ListPopupImpl extends WizardPopup implements ListPopup {
}
private void valuesSelected(final Object[] values) {
final String filter = getSpeedSearch().getFilter();
if (!StringUtil.isEmpty(filter)) {
for (Object value : values) {
final String text = getListStep().getTextFor(value);
StatisticsManager.getInstance().incUseCount(new StatisticsInfo("#list_popup:" + getListStep().getTitle() + "#" + filter, text));
if (shouldUseStatistics()) {
final String filter = getSpeedSearch().getFilter();
if (!StringUtil.isEmpty(filter)) {
for (Object value : values) {
final String text = getListStep().getTextFor(value);
StatisticsManager.getInstance().incUseCount(new StatisticsInfo("#list_popup:" + getListStep().getTitle() + "#" + filter, text));
}
}
}
}
@@ -588,19 +594,23 @@ public class ListPopupImpl extends WizardPopup implements ListPopup {
protected void onSpeedSearchPatternChanged() {
myListModel.refilter();
if (myListModel.getSize() > 0) {
if (!autoSelectUsingStatistics()) {
int fullMatchIndex = myListModel.getClosestMatchIndex();
if (fullMatchIndex != -1) {
myList.setSelectedIndex(fullMatchIndex);
}
if (myListModel.getSize() <= myList.getSelectedIndex() || !myListModel.isVisible(myList.getSelectedValue())) {
myList.setSelectedIndex(0);
}
if (!(shouldUseStatistics() && autoSelectUsingStatistics())) {
selectBestMatch();
}
}
}
private void selectBestMatch() {
int fullMatchIndex = myListModel.getClosestMatchIndex();
if (fullMatchIndex != -1) {
myList.setSelectedIndex(fullMatchIndex);
}
if (myListModel.getSize() <= myList.getSelectedIndex() || !myListModel.isVisible(myList.getSelectedValue())) {
myList.setSelectedIndex(0);
}
}
@Override
protected void onSelectByMnemonic(Object value) {
if (myListModel.isVisible(value)) {