Search in sources :

Example 6 with ProjectManagerAdapter

use of com.intellij.openapi.project.ProjectManagerAdapter in project intellij-community by JetBrains.

the class ResizeToolWindowAction method update.

@Override
public final void update(AnActionEvent e) {
    Project project = e.getProject();
    if (project == null) {
        setDisabled(e);
        return;
    }
    if (!myListenerInstalled) {
        myListenerInstalled = true;
        ProjectManager.getInstance().addProjectManagerListener(new ProjectManagerAdapter() {

            @Override
            public void projectClosed(Project project) {
                setDisabled(null);
            }
        });
    }
    Component owner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
    if (owner == null) {
        setDisabled(e);
        return;
    }
    final Window windowAncestor = SwingUtilities.getWindowAncestor(owner);
    if (!(windowAncestor instanceof IdeFrame) || windowAncestor instanceof IdeFrame.Child) {
        setDisabled(e);
        return;
    }
    ToolWindowManager mgr = ToolWindowManager.getInstance(project);
    ToolWindow window = myToolWindow;
    if (window != null || mgr.getActiveToolWindowId() != null) {
        if (window == null) {
            window = mgr.getToolWindow(mgr.getActiveToolWindowId());
        }
        if (window == null || !window.isAvailable() || !window.isVisible() || window.getType() == ToolWindowType.FLOATING || window.getType() == ToolWindowType.WINDOWED || !window.isActive()) {
            setDisabled(e);
            return;
        }
        update(e, window, mgr);
        if (e.getPresentation().isEnabled()) {
            myLastWindow = window;
            myLastManager = mgr;
        } else {
            setDisabled(e);
        }
    } else {
        setDisabled(e);
    }
}
Also used : Project(com.intellij.openapi.project.Project) ProjectManagerAdapter(com.intellij.openapi.project.ProjectManagerAdapter)

Example 7 with ProjectManagerAdapter

use of com.intellij.openapi.project.ProjectManagerAdapter in project intellij-community by JetBrains.

the class ApplicationStatisticsPersistenceComponent method initComponent.

@Override
public void initComponent() {
    ApplicationManager.getApplication().getMessageBus().connect().subscribe(AppLifecycleListener.TOPIC, new AppLifecycleListener() {

        @Override
        public void appClosing() {
            persistOpenedProjects();
            persistOnClosing = false;
        }
    });
    ProjectManager.getInstance().addProjectManagerListener(new ProjectManagerAdapter() {

        @Override
        public void projectClosing(Project project) {
            if (persistOnClosing && project != null) {
                UsagesCollector.doPersistProjectUsages(project);
            }
        }
    });
    persistPeriodically();
}
Also used : Project(com.intellij.openapi.project.Project) ProjectManagerAdapter(com.intellij.openapi.project.ProjectManagerAdapter) AppLifecycleListener(com.intellij.ide.AppLifecycleListener)

Example 8 with ProjectManagerAdapter

use of com.intellij.openapi.project.ProjectManagerAdapter in project intellij-community by JetBrains.

the class CoverageDataManagerImpl method projectOpened.

public void projectOpened() {
    EditorFactory.getInstance().addEditorFactoryListener(new CoverageEditorFactoryListener(), myProject);
    ProjectManagerAdapter projectManagerListener = new ProjectManagerAdapter() {

        public void projectClosing(Project project) {
            synchronized (myLock) {
                myIsProjectClosing = true;
            }
        }
    };
    ProjectManager.getInstance().addProjectManagerListener(myProject, projectManagerListener);
}
Also used : Project(com.intellij.openapi.project.Project) ProjectManagerAdapter(com.intellij.openapi.project.ProjectManagerAdapter)

Aggregations

Project (com.intellij.openapi.project.Project)8 ProjectManagerAdapter (com.intellij.openapi.project.ProjectManagerAdapter)8 VirtualFile (com.intellij.openapi.vfs.VirtualFile)2 AppLifecycleListener (com.intellij.ide.AppLifecycleListener)1 EditorMouseEvent (com.intellij.openapi.editor.event.EditorMouseEvent)1 FileEditorManager (com.intellij.openapi.fileEditor.FileEditorManager)1 FileEditorManagerListener (com.intellij.openapi.fileEditor.FileEditorManagerListener)1 ProcessCanceledException (com.intellij.openapi.progress.ProcessCanceledException)1 ProjectManager (com.intellij.openapi.project.ProjectManager)1 Pair (com.intellij.openapi.util.Pair)1 EditorPopupHandler (com.intellij.util.EditorPopupHandler)1 MouseEvent (java.awt.event.MouseEvent)1 IOException (java.io.IOException)1 List (java.util.List)1 ExecutionException (java.util.concurrent.ExecutionException)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 NotNull (org.jetbrains.annotations.NotNull)1 IdeScriptEngine (org.jetbrains.ide.script.IdeScriptEngine)1 IdeScriptException (org.jetbrains.ide.script.IdeScriptException)1