Examples of IterableElementList


Examples of org.openiaml.model.xpath.IterableElementList

   
    // find the name of the first document
    Element root = xpathFirst(doc, "/GenEditorGenerator");
    shortcutName = root.getAttribute("modelID");
   
    IterableElementList nodes = xpath(doc, "//diagram/containsShortcutsTo");
    for (Element node : nodes) {
      String value = node.getFirstChild().getNodeValue();
      if (!shortcuts.contains(value))
        shortcuts.add(value);
    }
View Full Code Here

Examples of org.openiaml.model.xpath.IterableElementList

   */
  public void testContainsShortcutsTo() throws Exception {
    // now test them all
    for (String file : getAllGmfGens()) {
      Document doc = GmfGenTestCase.getCache().get(file);
      IterableElementList nodes = xpath(doc, "//diagram/containsShortcutsTo");
      assertEquals(file, nodes.getLength(), shortcuts.size());
      for (Element node : nodes) {
        String value = node.getFirstChild().getNodeValue();
        assertTrue( file + ": contains " + value, shortcuts.contains(value) );
      }
    }
View Full Code Here

Examples of org.openiaml.model.xpath.IterableElementList

   */
  public void testContainsProvidedFor() throws Exception {
    // now test them all
    for (String file : getAllGmfGens()) {
      Document doc = GmfGenTestCase.getCache().get(file);
      IterableElementList nodes = xpath(doc, "//diagram/shortcutsProvidedFor");
      assertEquals(file, nodes.getLength(), shortcuts.size());
      for (Element node : nodes) {
        String value = node.getFirstChild().getNodeValue();
        assertTrue( file + ": contains " + value, shortcuts.contains(value) );
      }
    }
View Full Code Here

Examples of org.openiaml.model.xpath.IterableElementList

    for (String file : getAllGmfGens()) {
      Document doc = GmfGenTestCase.getCache().get(file);
      DiagramUniqueness du = new DiagramUniqueness();
     
      // get all top level nodes
      IterableElementList nodes = xpath(doc, "//diagram/topLevelNodes");
     
      for (Element node : nodes) {
        IterableElementList behaviours = xpath(node, "behaviour");
        for (Element b : behaviours) {
          // assume each Behaviour is an OpenDiagramPolicy
          // (since we can't get xsi:type from xpath)
          String editPolicyClassName = b.getAttributes().getNamedItem("editPolicyClassName").getNodeValue();
          String diagramKind = b.getAttributes().getNamedItem("diagramKind").getNodeValue();
View Full Code Here

Examples of org.openiaml.model.xpath.IterableElementList

   */
  public void testOnlyOneOpenDiagramPolicy() throws Exception {
    for (String filename : getGenList()) {
      Document doc = getCache().get(filename);
     
      IterableElementList nodes = xpath(doc, "/GenEditorGenerator/diagram/topLevelNodes");
      assertFalse(filename + ": No nodes found", nodes.isEmpty());
     
      for (Element node : nodes) {
        // directly contained OpenDiagramPolicies
        IterableElementList opens = xpath(node, "behaviour");
        boolean foundOpen = false;
        for (Element open : opens) {
          if (open.getAttribute("xsi:type").equals("gmfgen:OpenDiagramBehaviour")) {
            assertFalse(filename + ": More than one OpenDiagram policy found for node '" + node + "'", foundOpen);
            foundOpen = true;
          }
        }
      }

      IterableElementList links = xpath(doc, "/GenEditorGenerator/diagram/links");
      assertFalse(filename + ": No links found", links.isEmpty());
      for (Element link : links) {
        // directly contained OpenDiagramPolicies
        IterableElementList opens = xpath(link, "behaviour");
        boolean foundOpen = false;
        for (Element open : opens) {
          if (open.getAttribute("xsi:type").equals("gmfgen:OpenDiagramBehaviour")) {
            assertFalse(filename + ": More than one OpenDiagram policy found for link '" + link + "'", foundOpen);
            foundOpen = true;
View Full Code Here

Examples of org.openiaml.model.xpath.IterableElementList

  public void testReadOnlyOpenDiagramPolicies() throws Exception {
    for (String filename : getGenList()) {
      Document doc = getCache().get(filename);
     
      // will do both links and nodes
      IterableElementList labels = xpath(doc, "//labels[@readOnly='true']");
      assertFalse(filename + ": No read-only labels found", labels.isEmpty());
     
      for (Element label : labels) {
        String labelName = label.getAttribute("editPartClassName");
       
        // does the parent have an OpenDiagramPolicy?
View Full Code Here

Examples of org.openiaml.model.xpath.IterableElementList

  public void testNonReadOnlyCannotHaveOpenPolicies() throws Exception {
    for (String filename : getGenList()) {
      Document doc = getCache().get(filename);
     
      // will do both links and nodes
      IterableElementList labels = xpath(doc, "//labels[not(@readOnly='true')]");
      assertFalse(filename + ": No normal labels found", labels.isEmpty());
     
      for (Element label : labels) {
        String labelName = label.getAttribute("editPartClassName");
       
        // it cannot have a OpenDiagram behaviour
        IterableElementList bh = xpath(label, "behaviour");
        for (Element b : bh) {
          assertNotEqual(filename + ": Normal editable label '" + labelName + "' cannot have an OpenDiagram behaviour",
            b.getAttribute("xsi:type"), "gmfgen:OpenDiagramBehaviour");
        }
      }
View Full Code Here

Examples of org.openiaml.model.xpath.IterableElementList

  public void testLabelOpenDiagramsMatch() throws Exception {
    for (String filename : getGenList()) {
      Document doc = getCache().get(filename);
     
      // will do both links and nodes
      IterableElementList labels = xpath(doc, "//labels");
      assertFalse(filename + ": No labels found", labels.isEmpty());
     
      for (Element label : labels) {
        String labelName = label.getAttribute("editPartClassName");
       
        // iterate over behaviours
        IterableElementList beh = xpath(label, "behaviour");
        for (Element b : beh) {
          if (b.getAttribute("xsi:type").equals("gmfgen:OpenDiagramBehaviour")) {
            // the parent must have the same node
           
            String query = "../behaviour[@editPolicyClassName='" + b.getAttribute("editPolicyClassName") + "' and @diagramKind='" + b.getAttribute("diagramKind") + "' and @editorID='" + b.getAttribute("editorID") + "']";
View Full Code Here

Examples of org.openiaml.model.xpath.IterableElementList

   */
  public void testOpenDiagramTargetElement() throws Exception {
    for (String filename : getGenList()) {
      Document doc = getCache().get(filename);
     
      IterableElementList nodes = xpath(doc, "/GenEditorGenerator/diagram/topLevelNodes");
      nodes.addAll(xpath(doc, "/GenEditorGenerator/diagram/links"));
      assertFalse(filename + ": No nodes found", nodes.isEmpty());
     
      for (Element node : nodes) {
        // find the meta element for this node
        Element meta = xpathFirst(node, "modelFacet/metaClass");
        // iaml.genmodel#//model/CompositeOperation
        String metaHref = meta.getAttribute("href");
       
        IterableElementList beh = xpath(node, "behaviour");
        for (Element b : beh) {
          if (b.getAttribute("xsi:type").equals("gmfgen:OpenDiagramBehaviour")) {
            // an OpenDiagram policy
            assertOpenDiagramElementMatches(filename, b.getAttribute("diagramKind"), metaHref);
          }
View Full Code Here

Examples of org.openiaml.model.xpath.IterableElementList

    iterate(new DefaultIterator() {
     
      @Override
      public void execute2(String filename, Document doc) throws Exception {
        // will do both links and nodes
        IterableElementList nodes = xpath(doc, "/GenEditorGenerator/diagram/topLevelNodes");
        nodes.addAll(xpath(doc, "/GenEditorGenerator/diagram/links"));
        assertFalse(filename + ": No nodes found", nodes.isEmpty());
       
        boolean changed = false;
        for (Element node : nodes) {
          // find the meta element for this node
          Element meta = xpathFirst(node, "modelFacet/metaClass");
          // iaml.genmodel#//model/CompositeOperation
          String metaHref = meta.getAttribute("href");
          // CompositeOperation
          metaHref = metaHref.substring(metaHref.lastIndexOf("/") + 1);
         
          EClass metaElement = resolveSimpleEClass(metaHref);
         
          try {
            RootElementPair pair = getBestPair(rootElements, metaElement);
           
            if (pair == null)
              continue;    // can't open this element
           
            // there must be a behaviour for this meta element!
            changed |= checkOrAddOpenBehaviour(doc, node, pair);
           
            // check readonly labels contained within
            IterableElementList labels = xpath(node, "labels[@readOnly='true']");
           
            for (Element label : labels) {
             
              try {
                changed |= checkOrAddOpenBehaviour(doc, label, pair);
              } catch (Throwable t) {
                String labelName = label.getAttribute("editPartClassName");
                throw new RuntimeException("Label " + labelName + ": " + t.getMessage(), t);
              }
             
            }


          } catch (Throwable t) {
            throw new RuntimeException(node.getAttribute("editPartClassName") + ": " + t.getMessage(), t);
          }
        } 
       
        if (changed) {
          saveDocument(doc, filename);
        }
      }
     
      /**
       * Checks the given node (can either be a /node, /link or /label)
       * that it contains the given OpenDiagramBehaviour. Adds it if it
       * doesn't exist, otherwise check that it matches what it should be.
       *
       * @param doc The root document
       * @param node The node to check for behaviour containment
       * @param pair The RootElementPair pointing to the editor it should open
       * @return true if the document has been modified, false otherwise
       * @throws XPathExpressionException
       */
      private boolean checkOrAddOpenBehaviour(Document doc, Element node, RootElementPair pair) throws XPathExpressionException {
        IterableElementList beh = xpath(node, "behaviour");
        assertFalse("Too many behaviours for " + node, beh.size() > 1);
       
        String policyName = camelCase(getName(pair.getFilename())) + "OpenDiagramEditPolicy";
        String diagramKind = pair.getModelID();
        String editorId = getPluginName(pair.getFilename()) + ".part.IamlDiagramEditorID";

        if (beh.size() == 1) {
          // check it is correct
          Element b = beh.item(0);
          assertEquals("gmfgen:OpenDiagramBehaviour", b.getAttribute("xsi:type"));
          assertEquals(policyName, b.getAttribute("editPolicyClassName"));
          assertEquals(diagramKind, b.getAttribute("diagramKind"));
          assertEquals(editorId, b.getAttribute("editorID"));
         
        } else if (beh.size() == 0) {
          // there is none; insert one
          log("Adding new behaviour " + policyName);
         
          Element behaviour = doc.createElement("behaviour");
          behaviour.setAttribute("xsi:type", "gmfgen:OpenDiagramBehaviour");
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.