TreePath path = mainTree.getSelectionPath();
Object treePathEnd = (path == null) ? null : path.getLastPathComponent();
if (treePathEnd != null &&
treePathEnd instanceof DirectoryTextTemplateTreeItem) {
DirectoryTextTemplateTreeItem treeItem = (DirectoryTextTemplateTreeItem) treePathEnd;
DirectoryTextTemplate dir = (DirectoryTextTemplate) DirectoryLocator.getDirectory(DirectoryTextTemplate.class, false);
TextTemplateDetails details = new TextTemplateDetails();
details.title = template;
details.groupId = treeItem.getID();
DirectoryTextTemplateItem newItem = new DirectoryTextTemplateItem(details);
dir.getItems().append(newItem);
rebuldListModel();
}
} catch (ClipsException ex) {
MessageBox.showException(ex);
}