public void setNodeName(String newName) {
    if (node == null) {
      return;
    }

    // validate...
    if (newName == null) {
      throw new ValidationException("Empty DataNode Name");
    }

    ProjectController parent = (ProjectController) getParent();
    DataNodeDefaults oldPref = parent.getDataNodePreferences();
    DataChannelDescriptor dataChannelDescriptor =
        (DataChannelDescriptor) getApplication().getProject().getRootNode();

    Collection<DataNodeDescriptor> matchingNode = dataChannelDescriptor.getNodeDescriptors();

    Iterator<DataNodeDescriptor> it = matchingNode.iterator();
    while (it.hasNext()) {
      DataNodeDescriptor node = it.next();
      if (node.getName().equals(newName)) {
        // there is an entity with the same name
        throw new ValidationException(
            "There is another DataNode named '" + newName + "'. Use a different name.");
      }
    }

    // passed validation, set value...

    // TODO: fixme....there is a slight chance that domain is different than the one
    // cached node belongs to
    ProjectUtil.setDataNodeName(
        (DataChannelDescriptor) parent.getProject().getRootNode(), node, newName);

    oldPref.copyPreferences(newName);
  }
  void setClassName(String newClassName) {
    if (newClassName != null && newClassName.trim().length() == 0) {
      newClassName = null;
    }

    Embeddable embeddable = mediator.getCurrentEmbeddable();

    if (embeddable == null) {
      return;
    }

    if (Util.nullSafeEquals(newClassName, embeddable.getClassName())) {
      return;
    }

    if (newClassName == null) {
      throw new ValidationException("Embeddable name is required.");
    } else if (embeddable.getDataMap().getEmbeddable(newClassName) == null) {

      // if newClassName dupliucates in other DataMaps
      DataChannelDescriptor domain = (DataChannelDescriptor) mediator.getProject().getRootNode();
      if (domain != null) {
        for (DataMap nextMap : domain.getDataMaps()) {
          if (nextMap == embeddable.getDataMap()) {
            continue;
          }

          Embeddable conflictingEmbeddable = nextMap.getEmbeddable(newClassName);
          if (conflictingEmbeddable != null) {
            throw new ValidationException(
                "Duplicate Embeddable name in another DataMap: " + newClassName + ".");
          }
        }
      }

      // completely new name, set new name for embeddable
      EmbeddableEvent e = new EmbeddableEvent(this, embeddable, embeddable.getClassName());
      String oldName = embeddable.getClassName();
      embeddable.setClassName(newClassName);

      mediator.fireEmbeddableEvent(e, mediator.getCurrentDataMap());

      Iterator it =
          ((DataChannelDescriptor) mediator.getProject().getRootNode()).getDataMaps().iterator();
      while (it.hasNext()) {
        DataMap dataMap = (DataMap) it.next();
        Iterator<ObjEntity> ent = dataMap.getObjEntities().iterator();

        while (ent.hasNext()) {

          Collection<ObjAttribute> attr = ent.next().getAttributes();
          Iterator<ObjAttribute> attrIt = attr.iterator();

          while (attrIt.hasNext()) {
            ObjAttribute atribute = attrIt.next();
            if (atribute.getType() == null || atribute.getType().equals(oldName)) {
              atribute.setType(newClassName);
              AttributeEvent ev = new AttributeEvent(this, atribute, atribute.getEntity());
              mediator.fireObjAttributeEvent(ev);
            }
          }
        }
      }

    } else {
      // there is an embeddable with the same name
      throw new ValidationException(
          "There is another embeddable with name '" + newClassName + "'.");
    }
  }