Example usage for com.intellij.openapi.ui.popup ListPopup cancel

List of usage examples for com.intellij.openapi.ui.popup ListPopup cancel

Introduction

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

Prototype

void cancel();

Source Link

Document

Cancels the popup as if Esc was pressed or any other "cancel" action.

Usage

From source file:com.intellij.debugger.ui.DebuggerEditorImpl.java

License:Apache License

public DebuggerEditorImpl(Project project, PsiElement context, String recentsId,
        final CodeFragmentFactory factory) {
    myProject = project;/*from w ww .  j a v a  2  s  . c  o m*/
    myContext = context;
    myRecentsId = recentsId;
    PsiManager.getInstance(project).addPsiTreeChangeListener(myPsiListener);
    setFactory(factory);
    myInitialFactory = true;

    setFocusable(false);

    myChooseFactory.setToolTipText("Click to change the language");
    myChooseFactory.setBorder(new EmptyBorder(0, 3, 0, 3));
    new ClickListener() {
        @Override
        public boolean onClick(@NotNull MouseEvent e, int clickCount) {
            ListPopup oldPopup = SoftReference.dereference(myPopup);
            if (oldPopup != null && !oldPopup.isDisposed()) {
                oldPopup.cancel();
                myPopup = null;
                return true;
            }

            if (myContext == null) {
                return true;
            }

            ListPopup popup = createLanguagePopup();
            popup.showUnderneathOf(myChooseFactory);
            myPopup = new WeakReference<ListPopup>(popup);
            return true;
        }
    }.installOn(myChooseFactory);
}

From source file:com.intellij.xdebugger.impl.ui.XDebuggerEditorBase.java

License:Apache License

protected XDebuggerEditorBase(final Project project, @NotNull XDebuggerEditorsProvider debuggerEditorsProvider,
        @NotNull EvaluationMode mode, @Nullable @NonNls String historyId,
        final @Nullable XSourcePosition sourcePosition) {
    myProject = project;// ww  w. j  a  v  a2  s  . c  om
    myDebuggerEditorsProvider = debuggerEditorsProvider;
    myMode = mode;
    myHistoryId = historyId;
    mySourcePosition = sourcePosition;

    myChooseFactory.setToolTipText("Click to change the language");
    myChooseFactory.setBorder(new EmptyBorder(0, 3, 0, 3));
    new ClickListener() {
        @Override
        public boolean onClick(@NotNull MouseEvent e, int clickCount) {
            ListPopup oldPopup = SoftReference.dereference(myPopup);
            if (oldPopup != null && !oldPopup.isDisposed()) {
                oldPopup.cancel();
                myPopup = null;
                return true;
            }
            ListPopup popup = createLanguagePopup();
            popup.showUnderneathOf(myChooseFactory);
            myPopup = new WeakReference<ListPopup>(popup);
            return true;
        }
    }.installOn(myChooseFactory);
}

From source file:net.groboclown.idea.p4ic.ui.P4MultipleConnectionWidget.java

License:Apache License

private void showPopup(@NotNull MouseEvent event) {
    // it isn't getting bubbled up to the parent
    DataContext dataContext = getContext();
    final ListPopup popup = createListPopup(dataContext);
    if (popup.isVisible()) {
        popup.cancel();
        return;/*from  w  w  w.  j  a  v a2  s.  co m*/
    }
    final Dimension dimension = popup.getContent().getPreferredSize();
    final Point at = new Point(0, -dimension.height);
    popup.show(new RelativePoint(event.getComponent(), at));
    Disposer.register(this, popup); // destroy popup on unexpected project close
}