Examples of ODOMElement


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

           
        // Default to no change
        ProxyElementDetails.ChangeReason change = null;

        // Get the target element
        final ODOMElement targetElement =
                sourceTargetPairs.getTarget(pairIndex);

        // Does the attribute NOT exist in the target?
        if (targetElement == null
            || targetElement.getAttribute(attribName) == null) {

            // If there is an attribute value passed in, need to create the
            // attribute to receive it (otherwise there is nothing to do and
            // the default return of null applies)
            if (attribValue != null && attribValue.length() != 0) {
               
                // Create the attrib and note whether an element was created
                final boolean elementCreated =
                    propagateCreateAttribute(
                        attribName, attribValue, pairIndex);
                       
                // Convert the result accordingly
                change = (elementCreated
                    ? ProxyElementDetails.ELEMENTS
                    : ProxyElementDetails.ATTRIBUTES);
            }
           
        } else {
            // Target attribute DOES exist in the target: get it
            final ODOMAttribute existingAttribute =
                (ODOMAttribute) targetElement.getAttribute(attribName);
               
            // If there is an attribute value passed in...
            if (attribValue != null && attribValue.length() != 0) {   
               
                // Just update the existing attribute with the new value
View Full Code Here

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

        ProxyElementDetails.ChangeReason change = null;

        boolean wasTargetCreated = false;

        // Get the target element
        ODOMElement targetElement =
                sourceTargetPairs.getTarget(pairIndex);

        if (targetElement == null) {
            ODOMElement sourceElement = sourceTargetPairs.getSource(pairIndex);
            // Create the element if it isn't there...
            sourceToTargetPath.create(sourceElement, odomFactory);

            // Navigate to the target that the create should have made
            targetElement =
View Full Code Here

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

                int pairIndex)
                throws XPathException {

        // Get the souce and target elements: the source is immutable so
        // final, but we may have to re-assign the target
        final ODOMElement sourceElement =
                    sourceTargetPairs.getSource(pairIndex);

        ODOMElement targetElement =
                    sourceTargetPairs.getTarget(pairIndex);

        // flag that will be set to true if the target element had to be
        // created
        boolean wasTargetCreated = false;

        // if the target element is a ProxyElement then we do not delete an
        // attribute, instead we just set it's value to an empty string. The
        // target proxy will then propagate this "effective" delete to its
        // targets.
        if (targetElement instanceof ProxyElement) {
            targetElement.setAttribute(attribName, attribValue);
        } else {
            // Create the attribute to insert
            final ODOMAttribute newAttribute =
                        (ODOMAttribute) odomFactory.
                        attribute(attribName, attribValue);
View Full Code Here

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

                int pairIndex)
                throws XPathException {

        // Get the souce and target elements: the source is immutable so
        // final, but we may have to re-assign the target
        final ODOMElement sourceElement =
                    sourceTargetPairs.getSource(pairIndex);

        ODOMElement targetElement =
                    sourceTargetPairs.getTarget(pairIndex);

        // flag that will be set to true if the target element was deleted
        boolean wasTargetDeleted = false;

        if (targetElement instanceof ProxyElement) {
            targetElement.setAttribute(existingAttribute.getName(), "");
        } else {

            // Use a remove xpath instead of just removeAttribute on the
            // target as only the former method removes the "whole path"
            // from source to target (e.g. if latter is grandchild)
View Full Code Here

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

            (ODOMObservable node, ODOMChangeEvent event) {

        // Get the event source and node in typesafe form (we know the node
        // is an element because we only listen on sources)
        final ODOMObservable eventSrc = event.getSource();
        final ODOMElement nodeEle = (ODOMElement)node;

        // Switch on change type
        if (event.getChangeQualifier() == ChangeQualifier.HIERARCHY) {

            // Just delegate to attribute or element hierarchy event handler
View Full Code Here

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

     * @param event The original event from the changed callback
     */
    private void processElementHierarchyEvent(ODOMElement sourceElement,
                                              ODOMChangeEvent event) {
        // Get the event source, which we know to be an element
        final ODOMElement eventSrcElement = (ODOMElement) event.getSource();

        if ((sourceElement != eventSrcElement) &&
                sourceTargetPairs.isSourceElement(eventSrcElement)) {
            // ignore this event explicitly. This is here to avoid erroneous
            // multiple processings of the event when the proxy is used in
            // a situation where both an element and one of its ancestors can
            // both be sources: in this case, because of how events propagate
            // up the hierarchy in the ODOM, the proxy can get confused (e.g.
            // if the child is removed, it might appear that the
            // "sourceElement" (its ancestor) is being removed but then an
            // illegal state exception ("removing nonexistant target") would
            // be thrown).
        } else {
            // Find the corresponding proxy target (which may/may not be null)
            final int proxyIndex =
                sourceTargetPairs.getSourceIndex(sourceElement);
            final ODOMElement existingProxyTarget =
                sourceTargetPairs.getTarget(proxyIndex);

            // This combination indicates an addition
            if ((event.getNewValue() != null) &&
                    (event.getOldValue() == null)) {
View Full Code Here

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

     */
    private ODOMElement navigateToTarget(ODOMElement sourceElement) {

        // The default is either null (for when the xpath is NOT null)
        // or the source element (for when the xpath IS null)
        ODOMElement targetElement =
            (sourceToTargetPath != null ? null : sourceElement);
       
        // If the xpath is not null, try to find a non-null target
        if (sourceToTargetPath != null) {
           
View Full Code Here

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

     */
    public void removeEmptyTargets() {
        List targets = getTargets();

        for (int i = 0; i < targets.size(); i++) {
            ODOMElement odomElement = (ODOMElement) targets.get(i);
            if (odomElement != null) {
                List attributes = odomElement.getAttributes();
                if (attributes == null || attributes.size() == 0) {
                    // has no attributes.
                    List content = odomElement.getContent();
                    if (content != null && content.size() == 0) {
                        // no content therefore eligible for removal.
                        try {
                            sourceToTargetPath.remove(sourceTargetPairs.getSource(i));
                            sourceTargetPairs.setTarget(i, null);
View Full Code Here

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

     * Create targets if the target is empty (null).
     */
    public void createEmptyTargets() {
        List targets = getTargets();
        for (int i = 0; i < targets.size(); i++) {
            ODOMElement odomElement = (ODOMElement) targets.get(i);
            if (odomElement == null) {
                // empty target
                try {
                    ODOMElement target = (ODOMElement) sourceToTargetPath.create(
                            sourceTargetPairs.getSource(i), odomFactory);
                    sourceTargetPairs.setTarget(i, target);
                } catch (XPathException e) {
                    throw new IllegalStateException("Unabled to create XPath: "  +
                            sourceToTargetPath);
View Full Code Here

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

            supportDND(formatComposite);
        }

        Iterator childIterator = element.getChildren().iterator();
        while (childIterator.hasNext()) {
            ODOMElement child = (ODOMElement) childIterator.next();
            FormatComposite childFC =
                    buildFormatComposite(parent, child, root);
            if (childFC != null) {
                GridData data = new GridData(GridData.FILL_BOTH);
                childFC.setLayoutData(data);
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.