Java 类com.intellij.openapi.components.StoragePathMacros 实例源码

项目:consulo    文件:StorageUtil.java   
public static boolean isProjectOrModuleFile(@Nonnull String fileSpec) {
  return fileSpec.startsWith(StoragePathMacros.PROJECT_CONFIG_DIR);
}
项目:consulo    文件:ApplicationStoreImpl.java   
@SuppressWarnings({"UnusedDeclaration"})
public ApplicationStoreImpl(final ApplicationEx2 application, PathMacroManager pathMacroManager) {
  myApplication = application;
  myStateStorageManager =
          new StateStorageManagerImpl(pathMacroManager.createTrackingSubstitutor(), ROOT_ELEMENT_NAME, application, application.getPicoContainer()) {
            private boolean myConfigDirectoryRefreshed;

            @Nonnull
            @Override
            protected String getConfigurationMacro(boolean directorySpec) {
              return directorySpec ? StoragePathMacros.ROOT_CONFIG : StoragePathMacros.APP_CONFIG;
            }

            @Override
            protected StorageData createStorageData(@Nonnull String fileSpec, @Nonnull String filePath) {
              return new StorageData(ROOT_ELEMENT_NAME);
            }

            @Override
            protected TrackingPathMacroSubstitutor getMacroSubstitutor(@Nonnull final String fileSpec) {
              if (fileSpec.equals(StoragePathMacros.APP_CONFIG + '/' + PathMacrosImpl.EXT_FILE_NAME + DirectoryStorageData.DEFAULT_EXT)) return null;
              return super.getMacroSubstitutor(fileSpec);
            }

            @Override
            protected boolean isUseXmlProlog() {
              return false;
            }

            @Override
            protected void beforeFileBasedStorageCreate() {
              if (!myConfigDirectoryRefreshed && (application.isUnitTestMode() || application.isDispatchThread())) {
                try {
                  VirtualFile configDir = LocalFileSystem.getInstance().refreshAndFindFileByPath(getConfigPath());
                  if (configDir != null) {
                    VfsUtil.markDirtyAndRefresh(false, true, true, configDir);
                  }
                }
                finally {
                  myConfigDirectoryRefreshed = true;
                }
              }
            }
          };
}
项目:consulo    文件:ApplicationStoreImpl.java   
@Override
public void setOptionsPath(@Nonnull String path) {
  myStateStorageManager.addMacro(StoragePathMacros.APP_CONFIG, path);
  myStateStorageManager.addMacro(StoragePathMacros.DEFAULT_FILE, path + "/other" + DirectoryStorageData.DEFAULT_EXT);
}
项目:consulo    文件:ApplicationStoreImpl.java   
@Override
public void setConfigPath(@Nonnull final String configPath) {
  myStateStorageManager.addMacro(StoragePathMacros.ROOT_CONFIG, configPath);
  myConfigPath = configPath;
}
项目:consulo    文件:ProjectStateStorageManager.java   
@Nonnull
@Override
protected String getConfigurationMacro(boolean directorySpec) {
  return StoragePathMacros.PROJECT_CONFIG_DIR;
}
项目:consulo    文件:ExportSettingsAction.java   
@Nonnull
public static MultiMap<File, ExportableItem> getExportableComponentsMap(final boolean onlyExisting) {
  final MultiMap<File, ExportableItem> result = MultiMap.createLinkedSet();

  ApplicationImpl application = (ApplicationImpl)ApplicationManager.getApplication();
  final StateStorageManager storageManager = application.getStateStore().getStateStorageManager();
  ServiceManagerImpl.processAllImplementationClasses(application, (aClass, pluginDescriptor) -> {
    State stateAnnotation = aClass.getAnnotation(State.class);
    if (stateAnnotation != null && !StringUtil.isEmpty(stateAnnotation.name())) {
      int storageIndex;
      Storage[] storages = stateAnnotation.storages();
      if (storages.length == 1) {
        storageIndex = 0;
      }
      else if (storages.length > 1) {
        storageIndex = storages.length - 1;
      }
      else {
        return true;
      }

      Storage storage = storages[storageIndex];
      if (storage.roamingType() != RoamingType.DISABLED) {
        String fileSpec = storageManager.buildFileSpec(storage);

        if (!fileSpec.startsWith(StoragePathMacros.APP_CONFIG)) {
          return true;
        }

        File file = new File(storageManager.expandMacros(fileSpec));

        File additionalExportFile = null;
        if (!StringUtil.isEmpty(stateAnnotation.additionalExportFile())) {
          additionalExportFile = new File(storageManager.expandMacros(stateAnnotation.additionalExportFile()));
          if (onlyExisting && !additionalExportFile.exists()) {
            additionalExportFile = null;
          }
        }

        boolean fileExists = !onlyExisting || file.exists();
        if (fileExists || additionalExportFile != null) {
          File[] files;
          if (additionalExportFile == null) {
            files = new File[]{file};
          }
          else {
            files = fileExists ? new File[]{file, additionalExportFile} : new File[]{additionalExportFile};
          }
          ExportableItem item = new ExportableItem(files, getComponentPresentableName(stateAnnotation, aClass, pluginDescriptor));
          result.putValue(file, item);
          if (additionalExportFile != null) {
            result.putValue(additionalExportFile, item);
          }
        }
      }
    }
    return true;
  });
  return result;
}