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

项目:tools-idea    文件:ProjectManagerImpl.java   
private void registerProjectToReload(@Nullable final Project project, final VirtualFile cause, @Nullable final StateStorage storage) {
  if (LOG.isDebugEnabled()) {
    LOG.debug("[RELOAD] Registering project to reload: " + cause, new Exception());
  }

  if (project != null) {
    synchronized (myChangedProjectFiles) {
      List<Pair<VirtualFile, StateStorage>> changedProjectFiles = myChangedProjectFiles.get(project);
      if (changedProjectFiles == null) {
        changedProjectFiles = new ArrayList<Pair<VirtualFile, StateStorage>>();
        myChangedProjectFiles.put(project, changedProjectFiles);
      }

      changedProjectFiles.add(new Pair<VirtualFile, StateStorage>(cause, storage));
    }
  }
  else {
    myChangedApplicationFiles.add(new Pair<VirtualFile, StateStorage>(cause, storage));
  }

  myChangedFilesAlarm.cancelAllRequests();
  myChangedFilesAlarm.addRequest(new Runnable() {
    @Override
    public void run() {
      LOG.debug("[RELOAD] Scheduling reload application & project, myReloadBlockCount = " + myReloadBlockCount);
      if (myReloadBlockCount.get() == 0) {
        scheduleReloadApplicationAndProject();
      }
    }
  }, 444);
}
项目:tools-idea    文件:CompoundSaveSession.java   
public CompoundSaveSession(final CompoundExternalizationSession compoundExternalizationSession) {
  final Collection<StateStorage> stateStorages = compoundExternalizationSession.getStateStorages();

  for (StateStorage stateStorage : stateStorages) {
    mySaveSessions.put(stateStorage, stateStorage.startSave(compoundExternalizationSession.getExternalizationSession(stateStorage)));
  }
}
项目:tools-idea    文件:CompoundSaveSession.java   
public List<IFile> getAllStorageFilesToSave() throws StateStorageException {
  List<IFile> result = new ArrayList<IFile>();

  for (StateStorage stateStorage : mySaveSessions.keySet()) {
    final StateStorage.SaveSession saveSession = mySaveSessions.get(stateStorage);

    result.addAll(saveSession.getStorageFilesToSave());
  }

  return result;
}
项目:tools-idea    文件:CompoundSaveSession.java   
public void finishSave() {
  RuntimeException re = null;
  for (StateStorage stateStorage : mySaveSessions.keySet()) {
    final StateStorage.SaveSession saveSession = mySaveSessions.get(stateStorage);
    try {
      stateStorage.finishSave(saveSession);
    } catch(RuntimeException t) {
      re = t;
    }
  }

  if (re != null) {
    throw re;
  }
}
项目:tools-idea    文件:CompoundSaveSession.java   
public List<IFile> getAllStorageFiles() {
  List<IFile> result = new ArrayList<IFile>();
  for (StateStorage.SaveSession saveSession : mySaveSessions.values()) {
    result.addAll(saveSession.getAllStorageFiles());
  }

  return result;
}
项目:tools-idea    文件:CompoundExternalizationSession.java   
@NotNull
public StateStorage.ExternalizationSession getExternalizationSession(@NotNull StateStorage stateStore) {
  StateStorage.ExternalizationSession session = mySessions.get(stateStore);
  if (session == null) {
    mySessions.put(stateStore, session = stateStore.startExternalization());
  }

  return session;
}
项目:tools-idea    文件:XmlElementStorageTest.java   
public void testSetStateOverridesOldState() throws Exception {
  MyXmlElementStorage storage =
      new MyXmlElementStorage(document(tag("root", tag("component", attr("name", "test"), tag("foo")))), myParentDisposable);
  Element newState = tag("component", attr("name", "test"), tag("bar"));
  StateStorage.ExternalizationSession externalizationSession = storage.startExternalization();
  externalizationSession.setState(this, "test", newState, null);
  storage.startSave(externalizationSession).save();
  assertNotNull(storage.mySavedDocument);
  assertNotNull(storage.mySavedDocument.getRootElement().getChild("component").getChild("bar"));
  assertNull(storage.mySavedDocument.getRootElement().getChild("component").getChild("foo"));
}
项目:tools-idea    文件:ProjectWithModulesStoreImpl.java   
@Override
@Nullable
public Set<String> analyzeExternalChanges(@NotNull final Set<Pair<VirtualFile,StateStorage>> changedFiles) {
  final Set<String> result = super.analyzeExternalChanges(changedFiles);
  if (result == null) return null;

  for (SaveSession moduleSaveSession : myModuleSaveSessions) {
    final Set<String> s = moduleSaveSession.analyzeExternalChanges(changedFiles);
    if (s == null) return null;
    result.addAll(s);
  }

  return result;
}
项目:consulo    文件:XmlElementStorageTest.java   
public void testSetStateOverridesOldState() throws Exception {
  MyXmlElementStorage storage =
          new MyXmlElementStorage(tag("root", tag("component", attr("name", "test"), tag("foo"))));
  Element newState = tag("component", attr("name", "test"), tag("bar"));
  StateStorage.ExternalizationSession externalizationSession = storage.startExternalization();
  externalizationSession.setState(this, "test", newState, null);
  externalizationSession.createSaveSession().save();
  assertNotNull(storage.mySavedElement);
  assertNotNull(storage.mySavedElement.getChild("component").getChild("bar"));
  assertNull(storage.mySavedElement.getChild("component").getChild("foo"));
}
项目:intellij-ce-playground    文件:ReadOnlyModificationException.java   
public ReadOnlyModificationException(@NotNull VirtualFile file, @Nullable Throwable cause, StateStorage.SaveSession session) {
  super(cause);

  myFile = file;
  mySession = session;
}
项目:intellij-ce-playground    文件:ReadOnlyModificationException.java   
@Nullable
public StateStorage.SaveSession getSession() {
  return mySession;
}
项目:intellij-ce-playground    文件:ClasspathStorageProvider.java   
@NotNull
StateStorage.ExternalizationSession startExternalization();
项目:intellij-ce-playground    文件:ClasspathSaveSession.java   
@Nullable
@Override
public StateStorage.SaveSession createSaveSession() {
  return modifiedContent.isEmpty() && deletedContent.isEmpty() ? null : this;
}
项目:tools-idea    文件:MockProjectStore.java   
@Override
public boolean reload(@NotNull final Set<Pair<VirtualFile,StateStorage>> changedFiles) {
  throw new UnsupportedOperationException("Method reload not implemented in " + getClass());
}
项目:tools-idea    文件:ProjectManagerImpl.java   
private void saveChangedProjectFile(final VirtualFile file, @Nullable final Project project, final StateStorage storage) {
  if (file.exists()) {
    copyToTemp(file);
  }
  registerProjectToReload(project, file, storage);
}
项目:tools-idea    文件:CompoundSaveSession.java   
public void save() throws StateStorageException {
  for (StateStorage.SaveSession saveSession : mySaveSessions.values()) {
    saveSession.save();
  }
}
项目:tools-idea    文件:CompoundSaveSession.java   
public StateStorage.SaveSession getSaveSession(final StateStorage storage) {
  return mySaveSessions.get(storage);
}
项目:tools-idea    文件:CompoundExternalizationSession.java   
@NotNull
public Collection<StateStorage> getStateStorages() {
  return mySessions.keySet();
}
项目:tools-idea    文件:IApplicationStore.java   
boolean reload(@NotNull Set<Pair<VirtualFile, StateStorage>> changedFiles, @NotNull Collection<String> notReloadableComponents)
throws StateStorageException, IOException;
项目:tools-idea    文件:IComponentStore.java   
@Nullable
Set<String> analyzeExternalChanges(@NotNull Set<Pair<VirtualFile,StateStorage>> changedFiles);
项目:tools-idea    文件:StateStorageManagerImplTest.java   
public void testCreateFileStateStorageMacroSubstituted() {
  StateStorage data = myStateStorageManager.getFileStateStorage("$MACRO1$/test.xml");
  assertThat(data, is(notNullValue()));
}
项目:tools-idea    文件:StateStorageManagerImplTest.java   
public void testCreateFileStateStorageMacroSubstitutedWhenExpansionHas$() {
  myStateStorageManager.addMacro("DOLLAR_MACRO", "/temp/d$");
  StateStorage data = myStateStorageManager.getFileStateStorage("$DOLLAR_MACRO$/test.xml");
  assertThat(data, is(notNullValue()));
}
项目:tools-idea    文件:ClasspathStorage.java   
@Override
@Nullable
public Set<String> analyzeExternalChanges(@NotNull final Set<Pair<VirtualFile, StateStorage>> changedFiles) {
  return null;
}
项目:consulo    文件:MockProjectStore.java   
@Override
public void save(@Nonnull List<Pair<StateStorage.SaveSession, VirtualFile>> readonlyFiles) {
  throw new UnsupportedOperationException();
}
项目:consulo    文件:MockProjectStore.java   
@Nullable
@Override
public Collection<String> reload(@Nonnull Collection<? extends StateStorage> changedStorages) {
  return null;
}
项目:consulo    文件:StateStorageManagerImplTest.java   
public void testCreateFileStateStorageMacroSubstituted() {
  StateStorage data = myStateStorageManager.getStateStorage("$MACRO1$/test.xml", RoamingType.PER_USER);
  assertThat(data, is(notNullValue()));
}
项目:consulo    文件:StateStorageManagerImplTest.java   
public void testCreateFileStateStorageMacroSubstitutedWhenExpansionHas$() {
  myStateStorageManager.addMacro("$DOLLAR_MACRO$", "/temp/d$");
  StateStorage data = myStateStorageManager.getStateStorage("$DOLLAR_MACRO$/test.xml", RoamingType.PER_USER);
  assertThat(data, is(notNullValue()));
}
项目:consulo    文件:StorageUtil.java   
public static boolean isChangedByStorageOrSaveSession(@Nonnull VirtualFileEvent event) {
  return event.getRequestor() instanceof StateStorage.SaveSession || event.getRequestor() instanceof StateStorage;
}
项目:consulo    文件:ProjectStateStorageManager.java   
@Nonnull
@Override
protected StateStorage.Listener createStorageTopicListener() {
  return myProject.getMessageBus().syncPublisher(StateStorage.PROJECT_STORAGE_TOPIC);
}
项目:consulo    文件:ComponentSaveSession.java   
@Nonnull
ComponentSaveSession save(@Nonnull List<Pair<StateStorage.SaveSession, VirtualFile>> readonlyFiles);
项目:consulo    文件:IComponentStore.java   
/**
 * null if reloaded
 * empty list if nothing to reload
 * list of not reloadable components (reload is not performed)
 */
@Nullable
Collection<String> reload(@Nonnull Collection<? extends StateStorage> changedStorages);
项目:intellij-ce-playground    文件:IComponentStore.java   
void save(@NotNull List<Pair<StateStorage.SaveSession, VirtualFile>> readonlyFiles);
项目:tools-idea    文件:IProjectStore.java   
boolean reload(@NotNull Set<Pair<VirtualFile,StateStorage>> changedFiles) throws StateStorageException, IOException;
项目:consulo    文件:IComponentStore.java   
void save(@Nonnull List<Pair<StateStorage.SaveSession, VirtualFile>> readonlyFiles);