Java Code Examples for com.intellij.openapi.ui.popup.JBPopup#cancel()

The following examples show how to use com.intellij.openapi.ui.popup.JBPopup#cancel() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SearchUtil.java    From consulo with Apache License 2.0 6 votes vote down vote up
public static void showHintPopup(final ConfigurableSearchTextField searchField,
                                 final JBPopup[] activePopup,
                                 final Alarm showHintAlarm,
                                 final Consumer<String> selectConfigurable,
                                 final Project project) {
  for (JBPopup aPopup : activePopup) {
    if (aPopup != null) {
      aPopup.cancel();
    }
  }

  final JBPopup popup = createPopup(searchField, activePopup, showHintAlarm, selectConfigurable, project, 0); //no selection
  if (popup != null) {
    popup.showUnderneathOf(searchField);
    searchField.requestFocusInWindow();
  }

  activePopup[0] = popup;
  activePopup[1] = null;
}
 
Example 2
Source File: SetShortcutAction.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public void actionPerformed(@Nonnull AnActionEvent e) {
  Project project = e.getProject();
  JBPopup seDialog = project == null ? null : project.getUserData(SearchEverywhereManager.SEARCH_EVERYWHERE_POPUP);
  if (seDialog == null) {
    return;
  }

  KeymapManager km = KeymapManager.getInstance();
  Keymap activeKeymap = km != null ? km.getActiveKeymap() : null;
  if (activeKeymap == null) {
    return;
  }

  AnAction action = e.getData(SELECTED_ACTION);
  Component component = e.getData(PlatformDataKeys.CONTEXT_COMPONENT);
  if (action == null || component == null) {
    return;
  }

  seDialog.cancel();
  String id = ActionManager.getInstance().getId(action);
  KeymapPanel.addKeyboardShortcut(id, ActionShortcutRestrictions.getInstance().getForActionId(id), activeKeymap, component);
}
 
Example 3
Source File: SwingValidator.java    From consulo with Apache License 2.0 6 votes vote down vote up
public boolean validateValue(Component awtComponent, V value, boolean silence) {
  for (ValidableComponent.Validator<V> validator : myValidators) {
    ValidableComponent.ValidationInfo validationInfo = validator.validateValue(value);
    if (validationInfo != null) {
      if(!silence) {
        doShowPopup((JComponent)awtComponent, validationInfo);
      }
      return false;
    }
    else {
      JBPopup popup = SoftReference.dereference(myLastPopup);
      if(popup != null) {
        popup.cancel();
        myLastPopup = null;
      }
    }
  }
  return true;
}
 
Example 4
Source File: SearchUtil.java    From consulo with Apache License 2.0 5 votes vote down vote up
private static boolean cancelPopups(final JBPopup[] activePopup) {
  for (JBPopup popup : activePopup) {
    if (popup != null && popup.isVisible()) {
      popup.cancel();
      return true;
    }
  }
  return false;
}
 
Example 5
Source File: DocumentationManager.java    From consulo with Apache License 2.0 5 votes vote down vote up
private void closeDocHint() {
  JBPopup hint = getDocInfoHint();
  if (hint == null) {
    return;
  }
  myCloseOnSneeze = false;
  hint.cancel();
  Component toFocus = SoftReference.dereference(myFocusedBeforePopup);
  hint.cancel();
  if (toFocus != null) {
    IdeFocusManager.getInstance(myProject).requestFocus(toFocus, true);
  }
}
 
Example 6
Source File: DocumentationManager.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nullable
public JBPopup getDocInfoHint() {
  if (myDocInfoHintRef == null) return null;
  JBPopup hint = myDocInfoHintRef.get();
  if (hint == null || !hint.isVisible() && !ApplicationManager.getApplication().isUnitTestMode()) {
    if (hint != null) {
      // hint's window might've been hidden by AWT without notifying us
      // dispose to remove the popup from IDE hierarchy and avoid leaking components
      hint.cancel();
    }
    myDocInfoHintRef = null;
    return null;
  }
  return hint;
}
 
Example 7
Source File: DocumentationComponent.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void actionPerformed(@Nonnull AnActionEvent e) {
  super.actionPerformed(e);
  JBPopup hint = myHint;
  if (hint != null && hint.isVisible()) {
    hint.cancel();
  }
}
 
Example 8
Source File: QuickDocOnMouseOverManager.java    From consulo with Apache License 2.0 5 votes vote down vote up
private void closeQuickDocIfPossible() {
  myAlarm.cancelAllRequests();
  DocumentationManager docManager = getDocManager();
  if (docManager != null) {
    JBPopup hint = docManager.getDocInfoHint();
    if (hint != null) hint.cancel();
  }
}
 
Example 9
Source File: BookmarksAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void handleMnemonic(KeyEvent e, Project project, JBPopup popup) {
  char mnemonic = e.getKeyChar();
  final Bookmark bookmark = BookmarkManager.getInstance(project).findBookmarkForMnemonic(mnemonic);
  if (bookmark != null) {
    popup.cancel();
    IdeFocusManager.getInstance(project).doWhenFocusSettlesDown(new Runnable() {
      @Override
      public void run() {
        bookmark.navigate(true);
      }
    });
  }
}
 
Example 10
Source File: BookmarksAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void itemChosen(ItemWrapper item, Project project, JBPopup popup, boolean withEnterOrDoubleClick) {
  if (item instanceof BookmarkItem && withEnterOrDoubleClick) {
    Bookmark bookmark = ((BookmarkItem)item).getBookmark();
    popup.cancel();
    bookmark.navigate(true);
  }
}
 
Example 11
Source File: ShowUsagesAction.java    From consulo with Apache License 2.0 4 votes vote down vote up
private static void cancel(@Nullable JBPopup popup) {
  if (popup != null) {
    popup.cancel();
  }
}