com.intellij.util.xmlb.XmlSerializer Java Examples

The following examples show how to use com.intellij.util.xmlb.XmlSerializer. 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: ChangelistConflictTracker.java    From consulo with Apache License 2.0 6 votes vote down vote up
public void loadState(Element from) {
  myConflicts.clear();
  List files = from.getChildren("file");
  for (Object file : files) {
    Element element = (Element)file;
    String path = element.getAttributeValue("path");
    if (path == null) {
      continue;
    }
    VirtualFile vf = LocalFileSystem.getInstance().findFileByIoFile(new File(path));
    if (vf == null || myChangeListManager.getChangeList(vf) == null) {
      continue;
    }
    Conflict conflict = new Conflict();
    conflict.ignored = Boolean.parseBoolean(element.getAttributeValue("ignored"));
    myConflicts.put(path, conflict);
  }
  XmlSerializer.deserializeInto(myOptions, from);
}
 
Example #2
Source File: BazelFieldsTest.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Test
public void shouldUpgradeFieldsFromOldXml() {
  final Element elt = new Element("test");
  addOption(elt, "entryFile", "/tmp/test/dir/lib/main.dart"); // obsolete
  addOption(elt, "launchingScript", "path/to/bazel-run.sh"); // obsolete
  addOption(elt, "bazelTarget", "//path/to/flutter/app:hello");
  addOption(elt, "enableReleaseMode", "true");
  addOption(elt, "additionalArgs", "--android_cpu=x86");

  final BazelFields fields = BazelFields.readFrom(elt);
  XmlSerializer.deserializeInto(fields, elt);
  assertEquals("//path/to/flutter/app:hello", fields.getBazelTarget());
  assertEquals(null, fields.getBazelArgs());
  assertEquals("--android_cpu=x86", fields.getAdditionalArgs());
  assertEquals(true, fields.getEnableReleaseMode());
}
 
Example #3
Source File: MultilanguageDuplocatorSettings.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public Element getState() {
  synchronized (mySettingsMap) {
    Element state = new Element("state");
    if (mySettingsMap.isEmpty()) {
      return state;
    }

    SkipDefaultValuesSerializationFilters filter = new SkipDefaultValuesSerializationFilters();
    for (String name : mySettingsMap.keySet()) {
      Element child = XmlSerializer.serializeIfNotDefault(mySettingsMap.get(name), filter);
      if (child != null) {
        child.setName("object");
        child.setAttribute("language", name);
        state.addContent(child);
      }
    }
    return state;
  }
}
 
Example #4
Source File: MuleSdkManagerImpl.java    From mule-intellij-plugins with Apache License 2.0 6 votes vote down vote up
@Nullable
@Override
public Element getState()
{
    Element element = new Element("mule-sdks");
    try
    {
        for (MuleSdk sdk : sdks)
        {
            final Element sdkElement = new Element("mule-sdk");
            XmlSerializer.serializeInto(sdk, sdkElement, new SkipDefaultValuesSerializationFilters());
            element.addContent(sdkElement);
        }
    }
    catch (XmlSerializationException e)
    {
        LOG.error(e);
    }
    return element;
}
 
Example #5
Source File: RunnerLayout.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nonnull
public Element write(@Nonnull Element parentNode) {
  for (ViewImpl eachState : myViews.values()) {
    if (myLightWeightIds != null && myLightWeightIds.contains(eachState.getID())) {
      continue;
    }
    parentNode.addContent(XmlSerializer.serialize(eachState));
  }

  SkipDefaultValuesSerializationFilters filter = new SkipDefaultValuesSerializationFilters();
  for (TabImpl eachTab : myTabs) {
    if (isUsed(eachTab)) {
      parentNode.addContent(XmlSerializer.serialize(eachTab, filter));
    }
  }

  parentNode.addContent(XmlSerializer.serialize(myGeneral, filter));

  return parentNode;
}
 
Example #6
Source File: DefaultStateSerializer.java    From consulo with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings({"unchecked"})
@Nullable
public static <T> T deserializeState(@Nullable Element stateElement, Class <T> stateClass) throws StateStorageException {
  if (stateElement == null) return null;

  if (stateClass.equals(Element.class)) {
    //assert mergeInto == null;
    return (T)stateElement;
  }
  else if (JDOMExternalizable.class.isAssignableFrom(stateClass)) {
    final T t = ReflectionUtil.newInstance(stateClass);
    try {
      ((JDOMExternalizable)t).readExternal(stateElement);
      return t;
    }
    catch (InvalidDataException e) {
      throw new StateStorageException(e);
    }
  }
  else {
    return XmlSerializer.deserialize(stateElement, stateClass);
  }
}
 
Example #7
Source File: FeatureUsageTrackerImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public void loadState(final Element element) {
  List featuresList = element.getChildren(FEATURE_TAG);
  for (Object aFeaturesList : featuresList) {
    Element featureElement = (Element)aFeaturesList;
    FeatureDescriptor descriptor =
      ((ProductivityFeaturesRegistryImpl)myRegistry).getFeatureDescriptorEx(featureElement.getAttributeValue(ATT_ID));
    if (descriptor != null) {
      descriptor.readStatistics(featureElement);
    }
  }

  Element stats = element.getChild(COMPLETION_STATS_TAG);
  if (stats != null) {
    myCompletionStats = XmlSerializer.deserialize(stats, CompletionStatistics.class);
  }

  Element fStats = element.getChild(FIXES_STATS_TAG);
  if (fStats != null) {
    myFixesStats = XmlSerializer.deserialize(fStats, CumulativeStatistics.class);
  }

  HAVE_BEEN_SHOWN = Boolean.valueOf(element.getAttributeValue(ATT_HAVE_BEEN_SHOWN));
}
 
Example #8
Source File: FeatureUsageTrackerImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public Element getState() {
  Element element = new Element("state");
  ProductivityFeaturesRegistry registry = ProductivityFeaturesRegistry.getInstance();
  Set<String> ids = registry.getFeatureIds();
  for (String id: ids) {
    Element featureElement = new Element(FEATURE_TAG);
    featureElement.setAttribute(ATT_ID, id);
    FeatureDescriptor descriptor = registry.getFeatureDescriptor(id);
    descriptor.writeStatistics(featureElement);
    element.addContent(featureElement);
  }

  Element statsTag = new Element(COMPLETION_STATS_TAG);
  XmlSerializer.serializeInto(myCompletionStats, statsTag);
  element.addContent(statsTag);

  Element fstatsTag = new Element(FIXES_STATS_TAG);
  XmlSerializer.serializeInto(myFixesStats, fstatsTag);
  element.addContent(fstatsTag);

  element.setAttribute(ATT_HAVE_BEEN_SHOWN, String.valueOf(HAVE_BEEN_SHOWN));

  return element;
}
 
Example #9
Source File: MuleSdkManagerImpl.java    From mule-intellij-plugins with Apache License 2.0 6 votes vote down vote up
@Override
public void loadState(Element state)
{
    final List<Element> children = state.getChildren();
    for (Element child : children)
    {
        try
        {
            final MuleSdk deserialize = XmlSerializer.deserialize(child, MuleSdk.class);
            if (deserialize != null && deserialize.getMuleHome() != null)
            {
                sdks.add(deserialize);
            }
        }
        catch (XmlSerializationException e)
        {
            LOG.error(e);
        }
    }
}
 
Example #10
Source File: LocalServerRunConfiguration.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public void writeExternal(Element element) throws WriteExternalException {
  ConfigurationState state = new ConfigurationState();
  if (myDeploymentSource != null) {
    DeploymentSourceType type = myDeploymentSource.getType();
    Element deploymentTag = new Element("deployment").setAttribute(DEPLOYMENT_SOURCE_TYPE_ATTRIBUTE, type.getId());
    type.save(myDeploymentSource, deploymentTag);
    if (myDeploymentConfiguration != null) {
      Object configurationState = myDeploymentConfiguration.getSerializer().getState();
      if (configurationState != null) {
        Element settingsTag = new Element(SETTINGS_ELEMENT);
        XmlSerializer.serializeInto(configurationState, settingsTag, SERIALIZATION_FILTERS);
        deploymentTag.addContent(settingsTag);
      }
    }
    state.myDeploymentTag = deploymentTag;
  }
  XmlSerializer.serializeInto(state, element, SERIALIZATION_FILTERS);
  super.writeExternal(element);
}
 
Example #11
Source File: LocalServerRunConfiguration.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public void readExternal(Element element) throws InvalidDataException {
  super.readExternal(element);
  ConfigurationState state = XmlSerializer.deserialize(element, ConfigurationState.class);
  myDeploymentSource = null;
  if (state != null) {
    Element deploymentTag = state.myDeploymentTag;
    if (deploymentTag != null) {
      String typeId = deploymentTag.getAttributeValue(DEPLOYMENT_SOURCE_TYPE_ATTRIBUTE);
      DeploymentSourceType<?> type = findDeploymentSourceType(typeId);
      if (type != null) {
        myDeploymentSource = type.load(deploymentTag, getProject());
        myDeploymentConfiguration = myDeploymentConfigurator.createDefaultConfiguration(myDeploymentSource);
        ComponentSerializationUtil.loadComponentState(myDeploymentConfiguration.getSerializer(), deploymentTag.getChild(SETTINGS_ELEMENT));
      }
      else {
        LOG.warn("Cannot load deployment source for '" + getName() + "' run configuration: unknown deployment type '" + typeId + "'");
      }
    }
  }
}
 
Example #12
Source File: SdkFieldsTest.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Test
public void roundTripShouldPreserveFields() {
  final SdkFields before = new SdkFields();
  before.setFilePath("main.dart");
  before.setAdditionalArgs("--trace-startup");

  final Element elt = new Element("test");
  XmlSerializer.serializeInto(before, elt, new SkipDefaultValuesSerializationFilters());

  // Make sure we no longer serialize workingDirectory
  assertArrayEquals(new String[]{"additionalArgs", "filePath"}, getOptionNames(elt).toArray());

  final SdkFields after = new SdkFields();
  XmlSerializer.deserializeInto(after, elt);
  assertEquals("main.dart", before.getFilePath());
  assertEquals("--trace-startup", before.getAdditionalArgs());
}
 
Example #13
Source File: BazelFieldsTest.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Test
public void shouldUpgradeFieldsFromOldXml() {
  final Element elt = new Element("test");
  addOption(elt, "entryFile", "/tmp/test/dir/lib/main.dart"); // obsolete
  addOption(elt, "launchingScript", "path/to/bazel-run.sh"); // obsolete
  addOption(elt, "bazelTarget", "//path/to/flutter/app:hello");
  addOption(elt, "enableReleaseMode", "true");
  addOption(elt, "additionalArgs", "--android_cpu=x86");

  final BazelFields fields = BazelFields.readFrom(elt);
  XmlSerializer.deserializeInto(fields, elt);
  assertEquals("//path/to/flutter/app:hello", fields.getBazelTarget());
  assertEquals(null, fields.getBazelArgs());
  assertEquals("--android_cpu=x86", fields.getAdditionalArgs());
  assertEquals(true, fields.getEnableReleaseMode());
}
 
Example #14
Source File: XDebuggerSettingsTest.java    From consulo with Apache License 2.0 6 votes vote down vote up
public void testSerialize() throws Exception {
  XDebuggerSettingManagerImpl settingsManager = XDebuggerSettingManagerImpl.getInstanceImpl();

  MyDebuggerSettings settings = MyDebuggerSettings.getInstance();
  assertNotNull(settings);
  settings.myOption = "239";

  Element element = XmlSerializer.serialize(settingsManager.getState());
  //System.out.println(JDOMUtil.writeElement(element, SystemProperties.getLineSeparator()));

  settings.myOption = "42";
  assertSame(settings, MyDebuggerSettings.getInstance());

  settingsManager.loadState(XmlSerializer.deserialize(element, XDebuggerSettingManagerImpl.SettingsState.class));
  assertSame(settings, MyDebuggerSettings.getInstance());
  assertEquals("239", settings.myOption);
}
 
Example #15
Source File: ThriftFacetConfigurationSerializer.java    From intellij-thrift with Apache License 2.0 6 votes vote down vote up
@Override
protected ThriftCompilerOptions loadExtension(@NotNull Element facetConfigurationElement,
                                              String name,
                                              JpsElement parent,
                                              JpsModule module) {
  ThriftCompilerOptions configuration = XmlSerializer.deserialize(
    facetConfigurationElement,
    ThriftCompilerOptions.class
  );

  if (configuration == null) {
    configuration = new ThriftCompilerOptions();
  }

  return configuration;
}
 
Example #16
Source File: VcsRootCacheStoreTest.java    From p4ic4idea with Apache License 2.0 6 votes vote down vote up
@Test
void serializeRestore_none() {
    MockVirtualFile localDir = MockVirtualFileSystem.createTree("/my/local/file", "data").get("/my/local/file");
    when(idea.getMockLocalFilesystem().findFileByPath("/my/local/file")).thenReturn(localDir);

    VcsRootCacheStore store = new VcsRootCacheStore(localDir);

    VcsRootCacheStore.State originalState = store.getState();
    Element serialized = XmlSerializer.serialize(originalState);
    assertNotNull(serialized);

    VcsRootCacheStore.State restored = XmlSerializer.deserialize(serialized, VcsRootCacheStore.State.class);
    assertNotNull(restored);
    assertEquals("/my/local/file", restored.rootDirectory);
    assertSize(0, restored.configParts);

    VcsRootCacheStore loaded = new VcsRootCacheStore(restored, getClass().getClassLoader());
    assertEquals(localDir, loaded.getRootDirectory());
    assertSize(0, loaded.getConfigParts());
}
 
Example #17
Source File: InspectionProfileEntry.java    From consulo with Apache License 2.0 6 votes vote down vote up
/**
 * Read in settings from XML config.
 * Default implementation uses XmlSerializer so you may use public fields (like <code>int TOOL_OPTION</code>)
 * and bean-style getters/setters (like <code>int getToolOption(), void setToolOption(int)</code>) to store your options.
 *
 * @param node to read settings from.
 * @throws InvalidDataException if the loaded data was not valid.
 */
@SuppressWarnings("deprecation")
public void readSettings(@Nonnull Element node) throws InvalidDataException {
  if (useNewSerializer()) {
    try {
      XmlSerializer.deserializeInto(this, node);
    }
    catch (XmlSerializationException e) {
      throw new InvalidDataException(e);
    }
  }
  else {
    //noinspection UnnecessaryFullyQualifiedName
    com.intellij.openapi.util.DefaultJDOMExternalizer.readExternal(this, node);
  }
}
 
Example #18
Source File: PrimitiveMapTest.java    From p4ic4idea with Apache License 2.0 6 votes vote down vote up
@Test
void serializeDeserialize()
        throws PrimitiveMap.UnmarshalException {
    PrimitiveMap map = new PrimitiveMap();
    map.putString("sk", "string key value");
    map.putStringList("slk", Arrays.asList("one", "two", "three"));
    map.putInt("ixk", Integer.MAX_VALUE);
    map.putInt("ink", Integer.MIN_VALUE);
    map.putLong("lxk", Long.MAX_VALUE);
    map.putLong("lnk", Long.MIN_VALUE);

    Element serialized = XmlSerializer.serialize(map);
    assertNotNull(serialized);
    PrimitiveMap demap = XmlSerializer.deserialize(serialized, PrimitiveMap.class);
    assertEquals("string key value", demap.getStringNotNull("sk"));
    assertContainsExactly(map.getStringList("slk"), "one", "two", "three");
    assertEquals(Integer.MAX_VALUE, demap.getIntNullable("ixk", 0));
    assertEquals(Integer.MIN_VALUE, demap.getIntNullable("ink", 0));
    assertEquals(Long.MAX_VALUE, demap.getLongNullable("lxk", 0));
    assertEquals(Long.MIN_VALUE, demap.getLongNullable("lnk", 0));
}
 
Example #19
Source File: XBreakpointManagerImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nullable
@RequiredWriteAction
<T extends XBreakpointProperties> XLineBreakpoint<T> copyLineBreakpoint(@Nonnull XLineBreakpoint<T> source, @Nonnull String fileUrl, int line) {
  ApplicationManager.getApplication().assertWriteAccessAllowed();
  if (!(source instanceof XLineBreakpointImpl<?>)) {
    return null;
  }
  myDependentBreakpointManager.saveState();
  final LineBreakpointState sourceState = ((XLineBreakpointImpl<?>)source).getState();

  final LineBreakpointState newState = XmlSerializer.deserialize(XmlSerializer.serialize(sourceState, SERIALIZATION_FILTER), LineBreakpointState.class);
  newState.setLine(line);
  newState.setFileUrl(fileUrl);

  //noinspection unchecked
  final XLineBreakpointImpl<T> breakpoint = (XLineBreakpointImpl<T>)createBreakpoint(newState);
  if (breakpoint != null) {
    addBreakpoint(breakpoint, false, true);
    final XBreakpoint<?> masterBreakpoint = myDependentBreakpointManager.getMasterBreakpoint(source);
    if (masterBreakpoint != null) {
      myDependentBreakpointManager.setMasterBreakpoint(breakpoint, masterBreakpoint, sourceState.getDependencyState().isLeaveEnabled());
    }
  }

  return breakpoint;
}
 
Example #20
Source File: XDebuggerSettingManagerImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public SettingsState getState() {
  SettingsState settingsState = new SettingsState();
  settingsState.setDataViewSettings(myDataViewSettings);
  settingsState.setGeneralSettings(myGeneralSettings);

  initSettings();
  if (!mySettingsById.isEmpty()) {
    SkipDefaultValuesSerializationFilters filter = new SkipDefaultValuesSerializationFilters();
    for (XDebuggerSettings<?> settings : mySettingsById.values()) {
      Object subState = settings.getState();
      if (subState != null) {
        Element serializedState = XmlSerializer.serializeIfNotDefault(subState, filter);
        if (!JDOMUtil.isEmpty(serializedState)) {
          SpecificSettingsState state = new SpecificSettingsState();
          state.id = settings.getId();
          state.configuration = serializedState;
          settingsState.specificStates.add(state);
        }
      }
    }
  }
  return settingsState;
}
 
Example #21
Source File: MultilanguageDuplocatorSettings.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public void loadState(@Nonnull Element state) {
  synchronized (mySettingsMap) {
    if (state == null) {
      return;
    }

    for (Element objectElement : state.getChildren("object")) {
      String language = objectElement.getAttributeValue("language");
      if (language != null) {
        ExternalizableDuplocatorState stateObject = mySettingsMap.get(language);
        if (stateObject != null) {
          XmlSerializer.deserializeInto(stateObject, objectElement);
        }
      }
    }
  }
}
 
Example #22
Source File: DeployToServerRunConfiguration.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public void readExternal(Element element) throws InvalidDataException {
  super.readExternal(element);
  ConfigurationState state = XmlSerializer.deserialize(element, ConfigurationState.class);
  myServerName =  null;
  myDeploymentSource = null;
  if (state != null) {
    myServerName = state.myServerName;
    Element deploymentTag = state.myDeploymentTag;
    if (deploymentTag != null) {
      String typeId = deploymentTag.getAttributeValue(DEPLOYMENT_SOURCE_TYPE_ATTRIBUTE);
      DeploymentSourceType<?> type = findDeploymentSourceType(typeId);
      if (type != null) {
        myDeploymentSource = type.load(deploymentTag, getProject());
        myDeploymentConfiguration = myDeploymentConfigurator.createDefaultConfiguration(myDeploymentSource);
        ComponentSerializationUtil.loadComponentState(myDeploymentConfiguration.getSerializer(), deploymentTag.getChild(SETTINGS_ELEMENT));
      }
      else {
        LOG.warn("Cannot load deployment source for '" + getName() + "' run configuration: unknown deployment type '" + typeId + "'");
      }
    }
  }
}
 
Example #23
Source File: VariablesAccessor.java    From intellij-xquery with Apache License 2.0 5 votes vote down vote up
public void writeVariables(XQueryRunConfiguration configuration, Element element) {
    XQueryRunVariables variables = configuration.getVariables();
    if (variables != null) {
        Element variablesElement = XmlSerializer.serialize(variables.getState());
        element.addContent(variablesElement);
    }
}
 
Example #24
Source File: LibraryImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void writeExternal(Element rootElement) {
  checkDisposed();

  Element element = new Element(ELEMENT);
  if (myName != null) {
    element.setAttribute(LIBRARY_NAME_ATTR, myName);
  }
  if (myKind != null) {
    element.setAttribute(LIBRARY_TYPE_ATTR, myKind.getKindId());
    LOG.assertTrue(myProperties != null, "Properties is 'null' in library with kind " + myKind);
    final Object state = myProperties.getState();
    if (state != null) {
      final Element propertiesElement = XmlSerializer.serialize(state);
      if (propertiesElement != null) {
        element.addContent(propertiesElement.setName(PROPERTIES_ELEMENT));
      }
    }
  }
  for (OrderRootType rootType : OrderRootType.getSortedRootTypes()) {
    VirtualFilePointerContainer roots = myRoots.get(rootType);
    if (roots == null || roots.isEmpty()) {
      continue;
    }

    final Element rootTypeElement = new Element(rootType.name());
    if (roots != null) {
      roots.writeExternal(rootTypeElement, ROOT_PATH_ELEMENT, false);
    }
    element.addContent(rootTypeElement);
  }
  if (myExcludedRoots != null && !myExcludedRoots.isEmpty()) {
    Element excluded = new Element(EXCLUDED_ROOTS_TAG);
    myExcludedRoots.writeExternal(excluded, ROOT_PATH_ELEMENT, false);
    element.addContent(excluded);
  }
  writeJarDirectories(element);
  rootElement.addContent(element);
}
 
Example #25
Source File: CodeInsightSettings.java    From consulo with Apache License 2.0 5 votes vote down vote up
public void writeExternal(final Element element) {
  try {
    XmlSerializer.serializeInto(this, element, new SkipDefaultValuesSerializationFilters());
  }
  catch (XmlSerializationException e) {
    LOG.info(e);
  }
}
 
Example #26
Source File: PathMappingSettings.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nullable
public static PathMappingSettings readExternal(@Nullable final Element element) {
  if (element == null) {
    return null;
  }

  final Element settingsElement = element.getChild(PathMappingSettings.class.getSimpleName());
  if (settingsElement == null) {
    return null;
  }

  return XmlSerializer.deserialize(settingsElement, PathMappingSettings.class);
}
 
Example #27
Source File: DataSourceAccessor.java    From intellij-xquery with Apache License 2.0 5 votes vote down vote up
public void writeDataSourceConfiguration(XQueryRunConfiguration configuration, Element xmlRootElement) {
    String dataSourceName = configuration.getDataSourceName();
    if (dataSourceName != null) {
        XQueryDataSourceConfiguration dataSourceConfiguration = getDataSourcesSettings()
                .getDataSourceConfigurationForName(dataSourceName);
        if (dataSourceConfiguration != null) {
            Element dataSourceElement = XmlSerializer.serialize(dataSourceConfiguration);
            xmlRootElement.addContent(dataSourceElement);
        }
    }
}
 
Example #28
Source File: PluginManagerUISettings.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public Element getState() {
  Element element = new Element("state");
  XmlSerializer.serializeInto(this, element, FILTERS);
  XmlSerializer.serializeInto(mySplitterProportionsData, element, FILTERS);

  final Element availableProportions = new Element(AVAILABLE_PROPORTIONS);
  XmlSerializer.serializeInto(myAvailableSplitterProportionsData, availableProportions, FILTERS);
  element.addContent(availableProportions);
  return element;
}
 
Example #29
Source File: HttpConfigurable.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void afterLoadState() {
  final HttpConfigurable currentState = getState();
  if (currentState != null) {
    final Element serialized = XmlSerializer.serializeIfNotDefault(currentState, new SkipDefaultsSerializationFilter());
    if (serialized == null) {
      // all settings are defaults
      // trying user's proxy configuration entered while obtaining the license
      final SharedProxyConfig.ProxyParameters cfg = SharedProxyConfig.load();
      if (cfg != null) {
        SharedProxyConfig.clear();
        if (cfg.host != null) {
          USE_HTTP_PROXY = true;
          PROXY_HOST = cfg.host;
          PROXY_PORT = cfg.port;
          if (cfg.login != null) {
            setPlainProxyPassword(new String(cfg.password));
            storeSecure("proxy.login", cfg.login);
            PROXY_AUTHENTICATION = true;
            KEEP_PROXY_PASSWORD = true;
          }
        }
      }
    }
  }


  mySelector = new IdeaWideProxySelector(this);
  String name = getClass().getName();
  CommonProxy.getInstance().setCustom(name, mySelector);
  CommonProxy.getInstance().setCustomAuth(name, new IdeaWideAuthenticator(this));
}
 
Example #30
Source File: MasterDetailsStateService.java    From consulo with Apache License 2.0 5 votes vote down vote up
public void setComponentState(@Nonnull @NonNls String key, @Nonnull MasterDetailsState state) {
  final Element element = XmlSerializer.serialize(state, mySerializationFilter);
  if (element == null) {
    myStates.remove(key);
  }
  else {
    final ComponentState componentState = new ComponentState();
    componentState.myKey = key;
    componentState.mySettings = element;
    myStates.put(key, componentState);
  }
}