static Element write(ProjectRoot projectRoot) throws WriteExternalException { Element element = new Element(ELEMENT_ROOT); if (projectRoot instanceof SimpleProjectRoot) { element.setAttribute(ATTRIBUTE_TYPE, SIMPLE_ROOT); ((JDOMExternalizable)projectRoot).writeExternal(element); } else if (projectRoot instanceof CompositeProjectRoot) { element.setAttribute(ATTRIBUTE_TYPE, COMPOSITE_ROOT); ((CompositeProjectRoot)projectRoot).writeExternal(element); } else { throw new IllegalArgumentException("Wrong root: " + projectRoot); } return element; }
@SuppressWarnings({"unchecked"}) @Nullable public static <T> T deserializeState(@Nullable Element stateElement, Class <T> stateClass, @Nullable T mergeInto) { if (stateElement == null) { return mergeInto; } else if (stateClass == Element.class) { return (T)stateElement; } else if (JDOMExternalizable.class.isAssignableFrom(stateClass)) { if (mergeInto != null) { String elementText = JDOMUtil.writeElement(stateElement, "\n"); LOG.error("State is " + stateClass.getName() + ", merge into is " + mergeInto.toString() + ", state element text is " + elementText); } T t = ReflectionUtil.newInstance(stateClass); try { ((JDOMExternalizable)t).readExternal(stateElement); return t; } catch (InvalidDataException e) { throw new RuntimeException(e); } } else if (mergeInto == null) { return XmlSerializer.deserialize(stateElement, stateClass); } else { XmlSerializer.deserializeInto(mergeInto, stateElement); return mergeInto; } }
@Nullable 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()); } }
@SuppressWarnings({"unchecked"}) @Nullable public static <T> T deserializeState(@Nullable Element stateElement, Class <T> stateClass, @Nullable T mergeInto) throws StateStorageException { if (stateElement == null) return mergeInto; if (stateClass.equals(Element.class)) { //assert mergeInto == null; return (T)stateElement; } else if (JDOMExternalizable.class.isAssignableFrom(stateClass)) { if (mergeInto != null) { String elementText = JDOMUtil.writeElement(stateElement, "\n"); LOG.error("State is " + stateClass.getName() + ", merge into is " + mergeInto.toString() + ", state element text is " + elementText); } final T t = ReflectionUtil.newInstance(stateClass); try { ((JDOMExternalizable)t).readExternal(stateElement); return t; } catch (InvalidDataException e) { throw new StateStorageException(e); } } else if (mergeInto == null) { return XmlSerializer.deserialize(stateElement, stateClass); } else { XmlSerializer.deserializeInto(mergeInto, stateElement); return mergeInto; } }
/** * @deprecated */ public <T extends JDOMExternalizable> void registerProperty(ListProperty<T> property, @NonNls String itemTagName, Factory<T> factory) { registerProperty(property, itemTagName, Externalizer.FactoryBased.create(factory)); }
public static <T extends JDOMExternalizable> FactoryBased<T> create(Factory<T> factory) { return new FactoryBased<T>(factory); }
public void readExternal(Element element) throws InvalidDataException { ((JDOMExternalizable)editorOptions).readExternal(element); ((JDOMExternalizable)externalEditorOptions).readExternal(element); }
public void writeExternal(Element element) throws WriteExternalException { ((JDOMExternalizable)editorOptions).writeExternal(element); ((JDOMExternalizable)externalEditorOptions).writeExternal(element); }
public void readExternal(Element element) throws InvalidDataException { ((JDOMExternalizable)gridOptions).readExternal(element); ((JDOMExternalizable)transparencyChessboardOptions).readExternal(element); ((JDOMExternalizable)zoomOptions).readExternal(element); }
public void writeExternal(Element element) throws WriteExternalException { ((JDOMExternalizable)gridOptions).writeExternal(element); ((JDOMExternalizable)transparencyChessboardOptions).writeExternal(element); ((JDOMExternalizable)zoomOptions).writeExternal(element); }
public <T extends JDOMExternalizable> TableListBinding<T> bindList(JTable table, ColumnInfo[] columns, ListProperty<T> property) { final TableListBinding<T> binding = new TableListBinding<T>(table, columns, property); myBindings.add(binding); return binding; }
public JDOMExternalizableWrapper(JDOMExternalizable jdomExternalizable) { myJDOMExternalizable = jdomExternalizable; }