Java 类com.intellij.openapi.components.impl.stores.IProjectStore 实例源码

项目:intellij-ce-playground    文件:ProjectUtil.java   
private static boolean isSameProject(String path, @NotNull Project project) {
  IProjectStore projectStore = (IProjectStore)ServiceKt.getStateStore(project);

  String toOpen = FileUtil.toSystemIndependentName(path);
  String existing = projectStore.getProjectFilePath();

  String existingBaseDir = projectStore.getProjectBasePath();
  if (existingBaseDir == null) {
    // could be null if not yet initialized
    return false;
  }

  final File openFile = new File(toOpen);
  if (openFile.isDirectory()) {
    return FileUtil.pathsEqual(toOpen, existingBaseDir);
  }
  if (StorageScheme.DIRECTORY_BASED == projectStore.getStorageScheme()) {
    // todo: check if IPR is located not under the project base dir
    return FileUtil.pathsEqual(FileUtil.toSystemIndependentName(openFile.getParentFile().getPath()), existingBaseDir);
  }

  return FileUtil.pathsEqual(toOpen, existing);
}
项目:tools-idea    文件:ProjectUtil.java   
private static boolean isSameProject(String path, Project p) {
  final IProjectStore projectStore = ((ProjectEx)p).getStateStore();

  String toOpen = FileUtil.toSystemIndependentName(path);
  String existing = FileUtil.toSystemIndependentName(projectStore.getProjectFilePath());

  final VirtualFile existingBaseDir = projectStore.getProjectBaseDir();
  if (existingBaseDir == null) return false; // could be null if not yet initialized

  final File openFile = new File(toOpen);
  if (openFile.isDirectory()) {
    return FileUtil.pathsEqual(toOpen, existingBaseDir.getPath());
  }
  if (StorageScheme.DIRECTORY_BASED == projectStore.getStorageScheme()) {
    // todo: check if IPR is located not under the project base dir
    return FileUtil.pathsEqual(FileUtil.toSystemIndependentName(openFile.getParentFile().getPath()), existingBaseDir.getPath());
  }

  return FileUtil.pathsEqual(toOpen, existing);
}
项目:tools-idea    文件:ProjectFileVersionImpl.java   
@Override
public void disposeComponent() {
  if (myProject.isDefault() || ApplicationManager.getApplication().isUnitTestMode()) return;
  final IProjectStore stateStore = ((ProjectEx)myProject).getStateStore();
  final String filePath;
  if (stateStore.getStorageScheme() == StorageScheme.DEFAULT) {
    filePath = stateStore.getProjectFilePath();
  }
  else {
    final VirtualFile baseDir = stateStore.getProjectBaseDir();
    filePath = baseDir != null ? baseDir.getPath() : null;
  }
  if (filePath != null) {
    ConversionServiceImpl.saveConversionResult(FileUtil.toSystemDependentName(filePath));
  }
  else {
    LOG.info("Cannot save conversion result: filePath == null");
  }
}
项目:consulo    文件:ProjectUtil.java   
public static boolean isSameProject(@Nullable String projectFilePath, @Nonnull Project project) {
  if (projectFilePath == null) return false;

  IProjectStore projectStore = ((ProjectEx)project).getStateStore();
  String existingBaseDirPath = projectStore.getProjectBasePath();
  if (existingBaseDirPath == null) {
    // could be null if not yet initialized
    return false;
  }

  File projectFile = new File(projectFilePath);
  if (projectFile.isDirectory()) {
    return FileUtil.pathsEqual(projectFilePath, existingBaseDirPath);
  }


  File parent = projectFile.getParentFile();
  if (parent.getName().equals(Project.DIRECTORY_STORE_FOLDER)) {
    parent = parent.getParentFile();
    return parent != null && FileUtil.pathsEqual(parent.getPath(), existingBaseDirPath);
  }
  return false;
}
项目:intellij-ce-playground    文件:ProjectImpl.java   
@NonNls
@Override
public String getPresentableUrl() {
  if (myName == null || isDefault()) {
    // not yet initialized
    return null;
  }

  IProjectStore store = getStateStore();
  String path = store.getStorageScheme() == StorageScheme.DIRECTORY_BASED ? store.getProjectBasePath() : store.getProjectFilePath();
  return path == null ? null : FileUtil.toSystemDependentName(path);
}
项目:intellij-ce-playground    文件:ProjectImpl.java   
private boolean isToSaveProjectName() {
  if (!isDefault()) {
    IProjectStore stateStore = getStateStore();
    if (stateStore.getStorageScheme().equals(StorageScheme.DIRECTORY_BASED)) {
      String basePath = stateStore.getProjectBasePath();
      File baseDir = basePath == null ? null : new File(basePath);
      if (baseDir != null && baseDir.exists()) {
        return myOldName != null && !myOldName.equals(getName());
      }
    }
  }

  return false;
}
项目:intellij-ce-playground    文件:NonProjectFileWritingAccessProvider.java   
private static boolean isProjectFile(@NotNull VirtualFile file, @NotNull Project project) {
  ProjectFileIndex fileIndex = ProjectFileIndex.SERVICE.getInstance(project);
  if (fileIndex.isInContent(file)) return true;
  if (!Registry.is("ide.hide.excluded.files") && fileIndex.isExcluded(file) && !fileIndex.isUnderIgnored(file)) return true;

  if (project instanceof ProjectEx && !project.isDefault()) {
    if (ProjectUtil.isDirectoryBased(project)) {
      VirtualFile baseDir = project.getBaseDir();
      VirtualFile dotIdea = baseDir == null ? null : baseDir.findChild(Project.DIRECTORY_STORE_FOLDER);
      if (dotIdea != null && VfsUtilCore.isAncestor(dotIdea, file, false)) return true;
    }

    IProjectStore store = (IProjectStore)ServiceKt.getStateStore(project);
    String filePath = file.getPath();
    if (FileUtil.namesEqual(filePath, store.getWorkspaceFilePath()) || FileUtil.namesEqual(filePath, store.getProjectFilePath())) {
      return true;
    }
    for (Module module : ModuleManager.getInstance(project).getModules()) {
      if (FileUtil.namesEqual(filePath, module.getModuleFilePath())) {
        return true;
      }
    }
  }

  for (NonProjectFileWritingAccessExtension each : Extensions.getExtensions(NonProjectFileWritingAccessExtension.EP_NAME, project)) {
    if(each.isWritable(file)) return true;
  }

  return false;
}
项目:tools-idea    文件:ProjectImpl.java   
@NotNull
@Override
public IProjectStore getStateStore() {
  IProjectStore componentStore = myComponentStore;
  if (componentStore != null) return componentStore;
  synchronized (this) {
    componentStore = myComponentStore;
    if (componentStore == null) {
      myComponentStore = componentStore = (IProjectStore)getPicoContainer().getComponentInstance(IComponentStore.class);
    }
    return componentStore;
  }
}
项目:tools-idea    文件:ProjectImpl.java   
public boolean isToSaveProjectName() {
  if (!isDefault()) {
    final IProjectStore stateStore = getStateStore();
    if (stateStore.getStorageScheme().equals(StorageScheme.DIRECTORY_BASED)) {
      final VirtualFile baseDir = stateStore.getProjectBaseDir();
      if (baseDir != null && baseDir.isValid()) {
        return myOldName != null && !myOldName.equals(getName());
      }
    }
  }

  return false;
}
项目:tools-idea    文件:ProjectStoreImplIdeaDirTest.java   
public void testLoadFromDirectoryStorage() throws Exception {
  final IProjectStore projectStore = ((ProjectEx)myProject).getStateStore();
  ((ProjectEx)myProject).setOptimiseTestLoadSpeed(false);

  final TestIprComponent testIprComponent = new TestIprComponent();
  projectStore.initComponent(testIprComponent, false);
  assertNotNull(testIprComponent.myState);
}
项目:tools-idea    文件:ProjectStoreImplIprFileTest.java   
public void testLoadFromOldStorage() throws Exception {
  final IProjectStore projectStore = ((ProjectEx)myProject).getStateStore();

  ((ProjectEx)myProject).setOptimiseTestLoadSpeed(false);

  final TestIprComponent testIprComponent = new TestIprComponent();
  projectStore.initComponent(testIprComponent, false);
  assertNotNull(testIprComponent.myState);
}
项目:consulo    文件:ProjectStoreImplIdeaDirTest.java   
public void testLoadFromDirectoryStorage() throws Exception {
  final IProjectStore projectStore = ((ProjectEx)myProject).getStateStore();
  ((ProjectEx)myProject).setOptimiseTestLoadSpeed(false);

  final TestIprComponent testIprComponent = new TestIprComponent();
  projectStore.initComponent(testIprComponent);
  assertNotNull(testIprComponent.myState);
}
项目:intellij-ce-playground    文件:ProjectImpl.java   
@NotNull
IProjectStore getStateStore() {
  return (IProjectStore)ServiceKt.getStateStore(this);
}
项目:intellij-ce-playground    文件:ProjectUtil.java   
public static boolean isDirectoryBased(@NotNull Project project) {
  IComponentStore store = ServiceKt.getStateStore(project);
  return store instanceof IProjectStore && StorageScheme.DIRECTORY_BASED.equals(((IProjectStore)store).getStorageScheme());
}
项目:intellij-ce-playground    文件:ProjectRootManagerComponent.java   
@Nullable
private Pair<Set<String>, Set<String>> getAllRoots(boolean includeSourceRoots) {
  if (myProject.isDefault()) return null;

  final Set<String> recursive = new HashSet<String>();
  final Set<String> flat = new HashSet<String>();

  final String projectFilePath = myProject.getProjectFilePath();
  final File projectDirFile = projectFilePath == null ? null : new File(projectFilePath).getParentFile();
  if (projectDirFile != null && projectDirFile.getName().equals(Project.DIRECTORY_STORE_FOLDER)) {
    recursive.add(projectDirFile.getAbsolutePath());
  }
  else {
    flat.add(projectFilePath);
    // may be not existing yet
    ContainerUtil.addIfNotNull(flat, ((IProjectStore)ServiceKt.getStateStore(myProject)).getWorkspaceFilePath());
  }

  for (WatchedRootsProvider extension : Extensions.getExtensions(WatchedRootsProvider.EP_NAME, myProject)) {
    recursive.addAll(extension.getRootsToWatch());
  }

  final Module[] modules = ModuleManager.getInstance(myProject).getModules();
  for (Module module : modules) {
    flat.add(module.getModuleFilePath());

    final ModuleRootManager moduleRootManager = ModuleRootManager.getInstance(module);

    addRootsToTrack(moduleRootManager.getContentRootUrls(), recursive, flat);

    if (includeSourceRoots) {
      addRootsToTrack(moduleRootManager.getSourceRootUrls(), recursive, flat);
    }

    final OrderEntry[] orderEntries = moduleRootManager.getOrderEntries();
    for (OrderEntry entry : orderEntries) {
      if (entry instanceof LibraryOrSdkOrderEntry) {
        final LibraryOrSdkOrderEntry libSdkEntry = (LibraryOrSdkOrderEntry)entry;
        for (OrderRootType orderRootType : OrderRootType.getAllTypes()) {
          addRootsToTrack(libSdkEntry.getRootUrls(orderRootType), recursive, flat);
        }
      }
    }
  }

  return Pair.create(recursive, flat);
}
项目:tools-idea    文件:MockProjectEx.java   
@Override
@NotNull
public IProjectStore getStateStore() {
  return new MockProjectStore();
}
项目:tools-idea    文件:ProjectEx.java   
@NotNull
IProjectStore getStateStore();
项目:tools-idea    文件:ProjectManagerImpl.java   
public void reloadProjectImpl(@NotNull final Project p, final boolean clearCopyToRestore) {
  if (clearCopyToRestore) {
    mySavedCopies.clear();
    mySavedTimestamps.clear();
  }

  final Project[] project = {p};

  ProjectReloadState.getInstance(project[0]).onBeforeAutomaticProjectReload();
  final Application application = ApplicationManager.getApplication();

  application.invokeLater(new Runnable() {
    @Override
    public void run() {
      LOG.debug("Reloading project.");
      ProjectImpl projectImpl = (ProjectImpl)project[0];
      if (projectImpl.isDisposed()) return;
      IProjectStore projectStore = projectImpl.getStateStore();
      final String location = projectImpl.getPresentableUrl();

      final List<IFile> original;
      try {
        final IComponentStore.SaveSession saveSession = projectStore.startSave();
        original = saveSession.getAllStorageFiles(true);
        saveSession.finishSave();
      }
      catch (IOException e) {
        LOG.error(e);
        return;
      }

      if (project[0].isDisposed() || ProjectUtil.closeAndDispose(project[0])) {
        application.runWriteAction(new Runnable() {
          @Override
          public void run() {
            for (final IFile originalFile : original) {
              restoreCopy(LocalFileSystem.getInstance().refreshAndFindFileByIoFile(originalFile));
            }
          }
        });

        project[0] = null; // Let it go.

        ProjectUtil.openProject(location, null, true);
      }
    }
  }, ModalityState.NON_MODAL);
}
项目:consulo    文件:MockProjectEx.java   
@Override
@Nonnull
public IProjectStore getStateStore() {
  return new MockProjectStore();
}
项目:consulo    文件:ProjectEx.java   
@Nonnull
IProjectStore getStateStore();
项目:consulo    文件:StoreIgnoredFileProvider.java   
@Override
public boolean isIgnoredFile(@Nonnull Project project, @Nonnull FilePath filePath) {
  IProjectStore stateStore = ((ProjectEx)project).getStateStore();
  return Comparing.equal(filePath.getVirtualFile(), stateStore.getWorkspaceFile());
}