Java 类com.intellij.openapi.project.ex.ProjectEx 实例源码

项目:intellij-ce-playground    文件:LibraryDefinitionsGeneratorFactory.java   
public LibraryDefinitionsGeneratorFactory(ProjectEx project, GenerationOptions genOptions) {
  myProject = project;
  myGenOptions = genOptions;
  final ModuleManager moduleManager = ModuleManager.getInstance(project);
  final Module[] modules = moduleManager.getModules();
  for (Module module : modules) {
    ModuleRootManager.getInstance(module).orderEntries().forEachLibrary(new Processor<Library>() {
      @Override
      public boolean process(Library library) {
        final String name = library.getName();
        if (name != null) {
          myUsedLibraries.add(name);
        }
        return true;
      }
    });
  }
}
项目:intellij-ce-playground    文件:ProjectDataServiceImpl.java   
private static void renameProject(@NotNull final String newName,
                                  @NotNull final ProjectSystemId externalSystemId,
                                  @NotNull final Project project)
{
  if (!(project instanceof ProjectEx) || newName.equals(project.getName())) {
    return;
  }
  ExternalSystemApiUtil.executeProjectChangeAction(true, new DisposeAwareProjectChange(project) {
    @Override
    public void execute() {
      String oldName = project.getName();
      ((ProjectEx)project).setProjectName(newName);
      ExternalSystemApiUtil.getSettings(project, externalSystemId).getPublisher().onProjectRenamed(oldName, newName);
    }
  });
}
项目:intellij-ce-playground    文件:PathMacroManagerTest.java   
private void setUpMocks(final String projectPath) {
  myModule = context.mock(Module.class);
  myPathMacros = context.mock(PathMacrosImpl.class);
  myProject = context.mock(ProjectEx.class);

  final VirtualFile projectFile = context.mock(VirtualFile.class, "projectFile");

  context.checking(new Expectations() {{
    allowing(myModule).isDisposed(); will(returnValue(false));
    allowing(myProject).isDisposed(); will(returnValue(false));

    allowing(projectFile).getPath(); will(returnValue(projectPath));

    final String moduleFilePath = projectPath + "/module/module.iml";

    allowing(myApplication).getComponent(with(equal(PathMacros.class))); will(returnValue(myPathMacros));
    allowing(myPathMacros).addMacroReplacements(with(any(ReplacePathToMacroMap.class)));

    allowing(myProject).getBaseDir(); will(returnValue(projectFile));
    allowing(myModule).getModuleFilePath(); will(returnValue(moduleFilePath));
    allowing(myModule).getProject(); will(returnValue(myProject));
  }});
}
项目:intellij-ce-playground    文件:RenameProjectAction.java   
@Override
public void actionPerformed(AnActionEvent e) {
  final DataContext dataContext = e.getDataContext();
  final Project project = CommonDataKeys.PROJECT.getData(dataContext);
  LOG.assertTrue(project instanceof ProjectEx);
  Module module;
  Module[] modules = ModuleManager.getInstance(project).getModules();
  if (modules.length == 1 && project.getName().equals(modules[0].getName())) {
    module = modules[0];
  }
  else {
    module = null;
  }
  Messages.showInputDialog(project, RefactoringBundle.message("enter.new.project.name"), RefactoringBundle.message("rename.project"),
                           Messages.getQuestionIcon(),
                           project.getName(),
                           new RenameProjectHandler.MyInputValidator((ProjectEx)project, module));
}
项目:tools-idea    文件:LibraryDefinitionsGeneratorFactory.java   
public LibraryDefinitionsGeneratorFactory(ProjectEx project, GenerationOptions genOptions) {
  myProject = project;
  myGenOptions = genOptions;
  final ModuleManager moduleManager = ModuleManager.getInstance(project);
  final Module[] modules = moduleManager.getModules();
  for (Module module : modules) {
    ModuleRootManager.getInstance(module).orderEntries().forEachLibrary(new Processor<Library>() {
      @Override
      public boolean process(Library library) {
        final String name = library.getName();
        if (name != null) {
          myUsedLibraries.add(name);
        }
        return true;
      }
    });
  }
}
项目:tools-idea    文件:ProjectDataServiceImpl.java   
@SuppressWarnings("MethodMayBeStatic")
public void renameProject(@NotNull final String newName,
                          @NotNull final ProjectSystemId externalSystemId,
                          @NotNull final Project project,
                          boolean synchronous)
{
  if (!(project instanceof ProjectEx) || newName.equals(project.getName())) {
    return;
  }
  ExternalSystemApiUtil.executeProjectChangeAction(synchronous, new Runnable() {
    @Override
    public void run() {
      String oldName = project.getName();
      ((ProjectEx)project).setProjectName(newName);
      mySettingsManager.getSettings(project, externalSystemId).getPublisher().onProjectRenamed(oldName, newName);
    }
  });
}
项目: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    文件:PathMacroManagerTest.java   
private void setUpMocks(final String projectPath) {
  myModule = context.mock(Module.class);
  myPathMacros = context.mock(PathMacrosImpl.class);
  myProject = context.mock(ProjectEx.class);

  final VirtualFile projectFile = context.mock(VirtualFile.class, "projectFile");

  context.checking(new Expectations() {{
    allowing(myModule).isDisposed(); will(returnValue(false));
    allowing(myProject).isDisposed(); will(returnValue(false));

    allowing(projectFile).getPath(); will(returnValue(projectPath));

    final String moduleFilePath = projectPath + "/module/module.iml";

    allowing(myApplication).getComponent(with(equal(PathMacros.class))); will(returnValue(myPathMacros));
    allowing(myPathMacros).addMacroReplacements(with(any(ReplacePathToMacroMap.class)));

    allowing(myProject).getBaseDir(); will(returnValue(projectFile));
    allowing(myModule).getModuleFilePath(); will(returnValue(moduleFilePath));
    allowing(myModule).getProject(); will(returnValue(myProject));
  }});
}
项目:tools-idea    文件:DefaultVcsRootPolicy.java   
public String getProjectConfigurationMessage(final Project project) {
  final StorageScheme storageScheme = ((ProjectEx) project).getStateStore().getStorageScheme();
  boolean isDirectoryBased = StorageScheme.DIRECTORY_BASED.equals(storageScheme);
  final String[] parts = new String[] {"Content roots of all modules", "all immediate descendants of project base directory",
    Project.DIRECTORY_STORE_FOLDER + " directory contents"};
  final StringBuilder sb = new StringBuilder(parts[0]);
  if (isDirectoryBased) {
    sb.append(", ");
  } else {
    sb.append(", and ");
  }
  sb.append(parts[1]);
  if (isDirectoryBased) {
    sb.append(", and ");
    sb.append(parts[2]);
  }
  return sb.toString();
}
项目:tools-idea    文件:RenameProjectAction.java   
@Override
public void actionPerformed(AnActionEvent e) {
  final DataContext dataContext = e.getDataContext();
  final Project project = PlatformDataKeys.PROJECT.getData(dataContext);
  LOG.assertTrue(project instanceof ProjectEx);
  Module module;
  Module[] modules = ModuleManager.getInstance(project).getModules();
  if (modules.length == 1 && project.getName().equals(modules[0].getName())) {
    module = modules[0];
  }
  else {
    module = null;
  }
  Messages.showInputDialog(project, RefactoringBundle.message("enter.new.project.name"), RefactoringBundle.message("rename.project"),
                           Messages.getQuestionIcon(),
                           project.getName(),
                           new RenameProjectHandler.MyInputValidator((ProjectEx)project, module));
}
项目:tools-idea    文件:BeforeCheckinHandlerUtil.java   
public static PsiFile[] getPsiFiles(final Project project, final Collection<VirtualFile> selectedFiles) {
  ArrayList<PsiFile> result = new ArrayList<PsiFile>();
  PsiManager psiManager = PsiManager.getInstance(project);

  VirtualFile projectFileDir = null;
  final StorageScheme storageScheme = ((ProjectEx) project).getStateStore().getStorageScheme();
  if (StorageScheme.DIRECTORY_BASED.equals(storageScheme)) {
    VirtualFile baseDir = project.getBaseDir();
    if (baseDir != null) {
      projectFileDir = baseDir.findChild(Project.DIRECTORY_STORE_FOLDER);
    }
  }

  for (VirtualFile file : selectedFiles) {
    if (file.isValid()) {
      if (isUnderProjectFileDir(projectFileDir, file) || !isFileUnderSourceRoot(project, file)) {
        continue;
      }
      PsiFile psiFile = psiManager.findFile(file);
      if (psiFile != null) result.add(psiFile);
    }
  }
  return PsiUtilCore.toPsiFileArray(result);
}
项目:tools-idea    文件:ModuleDefaultVcsRootPolicy.java   
@Override
@Nullable
public VirtualFile getVcsRootFor(final VirtualFile file) {
  if (myBaseDir != null && PeriodicalTasksCloser.getInstance().safeGetService(myProject, FileIndexFacade.class)
    .isValidAncestor(myBaseDir, file)) {
    return myBaseDir;
  }
  final VirtualFile contentRoot = ProjectRootManager.getInstance(myProject).getFileIndex().getContentRootForFile(file);
  if (contentRoot != null) {
    return contentRoot;
  }
  final StorageScheme storageScheme = ((ProjectEx) myProject).getStateStore().getStorageScheme();
  if (StorageScheme.DIRECTORY_BASED.equals(storageScheme) && (myBaseDir != null)) {
    final VirtualFile ideaDir = myBaseDir.findChild(Project.DIRECTORY_STORE_FOLDER);
    if (ideaDir != null && ideaDir.isValid() && ideaDir.isDirectory()) {
      if (VfsUtilCore.isAncestor(ideaDir, file, false)) {
        return ideaDir;
      }
    }
  }
  return null;
}
项目:tools-idea    文件:ConsoleHistoryController.java   
public void install() {
  if (myHelper.getId() != null) {
    ApplicationManager.getApplication().getMessageBus().connect(myConsole).subscribe(
      ProjectEx.ProjectSaved.TOPIC, new ProjectEx.ProjectSaved() {
      @Override
      public void saved(@NotNull final Project project) {
        saveHistory();
      }
    });
    Disposer.register(myConsole, new Disposable() {
      @Override
      public void dispose() {
        saveHistory();
      }
    });
    loadHistory(myHelper.getId());
  }
  configureActions();
  myLastSaveStamp = getCurrentTimeStamp();
}
项目: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    文件:LightPlatformTestCase.java   
@RequiredWriteAction
public static synchronized void closeAndDeleteProject() {
  if (ourProject != null) {
    ApplicationManager.getApplication().assertWriteAccessAllowed();
    for (Sdk registeredSdk : ourRegisteredSdks) {
      SdkTable.getInstance().removeSdk(registeredSdk);
    }
    ((ProjectImpl)ourProject).setTemporarilyDisposed(false);
    final VirtualFile projFile = ((ProjectEx)ourProject).getStateStore().getProjectFile();
    final File projectFile = projFile == null ? null : VfsUtilCore.virtualToIoFile(projFile);
    if (!ourProject.isDisposed()) Disposer.dispose(ourProject);

    if (projectFile != null) {
      FileUtil.delete(projectFile);
    }
    ourProject = null;
  }
}
项目:consulo    文件:PathMacroManagerTest.java   
private void setUpMocks(final String projectPath) {
  myModule = context.mock(Module.class);
  myPathMacros = context.mock(PathMacrosImpl.class);
  myProject = context.mock(ProjectEx.class);

  final VirtualFile projectFile = context.mock(VirtualFile.class, "projectFile");

  context.checking(new Expectations() {{
    allowing(myModule).isDisposed(); will(returnValue(false));
    allowing(myProject).isDisposed(); will(returnValue(false));

    allowing(projectFile).getPath(); will(returnValue(projectPath));

    final String moduleFilePath = projectPath + "/module/module.iml";

    allowing(myApplication).getComponent(with(equal(PathMacros.class))); will(returnValue(myPathMacros));
    allowing(myPathMacros).addMacroReplacements(with(any(ReplacePathToMacroMap.class)));

    allowing(myProject).getBaseDir(); will(returnValue(projectFile));
    allowing(myModule).getModuleDir(); will(returnValue(moduleFilePath));
    allowing(myModule).getProject(); will(returnValue(myProject));
  }});
}
项目:consulo    文件:ProjectDataServiceImpl.java   
@SuppressWarnings("MethodMayBeStatic")
public void renameProject(@Nonnull final String newName,
                          @Nonnull final ProjectSystemId externalSystemId,
                          @Nonnull final Project project,
                          boolean synchronous)
{
  if (!(project instanceof ProjectEx) || newName.equals(project.getName())) {
    return;
  }
  ExternalSystemApiUtil.executeProjectChangeAction(synchronous, new DisposeAwareProjectChange(project) {
    @RequiredDispatchThread
    @Override
    public void execute() {
      String oldName = project.getName();
      ((ProjectEx)project).setProjectName(newName);
      ExternalSystemApiUtil.getSettings(project, externalSystemId).getPublisher().onProjectRenamed(oldName, newName);
    }
  });
}
项目:consulo    文件:ProjectManagerImpl.java   
private boolean shouldReloadProject(@Nonnull Project project) {
  if (project.isDisposed()) {
    return false;
  }

  Collection<StateStorage> causes = new SmartList<>();
  Collection<StateStorage> changes;
  synchronized (myChangedProjectFiles) {
    changes = myChangedProjectFiles.remove(project);
    if (!ContainerUtil.isEmpty(changes)) {
      for (StateStorage change : changes) {
        causes.add(change);
      }
    }
  }

  return !causes.isEmpty() && ComponentStoreImpl.reloadStore(causes, ((ProjectEx)project).getStateStore()) == ReloadComponentStoreStatus.RESTART_AGREED;
}
项目:consulo    文件:ApplicationImpl.java   
@RequiredDispatchThread
@Override
public void saveAll() {
  if (myDoNotSave) return;

  FileDocumentManager.getInstance().saveAllDocuments();

  Project[] openProjects = ProjectManager.getInstance().getOpenProjects();
  for (Project openProject : openProjects) {
    if (openProject.isDisposed()) {
      // debug for https://github.com/consulo/consulo/issues/296
      LOG.error("Project is disposed: " + openProject.getName() + ", isInitialized: " + openProject.isInitialized());
      continue;
    }

    ProjectEx project = (ProjectEx)openProject;
    project.save();
  }

  saveSettings();
}
项目: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;
}
项目:consulo    文件:RenameProjectAction.java   
@Override
public void actionPerformed(AnActionEvent e) {
  final DataContext dataContext = e.getDataContext();
  final Project project = dataContext.getData(CommonDataKeys.PROJECT);
  LOG.assertTrue(project instanceof ProjectEx);
  Module module;
  Module[] modules = ModuleManager.getInstance(project).getModules();
  if (modules.length == 1 && project.getName().equals(modules[0].getName())) {
    module = modules[0];
  }
  else {
    module = null;
  }
  Messages.showInputDialog(project, RefactoringBundle.message("enter.new.project.name"), RefactoringBundle.message("rename.project"),
                           Messages.getQuestionIcon(),
                           project.getName(),
                           new RenameProjectHandler.MyInputValidator((ProjectEx)project, module));
}
项目:intellij-ce-playground    文件:FileDocumentManagerImpl.java   
@Override
public boolean process(final VirtualFile file, final Document document) {
  String message = UIBundle.message("file.cache.conflict.message.text", file.getPresentableUrl());

  final DialogBuilder builder = new DialogBuilder();
  builder.setCenterPanel(new JLabel(message, Messages.getQuestionIcon(), SwingConstants.CENTER));
  builder.addOkAction().setText(UIBundle.message("file.cache.conflict.load.fs.changes.button"));
  builder.addCancelAction().setText(UIBundle.message("file.cache.conflict.keep.memory.changes.button"));
  builder.addAction(new AbstractAction(UIBundle.message("file.cache.conflict.show.difference.button")) {
    @Override
    public void actionPerformed(ActionEvent e) {
      final ProjectEx project = (ProjectEx)ProjectLocator.getInstance().guessProjectForFile(file);

      FileType fileType = file.getFileType();
      String fsContent = LoadTextUtil.loadText(file).toString();
      DocumentContent content1 = DiffContentFactory.getInstance().create(fsContent, fileType);
      DocumentContent content2 = DiffContentFactory.getInstance().create(project, document, file);
      String title = UIBundle.message("file.cache.conflict.for.file.dialog.title", file.getPresentableUrl());
      String title1 = UIBundle.message("file.cache.conflict.diff.content.file.system.content");
      String title2 = UIBundle.message("file.cache.conflict.diff.content.memory.content");
      DiffRequest request = new SimpleDiffRequest(title, content1, content2, title1, title2);
      request.putUserData(DiffUserDataKeys.GO_TO_SOURCE_DISABLE, true);
      DialogBuilder diffBuilder = new DialogBuilder(project);
      DiffRequestPanel diffPanel = DiffManager.getInstance().createRequestPanel(project, diffBuilder, diffBuilder.getWindow());
      diffPanel.setRequest(request);
      diffBuilder.setCenterPanel(diffPanel.getComponent());
      diffBuilder.setDimensionServiceKey("FileDocumentManager.FileCacheConflict");
      diffBuilder.addOkAction().setText(UIBundle.message("file.cache.conflict.save.changes.button"));
      diffBuilder.addCancelAction();
      diffBuilder.setTitle(title);
      if (diffBuilder.show() == DialogWrapper.OK_EXIT_CODE) {
        builder.getDialogWrapper().close(DialogWrapper.CANCEL_EXIT_CODE);
      }
    }
  });
  builder.setTitle(UIBundle.message("file.cache.conflict.dialog.title"));
  builder.setButtonsAlignment(SwingConstants.CENTER);
  builder.setHelpId("reference.dialogs.fileCacheConflict");
  return builder.show() == 0;
}
项目: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;
}
项目:intellij-ce-playground    文件:UndoManagerImpl.java   
public UndoManagerImpl(Application application,
                       ProjectEx project,
                       CommandProcessor commandProcessor,
                       StartupManager startupManager) {
  myProject = project;
  myCommandProcessor = commandProcessor;
  myStartupManager = startupManager;

  init(application);

  myMerger = new CommandMerger(this);
}
项目:intellij-ce-playground    文件:RenameProjectHandler.java   
@Override
public void invoke(@NotNull Project project, @NotNull PsiElement[] elements, DataContext dataContext) {
  LOG.assertTrue(project instanceof ProjectEx);

  final Module module = LangDataKeys.MODULE_CONTEXT.getData(dataContext);
  LOG.assertTrue(module != null);
  Messages.showInputDialog(project, RefactoringBundle.message("enter.new.project.name"), RefactoringBundle.message("rename.project"),
                           Messages.getQuestionIcon(),
                           module.getName(),
                           new MyInputValidator((ProjectEx)project, module));
}
项目:intellij-ce-playground    文件:ConsoleHistoryController.java   
public void install() {
  class Listener extends FileDocumentManagerAdapter implements ProjectEx.ProjectSaved {
    @Override
    public void beforeDocumentSaving(@NotNull Document document) {
      if (document == myConsole.getEditorDocument()) {
        saveHistory();
      }
    }

    @Override
    public void saved(@NotNull Project project) {
      saveHistory();
    }
  }
  Listener listener = new Listener();
  ApplicationManager.getApplication().getMessageBus().connect(myConsole).subscribe(ProjectEx.ProjectSaved.TOPIC, listener);
  myConsole.getProject().getMessageBus().connect(myConsole).subscribe(AppTopics.FILE_DOCUMENT_SYNC, listener);

  myConsole.getVirtualFile().putUserData(CONTROLLER_KEY, this);
  Disposer.register(myConsole, new Disposable() {
    @Override
    public void dispose() {
      myConsole.getVirtualFile().putUserData(CONTROLLER_KEY, null);
      saveHistory();
    }
  });
  if (myHelper.getModel().getHistorySize() == 0) {
    loadHistory(myHelper.getId());
  }
  configureActions();
  myLastSaveStamp = getCurrentTimeStamp();
}
项目:tools-idea    文件:LightPlatformTestCase.java   
public static synchronized void closeAndDeleteProject() {
  if (ourProject != null) {
    ApplicationManager.getApplication().assertWriteAccessAllowed();
    ((ProjectImpl)ourProject).setTemporarilyDisposed(false);
    final VirtualFile projFile = ((ProjectEx)ourProject).getStateStore().getProjectFile();
    final File projectFile = projFile == null ? null : VfsUtilCore.virtualToIoFile(projFile);
    if (!ourProject.isDisposed()) Disposer.dispose(ourProject);

    if (projectFile != null) {
      FileUtil.delete(projectFile);
    }
    ourProject = null;
  }
}
项目:tools-idea    文件:PathMacroConfigurable.java   
public void apply() throws ConfigurationException {
  myEditor.commit();

  final Project[] projects = ProjectManager.getInstance().getOpenProjects();
  for (Project project : projects) {
    ((ProjectEx)project).checkUnknownMacros(false);
  }
}
项目:tools-idea    文件:ApplicationImpl.java   
@Override
public void saveAll() {
  if (myDoNotSave) return;

  FileDocumentManager.getInstance().saveAllDocuments();

  Project[] openProjects = ProjectManager.getInstance().getOpenProjects();
  for (Project openProject : openProjects) {
    ProjectEx project = (ProjectEx)openProject;
    project.save();
  }

  saveSettings();
}
项目:tools-idea    文件:UndoManagerImpl.java   
public UndoManagerImpl(Application application,
                       ProjectEx project,
                       CommandProcessor commandProcessor,
                       StartupManager startupManager) {
  myProject = project;
  myCommandProcessor = commandProcessor;
  myStartupManager = startupManager;

  init(application);

  myMerger = new CommandMerger(this);
}
项目:tools-idea    文件:StorageUtil.java   
public static void notifyUnknownMacros(@NotNull TrackingPathMacroSubstitutor substitutor,
                                       @NotNull final Project project,
                                       @Nullable String componentName) {
  final LinkedHashSet<String> macros = new LinkedHashSet<String>(substitutor.getUnknownMacros(componentName));
  if (macros.isEmpty()) {
    return;
  }

  UIUtil.invokeLaterIfNeeded(new Runnable() {
    public void run() {
      macros.removeAll(getMacrosFromExistingNotifications(project));

      if (!macros.isEmpty()) {
        String format = "<p><i>%s</i> %s undefined. <a href=\"define\">Fix it</a></p>";
        String productName = ApplicationNamesInfo.getInstance().getProductName();
        String content = String.format(format, StringUtil.join(macros, ", "), macros.size() == 1 ? "is" : "are") +
                         "<br>Path variables are used to substitute absolute paths " +
                         "in " + productName + " project files " +
                         "and allow project file sharing in version control systems.<br>" +
                         "Some of the files describing the current project settings contain unknown path variables " +
                         "and " + productName + " cannot restore those paths.";
        new UnknownMacroNotification("Load Error", "Load error: undefined path variables", content, NotificationType.ERROR,
                                     new NotificationListener() {
                                       public void hyperlinkUpdate(@NotNull Notification notification, @NotNull HyperlinkEvent event) {
                                         ((ProjectEx)project).checkUnknownMacros(true);
                                       }
                                     }, macros).notify(project);
      }
    }
  });
}
项目:tools-idea    文件:SaveAsDirectoryBasedFormatAction.java   
@Override
public void update(AnActionEvent e) {
  final Presentation presentation = e.getPresentation();

  final Project project = PlatformDataKeys.PROJECT.getData(e.getDataContext());
  boolean visible = project != null;

  if (project instanceof ProjectEx) {
    visible = ((ProjectEx)project).getStateStore().getStorageScheme() != StorageScheme.DIRECTORY_BASED;
  }

  presentation.setVisible(visible);
}
项目: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);
}
项目:tools-idea    文件:ProjectLevelVcsManagerImpl.java   
private boolean isInDirectoryBasedRoot(final VirtualFile file) {
  if (file == null) return false;
  final StorageScheme storageScheme = ((ProjectEx) myProject).getStateStore().getStorageScheme();
  if (StorageScheme.DIRECTORY_BASED.equals(storageScheme)) {
    final VirtualFile baseDir = myProject.getBaseDir();
    if (baseDir == null) return false;
    final VirtualFile ideaDir = baseDir.findChild(Project.DIRECTORY_STORE_FOLDER);
    return ideaDir != null && ideaDir.isValid() && ideaDir.isDirectory() && VfsUtil.isAncestor(ideaDir, file, false);
  }
  return false;
}
项目:tools-idea    文件:RenameProjectHandler.java   
@Override
public void invoke(@NotNull Project project, @NotNull PsiElement[] elements, DataContext dataContext) {
  LOG.assertTrue(project instanceof ProjectEx);

  final Module module = LangDataKeys.MODULE_CONTEXT.getData(dataContext);
  LOG.assertTrue(module != null);
  Messages.showInputDialog(project, RefactoringBundle.message("enter.new.project.name"), RefactoringBundle.message("rename.project"),
                           Messages.getQuestionIcon(),
                           project.getName(),
                           new MyInputValidator((ProjectEx)project, module));
}
项目: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);
}
项目:consulo    文件:PathMacroConfigurable.java   
public void apply() throws ConfigurationException {
  myEditor.commit();

  final Project[] projects = ProjectManager.getInstance().getOpenProjects();
  for (Project project : projects) {
    ((ProjectEx)project).checkUnknownMacros(false);
  }
}
项目:consulo    文件:ProjectManagerImpl.java   
@Override
public void saveChangedProjectFile(@Nonnull VirtualFile file, @Nonnull Project project) {
  StateStorageManager storageManager = ((ProjectEx)project).getStateStore().getStateStorageManager();
  String fileSpec = storageManager.collapseMacros(file.getPath());
  Couple<Collection<FileBasedStorage>> storages = storageManager.getCachedFileStateStorages(Collections.singletonList(fileSpec), Collections.<String>emptyList());
  FileBasedStorage storage = ContainerUtil.getFirstItem(storages.first);
  // if empty, so, storage is not yet loaded, so, we don't have to reload
  if (storage != null) {
    registerProjectToReload(project, file, storage);
  }
}
项目:consulo    文件:MemoryDiskConflictResolver.java   
public boolean askReloadFromDisk(VirtualFile file, Document document) {
  String message = UIBundle.message("file.cache.conflict.message.text", file.getPresentableUrl());

  final DialogBuilder builder = new DialogBuilder();
  builder.setCenterPanel(new JLabel(message, Messages.getQuestionIcon(), SwingConstants.CENTER));
  builder.addOkAction().setText(UIBundle.message("file.cache.conflict.load.fs.changes.button"));
  builder.addCancelAction().setText(UIBundle.message("file.cache.conflict.keep.memory.changes.button"));
  builder.addAction(new AbstractAction(UIBundle.message("file.cache.conflict.show.difference.button")) {
    @Override
    public void actionPerformed(ActionEvent e) {
      final ProjectEx project = (ProjectEx)ProjectLocator.getInstance().guessProjectForFile(file);

      FileType fileType = file.getFileType();
      String fsContent = LoadTextUtil.loadText(file).toString();
      DocumentContent content1 = DiffContentFactory.getInstance().create(project, fsContent, fileType);
      DocumentContent content2 = DiffContentFactory.getInstance().create(project, document, file);
      String title = UIBundle.message("file.cache.conflict.for.file.dialog.title", file.getPresentableUrl());
      String title1 = UIBundle.message("file.cache.conflict.diff.content.file.system.content");
      String title2 = UIBundle.message("file.cache.conflict.diff.content.memory.content");
      DiffRequest request = new SimpleDiffRequest(title, content1, content2, title1, title2);
      request.putUserData(DiffUserDataKeys.GO_TO_SOURCE_DISABLE, true);
      DialogBuilder diffBuilder = new DialogBuilder(project);
      DiffRequestPanel diffPanel = DiffManager.getInstance().createRequestPanel(project, diffBuilder, diffBuilder.getWindow());
      diffPanel.setRequest(request);
      diffBuilder.setCenterPanel(diffPanel.getComponent());
      diffBuilder.setDimensionServiceKey("FileDocumentManager.FileCacheConflict");
      diffBuilder.addOkAction().setText(UIBundle.message("file.cache.conflict.save.changes.button"));
      diffBuilder.addCancelAction();
      diffBuilder.setTitle(title);
      if (diffBuilder.show() == DialogWrapper.OK_EXIT_CODE) {
        builder.getDialogWrapper().close(DialogWrapper.CANCEL_EXIT_CODE);
      }
    }
  });
  builder.setTitle(UIBundle.message("file.cache.conflict.dialog.title"));
  builder.setButtonsAlignment(SwingConstants.CENTER);
  builder.setHelpId("reference.dialogs.fileCacheConflict");
  return builder.show() == 0;
}