IDEA-88507 Throwable at ToolWindowManagerImpl.notifyByBalloon() from notification

This commit is contained in:
peter
2012-07-10 11:54:02 +02:00
parent fdfb4fe140
commit c4d856126e
5 changed files with 23 additions and 2 deletions
@@ -27,6 +27,8 @@ import javax.swing.event.HyperlinkListener;
public abstract class ToolWindowManager {
public abstract boolean canShowNotification(@NotNull String toolWindowId);
public static ToolWindowManager getInstance(Project project){
return project.getComponent(ToolWindowManager.class);
}
@@ -46,7 +46,6 @@ import javax.swing.event.HyperlinkEvent;
import javax.swing.event.HyperlinkListener;
import java.awt.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/**
@@ -142,7 +141,7 @@ public class NotificationsManagerImpl extends NotificationsManager implements No
NotificationDisplayType type = settings.getDisplayType();
String toolWindowId = NotificationsConfigurationImpl.getNotificationsConfigurationImpl().getToolWindowId(groupId);
if (type == NotificationDisplayType.TOOL_WINDOW &&
(toolWindowId == null || project == null || !Arrays.asList(ToolWindowManager.getInstance(project).getToolWindowIds()).contains(toolWindowId))) {
(toolWindowId == null || project == null || !ToolWindowManager.getInstance(project).canShowNotification(toolWindowId))) {
type = NotificationDisplayType.BALLOON;
}
@@ -56,6 +56,10 @@ import java.util.List;
@SuppressWarnings({"ConstantConditions"})
public class ToolWindowHeadlessManagerImpl extends ToolWindowManagerEx {
@Override
public boolean canShowNotification(@NotNull String toolWindowId) {
return false;
}
@Override
public void notifyByBalloon(@NotNull final String toolWindowId, @NotNull final MessageType type, @NotNull final String htmlBody) {
@@ -1288,6 +1288,16 @@ public final class ToolWindowManagerImpl extends ToolWindowManagerEx implements
return IdeFocusManager.getInstance(myProject);
}
@Override
public boolean canShowNotification(@NotNull final String toolWindowId) {
if (!Arrays.asList(getToolWindowIds()).contains(toolWindowId)) {
return false;
}
final Stripe stripe = myToolWindowsPane.getStripeFor(toolWindowId);
return stripe.getButtonFor(toolWindowId) != null;
}
@Override
public void notifyByBalloon(@NotNull final String toolWindowId, @NotNull final MessageType type, @NotNull final String htmlBody) {
notifyByBalloon(toolWindowId, type, htmlBody, null, null);
@@ -531,6 +531,12 @@ public class Mock {
}
public static class MyToolWindowManager extends ToolWindowManager {
@Override
public boolean canShowNotification(@NotNull String toolWindowId) {
return false;
}
@Override
public ToolWindow registerToolWindow(@NotNull String id, @NotNull JComponent component, @NotNull ToolWindowAnchor anchor) {
return null;