Search in sources :

Example 6 with ComponentPopupBuilder

use of com.intellij.openapi.ui.popup.ComponentPopupBuilder in project intellij-community by JetBrains.

the class MultilinePopupBuilder method createPopup.

@NotNull
JBPopup createPopup() {
    JPanel panel = new JPanel(new BorderLayout());
    panel.add(myTextField, BorderLayout.CENTER);
    ComponentPopupBuilder builder = JBPopupFactory.getInstance().createComponentPopupBuilder(panel, myTextField).setCancelOnClickOutside(true).setAdText(KeymapUtil.getShortcutsText(CommonShortcuts.CTRL_ENTER.getShortcuts()) + " to finish").setRequestFocus(true).setResizable(true).setMayBeParent(true);
    final JBPopup popup = builder.createPopup();
    popup.setMinimumSize(new JBDimension(200, 90));
    AnAction okAction = new DumbAwareAction() {

        @Override
        public void actionPerformed(@NotNull AnActionEvent e) {
            unregisterCustomShortcutSet(popup.getContent());
            popup.closeOk(e.getInputEvent());
        }
    };
    okAction.registerCustomShortcutSet(CommonShortcuts.CTRL_ENTER, popup.getContent());
    return popup;
}
Also used : ComponentPopupBuilder(com.intellij.openapi.ui.popup.ComponentPopupBuilder) JBDimension(com.intellij.util.ui.JBDimension) JBPopup(com.intellij.openapi.ui.popup.JBPopup) AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) AnAction(com.intellij.openapi.actionSystem.AnAction) DumbAwareAction(com.intellij.openapi.project.DumbAwareAction) NotNull(org.jetbrains.annotations.NotNull) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

ComponentPopupBuilder (com.intellij.openapi.ui.popup.ComponentPopupBuilder)6 JBPopup (com.intellij.openapi.ui.popup.JBPopup)4 AnAction (com.intellij.openapi.actionSystem.AnAction)2 AnActionEvent (com.intellij.openapi.actionSystem.AnActionEvent)2 Project (com.intellij.openapi.project.Project)2 IdeFrameImpl (com.intellij.openapi.wm.impl.IdeFrameImpl)2 RelativePoint (com.intellij.ui.awt.RelativePoint)2 HintManager (com.intellij.codeInsight.hint.HintManager)1 ImplementationViewComponent (com.intellij.codeInsight.hint.ImplementationViewComponent)1 CoverageDataManager (com.intellij.coverage.CoverageDataManager)1 CoverageSuite (com.intellij.coverage.CoverageSuite)1 CoverageSuitesBundle (com.intellij.coverage.CoverageSuitesBundle)1 PropertiesComponent (com.intellij.ide.util.PropertiesComponent)1 com.intellij.openapi.actionSystem (com.intellij.openapi.actionSystem)1 Logger (com.intellij.openapi.diagnostic.Logger)1 Editor (com.intellij.openapi.editor.Editor)1 ProgressManager (com.intellij.openapi.progress.ProgressManager)1 DumbAwareAction (com.intellij.openapi.project.DumbAwareAction)1 DumbService (com.intellij.openapi.project.DumbService)1 PanelWithText (com.intellij.openapi.ui.PanelWithText)1