message view is dumb-aware
[fedora-idea.git] / platform / platform-impl / src / com / intellij / ui / content / impl / MessageViewImpl.java
blob6a9409d232db191ecd6093391f84c1b65884996a
2 /*
3 * Copyright 2000-2009 JetBrains s.r.o.
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
17 package com.intellij.ui.content.impl;
19 import com.intellij.ide.impl.ContentManagerWatcher;
20 import com.intellij.openapi.project.Project;
21 import com.intellij.openapi.startup.StartupManager;
22 import com.intellij.openapi.util.IconLoader;
23 import com.intellij.openapi.wm.ToolWindow;
24 import com.intellij.openapi.wm.ToolWindowAnchor;
25 import com.intellij.openapi.wm.ToolWindowId;
26 import com.intellij.openapi.wm.ToolWindowManager;
27 import com.intellij.ui.content.ContentManager;
28 import com.intellij.ui.content.MessageView;
30 import java.util.ArrayList;
31 import java.util.List;
33 /**
34 * @author Eugene Belyaev
36 public class MessageViewImpl implements MessageView {
37 private ToolWindow myToolWindow;
38 private final List<Runnable> myPostponedRunnables = new ArrayList<Runnable>();
40 public MessageViewImpl(final Project project, final StartupManager startupManager, final ToolWindowManager toolWindowManager) {
41 final Runnable runnable = new Runnable() {
42 public void run() {
43 myToolWindow = toolWindowManager.registerToolWindow(ToolWindowId.MESSAGES_WINDOW, true, ToolWindowAnchor.BOTTOM, project, true);
44 myToolWindow.setIcon(IconLoader.getIcon("/general/toolWindowMessages.png"));
45 new ContentManagerWatcher(myToolWindow, getContentManager());
46 for (Runnable postponedRunnable : myPostponedRunnables) {
47 postponedRunnable.run();
49 myPostponedRunnables.clear();
52 if (project.isInitialized()) {
53 runnable.run();
55 else {
56 startupManager.registerPostStartupActivity(new Runnable(){
57 public void run() {
58 runnable.run();
60 });
65 public ContentManager getContentManager() {
66 return myToolWindow.getContentManager();
69 public void runWhenInitialized(final Runnable runnable) {
70 if (myToolWindow != null) {
71 runnable.run();
73 else {
74 myPostponedRunnables.add(runnable);