@NotNull @Override public FileEditorState readState( @NotNull Element sourceElement, @NotNull Project project, @NotNull VirtualFile file) { final IpnbEditorState state = new IpnbEditorState(-1, 0, 0); final Element child = sourceElement.getChild(SELECTED_CELL); state.setSelectedIndex(child == null ? 0 : Integer.parseInt(child.getAttributeValue(ID))); state.setSelectedTop(child == null ? 0 : Integer.parseInt(child.getAttributeValue(TOP))); return state; }
@Override public void writeState( @NotNull FileEditorState state, @NotNull Project project, @NotNull Element targetElement) { IpnbEditorState editorState = (IpnbEditorState) state; final int id = editorState.getSelectedIndex(); final int location = editorState.getSelectedTop(); final Element element = new Element(SELECTED_CELL); element.setAttribute(ID, String.valueOf(id)); element.setAttribute(TOP, String.valueOf(location)); targetElement.addContent(element); }