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();
}
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;
}
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);
}
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);
}
}
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);
}
}
}
Aggregations