more functionality in platform-api

This commit is contained in:
Konstantin Bulenkov
2012-01-05 17:23:50 +01:00
parent 5d19700bda
commit 4afd958e3a
2 changed files with 31 additions and 9 deletions
@@ -23,21 +23,44 @@ import org.jetbrains.annotations.Nullable;
import javax.swing.*;
/**
* User: spLeaner
* @author spLeaner
* @author Konstantin Bulenkov
*/
public abstract class SpeedSearchSupply {
protected static final Key SPEED_SEARCH_COMPONENT_MARKER = new Key("SPEED_SEARCH_COMPONENT_MARKER");
private static final Key SPEED_SEARCH_COMPONENT_MARKER = new Key("SPEED_SEARCH_COMPONENT_MARKER");
@Nullable
public static SpeedSearchSupply getSupply(@NotNull final JComponent speedSearchEnabledComponent) {
SpeedSearchSupply speedSearch = (SpeedSearchSupply) speedSearchEnabledComponent.getClientProperty(SPEED_SEARCH_COMPONENT_MARKER);
return speedSearch != null && speedSearch.isPopupActive() ? speedSearch : null;
public static SpeedSearchSupply getSupply(@NotNull final JComponent component) {
return getSupply(component, false);
}
@Nullable
public static SpeedSearchSupply getSupply(@NotNull final JComponent component, boolean evenIfInactive) {
SpeedSearchSupply speedSearch = (SpeedSearchSupply)component.getClientProperty(SPEED_SEARCH_COMPONENT_MARKER);
if (evenIfInactive) {
return speedSearch;
}
return speedSearch != null && speedSearch.isPopupActive() ? speedSearch : null;
}
@Nullable
public abstract Iterable<TextRange> matchingFragments(@NotNull final String text);
/**
* Selects element according to search criteria changes
*/
public abstract void refreshSelection();
public abstract boolean isPopupActive();
@Nullable
public abstract Iterable<TextRange> matchingFragments(@NotNull final String text);
public String getEnteredPrefix() {
return null;
}
protected void installSupplyTo(JComponent component) {
component.putClientProperty(SPEED_SEARCH_COMPONENT_MARKER, this);
}
}
@@ -78,12 +78,11 @@ public abstract class SpeedSearchBase<Comp extends JComponent> extends SpeedSear
}
});
component.putClientProperty(SPEED_SEARCH_COMPONENT_MARKER, this);
installSupplyTo(component);
}
public static boolean hasActiveSpeedSearch(JComponent component) {
SpeedSearchBase speedSearch = (SpeedSearchBase)component.getClientProperty(SPEED_SEARCH_COMPONENT_MARKER);
return speedSearch != null && speedSearch.mySearchPopup != null && speedSearch.mySearchPopup.isVisible();
return getSupply(component) != null;
}
public void setClearSearchOnNavigateNoMatch(boolean clearSearchOnNavigateNoMatch) {