public void parse() {
    String str = myXmlOutput.getText();
    HashSet<CycleView.Prop> props = preParse(str);
    if (DEBUG) {
      System.out.println("types  " + Arrays.toString(props.toArray()));
    }
    ArrayList<Cycle> unused = new ArrayList<>(myCycles);
    CycleView.Prop[] table = CycleView.Prop.values();
    Cycle[] cycles = myCycles.toArray(new Cycle[0]);
    for (int i = 0; i < cycles.length; i++) {
      Cycle cycle = cycles[i];
      CycleView.Prop p = table[cycle.myModel.mAttrIndex];
      if (DEBUG) {
        System.out.println("-- cycle " + table[cycle.myModel.mAttrIndex].name());
      }
      if (props.contains(p)) {
        unused.remove(cycle);
        if (DEBUG) {
          System.out.println("parse 1");
        }
        cycle.myModel.parseXML(str);
        if (DEBUG) {
          System.out.println("done parse 1 ");
          System.out.println("update name to = " + cycle.myModel.getAttName());
        }
        // cycle.myControl.updateTabName(cycle.myModel.getAttName());
        cycle.myControl.attrName.setSelectedIndex(cycle.myModel.mAttrIndex);
        props.remove(p);
      } else {
        if (DEBUG) {
          System.out.println(" not found");
        }
      }
    }

    // if you have used all props and tabs
    if (props.size() == 0 && unused.size() == 0) { // all used up we are done
      if (DEBUG) {
        System.out.println("all done");
      }
      return;
    }
    if (DEBUG) {
      System.out.println("props.size() ==" + props.size() + "  unused.size() == " + unused.size());
    }
    ArrayList<CycleView.Prop> propList = new ArrayList<>(props);

    while (propList.size() > 0 && unused.size() > 0) {
      Cycle cycle = unused.remove(0);
      int propIndex = propList.remove(0).ordinal();
      if (DEBUG) {
        System.out.println(
            "1reuse unused ==" + table[cycle.myModel.mAttrIndex].name() + "  unused.size() == "
                + table[propIndex].name());
      }
      cycle.myModel.mAttrIndex = propIndex;
      if (DEBUG) {
        System.out.println("parse 2");
      }
      cycle.myModel.parseXML(str);
      if (DEBUG) {
        System.out.println("done parse 2");
        System.out.println(
            "2reuse unused ==" + table[cycle.myModel.mAttrIndex].name() + "  unused.size() == "
                + table[propIndex].name());
        System.out.println("update name to = " + cycle.myModel.getAttName());

      }
      // cycle.myControl.updateTabName(cycle.myModel.getAttName());
      cycle.myControl.attrName.setSelectedIndex(cycle.myModel.mAttrIndex);
    }

    while (propList.size() > 0) {
      int attrIndex = propList.remove(0).ordinal();

      Cycle cycle = myMainPanel.createNewCycle();
      cycle.myModel.mAttrIndex = attrIndex;
      if (DEBUG) {
        System.out.println("parse 3");
      }
      cycle.myModel.parseXML(str);
      if (DEBUG) {
        System.out.println("done parse 3");
        System.out.println("update name to = " + cycle.myModel.getAttName());

      }
      // cycle.myControl.updateTabName(cycle.myModel.getAttName());
      cycle.myControl.attrName.setSelectedIndex(cycle.myModel.mAttrIndex);
    }

    while (unused.size() > 0) {
      Cycle cycle = unused.remove(0);
      System.out.println("remove " + table[cycle.myModel.mAttrIndex].name());

      myMainPanel.removeCycle(cycle);
    }
  }
The management of a collection of Cycles which contain the
model, view (graph) and the controller ui panel.
ConstraintLayoutExamples/CycleEditor/src/com/google/androidstudio/motionlayoutcycles/CycleSetModel.java