Search in sources :

Example 16 with Balloon

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

the class BalloonLayoutImpl method add.

@Override
public void add(@NotNull final Balloon balloon, @Nullable Object layoutData) {
    ApplicationManager.getApplication().assertIsDispatchThread();
    Balloon merge = merge(layoutData);
    if (merge == null) {
        if (getVisibleCount() > 0 && layoutData instanceof BalloonLayoutData && ((BalloonLayoutData) layoutData).groupId != null) {
            int index = -1;
            int count = 0;
            for (int i = 0, size = myBalloons.size(); i < size; i++) {
                BalloonLayoutData ld = myLayoutData.get(myBalloons.get(i));
                if (ld != null && ld.groupId != null) {
                    if (index == -1) {
                        index = i;
                    }
                    count++;
                }
            }
            if (count > 0 && count == getVisibleCount()) {
                remove(myBalloons.get(index));
            }
        }
        myBalloons.add(balloon);
    } else {
        int index = myBalloons.indexOf(merge);
        remove(merge);
        myBalloons.add(index, balloon);
    }
    if (layoutData instanceof BalloonLayoutData) {
        BalloonLayoutData balloonLayoutData = (BalloonLayoutData) layoutData;
        balloonLayoutData.closeAll = myCloseAll;
        balloonLayoutData.doLayout = myLayoutRunnable;
        myLayoutData.put(balloon, balloonLayoutData);
    }
    Disposer.register(balloon, new Disposable() {

        public void dispose() {
            clearNMore(balloon);
            remove(balloon, false);
            queueRelayout();
        }
    });
    if (myLafListener == null && layoutData != null) {
        myLafListener = new LafManagerListener() {

            @Override
            public void lookAndFeelChanged(LafManager source) {
                for (BalloonLayoutData layoutData : myLayoutData.values()) {
                    if (layoutData.lafHandler != null) {
                        layoutData.lafHandler.run();
                    }
                }
            }
        };
        LafManager.getInstance().addLafManagerListener(myLafListener);
    }
    calculateSize();
    relayout();
    if (!balloon.isDisposed()) {
        balloon.show(myLayeredPane);
    }
    fireRelayout();
}
Also used : Disposable(com.intellij.openapi.Disposable) Balloon(com.intellij.openapi.ui.popup.Balloon) LafManager(com.intellij.ide.ui.LafManager) LafManagerListener(com.intellij.ide.ui.LafManagerListener)

Example 17 with Balloon

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

the class BalloonLayoutImpl method calculateSize.

private void calculateSize() {
    myWidth = null;
    for (Balloon balloon : myBalloons) {
        BalloonLayoutData layoutData = myLayoutData.get(balloon);
        if (layoutData != null) {
            layoutData.height = balloon.getPreferredSize().height;
        }
    }
    myWidth = BalloonLayoutConfiguration.FixedWidth;
}
Also used : Balloon(com.intellij.openapi.ui.popup.Balloon)

Example 18 with Balloon

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

the class AnnotateDiffViewerAction method showNotification.

private static void showNotification(@NotNull DiffViewerBase viewer, @NotNull Notification notification) {
    JComponent component = viewer.getComponent();
    Window window = UIUtil.getWindow(component);
    if (window instanceof IdeFrame && NotificationsManagerImpl.findWindowForBalloon(viewer.getProject()) == window) {
        notification.notify(viewer.getProject());
        return;
    }
    Balloon balloon = NotificationsManagerImpl.createBalloon(component, notification, false, true, BalloonLayoutData.fullContent(), viewer);
    Dimension componentSize = component.getSize();
    Dimension balloonSize = balloon.getPreferredSize();
    int width = Math.min(balloonSize.width, componentSize.width);
    int height = Math.min(balloonSize.height, componentSize.height);
    // top-right corner, 20px to the edges
    RelativePoint point = new RelativePoint(component, new Point(componentSize.width - 20 - width / 2, 20 + height / 2));
    balloon.show(point, Balloon.Position.above);
}
Also used : Balloon(com.intellij.openapi.ui.popup.Balloon) RelativePoint(com.intellij.ui.awt.RelativePoint) RelativePoint(com.intellij.ui.awt.RelativePoint) IdeFrame(com.intellij.openapi.wm.IdeFrame) RelativePoint(com.intellij.ui.awt.RelativePoint)

Example 19 with Balloon

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

the class PowerSaveModeNotifier method notifyOnPowerSaveMode.

static void notifyOnPowerSaveMode(@Nullable Project project) {
    if (PropertiesComponent.getInstance().getBoolean(IGNORE_POWER_SAVE_MODE)) {
        return;
    }
    Notification notification = POWER_SAVE_MODE.createNotification("Power save mode is on", "Code insight and background tasks are disabled.", NotificationType.WARNING, null);
    notification.addAction(new NotificationAction("Do Not Show Again") {

        @Override
        public void actionPerformed(@NotNull AnActionEvent e, @NotNull Notification notification) {
            PropertiesComponent.getInstance().setValue(IGNORE_POWER_SAVE_MODE, true);
            notification.expire();
        }
    });
    notification.addAction(new NotificationAction("Disable Power Save Mode") {

        @Override
        public void actionPerformed(@NotNull AnActionEvent e, @NotNull Notification notification) {
            PowerSaveMode.setEnabled(false);
            notification.expire();
        }
    });
    notification.notify(project);
    Balloon balloon = notification.getBalloon();
    if (balloon != null) {
        MessageBus bus = project == null ? ApplicationManager.getApplication().getMessageBus() : project.getMessageBus();
        MessageBusConnection connection = bus.connect();
        connection.subscribe(PowerSaveMode.TOPIC, () -> notification.expire());
        Disposer.register(balloon, connection);
    }
}
Also used : MessageBus(com.intellij.util.messages.MessageBus) MessageBusConnection(com.intellij.util.messages.MessageBusConnection) NotificationAction(com.intellij.notification.NotificationAction) Balloon(com.intellij.openapi.ui.popup.Balloon) AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) Notification(com.intellij.notification.Notification)

Example 20 with Balloon

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

the class ResetConfigurationModuleAdapter method hyperlinkActivated.

@Override
protected void hyperlinkActivated(HyperlinkEvent e) {
    final Module moduleByName = ModuleManager.getInstance(myProject).findModuleByName(e.getDescription());
    if (moduleByName != null) {
        myConfiguration.getConfigurationModule().setModule(moduleByName);
        try {
            Executor executor = myIsDebug ? DefaultDebugExecutor.getDebugExecutorInstance() : DefaultRunExecutor.getRunExecutorInstance();
            ExecutionEnvironmentBuilder.create(myProject, executor, myConfiguration).contentToReuse(null).buildAndExecute();
            Balloon balloon = myToolWindowManager.getToolWindowBalloon(myTestRunDebugId);
            if (balloon != null) {
                balloon.hide();
            }
        } catch (ExecutionException e1) {
            LOG.error(e1);
        }
    }
}
Also used : DefaultRunExecutor(com.intellij.execution.executors.DefaultRunExecutor) DefaultDebugExecutor(com.intellij.execution.executors.DefaultDebugExecutor) Executor(com.intellij.execution.Executor) Balloon(com.intellij.openapi.ui.popup.Balloon) Module(com.intellij.openapi.module.Module) JavaRunConfigurationModule(com.intellij.execution.configurations.JavaRunConfigurationModule) ExecutionException(com.intellij.execution.ExecutionException)

Aggregations

Balloon (com.intellij.openapi.ui.popup.Balloon)40 RelativePoint (com.intellij.ui.awt.RelativePoint)14 BalloonBuilder (com.intellij.openapi.ui.popup.BalloonBuilder)11 IdeFrame (com.intellij.openapi.wm.IdeFrame)5 AnActionEvent (com.intellij.openapi.actionSystem.AnActionEvent)4 Disposable (com.intellij.openapi.Disposable)3 JBPopupFactory (com.intellij.openapi.ui.popup.JBPopupFactory)3 LightweightWindowEvent (com.intellij.openapi.ui.popup.LightweightWindowEvent)3 BalloonImpl (com.intellij.ui.BalloonImpl)3 HyperlinkEvent (javax.swing.event.HyperlinkEvent)3 Executor (com.intellij.execution.Executor)2 Notification (com.intellij.notification.Notification)2 ApplicationManager (com.intellij.openapi.application.ApplicationManager)2 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)2 BalloonLayout (com.intellij.ui.BalloonLayout)2 Alarm (com.intellij.util.Alarm)2 java.awt (java.awt)2 MouseEvent (java.awt.event.MouseEvent)2 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2