com.intellij.openapi.project.impl.ProjectManagerImpl Java Examples

The following examples show how to use com.intellij.openapi.project.impl.ProjectManagerImpl. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AndroidModuleLibraryManager.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public void init41(@Nullable ProgressIndicator indicator) {
  boolean finished = false;
  try {
    //ProjectManagerImpl.initProject(path, this, true, null, null);
    Method method = ReflectionUtil
      .getDeclaredMethod(ProjectManagerImpl.class, "initProject", Path.class, ProjectImpl.class, boolean.class, Project.class,
                         ProgressIndicator.class);
    assert (method != null);
    try {
      method.invoke(null, path, this, true, null, null);
    }
    catch (IllegalAccessException | InvocationTargetException e) {
      throw new RuntimeException(e);
    }
    finished = true;
  }
  finally {
    if (!finished) {
      TransactionGuard.submitTransaction(this, () -> WriteAction.run(() -> Disposer.dispose(this)));
    }
  }
}
 
Example #2
Source File: AndroidModuleLibraryManager.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public void init41(@Nullable ProgressIndicator indicator) {
  boolean finished = false;
  try {
    //ProjectManagerImpl.initProject(path, this, true, null, null);
    Method method = ReflectionUtil
      .getDeclaredMethod(ProjectManagerImpl.class, "initProject", Path.class, ProjectImpl.class, boolean.class, Project.class,
                         ProgressIndicator.class);
    assert (method != null);
    try {
      method.invoke(null, path, this, true, null, null);
    }
    catch (IllegalAccessException | InvocationTargetException e) {
      throw new RuntimeException(e);
    }
    finished = true;
  }
  finally {
    if (!finished) {
      TransactionGuard.submitTransaction(this, () -> WriteAction.run(() -> Disposer.dispose(this)));
    }
  }
}
 
Example #3
Source File: DesktopApplicationImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
@RequiredUIAccess
private boolean disposeSelf(final boolean checkCanCloseProject) {
  final ProjectManagerImpl manager = (ProjectManagerImpl)ProjectManagerEx.getInstanceEx();
  if (manager != null) {
    final boolean[] canClose = {true};
    for (final Project project : manager.getOpenProjects()) {
      try {
        CommandProcessor.getInstance().executeCommand(project, () -> {
          if (!manager.closeProject(project, true, true, checkCanCloseProject)) {
            canClose[0] = false;
          }
        }, ApplicationBundle.message("command.exit"), null);
      }
      catch (Throwable e) {
        LOG.error(e);
      }
      if (!canClose[0]) {
        return false;
      }
    }
  }
  runWriteAction(() -> consulo.disposer.Disposer.dispose(DesktopApplicationImpl.this));

  consulo.disposer.Disposer.assertIsEmpty();
  return true;
}
 
Example #4
Source File: ProjectUtils.java    From EclipseCodeFormatter with Apache License 2.0 5 votes vote down vote up
public static void notifyProjectsWhichUsesThisSettings(Settings deletedSettings, Project project) {
	Project[] openProjects = ProjectManagerImpl.getInstance().getOpenProjects();
	for (Project openProject : openProjects) {
		ProjectComponent component = openProject.getComponent(ProjectComponent.class);
		if (component != null) {
			Settings state = component.getSelectedProfile();
			if (deletedSettings.getId().equals(state.getId())) {
				component.getProjectSettings().getState().setSelectedGlobalProfile(null);
				if (project != openProject) {
					Notifier.notifyDeletedSettings(component.getProject());
				}
			}
		}
	}
}
 
Example #5
Source File: ProjectUtils.java    From EclipseCodeFormatter with Apache License 2.0 5 votes vote down vote up
public static void applyToAllOpenedProjects(Settings updatedSettings) {
	Project[] openProjects = ProjectManagerImpl.getInstance().getOpenProjects();
	for (Project openProject : openProjects) {
		ProjectComponent component = openProject.getComponent(ProjectComponent.class);
		if (component != null) {
			Settings state = component.getSelectedProfile();
			if (updatedSettings.getId().equals(state.getId())) {
				component.globalProfileUpdated(updatedSettings);
			}
		}
	}
}
 
Example #6
Source File: LightPlatformTestCase.java    From consulo with Apache License 2.0 5 votes vote down vote up
public static PsiDocumentManagerImpl clearUncommittedDocuments(@Nonnull Project project) {
  PsiDocumentManagerImpl documentManager = (PsiDocumentManagerImpl)PsiDocumentManager.getInstance(project);
  documentManager.clearUncommittedDocuments();

  ProjectManagerImpl projectManager = (ProjectManagerImpl)ProjectManager.getInstance();
  if (((DefaultProjectFactoryImpl)DefaultProjectFactory.getInstance()).isDefaultProjectInitialized()) {
    Project defaultProject = projectManager.getDefaultProject();
    ((PsiDocumentManagerImpl)PsiDocumentManager.getInstance(defaultProject)).clearUncommittedDocuments();
  }
  return documentManager;
}