String description = descriptionBox.getText();
BaseContentItem contentItem = selectionPanel.getSelection();
if (!description.isEmpty() || contentItem != null) {
String selectedText = richTextUtil.getSelection(richText.getElement());
richTextUtil.insertHTML(richText.getElement(), selectedText + " " +
new SourceLink(description, contentItem == null ? -1
: contentItem.getId()).getOuterHTML());
}
}
}));
popup.add(contentPanel);