sticky documentation popup [take 1]
[fedora-idea.git] / platform / platform-impl / src / com / intellij / ide / TipOfTheDayManager.java
blobf6b4e4ba5dda02831c4b0503282bedd40d85edd3
1 /*
2 * Copyright 2000-2009 JetBrains s.r.o.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package com.intellij.ide;
18 import com.intellij.ide.util.TipDialog;
19 import com.intellij.openapi.application.ApplicationManager;
20 import com.intellij.openapi.components.ApplicationComponent;
21 import com.intellij.openapi.project.DumbAwareRunnable;
22 import com.intellij.openapi.project.Project;
23 import com.intellij.openapi.project.ProjectManager;
24 import com.intellij.openapi.project.ProjectManagerAdapter;
25 import com.intellij.openapi.startup.StartupManager;
26 import com.intellij.openapi.wm.ToolWindowManager;
28 public class TipOfTheDayManager extends ProjectManagerAdapter implements ApplicationComponent {
29 private boolean myDoNotShowThisTime = false;
30 private boolean myVeryFirstProjectOpening = true;
32 public static TipOfTheDayManager getInstance() {
33 return ApplicationManager.getApplication().getComponent(TipOfTheDayManager.class);
37 public TipOfTheDayManager(ProjectManager projectManager) {
38 projectManager.addProjectManagerListener(this);
41 public String getComponentName() {
42 return "TipOfTheDayManager";
45 public void initComponent() { }
47 public void disposeComponent() {
48 ProjectManager.getInstance().removeProjectManagerListener(this);
51 public void projectOpened(final Project project) {
52 if (!myVeryFirstProjectOpening || !GeneralSettings.getInstance().showTipsOnStartup()) {
53 return;
56 myVeryFirstProjectOpening = false;
58 StartupManager.getInstance(project).registerPostStartupActivity(new DumbAwareRunnable() {
59 public void run() {
60 if (myDoNotShowThisTime) return;
61 ToolWindowManager.getInstance(project).invokeLater(new Runnable() {
62 public void run() {
63 if (project.isDisposed()) return;
64 ToolWindowManager.getInstance(project).invokeLater(new Runnable() {
65 public void run() {
66 if (project.isDisposed()) return;
67 new TipDialog().show();
69 });
71 });
73 });
76 public void doNotShowThisTime() {
77 myDoNotShowThisTime = true;