Examples of ODOMElement


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

            DeviceRepositoryAccessorManager dram) {

        DeviceEditorContext context = null;

        try {
            ODOMElement hierarchyRoot =
                    (ODOMElement) dram.getDeviceHierarchyDocument().
                    getRootElement();

            context = new DeviceEditorContext(
                    repositoryFile,
                    mementoOriginator,
                    hierarchyRoot,
                    hierarchyRoot.getName(),
                    dram);
        } catch (ParserErrorException e) {
            EclipseCommonPlugin.handleError(ABPlugin.getDefault(), e);
        } catch (SAXException e) {
            EclipseCommonPlugin.handleError(ABPlugin.getDefault(), e);
View Full Code Here

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

     */
    public ODOMElement getRootElement() {

        final Collection rootElements = getRootElements();

        ODOMElement rootElement = null;

        for (Iterator iter = rootElements.iterator(); iter.hasNext();) {

            final ODOMElement element = (ODOMElement) iter.next();
            if (DeviceRepositorySchemaConstants.HIERARCHY_ELEMENT_NAME.equals(
                    element.getName()) &&
                MCSNamespace.DEVICE_HIERARCHY.getURI().equals(
                    element.getNamespaceURI())) {
                if (rootElement == null) {
                    rootElement = element;
                } else {
                    throw new IllegalStateException(
                        "More than one hierarchy root element.");
View Full Code Here

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

        if (formatType == null) {
            throw new IllegalArgumentException(
                "A non-null format type is required"); //$NON-NLS-1$
        }

        ODOMElement prototype = (ODOMElement)prototypes.get(formatType);

        if (prototype == null) {
            FormatType.Structure structure = formatType.getStructure();
            String name = formatType.getElementName();

            // Double check that things won't go horribly wrong (simple
            // and grid containers both need to reference the empty format,
            // so the latter must be a leaf format)
            if ((formatType == FormatType.EMPTY) &&
                structure != FormatType.Structure.LEAF) {
                throw new IllegalStateException(
                            "The empty format must be a leaf " + //$NON-NLS-1$
                            "structured format"); //$NON-NLS-1$
            }

            // Create the main element for the prototype
            prototype = (ODOMElement)factory.element(name);

            if (structure == FormatType.Structure.LEAF) {
                // Leaf formats have no internal structure
            } else if (structure == FormatType.Structure.SIMPLE_CONTAINER) {
                // Simple containers have an empty format placeholder for child
                // creation
                prototype.addContent(get(FormatType.EMPTY));

                // The following code block inserts default values for new
                // Formats.  This will eventually be required for all formats.
                // However at the moment we only set the following required
                // fields of the Spatial Iterators....
                // - 2D Indexing Direction
                // - Row Iterations
                // - Column Iterations
                //
                // When this is extended to other formats the code should
                // almost certainly be refactored out of this method.
                //
                // Setting defaults allows the user to build a layout without
                // having to explicitly set all required fields, reducing the
                // level of error feedback and facilitating faster layout
                // construction.
                if (formatType == FormatType.SPATIAL_FORMAT_ITERATOR) {
                    prototype.setAttribute(
                            LayoutSchemaType.
                            SPATIAL_ITERATOR_COLUMNS_ATTRIBUTE.getName(),
                            LayoutSchemaType.
                            SPATIAL_ITERATOR_CELLS_VALUE_VARIABLE.getName());

                    prototype.setAttribute(
                            LayoutSchemaType.
                            SPATIAL_ITERATOR_COLUMN_COUNT_ATTRIBUTE.getName(),
                            "0");

                    prototype.setAttribute(
                            LayoutSchemaType.
                            SPATIAL_ITERATOR_ROWS_ATTRIBUTE.getName(),
                            LayoutSchemaType.
                            SPATIAL_ITERATOR_CELLS_VALUE_VARIABLE.getName());

                    prototype.setAttribute(
                            LayoutSchemaType.
                            SPATIAL_ITERATOR_ROW_COUNT_ATTRIBUTE.getName(),
                            "0");

                    prototype.setAttribute(
                            LayoutSchemaType.
                            SPATIAL_ITERATOR_INDEXING_DIRECTION_ATTRIBUTE.
                            getName(),
                            LayoutSchemaType.
                            SPATIAL_ITERATOR_INDEXING_DIRECTION_VALUE_ACROSS_DOWN.
                            getName());
                }
            } else if (structure == FormatType.Structure.GRID) {
                // Create the complex prototype structure based on the grid
                // format's name
                String gridName = prototype.getName();
                String colName = LayoutSchemaType.getGridColumnName(gridName);
                String colsName = LayoutSchemaType.getGridColumnsName(gridName);
                String rowName = LayoutSchemaType.getGridRowName(gridName);

                ODOMElement col = (ODOMElement)factory.element(colName);
                ODOMElement cols = (ODOMElement)factory.element(colsName);
                ODOMElement row = (ODOMElement)factory.element(rowName);

                prototype.addContent(cols);
                cols.addContent(col);
                prototype.addContent(row);
                row.addContent(get(FormatType.EMPTY));
            } else {
                throw new IllegalArgumentException(
                    "The given format type (" + //$NON-NLS-1$
                    formatType.getTypeName() +
                    ") has an unknown structure (" + //$NON-NLS-1$
View Full Code Here

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

    public static ODOMElement createSizedGrid(FormatType formatType,
                                              Element firstCell,
                                              int rowCount,
                                              int colCount,
                                              IProgressMonitor monitor) {
        ODOMElement grid = FormatPrototype.get(formatType);
        ODOMElement cols = (ODOMElement)grid.getContent().get(0);
        ODOMElement col = (ODOMElement)cols.getContent().get(0);
        ODOMElement row = (ODOMElement)grid.getContent().get(1);
        ODOMElement placeholder = (ODOMElement)row.getContent().get(0);

        if (firstCell != null) {
            colCount = Math.max(1, colCount);
            rowCount = Math.max(1, rowCount);
        }

        if (colCount < 0) {
            throw new IllegalArgumentException(
                "A zero or positive number of columns is " + //$NON-NLS-1$
                "required (" + //$NON-NLS-1$
                colCount +
                " specified)"); //$NON-NLS-1$
        } else if (colCount == 0) {
            // remove the elements that represent columns or column content
            col.detach();
            placeholder.detach();
        } else {
            ODOMElement newCol;
            ODOMElement newPlaceholder;

            for (int i = 1; i < colCount; i++) {
                newCol = (ODOMElement)col.clone();
                newPlaceholder = (ODOMElement)placeholder.clone();

                cols.addContent(newCol);
                row.addContent(newPlaceholder);
               
                if (monitor != null) {
                    monitor.worked(1);
                }
            }
        }

        if (rowCount < 0) {
            throw new IllegalArgumentException(
                "A zero or positive number of rows is" //$NON-NLS-1$
                " required (" + //$NON-NLS-1$
                rowCount + " specified)"); //$NON-NLS-1$
        } else if (rowCount == 0) {
            row.detach();
        } else {
            ODOMElement newRow;

            for (int i = 1; i < rowCount; i++) {
                newRow = (ODOMElement)row.clone();

                grid.addContent(newRow);
View Full Code Here

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

        // as requested. Otherwise the operation to perform requires user
        // input to determine a swap or replace operation.
        if (event.data == null) {
            event.detail = DND.DROP_NONE;
        } else {
            ODOMElement elements [] = (ODOMElement[]) event.data;
            ODOMElement sourceElement = elements[0];
            ODOMElement targetElement = getCurrentTarget(event);
            if (targetElement == sourceElement) {
                event.detail = DND.DROP_NONE;
            } else {
                XPath srcXPath = new XPath(actionDetails.getElement(0));
                boolean canReplace = ActionSupport.canReplace(sourceElement,
                        targetElement, srcXPath);
                if (!targetElement.getName().
                        equals(FormatType.EMPTY.getElementName())) {
                    boolean canSwap = event.detail == DND.DROP_MOVE;
                    ActionSupport.canSwap(sourceElement, targetElement);
                    if (canReplace || (canReplace && canSwap)) {
                        SwapReplaceDialog dialog =
View Full Code Here

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

     * Get the ODOMElement that is the target of the drop.
     * @param event the DropTargetEvent
     * @return the ODOMElement upon which the drop will occur.
     */
    protected ODOMElement getCurrentTarget(DropTargetEvent event) {
        ODOMElement target = event.item == null ? null :
                (ODOMElement) event.item.getData();
        return target;
    }
View Full Code Here

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

        // Do what the superclass needs to do
        super.run(details);

        // Now remove the element from the document, ensuring that it is
        // replaced by an empty element if necessary
        ODOMElement element = details.getElement(0);
        Element parent = element.getParent();

        if (parent.getParent() != null) {
            // A format is being cut as opposed to a device layout
            // so an empty format must take its place
            List content = parent.getContent();
            int index = content.indexOf(element);
            Element replacement = FormatPrototype.get(FormatType.EMPTY);
            replaceElement(element, replacement);
            List list = new ArrayList();
            list.add(replacement);
            selectionManager.setSelection(list);

        } else {
            element.detach();
        }
    }
View Full Code Here

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

    public void addSupplementaryValidator(
            DOMSupplementaryValidatorDetails validatorDetails) {
        if (!supplementaryValidators.contains(validatorDetails)) {
            Iterator rootElements = getRootElements().iterator();
            while (rootElements.hasNext()) {
                ODOMElement rootElement = (ODOMElement) rootElements.next();
                // Only register the supplementary validator on
                // ValidationManagers that manage validation on relevant
                // rootElements.
                if (rootElement.getNamespaceURI()
                        .equals(validatorDetails.namespaceURI)) {
                    ((ValidationManager) rootElementsToValidationManagers.
                            get(rootElement)).
                            addSupplementaryValidator(validatorDetails);
                }
View Full Code Here

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

            // Search this format and its decendents and set them to be
            // selected if their element is in the selection.
            Iterator iterator = structuredSelection.iterator();
            while (iterator.hasNext()) {
                ODOMElement selected = (ODOMElement) iterator.next();
                select(selected);
            }
        }
    }
View Full Code Here

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

            DOMSupplementaryValidatorDetails validatorDetails) {

        if (supplementaryValidators.remove(validatorDetails)) {
            Iterator rootElements = getRootElements().iterator();
            while (rootElements.hasNext()) {
                ODOMElement rootElement = (ODOMElement) rootElements.next();
                // Only unregister the supplementary validator on
                // ValidationManagers that manage validation on relevant
                // rootElements.
                if (rootElement.getNamespaceURI()
                        .equals(validatorDetails.namespaceURI)) {
                    ((ValidationManager) rootElementsToValidationManagers.
                            get(rootElement)).
                            removeSupplementaryValidator(validatorDetails);
                }
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.