mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-155300 Change non-sticky balloons behavior
This commit is contained in:
+7
-2
@@ -282,8 +282,13 @@ public class NotificationsManagerImpl extends NotificationsManager {
|
||||
}
|
||||
|
||||
if (!sticky) {
|
||||
((BalloonImpl)balloon).startFadeoutTimer(0);
|
||||
((BalloonImpl)balloon).setHideOnClickOutside(true);
|
||||
if (newEnabled()) {
|
||||
((BalloonImpl)balloon).startSmartFadeoutTimer(10000);
|
||||
}
|
||||
else {
|
||||
((BalloonImpl)balloon).startFadeoutTimer(0);
|
||||
((BalloonImpl)balloon).setHideOnClickOutside(true);
|
||||
}
|
||||
}
|
||||
else //noinspection ConstantConditions
|
||||
if (noProjects && !newEnabled()) {
|
||||
|
||||
@@ -16,9 +16,7 @@
|
||||
package com.intellij.ui;
|
||||
|
||||
import com.intellij.icons.AllIcons;
|
||||
import com.intellij.ide.IdeEventQueue;
|
||||
import com.intellij.ide.IdeTooltip;
|
||||
import com.intellij.ide.RemoteDesktopDetector;
|
||||
import com.intellij.ide.*;
|
||||
import com.intellij.openapi.MnemonicHelper;
|
||||
import com.intellij.openapi.actionSystem.ActionManager;
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
@@ -86,6 +84,10 @@ public class BalloonImpl implements Balloon, IdeTooltip.Ui {
|
||||
private long myFadeoutRequestMillis = 0;
|
||||
private int myFadeoutRequestDelay = 0;
|
||||
|
||||
private boolean mySmartFadeout;
|
||||
private boolean mySmartFadeoutPaused;
|
||||
private int mySmartFadeoutDelay;
|
||||
|
||||
private MyComponent myComp;
|
||||
private JLayeredPane myLayeredPane;
|
||||
private AbstractPosition myPosition;
|
||||
@@ -109,6 +111,11 @@ public class BalloonImpl implements Balloon, IdeTooltip.Ui {
|
||||
private final AWTEventListener myAwtActivityListener = new AWTEventListener() {
|
||||
@Override
|
||||
public void eventDispatched(final AWTEvent e) {
|
||||
if (mySmartFadeoutDelay > 0) {
|
||||
startFadeoutTimer(mySmartFadeoutDelay);
|
||||
mySmartFadeoutDelay = 0;
|
||||
}
|
||||
|
||||
final int id = e.getID();
|
||||
if (e instanceof MouseEvent) {
|
||||
final MouseEvent me = (MouseEvent)e;
|
||||
@@ -843,12 +850,45 @@ public class BalloonImpl implements Balloon, IdeTooltip.Ui {
|
||||
myAnimator.resume();
|
||||
}
|
||||
|
||||
public void runWithSmartFadeoutPause(@NotNull Runnable handler) {
|
||||
if (mySmartFadeout) {
|
||||
mySmartFadeoutPaused = true;
|
||||
handler.run();
|
||||
if (mySmartFadeoutPaused) {
|
||||
mySmartFadeoutPaused = false;
|
||||
}
|
||||
else {
|
||||
hide();
|
||||
}
|
||||
}
|
||||
else {
|
||||
handler.run();
|
||||
}
|
||||
}
|
||||
|
||||
public void startSmartFadeoutTimer(int delay) {
|
||||
mySmartFadeout = true;
|
||||
mySmartFadeoutDelay = delay;
|
||||
FrameStateManager.getInstance().addListener(new FrameStateListener.Adapter() {
|
||||
@Override
|
||||
public void onFrameDeactivated() {
|
||||
if (myFadeoutAlarm.getActiveRequestCount() > 0) {
|
||||
myFadeoutAlarm.cancelAllRequests();
|
||||
mySmartFadeoutDelay = myFadeoutRequestDelay - (int)(System.currentTimeMillis() - myFadeoutRequestMillis);
|
||||
if (mySmartFadeoutDelay <= 0) {
|
||||
mySmartFadeoutDelay = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}, this);
|
||||
}
|
||||
|
||||
public void startFadeoutTimer(final int fadeoutDelay) {
|
||||
if (fadeoutDelay > 0) {
|
||||
myFadeoutAlarm.cancelAllRequests();
|
||||
myFadeoutRequestMillis = System.currentTimeMillis();
|
||||
myFadeoutRequestDelay = fadeoutDelay;
|
||||
myFadeoutAlarm.addRequest(() -> hide(), fadeoutDelay, null);
|
||||
myFadeoutAlarm.addRequest(this::hide, fadeoutDelay, null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -911,6 +951,11 @@ public class BalloonImpl implements Balloon, IdeTooltip.Ui {
|
||||
private void hideAndDispose(final boolean ok) {
|
||||
if (myDisposed) return;
|
||||
|
||||
if (mySmartFadeoutPaused) {
|
||||
mySmartFadeoutPaused = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (myTraceDispose) {
|
||||
Logger.getInstance("#com.intellij.ui.BalloonImpl").error("Dispose balloon before showing", new Throwable());
|
||||
}
|
||||
|
||||
@@ -19,8 +19,6 @@ import com.intellij.icons.AllIcons;
|
||||
import com.intellij.notification.impl.NotificationsConfigurable;
|
||||
import com.intellij.notification.impl.NotificationsConfigurationImpl;
|
||||
import com.intellij.openapi.options.ShowSettingsUtil;
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.util.Consumer;
|
||||
import com.intellij.util.ui.JBRectangle;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -28,7 +26,6 @@ import org.jetbrains.annotations.Nullable;
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.InputEvent;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -69,13 +66,13 @@ public class NotificationBalloonActionProvider implements BalloonImpl.ActionProv
|
||||
mySettingButton = myBalloon.new ActionButton(
|
||||
AllIcons.Ide.Notification.Gear, AllIcons.Ide.Notification.GearHover,
|
||||
"Configure Notification",
|
||||
event -> {
|
||||
event -> myBalloon.runWithSmartFadeoutPause(() -> {
|
||||
final NotificationsConfigurable configurable = new NotificationsConfigurable();
|
||||
ShowSettingsUtil.getInstance().editConfigurable(myLayoutData.project, configurable, () -> {
|
||||
//noinspection ConstantConditions
|
||||
configurable.enableSearch(myDisplayGroupId).run();
|
||||
});
|
||||
}) {
|
||||
})) {
|
||||
@Override
|
||||
public void repaint() {
|
||||
super.repaint();
|
||||
|
||||
Reference in New Issue
Block a user