Example usage for com.google.gwt.xml.client Element hasAttribute

List of usage examples for com.google.gwt.xml.client Element hasAttribute

Introduction

In this page you can find the example usage for com.google.gwt.xml.client Element hasAttribute.

Prototype

boolean hasAttribute(String name);

Source Link

Document

This method determines whether this Element has an attribute with the supplied name.

Usage

From source file:com.qtitools.player.client.module.text.TextEntryModule.java

License:Open Source License

/**   
 * constructor/*from  www .j av a 2 s.  co  m*/
 * @param moduleSocket
 */
public TextEntryModule(Element element, ModuleSocket moduleSocket,
        ModuleStateChangedEventsListener stateChangedListener) {

    responseIdentifier = XMLUtils.getAttributeAsString(element, "responseIdentifier");

    id = Document.get().createUniqueId();
    response = moduleSocket.getResponse(responseIdentifier);
    stateListener = stateChangedListener;
    textBox = new TextBox();
    if (element.hasAttribute("expectedLength"))
        textBox.setMaxLength(XMLUtils.getAttributeAsInt(element, "expectedLength"));
    textBox.getElement().setId(id);

    if (!response.correctAnswers.get(0).matches(".*[^0-9].*"))
        textBox.getElement().setAttribute("type", "number");
    String width = Integer.toString(response.correctAnswers.get(0).length() * 10 + 50);
    textBox.setWidth(width + "px");
    getElement().appendChild(textBox.getElement());
    setStyleName("qp-text-textentry");

    NodeList inlineFeedbackNodes = element.getElementsByTagName("feedbackInline");
    for (int f = 0; f < inlineFeedbackNodes.getLength(); f++) {
        moduleSocket.add(new InlineFeedback(this, inlineFeedbackNodes.item(f)));
    }

}

From source file:com.sensia.gwt.relaxNG.RNGInstanceWriter.java

License:Open Source License

protected void ensureNamespaceDecl(String nsUri) {
    if (nsUri != null) {
        String prefix = nsUriToPrefixMap.get(nsUri);
        String attName = "xmlns";
        if (prefix != null)
            attName += ":" + prefix;

        Element rootElt = dom.getDocumentElement();
        if (!rootElt.hasAttribute(attName))
            rootElt.setAttribute(attName, nsUri);
    }/*from   ww  w . j  a va 2s .  c om*/
}

From source file:org.catrobat.html5player.client.Parser.java

License:Open Source License

private void parseUserVariableList(Node tree) {
    if (tree == null)
        return;//from   w w  w .  j a  va  2  s  .  c o  m

    //
    Element userVariables = getChildElementByTagName(tree, "objectVariableList");
    if (userVariables == null)
        return;
    for (int i = 0; i < getChildElements(userVariables).size(); i++) {
        Element entry = getChildElements(userVariables).get(i);
        Element object = getChildElements(entry).get(0); //extend for ALL objects of an entry!!

        //String objectReference = checkReference(object.getAttribute("reference"), null);//evt nicht checken
        object = xpathEvaluateFirst(object, object.getAttribute("reference"), Element.class); //evt nicht checken
        Element nameObjEl = getChildElementByTagName(object, "name"); //evt nicht checken

        String nameSprite = "";

        if (nameObjEl != null) {
            nameSprite = nameObjEl.getFirstChild().toString(); //evt nicht checken
        }

        //
        Element list = getChildElements(entry).get(1); //beutify

        if (list.hasChildNodes()) {
            for (int j = 0; j < getChildElements(list).size(); j++) {

                Element var = getChildElements(list).get(j);

                if (var.hasAttribute("reference")) {
                    String objectReference = checkReference(var.getAttribute("reference"), "userVariable"); //HIER CHECKEN

                    Element userVariable = xpathEvaluateFirst(var, objectReference, Element.class); //HIER CHECKEN
                    if (userVariable == null) {
                        return;
                    }
                    String name = "";
                    double value = 0.0;

                    Element nameEl = getChildElementByTagName(userVariable, "name");
                    if (nameEl != null) {
                        name = nameEl.getFirstChild().toString();
                    }

                    Element valueEl = getChildElementByTagName(userVariable, "value");
                    if (valueEl != null) {
                        value = Double.parseDouble(valueEl.getFirstChild().toString());
                    }

                    Stage.getInstance().getUserVariables().addSpriteUserVariable(nameSprite, name, value);
                }
            }

        }

    }
}

From source file:org.catrobat.html5player.client.Parser.java

License:Open Source License

private void parseProgramVariableList(Node tree) {
    if (tree == null)
        return;/*from ww  w .  j a  v  a 2s .  c om*/

    Element prorgamVariables = getChildElementByTagName(tree, "programVariableList");
    if (prorgamVariables == null)
        return;

    for (int i = 0; i < getChildElements(prorgamVariables).size(); i++) {
        Element var = getChildElements(prorgamVariables).get(i);
        if (var.hasAttribute("reference")) {
            String objectReference = checkReference(var.getAttribute("reference"), "userVariable");
            Element userVariable = xpathEvaluateFirst(var, objectReference, Element.class);
            if (userVariable == null) {
                return;
            }
            String name = "";
            double value = 0.0;

            Element nameEl = getChildElementByTagName(userVariable, "name");
            if (nameEl != null) {
                name = nameEl.getFirstChild().toString();
            }

            Element valueEl = getChildElementByTagName(userVariable, "value");
            if (valueEl != null) {
                value = Double.parseDouble(valueEl.getFirstChild().toString());
            }
            Stage.getInstance().getUserVariables().addProjectUserVariable(name, value);
        }
    }

}

From source file:org.catrobat.html5player.client.Parser.java

License:Open Source License

private boolean parseAndCreateObjects(Document messageDom) {
    Element objectListNode = getChildElementByTagName(messageDom.getDocumentElement(), "objectList");
    List<Element> objectNodes = getChildElementsByTagName(objectListNode, "object");

    int objectCounter = 0;

    for (Element objectNode : objectNodes) {
        String name;/*w w w .j  a  v  a  2 s . co m*/
        Node lookList;
        Node scriptList;
        Node soundList;

        if (objectNode.hasAttribute("reference")) {
            String objectReference = checkReference(objectNode.getAttribute("reference"), "object");
            Element referencedObjectNode = xpathEvaluateFirst(objectNode, objectReference, Element.class);
            objectNode = referencedObjectNode;
        }
        name = getText(getChildElementByTagName(objectNode, "name"));
        lookList = getChildElementByTagName(objectNode, "lookList");
        scriptList = getChildElementByTagName(objectNode, "scriptList");
        soundList = getChildElementByTagName(objectNode, "soundList");

        Sprite object = createObject(name, lookList, scriptList, soundList);
        if (object == null) {
            Window.alert("Could not parse XML document. There are unsupported elements!");
            //Window.alert(name+"");
            //Window.alert(lookList+"");
            //Window.alert(scriptList+"");
            //Window.alert(soundList+"");
            return false;
        }

        if (!object.isBackground()) {
            object.getLook().setZPosition(objectCounter);
        } else {
            object.getLook().setZPosition(Integer.MIN_VALUE);
            objectCounter++;
        }

        manager.addSprite(object);
        objectCounter--;
    }
    return true;
}

From source file:org.catrobat.html5player.client.Parser.java

License:Open Source License

private Brick checkBrick(Element brickNode, Sprite object, Script script) throws Exception {

    Element objectReference = getChildElementByTagName(brickNode, "object");

    String reference = objectReference != null ? objectReference.getAttribute("reference") : null;

    Element referencedObject = (objectReference != null && reference != null)
            ? xpathEvaluateFirst(objectReference, reference, Element.class)
            : null;// w ww  .j a  v  a  2  s.c  o  m

    String objName = object.getName();
    if (referencedObject != null && referencedObject.getNodeName().equals("object")) {
        String referenceName = getText(getChildElementByTagName(referencedObject, "name"));
        if (referenceName == null || referenceName.trim().length() == 0) {
            Stage.getInstance()
                    .log("Invalid object reference: " + referencedObject.getNodeName() + " for " + reference);
        } else if (!objName.equals(referenceName)) {
            objName = referenceName;
        }
    } else {
        CatrobatDebug.debug("INVALID - checkBrick - objectElement: " + referencedObject);
    }
    if (brickNode.getNodeName().equals("setLookBrick")) {

        Element lookReferenceElement = getChildElementByTagName(brickNode, "look");
        String lookReference = lookReferenceElement != null
                ? checkReference(lookReferenceElement.getAttribute("reference"), "look")
                : null;
        Element lookElement = lookReferenceElement != null && lookReference != null
                ? xpathEvaluateFirst(lookReferenceElement, lookReference, Element.class)
                : null;

        String lookName = null;
        if (lookElement != null) {
            lookName = getText(getChildElementByTagName(lookElement, "name"));
        } else {
            System.out.println("Look is null");
        }
        return new SetLookBrick(objName, lookName);
    } else if (brickNode.getNodeName().equals("waitBrick")) {
        Formula waitTime = FormulaParser
                .parseFormula(getChildElementByTagName(brickNode, "timeToWaitInSeconds"));
        return new WaitBrick(objName, waitTime, script);
    } else if (brickNode.getNodeName().equals("playSoundBrick")) {

        CatrobatDebug.debug("PlaySoundBrick:");

        Element soundInfoElement = getChildElementByTagName(brickNode, "sound");
        SoundInfo soundInfo = new SoundInfo();
        String soundId = null;
        String fileName = null;

        CatrobatDebug.debug("soundInfo: " + soundInfoElement);

        if (soundInfoElement != null) {
            if (soundInfoElement.hasAttribute("reference")) {
                String soundInfoReference = checkReference(soundInfoElement.getAttribute("reference"),
                        "PlaySoundBrick");
                Element referencedSoundInfoElement = xpathEvaluateFirst(soundInfoElement, soundInfoReference,
                        Element.class);

                CatrobatDebug.debug("PlaySoundBrick has a reference-attribute: " + soundInfoReference);
                CatrobatDebug.debug("referenced soundInfo: " + referencedSoundInfoElement);

                if (referencedSoundInfoElement != null) {
                    soundInfoElement = referencedSoundInfoElement;
                    CatrobatDebug.debug("soundInfoElement got set to the referenced soundInfo");
                } else {
                    CatrobatDebug.warn("referenced soundInfo is null");
                    return null;
                }
            }

            fileName = getText(getChildElementByTagName(soundInfoElement, "fileName"));

            CatrobatDebug.debug("Filename: " + fileName);
            soundInfo.setFileName(fileName);
            soundInfo.setTitle(getText(getChildElementByTagName(soundInfoElement, "name")));
            CatrobatDebug.debug("Title: " + getText(getChildElementByTagName(soundInfoElement, "name")));
            soundId = fileName.split("_")[0];
            CatrobatDebug.debug("Sound ID: " + soundId);
            soundInfo.setId(soundId);
        }

        if (soundId == null || soundId.trim().length() == 0) {
            System.out.println("sound is null");
        } else {
            object.addSound(soundInfo);
        }
        return new PlaySoundBrick(objName, soundId);
    } else if (brickNode.getNodeName().equals("speakBrick")) {
        String text = getChildElementByTagName(brickNode, "text").getFirstChild().getNodeValue();
        return new SpeakBrick(objName, text);
    } else if (brickNode.getNodeName().equals("changeVolumeByNBrick")) {
        Formula volume = FormulaParser.parseFormula(getChildElementByTagName(brickNode, "volume"));
        return new ChangeVolumeByBrick(objName, volume);
    } else if (brickNode.getNodeName().equals("setVolumeToBrick")) {
        Formula volume = FormulaParser.parseFormula(getChildElementByTagName(brickNode, "volume"));
        return new SetVolumeToBrick(objName, volume);
    } else if (brickNode.getNodeName().equals("placeAtBrick")) {
        Formula xPosition = FormulaParser.parseFormula(getChildElementByTagName(brickNode, "xPosition"));
        Formula yPosition = FormulaParser.parseFormula(getChildElementByTagName(brickNode, "yPosition"));
        return new PlaceAtBrick(objName, xPosition, yPosition);
    } else if (brickNode.getNodeName().equals("changeSizeByNBrick")) {
        Formula size = FormulaParser.parseFormula(getChildElementByTagName(brickNode, "size"));
        return new ChangeSizeByNBrick(objName, size);
    } else if (brickNode.getNodeName().equals("setYBrick")) {
        Formula yPosition = FormulaParser.parseFormula(getChildElementByTagName(brickNode, "yPosition"));
        return new SetYBrick(objName, yPosition);
    } else if (brickNode.getNodeName().equals("setXBrick")) {
        Formula xPosition = FormulaParser.parseFormula(getChildElementByTagName(brickNode, "xPosition"));
        return new SetXBrick(objName, xPosition);
    } else if (brickNode.getNodeName().equals("changeXByNBrick")) {
        Formula deltaX = FormulaParser.parseFormula(getChildElementByTagName(brickNode, "xMovement"));
        return new ChangeXByBrick(objName, deltaX);
    } else if (brickNode.getNodeName().equals("changeYByNBrick")) {
        Formula deltaY = FormulaParser.parseFormula(getChildElementByTagName(brickNode, "yMovement"));
        return new ChangeYByBrick(objName, deltaY);
    } else if (brickNode.getNodeName().equals("hideBrick")) {
        return new HideBrick(objName);
    } else if (brickNode.getNodeName().equals("showBrick")) {
        return new ShowBrick(objName);
    } else if (brickNode.getNodeName().equals("stopAllSoundsBrick")) {
        return new StopAllSoundsBrick(objName);
    } else if (brickNode.getNodeName().equals("turnLeftBrick")) {
        Formula degrees = FormulaParser.parseFormula(getChildElementByTagName(brickNode, "degrees"));
        return new TurnLeftBrick(objName, degrees);
    } else if (brickNode.getNodeName().equals("turnRightBrick")) {
        Formula degrees = FormulaParser.parseFormula(getChildElementByTagName(brickNode, "degrees"));
        return new TurnRightBrick(objName, degrees);
    } else if (brickNode.getNodeName().equals("pointInDirectionBrick")) {
        Formula degrees = FormulaParser.parseFormula(getChildElementByTagName(brickNode, "degrees"));
        return new PointInDirectionBrick(objName, degrees);
    } else if (brickNode.getNodeName().equals("goNStepsBackBrick")) {
        Formula steps = FormulaParser.parseFormula(getChildElementByTagName(brickNode, "steps"));
        return new GoNStepsBackBrick(objName, steps);
    } else if (brickNode.getNodeName().equals("comeToFrontBrick")) {
        return new ComeToFrontBrick(objName);
    } else if (brickNode.getNodeName().equals("glideToBrick")) {
        Formula duration = FormulaParser.parseFormula(getChildElementByTagName(brickNode, "durationInSeconds"));
        Formula xDestination = FormulaParser.parseFormula(getChildElementByTagName(brickNode, "xDestination"));
        Formula yDestination = FormulaParser.parseFormula(getChildElementByTagName(brickNode, "yDestination"));
        return new GlideToBrick(objName, duration, xDestination, yDestination, script);
    } else if (brickNode.getNodeName().equals("setSizeToBrick")) {
        Formula size = FormulaParser.parseFormula(getChildElementByTagName(brickNode, "size"));
        return new SetSizeToBrick(objName, size);
    } else if (brickNode.getNodeName().equals("broadcastBrick")) {
        String message = getText(getChildElementByTagName(brickNode, "broadcastMessage"));
        return new BroadcastBrick(objName, message);
    } else if (brickNode.getNodeName().equals("broadcastWaitBrick")) {
        String message = getText(getChildElementByTagName(brickNode, "broadcastMessage"));
        return new BroadcastWaitBrick(objName, message, script);
    } else if (brickNode.getNodeName().equals("moveNStepsBrick")) {
        Formula steps = FormulaParser.parseFormula(getChildElementByTagName(brickNode, "steps"));
        return new MoveNStepsBrick(objName, steps);
    } else if (brickNode.getNodeName().equals("nextLookBrick")) {
        return new NextLookBrick(objName);
    } else if (brickNode.getNodeName().equals("repeatBrick")) {
        Formula timesToRepeat = FormulaParser
                .parseFormula(getChildElementByTagName(brickNode, "timesToRepeat"));
        return new RepeatBrick(objName, timesToRepeat);
    } else if (brickNode.getNodeName().equals("loopEndBrick")) {

        RepeatBrick repeatBrick = script.getLastRepeatBrickWithoutLoopEndBrick();

        if (repeatBrick == null) {
            System.out.println("repeatBrick is null");
            return null;
        }
        LoopEndBrick loopEndBrick = new LoopEndBrick(objName, repeatBrick);
        repeatBrick.setLoopEndBrick(loopEndBrick);
        return loopEndBrick;

    } else if (brickNode.getNodeName().equals("foreverBrick")) {
        return new ForeverBrick(objName);
    } else if (brickNode.getNodeName().equals("loopEndlessBrick")) {

        ForeverBrick foreverBrick = script.getLastForeverBrickWithoutLoopEndlessBrick();

        if (foreverBrick == null) {
            System.out.println("foreverBrick is null");
            return null;
        }
        LoopEndlessBrick loopEndlessBrick = new LoopEndlessBrick(objName, foreverBrick);
        foreverBrick.setLoopEndlessBrick(loopEndlessBrick);
        return loopEndlessBrick;

    } else if (brickNode.getNodeName().equals("noteBrick")) {

        Element noteNode = getChildElementByTagName(brickNode, "note");

        String note = getText(noteNode);

        if (note == null) {
            return new NoteBrick(objName);
        } else {
            return new NoteBrick(objName, note);
        }
    } else if (brickNode.getNodeName().equals("setGhostEffectBrick")) {
        Formula ghostEffectValue = FormulaParser
                .parseFormula(getChildElementByTagName(brickNode, "transparency"));
        return new SetGhostEffectBrick(objName, ghostEffectValue);
    } else if (brickNode.getNodeName().equals("changeGhostEffectByNBrick")) {
        Formula changeGhostEffect = FormulaParser
                .parseFormula(getChildElementByTagName(brickNode, "changeGhostEffect"));
        return new ChangeGhostEffectByBrick(objName, changeGhostEffect);
    } else if (brickNode.getNodeName().equals("ifOnEdgeBounceBrick")) {
        return new IfOnEdgeBounceBrick(objName);
    } else if (brickNode.getNodeName().equals("pointToBrick")) {

        Element pointedSpriteNode = getChildElementByTagName(brickNode, "pointedObject");
        Element pointedSpriteNameNode = null;
        String pointedSpriteName = null;
        if (pointedSpriteNode.hasAttribute("reference")) {
            String pointedSpriteReference = pointedSpriteNode.getAttribute("reference");
            Element referencedSpriteNode = xpathEvaluateFirst(pointedSpriteNode, pointedSpriteReference,
                    Element.class);
            pointedSpriteNameNode = getChildElementByTagName(referencedSpriteNode, "name");
        } else {
            pointedSpriteNameNode = getChildElementByTagName(pointedSpriteNode, "name");
        }

        if (pointedSpriteNameNode != null) {
            pointedSpriteName = getText(pointedSpriteNameNode);
        }
        CatrobatDebug
                .debug("Sprite " + objName + " has PointToBrick which points to Sprite " + pointedSpriteName);

        return new PointToBrick(objName, pointedSpriteName);
    } else if (brickNode.getNodeName().equals("clearGraphicEffectBrick")) {
        return new ClearGraphicEffectBrick(objName);
    } else if (brickNode.getNodeName().equals("setBrightnessBrick")) {
        Formula brightness = FormulaParser.parseFormula(getChildElementByTagName(brickNode, "brightness"));
        return new SetBrightnessBrick(objName, brightness);
    } else if (brickNode.getNodeName().equals("changeBrightnessByNBrick")) {
        Formula changeBrightness = FormulaParser
                .parseFormula(getChildElementByTagName(brickNode, "changeBrightness"));
        return new ChangeBrightnessBrick(objName, changeBrightness);
    } else if (brickNode.getNodeName().equals("setVariableBrick")) {
        UserVariable userVar = parseUserVariable(brickNode);
        Formula formula = FormulaParser.parseFormula(getChildElementByTagName(brickNode, "variableFormula"));
        return new SetVariableBrick(objName, formula, userVar);
    } else if (brickNode.getNodeName().equals("changeVariableBrick")) {
        UserVariable userVar = parseUserVariable(brickNode);
        Formula formula = FormulaParser.parseFormula(getChildElementByTagName(brickNode, "variableFormula"));
        return new ChangeVariableBrick(objName, formula, userVar);
    } else if (brickNode.getNodeName().equals("ifLogicBeginBrick")) {
        Formula formula;
        if (brickNode.hasAttribute("reference")) {
            String r = checkReference(brickNode.getAttribute("reference"), "ifLogicBeginBrick");
            Element n = xpathEvaluateFirst(brickNode, r, Element.class);
            //System.out.println(n);
            //return new SequenceBrick(objName);
            formula = FormulaParser.parseFormula(getChildElementByTagName(n, "ifCondition"));
        } else {
            formula = FormulaParser.parseFormula(getChildElementByTagName(brickNode, "ifCondition"));
        }
        return new IfLogicBrick(objName, formula);
    } else if (brickNode.getNodeName().equals("ifLogicElseBrick")) {
        return new IfLogicElseBrick(objName);
    } else if (brickNode.getNodeName().equals("ifLogicEndBrick")) {
        return new IfLogicEndBrick(objName);
    } else {
        if (ignoreUnimplementedBricks) {
            return new SequenceBrick(objName);
        }
        CatrobatDebug.warn("Brick: " + brickNode.getNodeName() + " not implemented");
        Stage.getInstance().log("Brick not implemented:" + brickNode.getNodeName());
    }
    return null;
}

From source file:org.catrobat.html5player.client.Parser.java

License:Open Source License

public UserVariable parseUserVariable(Node tree) {
    Element userVariable = getChildElementByTagName(tree, "userVariable");
    if (userVariable == null) {
        return null;
    }// w ww .  j  a v a2 s .c  o  m

    Element object = getChildElementByTagName(tree, "object");
    String objectRef = object.getAttribute("reference");
    object = xpathEvaluateFirst(object, objectRef, Element.class);
    String object_name = getChildElementByTagName(object, "name").getFirstChild().toString();

    //first occurance of variable, name used
    Element nameEl = getChildElementByTagName(userVariable, "name");
    if (nameEl != null) {
        String name = nameEl.getFirstChild().toString();
        return Stage.getInstance().getUserVariables().getUserVariable(name, object_name);
    }

    //variable already exists, reference needed
    if (userVariable.hasAttribute("reference")) {
        String objectReference = checkReference(userVariable.getAttribute("reference"), "userVariable");
        userVariable = xpathEvaluateFirst(userVariable, objectReference, Element.class);
        if (userVariable == null) {
            return null;
        }
        nameEl = getChildElementByTagName(userVariable, "name");
        if (nameEl != null) {
            String name = nameEl.getFirstChild().toString();
            return Stage.getInstance().getUserVariables().getUserVariable(name, object_name);
        }
    }
    return null;
}

From source file:org.jbpm.formbuilder.client.XmlParseHelper.java

License:Apache License

private List<MainMenuOption> readMenuOptions(NodeList menuOptions) {
    List<MainMenuOption> options = new ArrayList<MainMenuOption>();
    for (int index = 0; index < menuOptions.getLength(); index++) {
        Node menuNode = menuOptions.item(index);
        Element menuElement = (Element) menuNode;
        String name = menuElement.getAttribute("name");
        MainMenuOption option = new MainMenuOption();
        option.setHtml(name);// w  ww  .  ja  va  2s .c o  m
        if (menuElement.hasAttribute("commandClass")) {
            String className = menuElement.getAttribute("commandClass");
            try {
                Object obj = ReflectionHelper.newInstance(className);
                if (obj instanceof BaseCommand) {
                    option.setCommand((BaseCommand) obj);
                } else {
                    option.setHtml(option.getHtml() + "(" + i18n.NotOfType(className, "BaseCommand") + ")");
                    option.setEnabled(false);
                }
            } catch (Exception e) {
                option.setHtml(option.getHtml() + i18n.Error(e.getLocalizedMessage()));
                option.setEnabled(false);
            }
        } else {
            option.setSubMenu(readMenuOptions(menuElement.getChildNodes()));
        }
        options.add(option);
    }
    return options;
}

From source file:org.metawidget.example.gwt.clientside.client.ui.TextAreaInspector.java

License:BSD License

public String inspect(Object toInspect, String type, String... names) {

    // Parse the XML (do this each time as it may have been updated by the user)

    Document document = XMLParser.parse(mTextArea.getText());

    // Fetch the type

    Element entityToReturn = getEntity(document, type);

    // Traverse any path

    for (String name : names) {
        Element property = getProperty(entityToReturn, name);

        if (!property.hasAttribute("type")) {
            throw InspectorException.newException("Property '" + name + "' does not have a 'type' attribute");
        }/*w w w .  j  av a  2 s.c o m*/

        entityToReturn = getEntity(document, property.getAttribute("type"));
    }

    // Return the XML

    return "<metawidget-metadata>" + nodeToString(entityToReturn) + "</metawidget-metadata>";
}

From source file:org.pentaho.ui.xul.gwt.AbstractGwtXulComponent.java

License:Open Source License

public void init(com.google.gwt.xml.client.Element srcEle, XulDomContainer container) {
    if (srcEle.hasAttribute("id")) {
        setId(srcEle.getAttribute("id"));
    }/* w w w .ja  v  a 2 s .  c  o m*/

    if (srcEle.hasAttribute("orient") && srcEle.getAttribute("orient").trim().length() > 0) {
        // TODO: setOrient should live in an interface somewhere???
        setOrient(srcEle.getAttribute("orient"));
    }
    if (srcEle.hasAttribute("tooltiptext") && srcEle.getAttribute("tooltiptext").trim().length() > 0) {
        // TODO: setOrient should live in an interface somewhere???
        setTooltiptext(srcEle.getAttribute("tooltiptext"));
    }

    if (srcEle.hasAttribute("flex") && srcEle.getAttribute("flex").trim().length() > 0) {
        try {
            setFlex(Integer.parseInt(srcEle.getAttribute("flex")));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    if (hasAttribute(srcEle, "width")) {
        try {
            setWidth(Integer.parseInt(srcEle.getAttribute("width")));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    if (hasAttribute(srcEle, "height")) {
        try {
            setHeight(Integer.parseInt(srcEle.getAttribute("height")));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    if (hasAttribute(srcEle, "spacing")) {
        try {
            setSpacing(Integer.parseInt(srcEle.getAttribute("spacing")));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    if (hasAttribute(srcEle, "padding")) {
        try {
            setPadding(Integer.parseInt(srcEle.getAttribute("padding")));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    if (hasAttribute(srcEle, "visible")) {
        try {
            setVisible(srcEle.getAttribute("visible").equalsIgnoreCase("true") ? true : false); //$NON-NLS-1$ //$NON-NLS-2$
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    if (hasAttribute(srcEle, "position")) {
        try {
            setPosition(Integer.parseInt(srcEle.getAttribute("position")));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    if (srcEle.hasAttribute("insertbefore") && srcEle.getAttribute("insertbefore").trim().length() > 0) {
        setInsertbefore(srcEle.getAttribute("insertbefore"));
    }

    if (srcEle.hasAttribute("insertafter") && srcEle.getAttribute("insertafter").trim().length() > 0) {
        setInsertafter(srcEle.getAttribute("insertafter"));
    }
    if (srcEle.hasAttribute("removeelement") && srcEle.getAttribute("removeelement").trim().length() > 0) {
        setRemoveelement("true".equals(srcEle.getAttribute("removeelement")));
    }

    NamedNodeMap attrs = srcEle.getAttributes();
    for (int i = 0; i < attrs.getLength(); i++) {
        Node n = attrs.item(i);
        if (n != null) {
            this.setAttribute(n.getNodeName(), n.getNodeValue());
        }
    }
}