Example usage for com.intellij.openapi.ui.popup LightweightWindowEvent asPopup

List of usage examples for com.intellij.openapi.ui.popup LightweightWindowEvent asPopup

Introduction

In this page you can find the example usage for com.intellij.openapi.ui.popup LightweightWindowEvent asPopup.

Prototype

@NotNull
    public JBPopup asPopup() 

Source Link

Usage

From source file:com.android.tools.idea.uibuilder.handlers.constraint.WidgetNavigatorPanel.java

License:Apache License

@Override
public void beforeShown(LightweightWindowEvent event) {
    myContainerPopup = event.asPopup();
}

From source file:com.intellij.ui.popup.PopupUpdateProcessor.java

License:Apache License

@Override
public void beforeShown(final LightweightWindowEvent windowEvent) {
    final Lookup activeLookup = LookupManager.getInstance(myProject).getActiveLookup();
    if (activeLookup != null) {
        activeLookup.addLookupListener(new LookupAdapter() {
            @Override//  www.ja va2 s  . co  m
            public void currentItemChanged(LookupEvent event) {
                if (windowEvent.asPopup().isVisible()) { //was not canceled yet
                    final LookupElement item = event.getItem();
                    if (item != null) {
                        PsiElement targetElement = CompletionUtil.getTargetElement(item);
                        if (targetElement == null) {
                            targetElement = DocumentationManager.getInstance(myProject)
                                    .getElementFromLookup(activeLookup.getEditor(), activeLookup.getPsiFile());
                        }

                        updatePopup(targetElement); //open next
                    }
                } else {
                    activeLookup.removeLookupListener(this);
                }
            }
        });
    } else {
        final Component focusedComponent = WindowManagerEx.getInstanceEx().getFocusedComponent(myProject);
        boolean fromQuickSearch = focusedComponent != null
                && focusedComponent.getParent() instanceof ChooseByNameBase.JPanelProvider;
        if (fromQuickSearch) {
            ChooseByNameBase.JPanelProvider panelProvider = (ChooseByNameBase.JPanelProvider) focusedComponent
                    .getParent();
            panelProvider.registerHint(windowEvent.asPopup());
        } else if (focusedComponent != null) {
            if (focusedComponent instanceof JBListWithHintProvider) {
                ((JBListWithHintProvider) focusedComponent).registerHint(windowEvent.asPopup());
            } else if (focusedComponent instanceof JBTableWithHintProvider) {
                ((JBTableWithHintProvider) focusedComponent).registerHint(windowEvent.asPopup());
            } else if (focusedComponent instanceof JBTreeWithHintProvider) {
                ((JBTreeWithHintProvider) focusedComponent).registerHint(windowEvent.asPopup());
            }
        }
    }
}