@Override
 public L_A_Seq fromStrategoTerm(IStrategoTerm alist) {
   L_A_Seq list = new L_A_Seq(NodeSource.fromStrategoTerm(alist));
   for (int l = alist.getSubtermCount() - 1; l >= 0; l--) {
     final INodeSource source = NodeSource.fromStrategoTerm(alist.getSubterm(l));
     list =
         new L_A_Seq(
             NodeSource.fromStrategoTerm(alist),
             new Generic_A_Seq(source, alist.getSubterm(l)),
             list);
   }
   return list;
 }
  public void nodesUpdated(Map<String, NodeSource> nodes) {
    if (selNode != null) {
      for (NodeSource ns : nodes.values()) {
        if (selNode.getSourceName().equals(ns.getSourceName())) {

          Node depl = ns.getDeploying().get(selNode.getNodeUrl());
          if (depl != null) {
            nodeSelected(depl);
            return;
          }

          for (Host h : ns.getHosts().values()) {
            if (selNode.getHostName().equals(h.getHostName())) {

              for (Node n : h.getNodes().values()) {
                if (n.getNodeUrl().equals(selNode.getNodeUrl())) {
                  nodeSelected(n);
                  return;
                }
              }
            }
          }
        }
      }
    } else if (selHost != null) {
      for (NodeSource ns : nodes.values()) {
        if (ns.getSourceName().equals(selHost.getSourceName())) {

          for (Host h : ns.getHosts().values()) {
            if (selHost.getHostName().equals(h.getHostName())) {
              hostSelected(h);
              return;
            }
          }
        }
      }
    } else if (selNS != null) {
      for (NodeSource ns : nodes.values()) {
        if (ns.getSourceName().equals(selNS.getSourceName())) {
          nodeSourceSelected(ns);
          return;
        }
      }
    }

    nodeUnselected();
  }
  /*
   * (non-Javadoc)
   * @see org.ow2.proactive_grid_cloud_portal.rm.client.Listeners.NodeSelectedListener#nodeSourceSelected(org.ow2.proactive_grid_cloud_portal.rm.client.NodeSource)
   */
  public void nodeSourceSelected(NodeSource ns) {
    DetailViewerRecord dv = new DetailViewerRecord();

    int numNodes = 0;
    for (Host h : ns.getHosts().values()) numNodes += h.getNodes().size();

    dv.setAttribute("sourceName", ns.getSourceName());
    dv.setAttribute("description", ns.getSourceDescription());
    dv.setAttribute("nodeProvider", ns.getNodeSourceAdmin());
    dv.setAttribute("nodes", numNodes);
    dv.setAttribute("hosts", ns.getHosts().size());

    this.nsDetails.setData(new DetailViewerRecord[] {dv});

    this.label.hide();
    this.nodeCanvas.hide();
    this.hostCanvas.hide();
    this.nsCanvas.show();

    this.selHost = null;
    this.selNS = ns;
    this.selNode = null;
  }