IDEA-93232 The notification balloon size should be correct always

This commit is contained in:
peter
2012-10-25 21:19:36 +02:00
parent 9404e50337
commit e2f9d8a3c7
3 changed files with 13 additions and 6 deletions
@@ -266,12 +266,14 @@ public class NotificationsManagerImpl extends NotificationsManager {
Dimension preferredSize = text.getPreferredSize();
text.setSize(preferredSize);
preferredSize = text.getPreferredSize();
Dimension paneSize = new Dimension(text.getPreferredSize());
int maxHeight = Math.min(400, window.getComponent().getHeight() - 20);
int maxWidth = Math.min(500, window.getComponent().getWidth() - 20);
Dimension maxSize = new Dimension(Math.min(preferredSize.width, maxWidth), Math.min(preferredSize.height, maxHeight));
if (!maxSize.equals(preferredSize)) {
pane.setPreferredSize(maxSize);
int maxWidth = Math.min(600, window.getComponent().getWidth() - 20);
if (paneSize.height > maxHeight) {
pane.setPreferredSize(new Dimension(Math.min(maxWidth, paneSize.width + UIUtil.getScrollBarWidth()), maxHeight));
} else if (paneSize.width > maxWidth) {
pane.setPreferredSize(new Dimension(maxWidth, paneSize.height + UIUtil.getScrollBarWidth()));
}
final BalloonBuilder builder = JBPopupFactory.getInstance().createBalloonBuilder(content);
@@ -63,7 +63,8 @@ public class NotificationTestAction extends AnAction implements DumbAware {
final Notification notification = new Notification(TEST_GROUP_ID, "This is a test notification", //"a",
"You can<br> close this very<p> very very very long notification by clicking <a href=\"close\">this link</a>. Long long long long. It should be long. Very long. Too long." +
StringUtil.repeat("<br>line", 100) +
//StringUtil.repeat("line", 100) +
//StringUtil.repeat("<br>line", 100) +
" And even longer.",
type, listener);
@@ -432,6 +432,10 @@ public class UIUtil {
return defColor;
}
public static int getScrollBarWidth() {
return UIManager.getInt("ScrollBar.width");
}
public static Font getLabelFont() {
return UIManager.getFont("Label.font");
}