void (JComponent editorComponent, PsiElement element) { String caption = XmlBundle.message("intention.color.chooser.dialog"); final XmlAttributeValue literal = PsiTreeUtil.getParentOfType(element, XmlAttributeValue.class, false); if (literal == null) return; final String text = StringUtil.unquoteString(literal.getValue()); Color oldColor; try { oldColor = Color.decode(text); } catch (NumberFormatException e) { oldColor = JBColor.GRAY; } Color color = ColorChooserService.getInstance().showDialog(element.getProject(), editorComponent, caption, oldColor, true); if (color == null) return; if (!Comparing.equal(color, oldColor)) { if (!FileModificationService.getInstance().preparePsiElementForWrite(element)) return; final String newText = "#" + ColorUtil.toHex(color); final PsiManager manager = literal.getManager(); final XmlAttribute newAttribute = XmlElementFactory.getInstance(manager.getProject()).createAttribute("name", newText, element); final Runnable replaceRunnable = () -> { final XmlAttributeValue valueElement = newAttribute.getValueElement(); assert valueElement != null; literal.replace(valueElement); }; WriteCommandAction.writeCommandAction(element.getProject()).withName(caption).run(() -> replaceRunnable.run()); } }