@SuppressWarnings({"HardCodedStringLiteral"}) private Element writePanel(final JPanel panel) { final Component comp = panel.getComponent(0); if (comp instanceof Splitter) { final Splitter splitter = (Splitter) comp; final Element res = new Element("splitter"); res.setAttribute("split-orientation", splitter.getOrientation() ? "vertical" : "horizontal"); res.setAttribute("split-proportion", Float.toString(splitter.getProportion())); final Element first = new Element("split-first"); first.addContent(writePanel((JPanel) splitter.getFirstComponent())); final Element second = new Element("split-second"); second.addContent(writePanel((JPanel) splitter.getSecondComponent())); res.addContent(first); res.addContent(second); return res; } else if (comp instanceof JBTabs) { final Element res = new Element("leaf"); final EditorWindow window = findWindowWith(comp); writeWindow(res, window); return res; } else if (comp instanceof EditorWindow.TCompForTablessMode) { final EditorWithProviderComposite composite = ((EditorWindow.TCompForTablessMode) comp).myEditor; final Element res = new Element("leaf"); writeComposite(res, composite.getFile(), composite, false, composite); return res; } else { LOG.error(comp != null ? comp.getClass().getName() : null); return null; } }
private void writeWindow(final Element res, final EditorWindow window) { if (window != null) { final EditorWithProviderComposite[] composites = window.getEditors(); for (int i = 0; i < composites.length; i++) { final VirtualFile file = window.getFileAt(i); final boolean isPinned = window.isFilePinned(file); final EditorWithProviderComposite composite = composites[i]; final EditorWithProviderComposite selectedEditor = window.getSelectedEditor(); writeComposite(res, file, composite, isPinned, selectedEditor); } } }