/**
   * Returns <code>null</code> as a Tree EditPart holds no children under it.
   *
   * @return <code>null</code>
   */
  protected List getModelChildren() {
    NamedObj namedObjectModel = getNamedObjectModel();

    List children = new ArrayList();
    if (namedObjectModel instanceof AtomicActor) {
      AtomicActor actor = (AtomicActor) namedObjectModel;
      children.addAll(actor.attributeList(Parameter.class));
      children.addAll(actor.inputPortList());
      children.addAll(actor.outputPortList());
    } else if (namedObjectModel instanceof CompositeActor) {
      CompositeActor composite = (CompositeActor) namedObjectModel;
      children.addAll(composite.attributeList(AtomicActor.class));
      children.addAll(composite.attributeList(Parameter.class));
      children.addAll(composite.inputPortList());

      Enumeration enumeration = composite.getEntities();
      while (enumeration.hasMoreElements()) {
        children.add(enumeration.nextElement());
      }
    } else if (namedObjectModel instanceof IOPort) {
      IOPort text = (IOPort) namedObjectModel;
      children.addAll(text.attributeList(ptolemy.kernel.util.StringAttribute.class));
    } else if (namedObjectModel instanceof Vertex) {
      Vertex text = (Vertex) namedObjectModel;
      children.addAll(text.attributeList(Vertex.class));
    } else if (namedObjectModel instanceof TextAttribute) {
      TextAttribute text = (TextAttribute) namedObjectModel;
      children.addAll(text.attributeList(ptolemy.kernel.util.StringAttribute.class));
    } else if (namedObjectModel instanceof Director) {
      Director director = (Director) namedObjectModel;
      children.addAll(director.attributeList(Parameter.class));
    }
    return children;
  }
  /**
   * Transform the graphic block diagram to text expression. Assume container only contains atomic
   * actors.
   *
   * @param container contains actors.
   * @return txtExpression of graphic block diagram.
   */
  private String _graphToText(CompositeActor container) throws IllegalActionException {
    // It is not trivial to transform graph to text.
    // Here, we assume there is only one Integrator and one expression actor.
    String txtString = "";
    LinkedList actors = new LinkedList(container.entityList());
    ListIterator actorIterator = actors.listIterator();

    // we begin with Integrator.
    AtomicActor beginActor = new AtomicActor();

    while (actorIterator.hasNext()) {
      Actor actor = (Actor) actorIterator.next();

      if (Integrator.class.isInstance(actor)) {
        beginActor = (AtomicActor) actor;
        break;
      }
    }

    if (beginActor == null) {
      throw new IllegalActionException("Integrator is needed!");
    } else {
      // we trace the output of the Integrator
      // we assume the output of the integrator is connectted
      // to the container output directly and they have same names
      // for simplicity at this time.
      // FIXME: we really need to reconsider the methods of ports.
      List outputs = beginActor.outputPortList();
      ListIterator outputIterator = outputs.listIterator();
      String outputName = "";

      if (outputs.size() != 1) {
        throw new IllegalActionException("Integrator only have one output!  " + outputs.size());
      } else {
        TypedIOPort output = (TypedIOPort) outputIterator.next();
        ListIterator sinkIterator = output.connectedPortList().listIterator();

        while (sinkIterator.hasNext()) {
          TypedIOPort sink = (TypedIOPort) sinkIterator.next();

          if (sink.isOutput()) {
            // FIXME: we need to consider depth in hierarchy
            // to avoid two outputs connected to same output
            // of composite actor
            outputName = sink.getName();
          }
        }

        txtString += ("diff { d(" + outputName + ") == ");
      }

      // we trace the input of the integrator
      List inputs = beginActor.inputPortList();
      ListIterator inputIterator = inputs.listIterator();

      if (inputs.size() != 1) {
        throw new IllegalActionException("Integrator only have one input!");
      } else {
        TypedIOPort input = (TypedIOPort) inputIterator.next();
        List sources = input.connectedPortList();

        if (sources.size() != 1) {
          throw new IllegalActionException("There is only one connection to the input!");
        } else {
          TypedIOPort source = (TypedIOPort) sources.get(0);

          // if there is just an integrator
          if (source.isInput()) {
            txtString += (source.getName() + " ; }" + _endLine);
          }
          // if there is some expression actor
          else {
            AtomicActor expressionActor = (AtomicActor) source.getContainer();

            if (Expression.class.isInstance(expressionActor)) {
              Parameter expPara = (Parameter) expressionActor.getAttribute("expression");
              txtString += (expPara.getExpression() + " ; } " + _endLine);
            } else {
              throw new IllegalActionException("This should be Expression Atomic Actor!");
            }
          }
        }
      }
    }

    return txtString;
  }