// Sort the value list and then iterate through node templates
ArrayList values =
new ArrayList(templates.getNodeTemplatesMap().values());
Collections.sort(values, new Comparator() {
public int compare(Object o1, Object o2) {
NodeTemplateDescriptor n1 = (NodeTemplateDescriptor) o1;
NodeTemplateDescriptor n2 = (NodeTemplateDescriptor) o2;
return n1.getName().compareTo(n2.getName());
}
});
Iterator iter = values.iterator();
while (iter.hasNext()) {
NodeTemplateDescriptor desc =
(NodeTemplateDescriptor) iter .next();
String toParse = desc.getXmlValue();
short nodeType = desc.getType();
String nodeCategory = desc.getCategory();
JMenuItem currentItem = new JMenuItem(desc.getName());
currentItem.addActionListener
(new NodeTemplateParser(toParse, nodeType));
JMenu currentSubmenu = (JMenu)menuMap.get(nodeCategory);
currentSubmenu.add(currentItem);
}