Package com.volantis.mcs.eclipse.common.odom

Examples of com.volantis.mcs.eclipse.common.odom.ODOMElement


        ODOMAttribute attribute = null;
        if (child.getName().equals("proxy")) {

            // It's a proxy element, so get it by name and lookup
            // the attribute
            final ODOMElement element = (ODOMElement)elementsMap.
                    get(child.getAttribute("name").getValue());
            attribute = (ODOMAttribute)element.getAttribute(name);

        } else if (child.getName().equals("pathToSelection")) {

            // It's an attribute within the selection, so first get
            // the context element
            final ODOMElement context = (ODOMElement)
                    getSingletonNode(
                            currentSelection,
                            child.getAttribute("context").getValue());

            // Use the context to get the attribute
View Full Code Here


        Assert.assertEquals("children", 1, children.size());
        final Element child = (Element)children.get(0);
        final String newName = directive.getAttribute("newName").getValue();

        // Get the thing to operate on
        ODOMElement element = null;
        if (child.getName().equals("proxy")) {

            // It's a proxy element, so just look it up
            element = (ODOMElement)elementsMap.
                    get(child.getAttribute("name").getValue());

        } else if (child.getName().equals("pathToSelection")) {

            // It's in the selection, so first get the context....
            final ODOMElement context = (ODOMElement)
                    getSingletonNode(
                            currentSelection,
                            child.getAttribute("context").getValue());

            // ...then look up the actual element to update - note that
View Full Code Here

        final List selection = new ArrayList(children.size());

        Iterator i = children.iterator();

        while (i.hasNext()) {
            ODOMElement e = (ODOMElement)i.next();

            if ("xpath".equals(e.getName())) {
                String xpath = e.getAttributeValue("path");

                if (xpath == null) {
                    throw new IllegalArgumentException(
                            "missing path atttribute");
                }

                // Add the resolved element
                selection.add(getSingletonNode(currentSelection, xpath));
            } else {
                throw new IllegalArgumentException(
                        "unrecognised child " + e.getName());
            }
        }

        // Apply the selection change to the top level proxy (which simulates
        // what should happen in the real environment)
View Full Code Here

        DOMConstraint constraint = createConstraint("ancestor",
                                                    "containerKey",
                                                    1,
                                                    "countKey");

        ODOMElement element = buildLPDMODOM(
            "<root>" +
            "    <something>" +
            "        <sub>" +
            "            <target/>" +
            "            <target/>" +
View Full Code Here

        DOMConstraint constraint = createConstraint("ancestor",
                                                 "containerKey",
                                                 1,
                                                 "countKey");

        ODOMElement element = buildLPDMODOM(
            "<root>" +
            "    <ancestor>" +
            "        <sub>" +
            "            <target/>" +
            "        </sub>" +
            "        <other>" +
            "            <nested>" +
            "               <target/>" +
            "            </nested>" +
            "        </other>" +
            "        <sub/>" +
            "    </ancestor>" +
            "</root>",
            "lpdm:ancestor/lpdm:sub/lpdm:target");

        doTest(constraint,
               element,
               "countKey");

        // Check the XPath cache
        doTest(constraint,
               element,
               "countKey");

        // Check against "sub"
        element = (ODOMElement)element.getParent();

        // Check the XPath cache
        doTest(constraint,
               element,
               "countKey");

        // Check against "other"
        element = (ODOMElement)element.getParent().getContent(
            new ElementFilter()).get(1);

        // Check the XPath cache
        doTest(constraint,
               element,
View Full Code Here

    /**
     * Test setAttribute method(s).
     */
    public void setSetAttributeValid() throws Exception {
        List list = new ArrayList(1);
        final ODOMElement element = (ODOMElement) odomFactory.element("test");
        element.setAttribute("attribute", "value");
        list.add(element);
        proxy.selectionChanged(new ODOMElementSelectionEvent(list));
        proxy.setAttribute("attribute", "");
    }
View Full Code Here

        assertNull("Should not have the duff attribute",
                proxy.getAttribute("duff"));

        List list = new ArrayList(1);
        final ODOMElement element = (ODOMElement) odomFactory.element("test");
        element.setAttribute("attribute", "value");
        list.add(element);

        details.setProxiedElements(list.iterator());

        proxy.selectionChanged(new ODOMElementSelectionEvent(list));
View Full Code Here

    public void testGetText() throws Exception {
        final String sampleText="quickbrownfox";
        // assertNull("Text should be null by default", proxy.getText());

        List list = new ArrayList(1);
        final ODOMElement element = (ODOMElement) odomFactory.element("test");
        element.setText(sampleText);
        list.add(element);

        proxy.addContent(new ProxyText());
        details.setProxiedElements(list.iterator());

        proxy.selectionChanged(new ODOMElementSelectionEvent(list));

        String text = proxy.getText();
        assertNotNull("Text should exist", text);

        assertEquals("Text value incorrect", sampleText, text);

        // Check that the proxy is updated correctly
        final String otherSample = "lazydog";
        element.setText(otherSample);

        text = proxy.getText();
        assertNotNull("Text should exist", text);

        assertEquals("Text value incorrect", otherSample, text);

        // Check that aggregation works correctly
        final ODOMElement otherElement =
                (ODOMElement) odomFactory.element("test");
        otherElement.setText(otherSample);

        list = new ArrayList(2);
        list.add(element);
        list.add(otherElement);
View Full Code Here

            }
        });

        manager.performOperation(new ODOMEditorContextOperation() {
            public void perform(ODOMEditorContext context) {
                ODOMElement element = context.getRootElement();

                assertNotNull("Root element is null.", element);

                assertEquals("Incorrect root element name.",
                        "imageComponent", element.getName());
            }
        });
    }
View Full Code Here

     * Tests the {@link com.volantis.mcs.eclipse.ab.editors.dom.ODOMEditorContext#addRootElement} method.
     * @throws Throwable if an error occurs.
     */
    public void testAddRootElement() throws Throwable {
        // create a root element
        final ODOMElement root = createRootElement();
        final IResource resource = createResource();

        ODOMEditorContextManager manager = new ODOMEditorContextManager(
                new ODOMEditorContextCreator() {
            public ODOMEditorContext create() throws Exception {
                return new ODOMEditorContext(resource,
                        NULL_UR_MEMENTO_ORIGINATOR,
                        root, null);
            }
        });

        manager.performOperation(new ODOMEditorContextOperation() {
            public void perform(ODOMEditorContext context) throws Exception {

                // check that the root element is the one that we are
                // interested in
                assertSame("rootElement is not as expected ",
                           root,
                           context.getRootElement());

                context.removeRootElement(root);

                // provide a new root element
                ODOMElement newRoot = createRootElement();
                // set the new root on the context
                context.addRootElement(newRoot, null);
                // check that the root element is the one that we are
                // interested in
                assertSame("new rootElement is not as expected ",
View Full Code Here

TOP

Related Classes of com.volantis.mcs.eclipse.common.odom.ODOMElement

Copyright © 2018 www.massapicom. 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.