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

项目:intellij-ce-playground    文件:AbstractExternalProjectImportBuilder.java   
@SuppressWarnings("unchecked")
private void executeAndRestoreDefaultProjectSettings(@NotNull Project project, @NotNull Runnable task) {
  AbstractExternalSystemSettings systemSettings = ExternalSystemApiUtil.getSettings(project, myExternalSystemId);
  Object systemStateToRestore = null;
  if (systemSettings instanceof PersistentStateComponent) {
    systemStateToRestore = ((PersistentStateComponent)systemSettings).getState();
  }
  systemSettings.copyFrom(myControl.getSystemSettings());
  Collection projectSettingsToRestore = systemSettings.getLinkedProjectsSettings();
  systemSettings.setLinkedProjectsSettings(Collections.singleton(getCurrentExternalProjectSettings()));
  try {
    task.run();
  }
  finally {
    if (systemStateToRestore != null) {
      ((PersistentStateComponent)systemSettings).loadState(systemStateToRestore);
    }
    else {
      systemSettings.setLinkedProjectsSettings(projectSettingsToRestore);
    }
  }
}
项目:intellij-ce-playground    文件:StoreUtil.java   
@NotNull
public static State getStateSpecOrError(@NotNull Class<? extends PersistentStateComponent> componentClass) {
  State spec = getStateSpec(componentClass);
  if (spec != null) {
    return spec;
  }

  PluginId pluginId = PluginManagerCore.getPluginByClassName(componentClass.getName());
  if (pluginId == null) {
    throw new RuntimeException("No @State annotation found in " + componentClass);
  }
  else {
    throw new PluginException("No @State annotation found in " + componentClass, pluginId);
  }
}
项目:intellij-ce-playground    文件:IdeSettingsStatisticsUtils.java   
@Nullable
private static Object getProviderInstance(Object componentInstance) {
  if (componentInstance instanceof PersistentStateComponent) {
    return ((PersistentStateComponent)componentInstance).getState();
  }

  return componentInstance;
}
项目:intellij-ce-playground    文件:FacetUtil.java   
public static void loadFacetConfiguration(final @NotNull FacetConfiguration configuration, final @Nullable Element config)
    throws InvalidDataException {
  if (config != null) {
    if (configuration instanceof PersistentStateComponent) {
      ComponentSerializationUtil.loadComponentState((PersistentStateComponent)configuration, config);
    }
    else {
      configuration.readExternal(config);
    }
  }
}
项目:intellij-ce-playground    文件:FacetUtil.java   
public static Element saveFacetConfiguration(final FacetConfiguration configuration) throws WriteExternalException {
  if (configuration instanceof PersistentStateComponent) {
    Object state = ((PersistentStateComponent)configuration).getState();
    if (state instanceof Element) return ((Element)state);
    return XmlSerializer.serialize(state, new SkipDefaultValuesSerializationFilters());
  }
  else {
    final Element config = new Element(JpsFacetSerializer.CONFIGURATION_TAG);
    configuration.writeExternal(config);
    return config;
  }
}
项目:tools-idea    文件:AbstractExternalProjectImportBuilder.java   
@SuppressWarnings("unchecked")
private void executeAndRestoreDefaultProjectSettings(@NotNull Project project, @NotNull Runnable task) {
  if (!project.isDefault()) {
    task.run();
    return;
  }

  AbstractExternalSystemSettings systemSettings = mySettingsManager.getSettings(project, myExternalSystemId);
  Object systemStateToRestore = null;
  if (systemSettings instanceof PersistentStateComponent) {
    systemStateToRestore = ((PersistentStateComponent)systemSettings).getState();
  }
  systemSettings.copyFrom(myControl.getSystemSettings());
  Collection projectSettingsToRestore = systemSettings.getLinkedProjectsSettings();
  systemSettings.setLinkedProjectsSettings(Collections.singleton(getCurrentExternalProjectSettings()));
  try {
    task.run();
  }
  finally {
    if (systemStateToRestore != null) {
      ((PersistentStateComponent)systemSettings).loadState(systemStateToRestore);
    }
    else {
      systemSettings.setLinkedProjectsSettings(projectSettingsToRestore);
    }
  }
}
项目:tools-idea    文件:IdeSettingsStatisticsUtils.java   
@Nullable
private static Object getProviderInstance(Object componentInstance) {
  if (componentInstance instanceof PersistentStateComponent) {
    return ((PersistentStateComponent)componentInstance).getState();
  }

  return componentInstance;
}
项目:tools-idea    文件:FacetUtil.java   
public static void loadFacetConfiguration(final @NotNull FacetConfiguration configuration, final @Nullable Element config)
    throws InvalidDataException {
  if (config != null) {
    if (configuration instanceof PersistentStateComponent) {
      ComponentSerializationUtil.loadComponentState((PersistentStateComponent)configuration, config);
    }
    else {
      configuration.readExternal(config);
    }
  }
}
项目:tools-idea    文件:FacetUtil.java   
public static Element saveFacetConfiguration(final FacetConfiguration configuration) throws WriteExternalException {
  if (configuration instanceof PersistentStateComponent) {
    Object state = ((PersistentStateComponent)configuration).getState();
    if (state instanceof Element) return ((Element)state);
    return XmlSerializer.serialize(state, new SkipDefaultValuesSerializationFilters());
  }
  else {
    final Element config = new Element(JpsFacetSerializer.CONFIGURATION_TAG);
    configuration.writeExternal(config);
    return config;
  }
}
项目:consulo    文件:AbstractExternalModuleImportProvider.java   
@SuppressWarnings("unchecked")
private void executeAndRestoreDefaultProjectSettings(@Nonnull Project project, @Nonnull Runnable task) {
  if (!project.isDefault()) {
    task.run();
    return;
  }

  AbstractExternalSystemSettings systemSettings = ExternalSystemApiUtil.getSettings(project, myExternalSystemId);
  Object systemStateToRestore = null;
  if (systemSettings instanceof PersistentStateComponent) {
    systemStateToRestore = ((PersistentStateComponent)systemSettings).getState();
  }
  systemSettings.copyFrom(myControl.getSystemSettings());
  Collection projectSettingsToRestore = systemSettings.getLinkedProjectsSettings();
  systemSettings.setLinkedProjectsSettings(Collections.singleton(getCurrentExternalProjectSettings()));
  try {
    task.run();
  }
  finally {
    if (systemStateToRestore != null) {
      ((PersistentStateComponent)systemSettings).loadState(systemStateToRestore);
    }
    else {
      systemSettings.setLinkedProjectsSettings(projectSettingsToRestore);
    }
  }
}
项目:consulo    文件:AbstractExternalProjectImportBuilder.java   
@SuppressWarnings("unchecked")
private void executeAndRestoreDefaultProjectSettings(@Nonnull Project project, @Nonnull Runnable task) {
  if (!project.isDefault()) {
    task.run();
    return;
  }

  AbstractExternalSystemSettings systemSettings = ExternalSystemApiUtil.getSettings(project, myExternalSystemId);
  Object systemStateToRestore = null;
  if (systemSettings instanceof PersistentStateComponent) {
    systemStateToRestore = ((PersistentStateComponent)systemSettings).getState();
  }
  systemSettings.copyFrom(myControl.getSystemSettings());
  Collection projectSettingsToRestore = systemSettings.getLinkedProjectsSettings();
  systemSettings.setLinkedProjectsSettings(Collections.singleton(getCurrentExternalProjectSettings()));
  try {
    task.run();
  }
  finally {
    if (systemStateToRestore != null) {
      ((PersistentStateComponent)systemSettings).loadState(systemStateToRestore);
    }
    else {
      systemSettings.setLinkedProjectsSettings(projectSettingsToRestore);
    }
  }
}
项目:intellij-ce-playground    文件:DeploymentConfigurationBase.java   
@Override
public PersistentStateComponent<?> getSerializer() {
  return this;
}
项目:intellij-ce-playground    文件:DummyDeploymentConfiguration.java   
@Override
public PersistentStateComponent<?> getSerializer() {
  return this;
}
项目:intellij-ce-playground    文件:ServerConfigurationBase.java   
@Override
public PersistentStateComponent<?> getSerializer() {
  return this;
}
项目:intellij-ce-playground    文件:StoreUtil.java   
@NotNull
public static <T> State getStateSpec(@NotNull PersistentStateComponent<T> persistentStateComponent) {
  return getStateSpecOrError(persistentStateComponent.getClass());
}
项目:intellij-ce-playground    文件:ServiceManagerImpl.java   
@Override
public Object getComponentInstance(@NotNull PicoContainer container) throws PicoInitializationException, PicoIntrospectionException {
  Object instance = myInitializedComponentInstance;
  if (instance != null) {
    return instance;
  }

  // we must take read action before adapter lock - if service requested from EDT (2) and pooled (1), will be a deadlock, because EDT waits adapter lock and Pooled waits read lock
  boolean useReadActionToInitService = isUseReadActionToInitService();
  AccessToken readToken = useReadActionToInitService ? ReadAction.start() : null;
  try {
    synchronized (this) {
      instance = myInitializedComponentInstance;
      if (instance != null) {
        // DCL is fine, field is volatile
        return instance;
      }

      ComponentAdapter delegate = getDelegate();

      // useReadActionToInitService is enabled currently only in internal or test mode or explicitly (registry) - we have enough feedback to fix, so, don't disturb all users
      if (!useReadActionToInitService && LOG.isDebugEnabled() && ApplicationManager.getApplication().isWriteAccessAllowed() && PersistentStateComponent.class.isAssignableFrom(delegate.getComponentImplementation())) {
        LOG.warn(new Throwable("Getting service from write-action leads to possible deadlock. Service implementation " + myDescriptor.getImplementation()));
      }

      // prevent storages from flushing and blocking FS
      AccessToken token = HeavyProcessLatch.INSTANCE.processStarted("Creating component '" + myDescriptor.getImplementation() + "'");
      try {
        instance = delegate.getComponentInstance(container);
        if (instance instanceof Disposable) {
          Disposer.register(myComponentManager, (Disposable)instance);
        }

        myComponentManager.initializeComponent(instance, true);

        myInitializedComponentInstance = instance;
        return instance;
      }
      finally {
        token.finish();
      }
    }
  }
  finally {
    if (readToken != null) {
      readToken.finish();
    }
  }
}
项目:intellij-ce-playground    文件:BreakpointsContextProvider.java   
public void loadContext(Element fromElement) throws InvalidDataException {
  //noinspection unchecked
  ((PersistentStateComponent<Element>)myDebuggerManager).loadState(fromElement);
}
项目:tools-idea    文件:DeploymentConfigurationBase.java   
@Override
public PersistentStateComponent<?> getSerializer() {
  return this;
}
项目:tools-idea    文件:DummyDeploymentConfiguration.java   
@Override
public PersistentStateComponent<?> getSerializer() {
  return this;
}
项目:tools-idea    文件:AppEngineServerConfiguration.java   
@Override
public PersistentStateComponent<?> getSerializer() {
  return this;
}
项目:consulo    文件:DeploymentConfigurationBase.java   
@Override
public PersistentStateComponent<?> getSerializer() {
  return this;
}
项目:consulo    文件:DummyDeploymentConfiguration.java   
@Override
public PersistentStateComponent<?> getSerializer() {
  return this;
}
项目:consulo    文件:ServerConfigurationBase.java   
@Override
public PersistentStateComponent<?> getSerializer() {
  return this;
}
项目:intellij-ce-playground    文件:DeploymentConfiguration.java   
public abstract PersistentStateComponent<?> getSerializer();
项目:intellij-ce-playground    文件:ServerConfiguration.java   
public abstract PersistentStateComponent<?> getSerializer();
项目:intellij-ce-playground    文件:IComponentStore.java   
void reloadState(@NotNull Class<? extends PersistentStateComponent<?>> componentClass);
项目:tools-idea    文件:DeploymentConfiguration.java   
public abstract PersistentStateComponent<?> getSerializer();
项目:tools-idea    文件:ServerConfiguration.java   
public abstract PersistentStateComponent<?> getSerializer();
项目:consulo    文件:DeploymentConfiguration.java   
public abstract PersistentStateComponent<?> getSerializer();
项目:consulo    文件:ServerConfiguration.java   
public abstract PersistentStateComponent<?> getSerializer();