当前位置: 首页>>代码示例>>Java>>正文


Java PersistentStateComponent类代码示例

本文整理汇总了Java中com.intellij.openapi.components.PersistentStateComponent的典型用法代码示例。如果您正苦于以下问题:Java PersistentStateComponent类的具体用法?Java PersistentStateComponent怎么用?Java PersistentStateComponent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


PersistentStateComponent类属于com.intellij.openapi.components包,在下文中一共展示了PersistentStateComponent类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: executeAndRestoreDefaultProjectSettings

import com.intellij.openapi.components.PersistentStateComponent; //导入依赖的package包/类
@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);
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:AbstractExternalProjectImportBuilder.java

示例2: getStateSpecOrError

import com.intellij.openapi.components.PersistentStateComponent; //导入依赖的package包/类
@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);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:16,代码来源:StoreUtil.java

示例3: getProviderInstance

import com.intellij.openapi.components.PersistentStateComponent; //导入依赖的package包/类
@Nullable
private static Object getProviderInstance(Object componentInstance) {
  if (componentInstance instanceof PersistentStateComponent) {
    return ((PersistentStateComponent)componentInstance).getState();
  }

  return componentInstance;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:IdeSettingsStatisticsUtils.java

示例4: loadFacetConfiguration

import com.intellij.openapi.components.PersistentStateComponent; //导入依赖的package包/类
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);
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:FacetUtil.java

示例5: saveFacetConfiguration

import com.intellij.openapi.components.PersistentStateComponent; //导入依赖的package包/类
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;
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:FacetUtil.java

示例6: executeAndRestoreDefaultProjectSettings

import com.intellij.openapi.components.PersistentStateComponent; //导入依赖的package包/类
@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);
    }
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:28,代码来源:AbstractExternalProjectImportBuilder.java

示例7: executeAndRestoreDefaultProjectSettings

import com.intellij.openapi.components.PersistentStateComponent; //导入依赖的package包/类
@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);
    }
  }
}
 
开发者ID:consulo,项目名称:consulo,代码行数:28,代码来源:AbstractExternalModuleImportProvider.java

示例8: getSerializer

import com.intellij.openapi.components.PersistentStateComponent; //导入依赖的package包/类
@Override
public PersistentStateComponent<?> getSerializer() {
  return this;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:5,代码来源:DeploymentConfigurationBase.java

示例9: getStateSpec

import com.intellij.openapi.components.PersistentStateComponent; //导入依赖的package包/类
@NotNull
public static <T> State getStateSpec(@NotNull PersistentStateComponent<T> persistentStateComponent) {
  return getStateSpecOrError(persistentStateComponent.getClass());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:5,代码来源:StoreUtil.java

示例10: getComponentInstance

import com.intellij.openapi.components.PersistentStateComponent; //导入依赖的package包/类
@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();
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:50,代码来源:ServiceManagerImpl.java

示例11: loadContext

import com.intellij.openapi.components.PersistentStateComponent; //导入依赖的package包/类
public void loadContext(Element fromElement) throws InvalidDataException {
  //noinspection unchecked
  ((PersistentStateComponent<Element>)myDebuggerManager).loadState(fromElement);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:5,代码来源:BreakpointsContextProvider.java

示例12: getSerializer

import com.intellij.openapi.components.PersistentStateComponent; //导入依赖的package包/类
public abstract PersistentStateComponent<?> getSerializer(); 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:2,代码来源:DeploymentConfiguration.java

示例13: reloadState

import com.intellij.openapi.components.PersistentStateComponent; //导入依赖的package包/类
void reloadState(@NotNull Class<? extends PersistentStateComponent<?>> componentClass); 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:2,代码来源:IComponentStore.java


注:本文中的com.intellij.openapi.components.PersistentStateComponent类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。