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

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


        assertSelectFromODOMObservable(newElement2);
    }

    public void testSelectElementWithNSinPath() throws Exception {
        final ODOMElement newElement2_2 = (ODOMElement) ((ODOMElement) (root.getChildren()
                .get(5))).getChild("newElement2_2");
        assertNotNull("sanity check", newElement2_2);

        assertSelectFromODOMObservable(newElement2_2);
    }
View Full Code Here


            // We have found a namespace so create an appropriate element
            // with this namespace.
            namespace = xPathToken.substring(0, index);
            elementName = xPathToken.substring(index + 1, xPathToken.length());
        }
        ODOMElement element = null;
        if (namespace != null) {
            String uri = null;
            if ((namespaceURIMap != null) &&
                    (uri = (String) namespaceURIMap.get(namespace)) != null) {
                element = (ODOMElement) factory.element(elementName,
View Full Code Here

        this.context = context;

        createDisplayArea(TITLE, MESSAGE);
        createListeners();

        ODOMElement identificationRootElement =
                (ODOMElement) context.getDeviceRepositoryAccessorManager().
                getDeviceIdentificationDocument().getRootElement();

        try {
            context.addRootElement(identificationRootElement,
                    identificationRootElement.getName());
            MarkerGeneratingErrorReporter errorReporter =
                    context.getErrorReporter(identificationRootElement);
            LocationDetailsRegistry registry =
                    errorReporter.getLocationDetailsRegistry();
            if (registry == null) {
View Full Code Here

     */
    private void calculateXPath(boolean recurse) {

        // Get the parent of this instance, which is expected to be either null
        // or another instance of this class
        final ODOMElement parent = (ODOMElement) getParent();
        if (parent == null) {

            // No parent, so we're top-level, so we don't need an xpath
            xpath = null;

        } else if (parent instanceof ProxyElement) {
            Namespace ns = details.getElementNamespace();

            if (ns != null) {
                String uri = ns.getURI();
                if (uri == null || "".equals(uri)) {
                    ns = null;
                } else {
                    String prefix = ns.getPrefix();
                    if ((prefix == null) ||
                            ("".equals(prefix))) {
                        // @todo dream up a unique internal prefix
                        prefix = "lpdm";
                        ns = Namespace.getNamespace(prefix, ns.getURI());
                    }
                }
            }

            // Parent is one of us, so we know our xpath will not be null, and
            // therefore we'll need the namespace in a form suitable for the
            // XPath constructors
            final Namespace[] namespaces =
                    (ns == null
                    ? null
                    : new Namespace[]{ns});

            // Now get the parent's xpath: if it's null, our xpath is just an
            // (absolute) path to the proxied element; otherwise, we just
            // append the name of the proxied element to the parent's xpath
            final XPath parentXPath = ((ProxyElement) parent).xpath;
            if (parentXPath == null) {
                if (ns != null) {
                    xpath = new ODOMXPath(new StringBuffer(ns.getPrefix()).
                            append(':').
                            append(details.getElementName()).
                            toString(),
                            namespaces);
                } else {
                    xpath = new ODOMXPath(details.getElementName(), namespaces);
                }
            } else {
                if (ns != null) {
                    xpath = new ODOMXPath(parentXPath,
                            new StringBuffer(ns.getPrefix()).
                            append(':').
                            append(details.getElementName()).
                            toString(),
                            namespaces);
                } else {
                    xpath = new ODOMXPath
                            (parentXPath, details.getElementName(), namespaces);
                }
            }
        } else {
            // Parent is a non-null non-ProxyElement
            throw new IllegalStateException("PE's parent is not PE");
        }

        // Last thing to do is get all this instance's children to re-calculate
        // their xpaths, because their xpaths depend on their parent's just
        // like ours did above
        if (recurse) {
            final Iterator childIter = getChildren().iterator();
            while (childIter.hasNext()) {
                ODOMElement child = (ODOMElement) childIter.next();
                if (child instanceof ProxyElement) {
                    ((ProxyElement) child).calculateXPath(true);
                } else {
                    throw new IllegalStateException("Child is not a PE");
                }
View Full Code Here

        // Now recursively do the same thing for any ProxyElement children,
        // thereby causing them to recalculate their xpath (which is why we
        // did not set recurse to true in calculateXPath above)
        final Iterator childIter = getChildren().iterator();
        while (childIter.hasNext()) {
            ODOMElement child = (ODOMElement) childIter.next();
            if (child instanceof ProxyElement) {
                ((ProxyElement) child).applySelection(event);
            }
        }
    }
View Full Code Here

        super(null, null);
    }

    // javadoc inherited
    public ODOMElement resolve(ODOMElement element) throws XPathException {
        ODOMElement resolved = NON_COLUMN;

        final Element parent = element.getParent();
        // If we are in a grid (parent element is a gridFormatRow or
        // segmentGridFormatRow) then continue resolving.
        if (parent != null && parentMatchList.contains(parent.getName())) {
View Full Code Here

     *                        ODOMElement or more than one element.
     */
    private ODOMElement resolvePathToElement(ODOMElement element, int index)
            throws XPathException {

        ODOMElement resolved = NON_COLUMN;
        StringBuffer xpath = new StringBuffer(XPATH_PART_1);
        xpath.append(index).append(XPATH_PART_2);
        xpath.append(index).append(XPATH_PART_3);

        XPath xpathResolver = new XPath(xpath.toString(), NAMESPACES);
View Full Code Here

                    "Resource not found in the file system: " + //$NON-NLS-1$
                    file.getLocation().toOSString());
        }

        final InputStream inputStream = file.getContents();
        final ODOMElement odomElement;
        if (inputStream != null) {

            try {
                // Create a non-validating builder.
                // Note that this builder is JRE 1.4 and Eclipse friendly
View Full Code Here

                                ODOMElementSelectionEvent event) {
                            // This is a single-select context. Note that this
                            // retrieved element comes from the hierarchy
                            // document and not from a device document.
                            if (!event.getSelection().isEmpty()) {
                                ODOMElement selectedElement = (ODOMElement)
                                        event.getSelection().getFirstElement();

                                String deviceName =
                                        selectedElement.getAttributeValue(
                                                DeviceRepositorySchemaConstants.
                                        DEVICE_NAME_ATTRIBUTE);

                                controller.setDeviceName(deviceName);
                            }
View Full Code Here

        // update/refresh the table as appropriate.
        context.addChangeListener(new ODOMChangeListener() {
            public void changed(ODOMObservable node,
                                ODOMChangeEvent event) {

                final ODOMElement contextRootElement = context.getRootElement();
                if (rootElement == null && contextRootElement != null ||
                    rootElement != null && !rootElement.equals(contextRootElement)) {
                    updateRootElement();
                } else if (event.getChangeQualifier() == ChangeQualifier.HIERARCHY) {
                    treeViewer.refresh();
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.