/**
   * Constructor
   *
   * @param _resource
   */
  public ResourceTreeNode(HumanResource _resource, MainTree _tree) {
    super();

    this.tree = _tree;
    this.resource = _resource;
    this.resource.addObserver(this);
    this.setUserObject(resource);

    Iterator<RoleDescriptor> localIterator = resource.getPerformingRoles().iterator();
    while (localIterator.hasNext()) {
      this.add(new RoleDescriptorTreeNode(localIterator.next(), tree));
    }
  }
  /**
   * Updating the roles and tasks defs for the resource
   *
   * @see java.util.Observer#update(java.util.Observable, java.lang.Object)
   */
  public void update(Observable _observable, Object _object) {
    if (_object != null && _object instanceof RoleDescriptor) {
      RoleDescriptor tempRole = (RoleDescriptor) _object;
      // If adding
      if (resource.getPerformingRoles().contains(_object)) {
        RoleDescriptorTreeNode localNode = new RoleDescriptorTreeNode(tempRole, tree);
        tree.getModel().insertNodeInto(localNode, this, getChildCount());
        tree.scrollPathToVisible(new TreePath(localNode.getPath()));

      }

      // Else deleting
      else {
        int localChildCount = getChildCount();
        for (int i = 0; i < localChildCount; i++) {
          if (((RoleDescriptorTreeNode) getChildAt(i)).getRole().getId().equals(tempRole.getId())) {
            tree.getModel().removeNodeFromParent((RoleDescriptorTreeNode) getChildAt(i));
            break;
          }
        }
      }
    }
  }