} else if (node instanceof TextNode) {
TextNode textNode = (TextNode)node;
textArea.setText(textNode.getText());
propertiesCardPane.setSelectedIndex(1);
} else if (node instanceof Element) {
Element element = (Element)node;
// Populate the namespaces table
ArrayList<HashMap<String, String>> namespacesTableData =
new ArrayList<HashMap<String, String>>();
String defaultNamespaceURI = element.getDefaultNamespaceURI();
if (defaultNamespaceURI != null) {
HashMap<String, String> row = new HashMap<String, String>();
row.put("prefix", "(default)");
row.put("uri", defaultNamespaceURI);
namespacesTableData.add(row);
}
Element.NamespaceDictionary namespaceDictionary = element.getNamespaces();
for (String prefix : namespaceDictionary) {
HashMap<String, String> row = new HashMap<String, String>();
row.put("prefix", prefix);
row.put("uri", namespaceDictionary.get(prefix));
namespacesTableData.add(row);
}
namespacesTableView.setTableData(namespacesTableData);
// Populate the attributes table
ArrayList<HashMap<String, String>> attributesTableData =
new ArrayList<HashMap<String, String>>();
for (Element.Attribute attribute : element.getAttributes()) {
HashMap<String, String> row = new HashMap<String, String>();
String attributeName = attribute.getName();
row.put("name", attributeName);
row.put("value", element.getElementDictionary().get(attributeName));
attributesTableData.add(row);
}
attributesTableView.setTableData(attributesTableData);