當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。