com.intellij.openapi.util.JDOMExternalizable Java Examples

The following examples show how to use com.intellij.openapi.util.JDOMExternalizable. 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: UsefulTestCase.java    From consulo with Apache License 2.0 6 votes vote down vote up
protected static void checkSettingsEqual(JDOMExternalizable expected, JDOMExternalizable settings, String message) throws Exception {
  if (expected == null) {
    return;
  }
  if (settings == null) {
    return;
  }
  Element oldS = new Element("temp");
  expected.writeExternal(oldS);
  Element newS = new Element("temp");
  settings.writeExternal(newS);

  String newString = JDOMUtil.writeElement(newS, "\n");
  String oldString = JDOMUtil.writeElement(oldS, "\n");
  assertEquals(message, oldString, newString);
}
 
Example #2
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 #3
Source File: DefaultStateSerializer.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nullable
public static Element serializeState(@Nonnull Object state, @Nullable final Storage storage) throws WriteExternalException {
  if (state instanceof Element) {
    return (Element)state;
  }
  else if (state instanceof JDOMExternalizable) {
    Element element = new Element("temp_element");
    ((JDOMExternalizable)state).writeExternal(element);
    return element;
  }
  else {
    return XmlSerializer.serializeIfNotDefault(state, new SkipDefaultValuesSerializationFilters());
  }
}
 
Example #4
Source File: ExternalizablePropertyContainer.java    From consulo with Apache License 2.0 4 votes vote down vote up
/**
 * @deprecated
 */
public <T extends JDOMExternalizable> void  registerProperty(ListProperty<T> property, @NonNls String itemTagName, Factory<T> factory) {
  registerProperty(property, itemTagName, Externalizer.FactoryBased.create(factory));
}
 
Example #5
Source File: Externalizer.java    From consulo with Apache License 2.0 4 votes vote down vote up
public static <T extends JDOMExternalizable> FactoryBased<T> create(Factory<T> factory) {
  return new FactoryBased<T>(factory);
}
 
Example #6
Source File: JDOMExternalizableWrapper.java    From consulo with Apache License 2.0 4 votes vote down vote up
public JDOMExternalizableWrapper(JDOMExternalizable jdomExternalizable) {
  myJDOMExternalizable = jdomExternalizable;
}