Java Code Examples for com.intellij.util.xmlb.XmlSerializer#deserializeInto()

The following examples show how to use com.intellij.util.xmlb.XmlSerializer#deserializeInto() . 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: 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 3
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 4
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 5
Source File: BazelTestFieldsTest.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Test
public void shouldUpgradeFieldsFromOldXml() {
  final Element elt = new Element("test");
  addOption(elt, "launchingScript", "path/to/bazel-run.sh"); // obsolete
  addOption(elt, "entryFile", "/tmp/test/dir/lib/main.dart"); // obsolete
  addOption(elt, "bazelTarget", "//path/to/flutter/app:hello");

  final BazelTestFields fields = BazelTestFields.readFrom(elt);
  XmlSerializer.deserializeInto(fields, elt);
  assertEquals(null, fields.getTestName());
  assertEquals("/tmp/test/dir/lib/main.dart", fields.getEntryFile());
  assertEquals("//path/to/flutter/app:hello", fields.getBazelTarget());
  assertEquals(null, fields.getAdditionalArgs());
}
 
Example 6
Source File: SdkFieldsTest.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Test
public void shouldReadFieldsFromXml() {
  final Element elt = new Element("test");
  addOption(elt, "filePath", "lib/main.dart");
  addOption(elt, "additionalArgs", "--trace-startup");


  final SdkFields fields = new SdkFields();
  XmlSerializer.deserializeInto(fields, elt);
  assertEquals("lib/main.dart", fields.getFilePath());
  assertEquals("--trace-startup", fields.getAdditionalArgs());
}
 
Example 7
Source File: SdkFieldsTest.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Test
public void shouldReadFieldsFromOldXml() {
  final Element elt = new Element("test");
  addOption(elt, "filePath", "lib/main.dart");
  addOption(elt, "additionalArgs", "--trace-startup");
  addOption(elt, "workingDirectory", "/tmp/test/example"); // obsolete

  final SdkFields fields = new SdkFields();
  XmlSerializer.deserializeInto(fields, elt);
  assertEquals("lib/main.dart", fields.getFilePath());
  assertEquals("--trace-startup", fields.getAdditionalArgs());
}
 
Example 8
Source File: ArtifactManagerImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
private static <S> void deserializeProperties(ArtifactProperties<S> artifactProperties, ArtifactPropertiesState propertiesState) {
  final Element options = propertiesState.getOptions();
  if (artifactProperties == null || options == null) {
    return;
  }
  final S state = artifactProperties.getState();
  if (state != null) {
    XmlSerializer.deserializeInto(state, options);
    artifactProperties.loadState(state);
  }
}
 
Example 9
Source File: TableModelEditor.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
public static <T> T cloneUsingXmlSerialization(@Nonnull T oldItem, @Nonnull T newItem) {
  Element serialized = XmlSerializer.serialize(oldItem, new SkipDefaultValuesSerializationFilters());
  if (!JDOMUtil.isEmpty(serialized)) {
    XmlSerializer.deserializeInto(newItem, serialized);
  }
  return newItem;
}
 
Example 10
Source File: SdkFieldsTest.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Test
public void shouldReadFieldsFromOldXml() {
  final Element elt = new Element("test");
  addOption(elt, "filePath", "lib/main.dart");
  addOption(elt, "additionalArgs", "--trace-startup");
  addOption(elt, "workingDirectory", "/tmp/test/example"); // obsolete

  final SdkFields fields = new SdkFields();
  XmlSerializer.deserializeInto(fields, elt);
  assertEquals("lib/main.dart", fields.getFilePath());
  assertEquals("--trace-startup", fields.getAdditionalArgs());
}
 
Example 11
Source File: EmbeddedLinuxJVMRunConfiguration.java    From embeddedlinux-jvmdebugger-intellij with Apache License 2.0 5 votes vote down vote up
/**
 * Read External
 * @param element
 * @throws InvalidDataException
 */
@Override
public void readExternal(Element element) throws InvalidDataException {
    super.readExternal(element);
    embeddedLinuxJVMRunConfigurationRunnerParameters = createRunnerParametersInstance();
    XmlSerializer.deserializeInto(embeddedLinuxJVMRunConfigurationRunnerParameters, element);
}
 
Example 12
Source File: PersistableCodeStyleSchemes.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void loadState(@Nonnull Element state) {
  CURRENT_SCHEME_NAME = CodeStyleScheme.DEFAULT_SCHEME_NAME;
  XmlSerializer.deserializeInto(this, state);
  CodeStyleScheme current = CURRENT_SCHEME_NAME == null ? null : findSchemeByName(CURRENT_SCHEME_NAME);
  setCurrentScheme(current == null ? getDefaultScheme() : current);
}
 
Example 13
Source File: Unity3dTestConfiguration.java    From consulo-unity3d with Apache License 2.0 5 votes vote down vote up
@Override
public void readExternal(Element element) throws InvalidDataException
{
	super.readExternal(element);

	XmlSerializer.deserializeInto(this, element);
}
 
Example 14
Source File: BackgroundTaskByVfsChangeManagerImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void loadState(Element state) {
  for (Element element : state.getChildren("task")) {
    String url = element.getAttributeValue("url");
    String name = element.getAttributeValue("name");
    String providerName = element.getAttributeValue("provider-name");
    boolean enabled = Boolean.valueOf(element.getAttributeValue("enabled"));

    VirtualFilePointer virtualFilePointer = VirtualFilePointerManager.getInstance().create(url, this, null);

    BackgroundTaskByVfsParametersImpl parameters = new BackgroundTaskByVfsParametersImpl(myProject);

    BackgroundTaskByVfsChangeTaskImpl task = new BackgroundTaskByVfsChangeTaskImpl(myProject, virtualFilePointer, providerName, name, parameters, this);
    task.setEnabled(enabled);

    Element parametersElement = element.getChild("parameters");
    if (parametersElement != null) {
      ReplacePathToMacroMap replaceMacroToPathMap = task.createReplaceMacroToPathMap();

      replaceMacroToPathMap.substitute(parametersElement, false, true);

      XmlSerializer.deserializeInto(parameters, parametersElement);
    }

    registerTask(task);
  }
}
 
Example 15
Source File: SdkRunConfig.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public void readExternal(@NotNull final Element element) throws InvalidDataException {
  super.readExternal(element);
  XmlSerializer.deserializeInto(getFields(), element);
}
 
Example 16
Source File: ViewImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
public ViewImpl(RunnerLayout settings, Element element) {
  XmlSerializer.deserializeInto(this, element);
  assignTab(settings.getOrCreateTab(myTabIndex));
}
 
Example 17
Source File: CommonCodeStyleSettings.java    From consulo with Apache License 2.0 4 votes vote down vote up
public void deserialize(Element indentOptionsElement) {
  XmlSerializer.deserializeInto(this, indentOptionsElement);
}
 
Example 18
Source File: SoftMargins.java    From consulo with Apache License 2.0 4 votes vote down vote up
public void deserializeFrom(@Nonnull Element element) {
  XmlSerializer.deserializeInto(this, element);
}
 
Example 19
Source File: TomcatRunConfiguration.java    From SmartTomcat with Apache License 2.0 4 votes vote down vote up
@Override
public void readExternal(Element element) throws InvalidDataException {
    super.readExternal(element);
    XmlSerializer.deserializeInto(this, element);

}
 
Example 20
Source File: HaxeApplicationConfiguration.java    From intellij-haxe with Apache License 2.0 4 votes vote down vote up
public void readExternal(final Element element) throws InvalidDataException {
  super.readExternal(element);
  readModule(element);
  XmlSerializer.deserializeInto(this, element);
}