Skip to content

Commit

Permalink
chore: don't use internal ActionToolbarImpl
Browse files Browse the repository at this point in the history
Signed-off-by: Fred Bricon <[email protected]>
  • Loading branch information
fbricon authored and angelozerr committed Sep 13, 2024
1 parent 239a9f1 commit 53886cb
Showing 1 changed file with 8 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import com.intellij.openapi.actionSystem.ActionUpdateThread;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.impl.ActionToolbarImpl;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.popup.Balloon;
Expand Down Expand Up @@ -106,17 +105,15 @@ private void showBalloon(@NotNull Project project) {
.filter(c -> ACTION_TOOLBAR_COMPONENT_NAME.equals(c.getName()))
.findFirst();

if (actionToolbarComponent.isEmpty()) {
return;
}
Component applyComponent = ((ActionToolbarImpl) actionToolbarComponent.get()).getComponent(0);

// Move the position by 1/2 of the component width, because the icon is not centered
Point point = new Point(applyComponent.getWidth()/2 ,0);
RelativePoint displayPoint = new RelativePoint(applyComponent, point);
if (actionToolbarComponent.isPresent() && actionToolbarComponent.get() instanceof JPanel actionToolBar) {
Component applyComponent = actionToolBar.getComponent(0);
// Move the position by 1/2 of the component width, because the icon is not centered
Point point = new Point(applyComponent.getWidth()/2 ,0);
RelativePoint displayPoint = new RelativePoint(applyComponent, point);

// Use invokeLater to prevent the balloon from resizing when it is shown
ApplicationManager.getApplication().invokeLater(() -> this.saveTipBalloon.show(displayPoint, Balloon.Position.above));
// Use invokeLater to prevent the balloon from resizing when it is shown
ApplicationManager.getApplication().invokeLater(() -> this.saveTipBalloon.show(displayPoint, Balloon.Position.above));
}
}

/**
Expand Down

0 comments on commit 53886cb

Please sign in to comment.