mirror of
https://github.com/JetBrains/intellij-sdk-code-samples.git
synced 2025-07-27 16:57:49 +08:00
maxOpenProjects: avoid ServiceManager
This commit is contained in:
parent
1b3de324c8
commit
7cdbebbda3
@ -1,9 +1,8 @@
|
|||||||
// Copyright 2000-2020 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
// Copyright 2000-2021 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||||
|
|
||||||
package org.intellij.sdk.maxOpenProjects;
|
package org.intellij.sdk.maxOpenProjects;
|
||||||
|
|
||||||
import com.intellij.openapi.application.ApplicationManager;
|
import com.intellij.openapi.application.ApplicationManager;
|
||||||
import com.intellij.openapi.components.ServiceManager;
|
|
||||||
import com.intellij.openapi.project.Project;
|
import com.intellij.openapi.project.Project;
|
||||||
import com.intellij.openapi.project.ProjectManagerListener;
|
import com.intellij.openapi.project.ProjectManagerListener;
|
||||||
import com.intellij.openapi.ui.Messages;
|
import com.intellij.openapi.ui.Messages;
|
||||||
@ -27,7 +26,8 @@ public class ProjectOpenCloseListener implements ProjectManagerListener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Get the counting service
|
// Get the counting service
|
||||||
ProjectCountingService projectCountingService = ServiceManager.getService(ProjectCountingService.class);
|
ProjectCountingService projectCountingService =
|
||||||
|
ApplicationManager.getApplication().getService(ProjectCountingService.class);
|
||||||
// Increment the project count
|
// Increment the project count
|
||||||
projectCountingService.incrProjectCount();
|
projectCountingService.incrProjectCount();
|
||||||
// See if the total # of projects violates the limit.
|
// See if the total # of projects violates the limit.
|
||||||
@ -52,7 +52,8 @@ public class ProjectOpenCloseListener implements ProjectManagerListener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Get the counting service
|
// Get the counting service
|
||||||
ProjectCountingService projectCountingService = ServiceManager.getService(ProjectCountingService.class);
|
ProjectCountingService projectCountingService =
|
||||||
|
ApplicationManager.getApplication().getService(ProjectCountingService.class);
|
||||||
// Decrement the count because a project just closed
|
// Decrement the count because a project just closed
|
||||||
projectCountingService.decrProjectCount();
|
projectCountingService.decrProjectCount();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user