/**
   * Updates attributes list on node selection change in the tags tree. Loads attributes of the
   * selected node into the attributes list. Just clears attributes if no node is selected.
   *
   * @param e
   */
  public void onTagChange(TreeSelectionEvent e) {
    if (e.getNewLeadSelectionPath() != null) {
      TreePath path = e.getNewLeadSelectionPath();
      attributes.clear();
      if (path.getPathCount() >= 1) {

        DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent();
        Tag tag = (Tag) node.getUserObject();
        for (String name : tag.getAttributes().keySet()) {
          Attribute attr = new Attribute();
          attr.setName(name);
          attr.setValue(tag.getAttribute(name));
          attributes.add(attr);
        }
      }
    }
  }