void () { LOG.debug("GuiEditor.saveToFile(): group ID=" + myNextSaveGroupId); CommandProcessor.getInstance().executeCommand(getProject(), () -> ApplicationManager.getApplication().runWriteAction(() -> { myInsideChange = true; try { final XmlWriter writer = new XmlWriter(); getRootContainer().write(writer); final String newText = writer.getText(); final String oldText = myDocument.getText(); try { final ReplaceInfo replaceInfo = findFragmentToChange(oldText, newText); if (replaceInfo.getStartOffset() == -1) { // do nothing - texts are equal } else { myDocument.replaceString(replaceInfo.getStartOffset(), replaceInfo.getEndOffset(), replaceInfo.getReplacement()); } } catch (Exception e) { LOG.error(e); myDocument.replaceString(0, oldText.length(), newText); } } finally { myInsideChange = false; } }), UIDesignerBundle.message("gui.editor.save.command"), myNextSaveGroupId); myNextSaveGroupId = new Object(); fireHierarchyChanged(); }