public void write(XMLWriter writer, Context context) {
try {
// Init context
MutableContext mutableContext = (MutableContext) context;
mutableContext.put(ToolWindowManager.class, manager);
boolean standalone = (Boolean) context.get("standalone");
// Start document
if (standalone)
writer.startDocument();
// Write header
AttributesImpl mydoggyAttributes = new AttributesImpl();
mydoggyAttributes.addAttribute(null, "version", null, null, "1.5.0");
mydoggyAttributes.addAttribute(null, "contentManagerEnabled", null, null,
String.valueOf(manager.getContentManager().isEnabled()));
writer.startElement("mydoggy", mydoggyAttributes);
// Write ToolWindows
writer.startElement("toolWindows");
// Write SharedWindows
writer.startElement("sharedWindows");
for (MultiSplitWindow<? extends Dockable> multiSplitWindow : toolWindowManager.getFloatingWindows()) {
storeMultiSplitWindow(writer, multiSplitWindow);
}
for (MultiSplitWindow<? extends Dockable> multiSplitWindow : toolWindowManager.getFloatingLiveWindows()) {
storeMultiSplitWindow(writer, multiSplitWindow);
}
writer.endElement("sharedWindows");
// Write tools
for (ToolWindow toolWindow : manager.getToolWindows()) {
if (!context.get(PersistenceDelegateFilter.class).storeToolWindow(toolWindow))
continue;
mutableContext.put(ToolWindow.class, toolWindow);
getElementWriter(ToolWindow.class).write(writer, context);
}
writer.endElement("toolWindows");
// Write ToolWindowManagerDescriptor
if (context.get(PersistenceDelegateFilter.class).storeToolWindowManagerDescriptor()) {
mutableContext.put(ToolWindowManagerDescriptor.class, manager.getToolWindowManagerDescriptor());
getElementWriter(ToolWindowManagerDescriptor.class).write(writer, context);
}
if (context.get(PersistenceDelegateFilter.class).storeContentManager()) {
// Write ContentManagerUI
mutableContext.put(ContentManager.class, manager.getContentManager());
mutableContext.put(ContentManagerUI.class, manager.getContentManager().getContentManagerUI());
ContentManager contentManager = manager.getContentManager();
writer.startElement("contentManagerUI");
getElementWriter(contentManager.getContentManagerUI().getClass()).write(writer, context);
writer.endElement("contentManagerUI");