IDEA-100922 Messages, Run & Debug tool windows pop up unexpectedly and disturb one from the current work

This commit is contained in:
Vassiliy Kudryashov
2013-02-20 17:33:39 +04:00
parent f396f3ae8e
commit a6f73c0cb5
5 changed files with 39 additions and 4 deletions
@@ -41,6 +41,7 @@ import com.intellij.openapi.project.DumbModeAction;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.project.ProjectManager;
import com.intellij.openapi.project.ProjectManagerListener;
import com.intellij.openapi.ui.MessageType;
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.util.Key;
import com.intellij.openapi.util.TextRange;
@@ -209,6 +210,18 @@ public class CompilerTask extends Task.Backgroundable {
closeUI();
}
stopAppIconProgress();
Runnable runnable = new Runnable() {
public void run() {
NotificationInfo notificationInfo = getNotificationInfo();
if (notificationInfo != null && !myMessagesAutoActivated && (myErrorCount > 0 || (myWarningCount > 0 && !ErrorTreeViewConfiguration.getInstance(myProject).isHideWarnings()))) {
MessageType messageType = myErrorCount > 0 ? MessageType.ERROR : myWarningCount > 0 ? MessageType.WARNING : MessageType.INFO;
ToolWindowManager.getInstance(myProject).notifyByBalloon(ToolWindowId.MESSAGES_WINDOW, messageType,
getNotificationInfo().getNotificationText(), null, null);
}
}
};
ApplicationManager.getApplication().invokeLater(runnable);
}
private void stopAppIconProgress() {
@@ -319,7 +332,6 @@ public class CompilerTask extends Task.Backgroundable {
(CompilerMessageCategory.WARNING.equals(category) && !ErrorTreeViewConfiguration.getInstance(myProject).isHideWarnings())
);
if (shouldAutoActivate) {
myMessagesAutoActivated = true;
activateMessageView();
}
}
@@ -444,7 +456,7 @@ public class CompilerTask extends Task.Backgroundable {
if (myErrorTreeView != null) {
final ToolWindow tw = ToolWindowManager.getInstance(myProject).getToolWindow(ToolWindowId.MESSAGES_WINDOW);
if (tw != null) {
tw.activate(null, false);
myMessagesAutoActivated = tw.activate(null, false, false, false);
}
}
}
@@ -342,7 +342,7 @@ public class RunContentManagerImpl implements RunContentManager, Disposable {
// mark the window as "last activated" windows and thus
// some action like navigation up/down in stactrace wont
// work correctly
window.activate(null, false, false);
window.activate(null, false, false, false);
}
});
}
@@ -46,6 +46,13 @@ public interface ToolWindow extends BusyObject {
void activate(@Nullable Runnable runnable, boolean autoFocusContents, boolean forced);
/**
* @param ignoreActiveWindowWithSameAnchor is <code>true</code> by default.
* If it's <code>false</code> and current active window has same anchor, activation will be cancelled
* @return <code>false</code> if activation was cancelled, otherwise <code>true</code>
*/
boolean activate(@Nullable Runnable runnable, boolean autoFocusContents, boolean forced, boolean ignoreActiveWindowWIthSameAnchor);
/**
* @return whether the tool window is visible or not.
* @exception IllegalStateException if tool window isn't installed.
@@ -212,6 +212,11 @@ public class ToolWindowHeadlessManagerImpl extends ToolWindowManagerEx {
public void activate(@Nullable Runnable runnable, boolean autoFocusContents, boolean forced) {
}
@Override
public boolean activate(@Nullable Runnable runnable, boolean autoFocusContents, boolean forced, boolean ignoreActiveWindowWIthSameAnchor) {
return true;
}
@Override
public void showContentPopup(InputEvent inputEvent) {
}
@@ -126,8 +126,18 @@ public final class ToolWindowImpl implements ToolWindowEx {
}
public void activate(@Nullable final Runnable runnable, boolean autoFocusContents, boolean forced) {
ApplicationManager.getApplication().assertIsDispatchThread();
activate(runnable, autoFocusContents, forced, true);
}
@Override
public boolean activate(@Nullable final Runnable runnable, boolean autoFocusContents, boolean forced, boolean ignoreActiveWindowWithSameAnchor) {
ApplicationManager.getApplication().assertIsDispatchThread();
if (!ignoreActiveWindowWithSameAnchor) {
String windowId = myToolWindowManager.getActiveToolWindowId();
if (windowId != null && windowId != myId && myToolWindowManager.getToolWindowAnchor(windowId) == getAnchor()) {
return false;
}
}
final UiActivity activity = new UiActivity.Focus("toolWindow:" + myId);
UiActivityMonitor.getInstance().addActivity(myToolWindowManager.getProject(), activity, ModalityState.NON_MODAL);
@@ -146,6 +156,7 @@ public final class ToolWindowImpl implements ToolWindowEx {
});
}
});
return true;
}
public final boolean isActive() {