}
@Override
public void run() {
super.run();
IDOMElement selection = getElementFromTreeItem(getSelectedTreeItem());
if (textView != null && selection != null) {
IDOMModel model = selection.getModel();
Document doc = null;
if (selection instanceof Document) {
doc = (Document) selection;
}
else if (selection.getOwnerDocument() != null) {
doc = selection.getOwnerDocument();
}
if (model != null && doc != null) {
model.beginRecording(textView);
IDOMElement child = (IDOMElement) doc.createElement(childName);
selection.appendChild(child);
processor.insertDefaultAttributes(child);
formatter.formatNode(child);
formatter.formatNode(child.getParentNode());
model.endRecording(textView);
if (treeViewer != null) {
treeViewer.setSelection(new StructuredSelection(child));
}
}