本文整理汇总了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);
}
}
}
示例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);
}
}
示例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;
}
示例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);
}
}
}
示例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;
}
}
示例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);
}
}
}
示例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);
}
}
}
示例8: getSerializer
import com.intellij.openapi.components.PersistentStateComponent; //导入依赖的package包/类
@Override
public PersistentStateComponent<?> getSerializer() {
return this;
}
示例9: getStateSpec
import com.intellij.openapi.components.PersistentStateComponent; //导入依赖的package包/类
@NotNull
public static <T> State getStateSpec(@NotNull PersistentStateComponent<T> persistentStateComponent) {
return getStateSpecOrError(persistentStateComponent.getClass());
}
示例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();
}
}
}
示例11: loadContext
import com.intellij.openapi.components.PersistentStateComponent; //导入依赖的package包/类
public void loadContext(Element fromElement) throws InvalidDataException {
//noinspection unchecked
((PersistentStateComponent<Element>)myDebuggerManager).loadState(fromElement);
}
示例12: getSerializer
import com.intellij.openapi.components.PersistentStateComponent; //导入依赖的package包/类
public abstract PersistentStateComponent<?> getSerializer();
示例13: reloadState
import com.intellij.openapi.components.PersistentStateComponent; //导入依赖的package包/类
void reloadState(@NotNull Class<? extends PersistentStateComponent<?>> componentClass);