private void createRequirementsFromJavaModel(
     JavaElement javaElement, AbstractRequirement reqParent, int depth) throws Exception {
   if (javaElement instanceof JavaPack) {
     if (depth != 0) {
       createRequirementsFromJavaModel(
           ((JavaPack) javaElement).getClasses(), reqParent, depth - 1);
     }
   } else if (javaElement instanceof Member) {
     Member member = (Member) javaElement;
     EClass reqClass = JexPackage.eINSTANCE.getJavaRequirement();
     if (member instanceof TestRunnable) {
       reqClass = JexPackage.eINSTANCE.getJUnitTest();
     }
     JavaRequirement req =
         (JavaRequirement) ensureRequirement(reqClass, member, reqParent.getRequirements());
     // must add to parent before searching hierarchy
     reqParent.getRequirements().add(req);
     if (req instanceof JUnitTest) {
       JUnitTest testReq = (JUnitTest) req;
       if (member instanceof TestRunnable) {
         String text = null;
         for (Member testElement : ((TestRunnable) member).getTestedElements()) {
           if (text == null) {
             text = "Test " + testElement.toString();
           } else {
             text += "; Test " + testElement.toString();
           }
         }
         testReq.setText(text != null ? text : "Test with " + javaElement.toString());
       }
     }
     if (javaElement instanceof JavaClass && depth != 0) {
       createRequirementsFromJavaModel(((JavaClass) javaElement).getMembers(), req, depth - 1);
     }
   }
 }
 private Requirement ensureRequirement(EClass eClass, Member javaElement, List otherReqs)
     throws JavaModelException {
   JavaRequirement newReq =
       (JavaRequirement) JexPackage.eINSTANCE.getEFactoryInstance().create(eClass);
   newReq.setJavaElement(javaElement);
   newReq.setText(javaElement.toString());
   //		if (newReq instanceof JUnitTest && javaElement instanceof TestRunnable) {
   //			((JUnitTest)newReq).setTestRunnable((TestRunnable)javaElement);
   //		}
   if (otherReqs != null) {
     for (int i = 0; i < otherReqs.size(); i++) {
       JavaRequirement otherReq = (JavaRequirement) otherReqs.get(i);
       Member otherJavaElement = (Member) otherReq.getJavaElement();
       if (otherJavaElement == javaElement) {
         return otherReq;
       }
     }
     otherReqs.add(newReq);
   }
   return newReq;
 }