Java 类com.intellij.openapi.project.impl.ProjectManagerImpl 实例源码

项目:intellij-codeception-integration    文件:MyMouseAdapter.java   
@Override
public void mouseClicked(MouseEvent e) {
    Project project = ProjectManagerImpl.getInstance().getOpenProjects()[0];
    if(project.getBasePath() == null) {
        return;
    }

    if (e.getClickCount() == 2 && e.getButton() == MouseEvent.BUTTON1) {
        JTree tree = (JTree) e.getSource();
        TreePath path = tree.getClosestPathForLocation(e.getX(), e.getY());
        if (path != null) {
            DefaultMutableTreeNode comp = (DefaultMutableTreeNode) path.getLastPathComponent();
            TestNode node = (TestNode) (comp.getUserObject());
            if(node.getPayload() == null || (File)node.getPayload() == null) {
                return;
            }
            VirtualFile fileToOpen = VfsUtil.findFileByIoFile((File)node.getPayload(), true);
            if(fileToOpen == null) {
                return;
            }
            OpenFileDescriptor d = new OpenFileDescriptor(project, fileToOpen, 0);
            d.navigate(true);
        }
    }
}
项目:intellij-ce-playground    文件:LightPlatformTestCase.java   
@SuppressWarnings("UseOfSystemOutOrSystemErr")
public static void reportTestExecutionStatistics() {
  System.out.println("----- TEST STATISTICS -----");
  UsefulTestCase.logSetupTeardownCosts();
  System.out.println(String.format("##teamcity[buildStatisticValue key='ideaTests.appInstancesCreated' value='%d']",
                                   MockApplication.INSTANCES_CREATED));
  System.out.println(String.format("##teamcity[buildStatisticValue key='ideaTests.projectInstancesCreated' value='%d']",
                                   ProjectManagerImpl.TEST_PROJECTS_CREATED));
  long totalGcTime = 0;
  for (GarbageCollectorMXBean mxBean : ManagementFactory.getGarbageCollectorMXBeans()) {
    totalGcTime += mxBean.getCollectionTime();
  }
  System.out.println(String.format("##teamcity[buildStatisticValue key='ideaTests.gcTimeMs' value='%d']", totalGcTime));
  System.out.println(String.format("##teamcity[buildStatisticValue key='ideaTests.classesLoaded' value='%d']",
                                   ManagementFactory.getClassLoadingMXBean().getTotalLoadedClassCount()));
}
项目:intellij-ce-playground    文件:PlatformTestCase.java   
public static void cleanupApplicationCaches(Project project) {
  if (project != null && !project.isDisposed()) {
    UndoManagerImpl globalInstance = (UndoManagerImpl)UndoManager.getGlobalInstance();
    if (globalInstance != null) {
      globalInstance.dropHistoryInTests();
    }
    ((UndoManagerImpl)UndoManager.getInstance(project)).dropHistoryInTests();

    ((PsiManagerImpl)PsiManager.getInstance(project)).cleanupForNextTest();
  }

  ProjectManagerImpl projectManager = (ProjectManagerImpl)ProjectManager.getInstance();
  if (projectManager.isDefaultProjectInitialized()) {
    Project defaultProject = projectManager.getDefaultProject();
    ((PsiManagerImpl)PsiManager.getInstance(defaultProject)).cleanupForNextTest();
  }

  LocalFileSystemImpl localFileSystem = (LocalFileSystemImpl)LocalFileSystem.getInstance();
  if (localFileSystem != null) {
    localFileSystem.cleanupForNextTest();
  }

}
项目:intellij-ce-playground    文件:ThemeEditorVirtualFileTest.java   
/**
 * Tests that the theme editor works with the right virtual file
 * when there are several projects with the same name open.
 */
public void testRightProject() throws IOException {
  ProjectManagerEx projectManager = ProjectManagerEx.getInstanceEx();
  Project otherProject = projectManager.newProject(getProject().getName(), FileUtilRt.generateRandomTemporaryPath().getPath(), true, true);
  try {
    assertNotNull(otherProject);
    projectManager.openProject(otherProject);

    ThemeEditorVirtualFile themeEditorVirtualFile = ThemeEditorVirtualFile.getThemeEditorFile(myModule.getProject());
    VirtualFile virtualFile = themeEditorVirtualFile.getFileSystem().findFileByPath(themeEditorVirtualFile.getPath());

    assertEquals(themeEditorVirtualFile, virtualFile);
  }
  finally {
    if (otherProject != null) {
      ((ProjectManagerImpl)projectManager).closeProject(otherProject, false, true, false);
    }
  }
}
项目:consulo    文件:ApplicationImpl.java   
@RequiredDispatchThread
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(() -> Disposer.dispose(ApplicationImpl.this));

  Disposer.assertIsEmpty();
  return true;
}
项目:intellij-codeception-integration    文件:TreeWorker.java   
static void refreshData(JTree jtree)
{
    Project project = ProjectManagerImpl.getInstance().getOpenProjects()[0];
    if(project.getBasePath() == null) {
        return;
    }
    File projectDir = new File(project.getBasePath());
    File codeceptYmlFile = DirWorker.findFile(projectDir, "codeception.yml", null);

    String testsFolder = "";

    try(BufferedReader br = new BufferedReader(new FileReader(codeceptYmlFile))) {
        for (String line; (line = br.readLine()) != null; ) {
            if (line.contains("tests:")) {
                testsFolder = line.replace("tests:", "").trim();
                if(testsFolder.startsWith("/")) {
                    testsFolder = testsFolder.replaceFirst("/", "");
                }
                break;
            }
        }
    } catch (Exception ex) {
        return;
    }
    if(testsFolder.isEmpty()) {
        return;
    }
    File testDir = new File(codeceptYmlFile.getParentFile().getAbsolutePath() + "/" + testsFolder);
    DefaultMutableTreeNode root = new DefaultMutableTreeNode(new TestNode("ROOT", null, null, null, null));
    root = DirWorker.getDirContent(testDir, root, testDir, codeceptYmlFile);
    jtree.setModel(new DefaultTreeModel(root));
}
项目:intellij-ce-playground    文件:LightPlatformTestCase.java   
public static PsiDocumentManagerImpl clearUncommittedDocuments(@NotNull Project project) {
  PsiDocumentManagerImpl documentManager = (PsiDocumentManagerImpl)PsiDocumentManager.getInstance(project);
  documentManager.clearUncommittedDocuments();

  ProjectManagerImpl projectManager = (ProjectManagerImpl)ProjectManager.getInstance();
  if (projectManager.isDefaultProjectInitialized()) {
    Project defaultProject = projectManager.getDefaultProject();
    ((PsiDocumentManagerImpl)PsiDocumentManager.getInstance(defaultProject)).clearUncommittedDocuments();
  }
  return documentManager;
}
项目:intellij-ce-playground    文件:ThreadTracker.java   
public void checkLeak() throws AssertionError {
  try {
    if (myDefaultProjectInitialized != ((ProjectManagerImpl)ProjectManager.getInstance()).isDefaultProjectInitialized()) return;

    Collection<Thread> after = new THashSet<Thread>(getThreads());
    after.removeAll(before);

    for (Thread thread : after) {
      if (thread == Thread.currentThread()) continue;
      ThreadGroup group = thread.getThreadGroup();
      if (group != null && "system".equals(group.getName()))continue;
      String name = thread.getName();
      if (name.startsWith("AWT-EventQueue-0")) continue;
      if (name.startsWith("JobScheduler pool ")) continue;
      if (wellKnownOffenders.contains(name)) continue;

      String trace = "Thread leaked: " + thread+": "+ name +";\n ";
      for (final StackTraceElement stackTraceElement : thread.getStackTrace()) {
        trace += " at "+stackTraceElement +"\n";
      }
      Assert.fail(trace);
    }
  }
  finally {
    before.clear();
  }
}
项目:intellij-ce-playground    文件:ApplicationImpl.java   
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, new Runnable() {
          @Override
          public void run() {
            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(new Runnable() {
    @Override
    public void run() {
      Disposer.dispose(ApplicationImpl.this);
    }
  });

  Disposer.assertIsEmpty();
  return true;
}
项目:tools-idea    文件:LightPlatformTestCase.java   
public static PsiDocumentManagerImpl clearUncommittedDocuments(@NotNull Project project) {
  PsiDocumentManagerImpl documentManager = (PsiDocumentManagerImpl)PsiDocumentManager.getInstance(project);
  documentManager.clearUncommittedDocuments();

  ProjectManagerImpl projectManager = (ProjectManagerImpl)ProjectManager.getInstance();
  if (projectManager.isDefaultProjectInitialized()) {
    Project defaultProject = projectManager.getDefaultProject();
    ((PsiDocumentManagerImpl)PsiDocumentManager.getInstance(defaultProject)).clearUncommittedDocuments();
  }
  return documentManager;
}
项目:tools-idea    文件:ThreadTracker.java   
public void checkLeak() throws AssertionError {
  try {
    if (myDefaultProjectInitialized != ((ProjectManagerImpl)ProjectManager.getInstance()).isDefaultProjectInitialized()) return;

    Collection<Thread> after = new THashSet<Thread>(getThreads());
    after.removeAll(before);

    for (Thread thread : after) {
      if (thread == Thread.currentThread()) continue;
      ThreadGroup group = thread.getThreadGroup();
      if (group != null && "system".equals(group.getName()))continue;
      String name = thread.getName();
      if (name.startsWith("AWT-EventQueue-0")) continue;
      if (name.startsWith("JobScheduler pool ")) continue;
      if (wellKnownOffenders.contains(name)) continue;

      String trace = "Thread leaked: " + thread+": "+ name +";\n ";
      for (final StackTraceElement stackTraceElement : thread.getStackTrace()) {
        trace += " at "+stackTraceElement +"\n";
      }
      Assert.fail(trace);
    }
  }
  finally {
    before.clear();
  }
}
项目:tools-idea    文件:ApplicationImpl.java   
private boolean disposeSelf(final boolean checkCanCloseProject) {
  final CommandProcessor commandProcessor = CommandProcessor.getInstance();
  final boolean[] canClose = {true};
  for (final Project project : ProjectManagerEx.getInstanceEx().getOpenProjects()) {
    try {
      commandProcessor.executeCommand(project, new Runnable() {
        @Override
        public void run() {
          final ProjectManagerImpl manager = (ProjectManagerImpl)ProjectManagerEx.getInstanceEx();
          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;
    }
  }
  ApplicationManager.getApplication().runWriteAction(new Runnable() {
    @Override
    public void run() {
      Disposer.dispose(ApplicationImpl.this);
    }
  });

  Disposer.assertIsEmpty();
  return true;
}
项目:tools-idea    文件:BaseFileConfigurableStoreImpl.java   
@Override
public void load(@NotNull final Element rootElement) throws IOException {
  super.load(rootElement);

  final String v = rootElement.getAttributeValue(VERSION_OPTION);
  if (v != null) {
    myVersion = Integer.parseInt(v);
  }
  else {
    myVersion = ProjectManagerImpl.CURRENT_FORMAT_VERSION;
  }
}
项目:tools-idea    文件:ProjectStoreImpl.java   
@Override
public void load(@NotNull final Element root) throws IOException {
  final String v = root.getAttributeValue(VERSION_OPTION);
  //noinspection AssignmentToStaticFieldFromInstanceMethod
  originalVersion = v != null ? Integer.parseInt(v) : 0;

  if (originalVersion != ProjectManagerImpl.CURRENT_FORMAT_VERSION) {
    convert(root, originalVersion);
  }

  super.load(root);
}
项目:EclipseCodeFormatter    文件:ProjectUtils.java   
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());
                }
            }
        }
    }
}
项目:EclipseCodeFormatter    文件:ProjectUtils.java   
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);
            }
        }
    }
}
项目:consulo    文件:CompilerServerApplication.java   
private boolean disposeSelf(final boolean checkCanCloseProject) {
  final CommandProcessor commandProcessor = CommandProcessor.getInstance();
  final boolean[] canClose = {true};
  for (final Project project : ProjectManagerEx.getInstanceEx().getOpenProjects()) {
    try {
      commandProcessor.executeCommand(project, new Runnable() {
        @Override
        public void run() {
          final ProjectManagerImpl manager = (ProjectManagerImpl)ProjectManagerEx.getInstanceEx();
          if (!manager.closeProject(project, true, true, checkCanCloseProject)) {
            canClose[0] = false;
          }
        }
      }, ApplicationBundle.message("command.exit"), null);
    }
    catch (Throwable e) {
      CompilerServerApplication.LOGGER.error(e);
    }
    if (!canClose[0]) {
      return false;
    }
  }
  ApplicationManager.getApplication().runWriteAction(new Runnable() {
    @Override
    public void run() {
      Disposer.dispose(CompilerServerApplication.this);
    }
  });

  Disposer.assertIsEmpty();
  return true;
}
项目:consulo    文件:LightPlatformTestCase.java   
public static PsiDocumentManagerImpl clearUncommittedDocuments(@Nonnull Project project) {
  PsiDocumentManagerImpl documentManager = (PsiDocumentManagerImpl)PsiDocumentManager.getInstance(project);
  documentManager.clearUncommittedDocuments();

  ProjectManagerImpl projectManager = (ProjectManagerImpl)ProjectManager.getInstance();
  if (projectManager.isDefaultProjectInitialized()) {
    Project defaultProject = projectManager.getDefaultProject();
    ((PsiDocumentManagerImpl)PsiDocumentManager.getInstance(defaultProject)).clearUncommittedDocuments();
  }
  return documentManager;
}
项目:consulo    文件:ThreadTracker.java   
public void checkLeak() throws AssertionError {
  try {
    if (myDefaultProjectInitialized != ((ProjectManagerImpl)ProjectManager.getInstance()).isDefaultProjectInitialized()) return;

    Collection<Thread> after = new THashSet<Thread>(getThreads());
    after.removeAll(before);

    for (Thread thread : after) {
      if (thread == Thread.currentThread()) continue;
      ThreadGroup group = thread.getThreadGroup();
      if (group != null && "system".equals(group.getName()))continue;
      String name = thread.getName();
      if (name.startsWith("AWT-EventQueue-0")) continue;
      if (name.startsWith("JobScheduler pool ")) continue;
      if (wellKnownOffenders.contains(name)) continue;

      String trace = "Thread leaked: " + thread+": "+ name +";\n ";
      for (final StackTraceElement stackTraceElement : thread.getStackTrace()) {
        trace += " at "+stackTraceElement +"\n";
      }
      Assert.fail(trace);
    }
  }
  finally {
    before.clear();
  }
}
项目:intellij-ce-playground    文件:ThreadTracker.java   
public ThreadTracker() {
  before = getThreads();
  myDefaultProjectInitialized = ((ProjectManagerImpl)ProjectManager.getInstance()).isDefaultProjectInitialized();
}
项目:intellij-ce-playground    文件:EditorListenerTracker.java   
public EditorListenerTracker() {
  EncodingManager.getInstance(); //adds listeners
  EditorEventMulticasterImpl multicaster = (EditorEventMulticasterImpl)EditorFactory.getInstance().getEventMulticaster();
  before = multicaster.getListeners();
  myDefaultProjectInitialized = ((ProjectManagerImpl)ProjectManager.getInstance()).isDefaultProjectInitialized();
}
项目:tools-idea    文件:ThreadTracker.java   
public ThreadTracker() {
  before = getThreads();
  myDefaultProjectInitialized = ((ProjectManagerImpl)ProjectManager.getInstance()).isDefaultProjectInitialized();
}
项目:tools-idea    文件:EditorListenerTracker.java   
public EditorListenerTracker() {
  EncodingManager.getInstance(); //adds listeners
  EditorEventMulticasterImpl multicaster = (EditorEventMulticasterImpl)EditorFactory.getInstance().getEventMulticaster();
  before = multicaster.getListeners();
  myDefaultProjectInitialized = ((ProjectManagerImpl)ProjectManager.getInstance()).isDefaultProjectInitialized();
}
项目:tools-idea    文件:BaseFileConfigurableStoreImpl.java   
protected BaseStorageData(BaseStorageData storageData) {
  super(storageData);

  myVersion = ProjectManagerImpl.CURRENT_FORMAT_VERSION;
}
项目:tools-idea    文件:DefaultProjectStoreImpl.java   
public DefaultProjectStoreImpl(final ProjectImpl project, final ProjectManagerImpl projectManager) {
  super(project);
  myProjectManager = projectManager;

  myElement = projectManager.getDefaultProjectRootElement();
}
项目:tools-idea    文件:ReloadProjectAction.java   
public void actionPerformed(AnActionEvent e) {
  Project project = PlatformDataKeys.PROJECT.getData(e.getDataContext());
  if (project != null) {
    ((ProjectManagerImpl)ProjectManager.getInstance()).reloadProjectImpl(project, false);
  }
}
项目:consulo    文件:ThreadTracker.java   
public ThreadTracker() {
  before = getThreads();
  myDefaultProjectInitialized = ((ProjectManagerImpl)ProjectManager.getInstance()).isDefaultProjectInitialized();
}
项目:consulo    文件:EditorListenerTracker.java   
public EditorListenerTracker() {
  EncodingManager.getInstance(); //adds listeners
  EditorEventMulticasterImpl multicaster = (EditorEventMulticasterImpl)EditorFactory.getInstance().getEventMulticaster();
  before = multicaster.getListeners();
  myDefaultProjectInitialized = ((ProjectManagerImpl)ProjectManager.getInstance()).isDefaultProjectInitialized();
}
项目:consulo    文件:DefaultProjectStoreImpl.java   
public DefaultProjectStoreImpl(@Nonnull ProjectImpl project, @Nonnull ProjectManagerImpl projectManager, @Nonnull PathMacroManager pathMacroManager) {
  super(project, pathMacroManager);

  myProjectManager = projectManager;
}