Added prefix change listener for tracking state after char typing

This commit is contained in:
Yaroslav Lepenkin
2015-12-09 16:04:29 +03:00
parent 2ac8b74039
commit 8e5d71f7bf
2 changed files with 35 additions and 1 deletions
@@ -67,8 +67,10 @@ import javax.swing.event.ListSelectionListener;
import java.awt.*;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
import java.util.*;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class LookupImpl extends LightweightHint implements LookupEx, Disposable, WeighingContext {
private static final Logger LOG = Logger.getInstance("#com.intellij.codeInsight.lookup.impl.LookupImpl");
@@ -102,6 +104,7 @@ public class LookupImpl extends LightweightHint implements LookupEx, Disposable,
final LookupCellRenderer myCellRenderer;
private final List<LookupListener> myListeners = ContainerUtil.createLockFreeCopyOnWriteList();
private PrefixChangeListener myPrefixChangeListener = new PrefixChangeListener.Adapter() {};
private long myStampShown = 0;
private boolean myShown = false;
@@ -307,6 +310,7 @@ public class LookupImpl extends LightweightHint implements LookupEx, Disposable,
requestResize();
refreshUi(false, true);
ensureSelectionVisible(true);
myPrefixChangeListener.afterAppend(c);
}
public void setStartCompletionWhenNothingMatches(boolean startCompletionWhenNothingMatches) {
@@ -1158,6 +1162,10 @@ public class LookupImpl extends LightweightHint implements LookupEx, Disposable,
}
}
public void setPrefixChangeListener(PrefixChangeListener listener) {
myPrefixChangeListener = listener;
}
public enum FocusDegree { FOCUSED, SEMI_FOCUSED, UNFOCUSED }
}
@@ -0,0 +1,26 @@
/*
* Copyright 2000-2015 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.codeInsight.lookup.impl;
public interface PrefixChangeListener {
void afterAppend(char c);
abstract class Adapter implements PrefixChangeListener {
@Override
public void afterAppend(char c) {}
}
}