Skip to content

Commit

Permalink
Fix a class cast exception in BalloonImpl
Browse files Browse the repository at this point in the history
  • Loading branch information
YiiGuxing committed Nov 10, 2024
1 parent f2f5bb3 commit aaf77db
Showing 1 changed file with 45 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import com.intellij.ide.RemoteDesktopService;
import com.intellij.ide.ui.PopupLocationTracker;
import com.intellij.ide.ui.ScreenAreaConsumer;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.MnemonicHelper;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
Expand Down Expand Up @@ -634,7 +635,7 @@ public void run() {

if (ApplicationManager.getApplication() != null) {
ApplicationManager.getApplication().getMessageBus().connect(this)
.subscribe(AnActionListener.TOPIC,new AnActionListener(){
.subscribe(AnActionListener.TOPIC, new AnActionListener() {
@Override
public void beforeActionPerformed(@NotNull AnAction action, @NotNull AnActionEvent event) {
if (myHideOnAction && !(action instanceof HintManagerImpl.ActionToIgnore)) {
Expand Down Expand Up @@ -892,49 +893,60 @@ public void show(JLayeredPane pane, @Nullable Rectangle bounds) {
}


private void runAnimation(boolean forward, final JLayeredPane layeredPane, @Nullable final Runnable onDone) {
if (myAnimator != null) {
Disposer.dispose(myAnimator);
private class MyAnimator extends Animator implements Disposable {

final JLayeredPane layeredPane;
final Runnable onDone;

MyAnimator(boolean forward, JLayeredPane layeredPane, Runnable onDone) {
super("Balloon", 8, isAnimationEnabled() ? myAnimationCycle : 0, false, forward);
this.layeredPane = layeredPane;
this.onDone = onDone;
}

myAnimator = new Animator("Balloon", 8, isAnimationEnabled() ? myAnimationCycle : 0, false, forward) {
@Override
public void paintNow(final int frame, final int totalFrames, final int cycle) {
if (myComp == null || myComp.getParent() == null || !isAnimationEnabled()) return;
myComp.setAlpha((float) frame / totalFrames);
}
@Override
public void paintNow(final int frame, final int totalFrames, final int cycle) {
if (myComp == null || myComp.getParent() == null || !isAnimationEnabled()) return;
myComp.setAlpha((float) frame / totalFrames);
}

@Override
protected void paintCycleEnd() {
if (myComp == null || myComp.getParent() == null) return;
@Override
protected void paintCycleEnd() {
if (myComp == null || myComp.getParent() == null) return;

if (isForward()) {
myComp.clear();
myComp.repaint();
if (isForward()) {
myComp.clear();
myComp.repaint();

myFadedIn = true;
myFadedIn = true;

if (!myFadeoutAlarm.isDisposed()) {
startFadeoutTimer((int) myFadeoutTime);
}
} else {
layeredPane.remove(myComp);
layeredPane.revalidate();
layeredPane.repaint();
if (!myFadeoutAlarm.isDisposed()) {
startFadeoutTimer((int) myFadeoutTime);
}
Disposer.dispose(this);
} else {
layeredPane.remove(myComp);
layeredPane.revalidate();
layeredPane.repaint();
}
Disposer.dispose(this);
}

@Override
public void dispose() {
super.dispose();
myAnimator = null;
if (onDone != null) {
onDone.run();
}
@Override
public void dispose() {
super.dispose();
myAnimator = null;
if (onDone != null) {
onDone.run();
}
};
}
}

private void runAnimation(boolean forward, final JLayeredPane layeredPane, @Nullable final Runnable onDone) {
if (myAnimator != null) {
Disposer.dispose(myAnimator);
}

myAnimator = new MyAnimator(forward, layeredPane, onDone);
myAnimator.resume();
}

Expand Down

0 comments on commit aaf77db

Please sign in to comment.