com.intellij.openapi.components.StoragePathMacros Java Examples

The following examples show how to use com.intellij.openapi.components.StoragePathMacros. 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: ApplicationStoreImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Inject
public ApplicationStoreImpl(Application application, ApplicationPathMacroManager pathMacroManager, Provider<ApplicationDefaultStoreCache> applicationDefaultStoreCache) {
  super(applicationDefaultStoreCache);
  myApplication = application;
  myStateStorageManager = new StateStorageManagerImpl(pathMacroManager.createTrackingSubstitutor(), ROOT_ELEMENT_NAME, application, () -> null, StateStorageFacade.JAVA_IO) {
    @Nonnull
    @Override
    protected String getConfigurationMacro(boolean directorySpec) {
      return directorySpec ? StoragePathMacros.ROOT_CONFIG : StoragePathMacros.APP_CONFIG;
    }

    @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;
    }
  };
}
 
Example #2
Source File: IoFileBasedStorage.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nullable
private Element processReadException(@Nullable Exception e) {
  boolean contentTruncated = e == null;
  myBlockSavingTheContent = !contentTruncated && (StorageUtil.isProjectOrModuleFile(myFileSpec) || myFileSpec.equals(StoragePathMacros.WORKSPACE_FILE));
  if (!ApplicationManager.getApplication().isUnitTestMode() && !ApplicationManager.getApplication().isHeadlessEnvironment()) {
    if (e != null) {
      LOG.info(e);
    }
    new Notification(Notifications.SYSTEM_MESSAGES_GROUP_ID, "Load Settings", "Cannot load settings from file '" +
                                                                              myFile.getPath() +
                                                                              "': " +
                                                                              (e == null ? "content truncated" : e.getMessage()) +
                                                                              "\n" +
                                                                              (myBlockSavingTheContent ? "Please correct the file content" : "File content will be recreated"),
                     NotificationType.WARNING).notify(null);
  }
  return null;
}
 
Example #3
Source File: VfsFileBasedStorage.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nullable
private Element processReadException(@Nullable Exception e) {
  boolean contentTruncated = e == null;
  myBlockSavingTheContent = !contentTruncated && (StorageUtil.isProjectOrModuleFile(myFileSpec) || myFileSpec.equals(StoragePathMacros.WORKSPACE_FILE));
  if (!ApplicationManager.getApplication().isUnitTestMode() && !ApplicationManager.getApplication().isHeadlessEnvironment()) {
    if (e != null) {
      LOG.info(e);
    }
    new Notification(Notifications.SYSTEM_MESSAGES_GROUP_ID, "Load Settings",
                     "Cannot load settings from file '" +
                     myFile.getPath() + "': " +
                     (e == null ? "content truncated" : e.getMessage()) + "\n" +
                     (myBlockSavingTheContent ? "Please correct the file content" : "File content will be recreated"),
                     NotificationType.WARNING).notify(null);
  }
  return null;
}
 
Example #4
Source File: StorageUtil.java    From consulo with Apache License 2.0 4 votes vote down vote up
public static boolean isProjectOrModuleFile(@Nonnull String fileSpec) {
  return fileSpec.startsWith(StoragePathMacros.PROJECT_CONFIG_DIR);
}
 
Example #5
Source File: ApplicationStoreImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public void setOptionsPath(@Nonnull String path) {
  myStateStorageManager.addMacro(StoragePathMacros.APP_CONFIG, path);
  myStateStorageManager.addMacro(StoragePathMacros.DEFAULT_FILE, path + "/other" + DirectoryStorageData.DEFAULT_EXT);
}
 
Example #6
Source File: ApplicationStoreImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public void setConfigPath(@Nonnull final String configPath) {
  myStateStorageManager.addMacro(StoragePathMacros.ROOT_CONFIG, configPath);
  myConfigPath = configPath;
}
 
Example #7
Source File: ProjectStateStorageManager.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
@Override
protected String getConfigurationMacro(boolean directorySpec) {
  return StoragePathMacros.PROJECT_CONFIG_DIR;
}