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

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


     */
    public TACPatternsSection(Composite parent, int style,
                              DeviceEditorContext context) {
        super(parent, style);
        this.context = context;
        ODOMElement identificationRootElement =
                (ODOMElement) context.getDeviceRepositoryAccessorManager().
                getDeviceTACIdentificationDocument().getRootElement();

        try {
            context.addRootElement(identificationRootElement,
                    identificationRootElement.getName());

            context.addSupplementaryValidator(new DOMSupplementaryValidatorDetails(
                    MCSNamespace.DEVICE_TAC_IDENTIFICATION.getURI(),
                    DeviceRepositorySchemaConstants.NUMBER_ELEMENT_NAME,
                    new TACNumberValidator()));

            // Censor xsd generated errors on the number element
            // of the TAC document since the error messages bear no relation
            // to what is shown in the gui.
            // todo remove this when validation is updated to provide good error messages.
            MarkerGeneratingErrorReporter errorReporter =
                    context.getErrorReporter((ODOMElement) context.
                    getDeviceRepositoryAccessorManager().
                    getDeviceTACIdentificationDocument().getRootElement());

            errorReporter.censor(DeviceRepositorySchemaConstants.
                    DEVICE_ELEMENT_NAME +
                    ":" + DeviceRepositorySchemaConstants.NUMBER_ELEMENT_NAME,
                    FaultTypes.INVALID_SCHEMA_PATTERN_VALUE);

            errorReporter.censor(DeviceRepositorySchemaConstants.
                    DEVICE_ELEMENT_NAME +
                    ":" + DeviceRepositorySchemaConstants.NUMBER_ELEMENT_NAME,
                    FaultTypes.INVALID_ELEMENT_CONTENT);

            errorReporter.putMessageKeyMapping(INVALID_TAC_NUMBER,
                    MarkerGeneratingErrorReporter.MESSAGE_KEY_PREFIX +
                    "invalidTACNumber");

            context.addRootElement(identificationRootElement,
                    identificationRootElement.getName());

            LocationDetailsRegistry registry =
                    errorReporter.getLocationDetailsRegistry();
            if (registry == null) {
                registry = new LocationDetailsRegistry();
View Full Code Here


            }
        });

        // We need to be notified of changes to the definitions document
        // associated with the device repository so we can refresh the viewer.
        ODOMElement definitions = (ODOMElement)
                dram.getDeviceDefinitionsDocument().getRootElement();
        definitions.addChangeListener(new ODOMChangeListener() {
            public void changed(ODOMObservable node,
                                ODOMChangeEvent event) {
                viewer.refresh();
            }
        });
View Full Code Here

        Element element = factory.element(DeviceRepositorySchemaConstants.
                POLICY_ELEMENT_NAME,
                MCSNamespace.DEVICE_DEFINITIONS);

        ODOMElement root = (ODOMElement)
                context.getDeviceRepositoryAccessorManager().
                getDeviceDefinitionsDocument().getRootElement();

        LocationDetails details =
                new CategoryPolicyLocationDetails(context.getDeviceRepositoryAccessorManager());
View Full Code Here

                                           String key) throws Exception {
        DOMConstraint constraint = createConstraint("ancestor",
                                                    key,
                                                    required);

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

                                        String key) throws Exception {
        DOMConstraint constraint = createConstraint("ancestor",
                                                 key,
                                                 required);

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

        }
    };
   
    private void setIdAttrib(int childPos, int attPos, String value) {
        for(int i = 0; i < childPos + 1 - assets.size(); i++) {
            assets.add(new ODOMElement(ASSET_NAME));
        }
        final ODOMElement element = (ODOMElement)assets.get(childPos);
        final String name = ID_ATTRIBS[attPos];
        Assert.assertNull("Att exists: " + name, element.getAttribute(name));
        element.setAttribute(name, value);
    }
View Full Code Here

        element.setAttribute(name, value);
    }
   
    private void setOtherAttrib(int childPos, int attPos) {
        for(int i = 0; i < childPos + 1 - assets.size(); i++) {
            assets.add(new ODOMElement(ASSET_NAME));
        }
        final ODOMElement element = (ODOMElement)assets.get(childPos);
        element.setAttribute(OTHER_ATTRIBS[attPos], "someNonIdValue");
    }
View Full Code Here

                                repository.getPath(),
                                new TestTransformerMetaFactory(), jdomFactory, false);

                String sName = DeviceRepositorySchemaConstants.STANDARD_ELEMENT_NAME;

                ODOMElement e = (ODOMElement) manager.retrieveDeviceIdentification("PC");
                //create a standard element and add it to the device identification
                ODOMElement standard = (ODOMElement) jdomFactory.element(sName,
                        e.getNamespace());
                e.addContent(standard);

                List children = e.getChildren();
                Object[] childArray = children.toArray();
                // make sure the standard element is that last element
                assertEquals("The standard element is the last child element",
                        sName, ((ODOMElement) childArray[childArray.length - 1]).
                        getName());

                //set the patterns
                String[] patterns = new String[]{"fred", "jane"};
                manager.setUserAgentPatterns("PC", patterns);

                // get the children of the element and start the tests
                children = e.getChildren();
                childArray = children.toArray();

                int count = 0;
                Iterator childIt = children.iterator();
                while (childIt.hasNext()) {
                    ODOMElement ode = (ODOMElement) childIt.next();
                    if (ode.getName().equals(sName)) {
                        count++;
                    }
                }

                // ensure that the context is correct for the test to proceed.
View Full Code Here

                                repository.getPath(),
                                new TestTransformerMetaFactory(), jdomFactory, false);

                String sName = DeviceRepositorySchemaConstants.STANDARD_ELEMENT_NAME;

                ODOMElement e = (ODOMElement) manager.retrieveDeviceIdentification("PC");
                // create a standard element
                ODOMElement standard = (ODOMElement) jdomFactory.element(sName,
                        e.getNamespace());
                //add to the element
                e.addContent(standard);

                List children = e.getChildren();
                Object[] childArray = children.toArray();
                assertEquals("The standard element is the last child element",
                        sName, ((ODOMElement) childArray[childArray.length - 1]).
                        getName());

                // set the Header Patterns
                DeviceHeaderPattern[] patterns
                        = new DeviceHeaderPattern[]{
                            new DeviceHeaderPattern("name1", "re1", "baseDevice1"),
                            new DeviceHeaderPattern("name2", "re2", "baseDevice2")
                        };
                manager.setHeaderPatterns("PC", patterns);

                // get the children of the element (it should be modified by here)
                children = e.getChildren();
                childArray = children.toArray();

                int count = 0;
                Iterator childIt = children.iterator();
                while (childIt.hasNext()) {
                    ODOMElement ode = (ODOMElement) childIt.next();
                    if (ode.getName().equals(sName)) {
                        count++;
                    }
                }
                // ensure that the context is correct for the test to proceed
                assertEquals("Only one standard element exists", 1, count);
View Full Code Here

        final ODOMXPath xpath = new ODOMXPath(xpathStr);
        Assert.assertEquals("xpath len", true, xpathStr.length() > 0);

        // ...but context may be, in which case it is taken to be
        // the entire selection
        final ODOMElement context =
                (contextStr.length() == 0
                ? currentSelection
                : (ODOMElement)getSingletonNode(
                        currentSelection, contextStr));
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.