use of com.intellij.openapi.project.ProjectManager in project intellij-code-outline by sitano.
the class CodeOutlinePlugin method addProjectListener.
private void addProjectListener() {
ProjectManager pm = ProjectManager.getInstance();
pm.addProjectManagerListener(new ProjectManagerAdapter() {
public void projectOpened(Project project) {
regForProject(project);
}
public void projectClosed(Project project) {
unregForProject(project);
}
});
}
use of com.intellij.openapi.project.ProjectManager in project intellij-code-outline by sitano.
the class CodeOutlinePlugin method createForOpenProjects.
private void createForOpenProjects() {
ProjectManager pm = ProjectManager.getInstance();
Project[] projects = pm.getOpenProjects();
for (Project project : projects) {
regForProject(project);
}
}
use of com.intellij.openapi.project.ProjectManager in project intellij-community by JetBrains.
the class CompilerTask method run.
@Override
public void run(@NotNull final ProgressIndicator indicator) {
myIndicator = indicator;
final ProjectManager projectManager = ProjectManager.getInstance();
projectManager.addProjectManagerListener(myProject, myCloseListener = new CloseListener());
final Semaphore semaphore = ((CompilerManagerImpl) CompilerManager.getInstance(myProject)).getCompilationSemaphore();
boolean acquired = false;
try {
try {
while (!acquired) {
acquired = semaphore.tryAcquire(300, TimeUnit.MILLISECONDS);
if (!acquired && !myWaitForPreviousSession) {
return;
}
if (indicator.isCanceled()) {
// let compile work begin in order to stop gracefuly on cancel event
break;
}
}
} catch (InterruptedException ignored) {
}
if (!isHeadless()) {
addIndicatorDelegate();
}
myCompileWork.run();
} catch (ProcessCanceledException ignored) {
} finally {
try {
indicator.stop();
projectManager.removeProjectManagerListener(myProject, myCloseListener);
} finally {
if (acquired) {
semaphore.release();
}
}
}
}
use of com.intellij.openapi.project.ProjectManager in project intellij-community by JetBrains.
the class ModuleLoadingStressTest method testContentEntryExchange.
public void testContentEntryExchange() throws Exception {
String path = myProject.getBasePath();
int count = 100;
for (int i = 0; i < count; i++) {
String name = "module" + i;
File folder = new File(path, name);
createModule(name, folder, path);
String inner = "inner" + i;
createModule(inner, new File(folder, inner), path);
}
ApplicationManagerEx.getApplicationEx().doNotSave(false);
myProject.save();
String projectFilePath = myProject.getProjectFilePath();
String moduleName = myModule.getName();
ProjectManager manager = ProjectManager.getInstance();
manager.closeProject(myProject);
ApplicationManager.getApplication().runWriteAction(() -> Disposer.dispose(myProject));
myProject = manager.loadAndOpenProject(projectFilePath);
Module[] modules = ModuleManager.getInstance(myProject).getModules();
assertEquals(count * 2 + 1, modules.length);
for (Module module : modules) {
if (moduleName.equals(module.getName()))
continue;
VirtualFile root = ModuleRootManager.getInstance(module).getContentRoots()[0];
assertEquals(module.getName(), root.getName());
}
}
use of com.intellij.openapi.project.ProjectManager in project intellij-community by JetBrains.
the class ApplicationImpl method saveAll.
@Override
public void saveAll() {
if (myDoNotSave)
return;
FileDocumentManager.getInstance().saveAllDocuments();
ProjectManager projectManager = ProjectManager.getInstance();
if (projectManager instanceof ProjectManagerEx) {
((ProjectManagerEx) projectManager).flushChangedProjectFileAlarm();
}
Project[] openProjects = projectManager.getOpenProjects();
for (Project openProject : openProjects) {
openProject.save();
}
saveSettings();
}
Aggregations