com.intellij.openapi.components.PersistentStateComponent Java Examples

The following examples show how to use com.intellij.openapi.components.PersistentStateComponent. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AbstractExternalModuleImportProvider.java    From consulo with Apache License 2.0 5 votes vote down vote up
@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);
    }
  }
}
 
Example #2
Source File: SandServerConfiguration.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public PersistentStateComponent<?> getSerializer() {
  return new PersistentStateComponent<Object>() {
    @Nullable
    @Override
    public Object getState() {
      return new Element("state");
    }

    @Override
    public void loadState(Object state) {

    }
  };
}
 
Example #3
Source File: StateComponentInfo.java    From consulo with Apache License 2.0 4 votes vote down vote up
public StateComponentInfo(PersistentStateComponent<T> component, State state) {
  myComponent = component;
  myState = state;
}
 
Example #4
Source File: StateComponentInfo.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
public PersistentStateComponent<T> getComponent() {
  return myComponent;
}
 
Example #5
Source File: DeploymentConfigurationBase.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public PersistentStateComponent<?> getSerializer() {
  return this;
}
 
Example #6
Source File: DummyDeploymentConfiguration.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public PersistentStateComponent<?> getSerializer() {
  return this;
}
 
Example #7
Source File: ServerConfigurationBase.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public PersistentStateComponent<?> getSerializer() {
  return this;
}
 
Example #8
Source File: DeploymentConfiguration.java    From consulo with Apache License 2.0 votes vote down vote up
public abstract PersistentStateComponent<?> getSerializer(); 
Example #9
Source File: ServerConfiguration.java    From consulo with Apache License 2.0 votes vote down vote up
public abstract PersistentStateComponent<?> getSerializer();