Search in sources :

Example 6 with JBPopupFactory

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

the class GotoCustomRegionAction method notifyCustomRegionsUnavailable.

private static void notifyCustomRegionsUnavailable(@NotNull Editor editor, @NotNull Project project) {
    final JBPopupFactory popupFactory = JBPopupFactory.getInstance();
    Balloon balloon = popupFactory.createHtmlTextBalloonBuilder(IdeBundle.message("goto.custom.region.message.unavailable"), MessageType.INFO, null).setFadeoutTime(2000).setHideOnClickOutside(true).setHideOnKeyOutside(true).createBalloon();
    Disposer.register(project, balloon);
    balloon.show(popupFactory.guessBestPopupLocation(editor), Balloon.Position.below);
}
Also used : JBPopupFactory(com.intellij.openapi.ui.popup.JBPopupFactory) Balloon(com.intellij.openapi.ui.popup.Balloon)

Example 7 with JBPopupFactory

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

the class InplaceRefactoring method showBalloon.

protected void showBalloon() {
    final JComponent component = getComponent();
    if (component == null)
        return;
    if (ApplicationManager.getApplication().isHeadlessEnvironment())
        return;
    final BalloonBuilder balloonBuilder = JBPopupFactory.getInstance().createDialogBalloonBuilder(component, null).setSmallVariant(true);
    myBalloon = balloonBuilder.createBalloon();
    Disposer.register(myProject, myBalloon);
    Disposer.register(myBalloon, new Disposable() {

        @Override
        public void dispose() {
            releaseIfNotRestart();
            myEditor.putUserData(PopupFactoryImpl.ANCHOR_POPUP_POSITION, null);
        }
    });
    EditorUtil.disposeWithEditor(myEditor, myBalloon);
    myEditor.getScrollingModel().scrollToCaret(ScrollType.MAKE_VISIBLE);
    final JBPopupFactory popupFactory = JBPopupFactory.getInstance();
    myBalloon.show(new PositionTracker<Balloon>(myEditor.getContentComponent()) {

        @Override
        public RelativePoint recalculateLocation(Balloon object) {
            if (myTarget != null && !popupFactory.isBestPopupLocationVisible(myEditor)) {
                return myTarget;
            }
            if (myCaretRangeMarker != null && myCaretRangeMarker.isValid()) {
                myEditor.putUserData(PopupFactoryImpl.ANCHOR_POPUP_POSITION, myEditor.offsetToVisualPosition(myCaretRangeMarker.getStartOffset()));
            }
            final RelativePoint target = popupFactory.guessBestPopupLocation(myEditor);
            final Point screenPoint = target.getScreenPoint();
            int y = screenPoint.y;
            if (target.getPoint().getY() > myEditor.getLineHeight() + myBalloon.getPreferredSize().getHeight()) {
                y -= myEditor.getLineHeight();
            }
            myTarget = new RelativePoint(new Point(screenPoint.x, y));
            return myTarget;
        }
    }, Balloon.Position.above);
}
Also used : Disposable(com.intellij.openapi.Disposable) JBPopupFactory(com.intellij.openapi.ui.popup.JBPopupFactory) Balloon(com.intellij.openapi.ui.popup.Balloon) RelativePoint(com.intellij.ui.awt.RelativePoint) RelativePoint(com.intellij.ui.awt.RelativePoint) BalloonBuilder(com.intellij.openapi.ui.popup.BalloonBuilder)

Example 8 with JBPopupFactory

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

the class NavigateToTestDataAction method actionPerformed.

@Override
public void actionPerformed(AnActionEvent e) {
    final DataContext dataContext = e.getDataContext();
    final Project project = e.getProject();
    List<String> fileNames = findTestDataFiles(dataContext);
    if (fileNames == null || fileNames.isEmpty()) {
        String testData = guessTestData(dataContext);
        if (testData == null) {
            String message = "Cannot find testdata files for class";
            final Notification notification = new Notification("testdata", "Found no testdata files", message, NotificationType.INFORMATION);
            Notifications.Bus.notify(notification, project);
            return;
        }
        fileNames = Collections.singletonList(testData);
    }
    final Editor editor = e.getData(CommonDataKeys.EDITOR);
    final JBPopupFactory popupFactory = JBPopupFactory.getInstance();
    final RelativePoint point = editor != null ? popupFactory.guessBestPopupLocation(editor) : popupFactory.guessBestPopupLocation(dataContext);
    TestDataNavigationHandler.navigate(point, fileNames, project);
}
Also used : Project(com.intellij.openapi.project.Project) DataContext(com.intellij.openapi.actionSystem.DataContext) JBPopupFactory(com.intellij.openapi.ui.popup.JBPopupFactory) RelativePoint(com.intellij.ui.awt.RelativePoint) Editor(com.intellij.openapi.editor.Editor) Notification(com.intellij.notification.Notification)

Example 9 with JBPopupFactory

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

the class ListenerNavigateButton method showNavigatePopup.

public static void showNavigatePopup(final RadComponent component, final boolean showIfEmpty) {
    final DefaultActionGroup actionGroup = prepareActionGroup(component);
    if (actionGroup != null && actionGroup.getChildrenCount() == 0 && showIfEmpty) {
        actionGroup.add(new MyNavigateAction(UIDesignerBundle.message("navigate.to.listener.empty"), null));
    }
    if (actionGroup != null && actionGroup.getChildrenCount() > 0) {
        final DataContext context = DataManager.getInstance().getDataContext(component.getDelegee());
        final JBPopupFactory factory = JBPopupFactory.getInstance();
        final ListPopup popup = factory.createActionGroupPopup(UIDesignerBundle.message("navigate.to.listener.title"), actionGroup, context, JBPopupFactory.ActionSelectionAid.NUMBERING, true);
        FormEditingUtil.showPopupUnderComponent(popup, component);
    }
}
Also used : DataContext(com.intellij.openapi.actionSystem.DataContext) JBPopupFactory(com.intellij.openapi.ui.popup.JBPopupFactory) ListPopup(com.intellij.openapi.ui.popup.ListPopup) DefaultActionGroup(com.intellij.openapi.actionSystem.DefaultActionGroup)

Example 10 with JBPopupFactory

use of com.intellij.openapi.ui.popup.JBPopupFactory in project android by JetBrains.

the class FlatComboAction method createPopup.

protected JBPopup createPopup(Runnable onDispose, DataContext context) {
    DefaultActionGroup group = createPopupActionGroup();
    JBPopupFactory factory = JBPopupFactory.getInstance();
    ListPopup popup = factory.createActionGroupPopup(null, group, context, true, onDispose, getMaxRows());
    popup.setMinimumSize(new Dimension(getMinWidth(), getMinHeight()));
    return popup;
}
Also used : JBPopupFactory(com.intellij.openapi.ui.popup.JBPopupFactory) ListPopup(com.intellij.openapi.ui.popup.ListPopup)

Aggregations

JBPopupFactory (com.intellij.openapi.ui.popup.JBPopupFactory)12 ListPopup (com.intellij.openapi.ui.popup.ListPopup)5 DataContext (com.intellij.openapi.actionSystem.DataContext)3 DefaultActionGroup (com.intellij.openapi.actionSystem.DefaultActionGroup)3 Balloon (com.intellij.openapi.ui.popup.Balloon)3 RelativePoint (com.intellij.ui.awt.RelativePoint)3 JBPopupListener (com.intellij.openapi.ui.popup.JBPopupListener)2 NotNull (org.jetbrains.annotations.NotNull)2 BeforeRunTask (com.intellij.execution.BeforeRunTask)1 BeforeRunTaskProvider (com.intellij.execution.BeforeRunTaskProvider)1 RunConfiguration (com.intellij.execution.configurations.RunConfiguration)1 UnknownRunConfiguration (com.intellij.execution.configurations.UnknownRunConfiguration)1 Notification (com.intellij.notification.Notification)1 Disposable (com.intellij.openapi.Disposable)1 AnAction (com.intellij.openapi.actionSystem.AnAction)1 AnActionEvent (com.intellij.openapi.actionSystem.AnActionEvent)1 Editor (com.intellij.openapi.editor.Editor)1 Project (com.intellij.openapi.project.Project)1 BalloonBuilder (com.intellij.openapi.ui.popup.BalloonBuilder)1 JBPopup (com.intellij.openapi.ui.popup.JBPopup)1