com.google.gwt.xml.client.Element Java Examples

The following examples show how to use com.google.gwt.xml.client.Element. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: XmlDebugPanel.java    From core with GNU Lesser General Public License v2.1 6 votes vote down vote up
public XmlDebugPanel(TreeTableModel model) {
  this.model = model;
  nodes = new IdentityHashMap<Object, Element>();
  document = XMLParser.createDocument();
  root = document.createElement("debug-panel");
  initWidget(textArea = new TextArea());
  textArea.ensureDebugId("debug-panel-xml");
  textArea.setStyleName(Utils.style() + "-xml");

  // Build the XML document based on the current state.
  document.appendChild(root);
  nodes.put(model.getRoot(), root);
  build(model.getRoot());

  model.addTreeTableModelListener(this);
}
 
Example #2
Source File: DialogXML.java    From core with GNU Lesser General Public License v2.1 6 votes vote down vote up
public Dialog unmarshall(String xml)
{

    try {
        Document document = XMLParser.parse(xml);
        Element root = document.getDocumentElement();

        // model
        Builder builder = new Builder();
        dfsElement(builder, DOMUtils.getFirstChildElement(root));

        // dialog
        Dialog dialog = new Dialog(new QName(root.getNamespaceURI(), root.getAttribute("id")), builder.build());

        return dialog;
    } catch (RuntimeException e) {
        Window.alert("Faile to parse XML: "+e.getMessage());
        throw e;
    }
}
 
Example #3
Source File: PropertiesAdapter.java    From core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
public Element toXML(Document document, InteractionUnit unit) {
    Element el = DOMUtils.createElementNS(document, unit.getId().getNamespaceURI(), getElementName());
    el.setAttribute("id", unit.getId().getLocalPart());
    el.setAttribute("label", unit.getLabel());

    if(unit instanceof Container)
    {
        Container container = (Container)unit;
        if(container.getTemporalOperator()!=null) {
            el.setAttribute("operator", container.getTemporalOperator().toString());
        }
    }

    return el;
}
 
Example #4
Source File: DialogXML.java    From core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
public void endVisit(Container container) {
    if(stack.size()>1){
        Node el = stack.pop();
        stack.peek().appendChild(el);
    }
    else if(stack.size()==1)
    {
        Node root = stack.pop();

        Element dialogEl = DOMUtils.createElementNS(document, dialog.getId().getNamespaceURI(), "dialog");
        dialogEl.setAttribute("id", dialog.getId().getLocalPart());
        dialogEl.appendChild(root);
        document.appendChild(dialogEl);

    }
    else
    {
        throw new RuntimeException("Parse error");
    }
}
 
Example #5
Source File: DialogXML.java    From core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void visit(InteractionUnit unit) {

    String name = unit.getStereotype()!=null ?
            unit.getStereotype().toString().toLowerCase() : resolveType(unit);

    Element el = getAdapter(name).toXML(document, unit);
    marshallMapping(unit, el);

    if(stack.isEmpty())
        throw new RuntimeException("Parse error");

    stack.peek().appendChild(el);
}
 
Example #6
Source File: UsewareAdapter.java    From core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public Element toXML(Document document, InteractionUnit unit) {

    Element el = DOMUtils.createElementNS(document, unit.getId().getNamespaceURI(), elementName);
    el.setAttribute("id", unit.getId().getLocalPart());
    el.setAttribute("label", unit.getLabel());

    if(unit instanceof Container)
    {
        Container container = (Container)unit;
        if(container.getTemporalOperator()!=null) {
            el.setAttribute("operator", container.getTemporalOperator().toString());
        }
    }
    else if(unit instanceof Trigger)
    {
        Trigger trigger = (Trigger)unit;
        el.setAttribute("type", trigger.getType().toString());
    }
    else if(unit instanceof Link)
    {
        Link link = (Link)unit;
        el.setAttribute("target", link.getTarget().toString());
    }

    return el;
}
 
Example #7
Source File: TodoAdapter.java    From core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public Element toXML(Document document, InteractionUnit unit) {
    Element el = DOMUtils.createElementNS(document, unit.getId().getNamespaceURI(), getElementName());
    el.setAttribute("id", unit.getId().getLocalPart());
    el.setAttribute("label", unit.getLabel());

    return el;
}
 
Example #8
Source File: FormAdapter.java    From core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public Element toXML(Document document, InteractionUnit unit) {
    Element el = DOMUtils.createElementNS(document, unit.getId().getNamespaceURI(), getElementName());
    el.setAttribute("id", unit.getId().getLocalPart());
    el.setAttribute("label", unit.getLabel());
    return el;
}
 
Example #9
Source File: EditorPanelAdapter.java    From core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public Element toXML(Document document, InteractionUnit unit) {
    Element el = DOMUtils.createElementNS(document, unit.getId().getNamespaceURI(), getElementName());
    el.setAttribute("id", unit.getId().getLocalPart());
    el.setAttribute("label", unit.getLabel());

    return el;
}
 
Example #10
Source File: PulldownAdapter.java    From core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public Element toXML(Document document, InteractionUnit unit) {
    Element el = DOMUtils.createElementNS(document, unit.getId().getNamespaceURI(), getElementName());
    el.setAttribute("id", unit.getId().getLocalPart());
    el.setAttribute("label", unit.getLabel());

    return el;
}
 
Example #11
Source File: PagesAdapter.java    From core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public Element toXML(Document document, InteractionUnit unit) {
    Element el = DOMUtils.createElementNS(document, unit.getId().getNamespaceURI(), getElementName());
    el.setAttribute("id", unit.getId().getLocalPart());
    el.setAttribute("label", unit.getLabel());

    return el;
}
 
Example #12
Source File: DialogXML.java    From core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private void marshallMapping(InteractionUnit unit, Element target)
{
    if(unit.hasMapping(MappingType.DMR))
    {
        DMRMapping mapping = (DMRMapping) unit.getMapping(MappingType.DMR);
        Element el = getAdapter("dmr").toXML(document, mapping);
        target.appendChild(el);
    }
}
 
Example #13
Source File: DialogXML.java    From core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void startVisit(Container container) {

    String name = container.getStereotype()!=null ?
            container.getStereotype().toString().toLowerCase() : "container";

    Element el = getAdapter(name).toXML(document, container);
    marshallMapping(container, el);

    stack.push(el);
}
 
Example #14
Source File: ToolstripAdapter.java    From core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public Element toXML(Document document, InteractionUnit unit) {
    Element el = DOMUtils.createElementNS(document, unit.getId().getNamespaceURI(), getElementName());
    el.setAttribute("id", unit.getId().getLocalPart());
    el.setAttribute("label", unit.getLabel());

    return el;
}
 
Example #15
Source File: XmlDebugPanel.java    From core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void nodeRemoved(Object parent, Object node, int index) {
  Element parentNode = parent == null ? root : nodes.get(parent);
  Element childNode = nodes.get(node);
  parentNode.removeChild(childNode);
  nodes.remove(node);
  updateTextArea();
}
 
Example #16
Source File: XmlDebugPanel.java    From core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void nodeAdded(Object parent, Object node, int index) {
  Element parentNode = nodes.get(parent);
  Element childNode = document.createElement("event");
  for (int i = 0; i < model.getColumnCount(); i++) {
    childNode.setAttribute(getAttributeName(i), getAttributeValue(node, i));
  }
  parentNode.appendChild(childNode);
  nodes.put(node, childNode);
  updateTextArea();
}
 
Example #17
Source File: TestReader.java    From jts with GNU Lesser General Public License v2.1 5 votes vote down vote up
private void parseTest(Node test, Test t) {
	Element testEl = (Element) test;

	HashMap<Integer, String> args = new HashMap<>();

	t.exception = testEl.getAttribute("expect");

	Element op = (Element) testEl.getElementsByTagName("op").item(0);

	NamedNodeMap attrs = op.getAttributes();
	for (int i = 0; i < attrs.getLength(); i++) {
		Node attr = attrs.item(i);
		String name = attr.getNodeName();

		switch (name) {
		case "name":
			t.operation = attr.getNodeValue();
			break;
		default:
			if (name.startsWith("arg")) {
				int argIdx = Integer.valueOf(name.replace("arg", ""));
				args.put(argIdx, attr.getNodeValue());
			} else {
				// sLogger.severe("-------" + name + "-------");
			}
			break;
		}
	}

	for (int i = 1; i <= args.size(); i++) {
		String argN = args.get(i);
		t.arguments.add(argN);
	}

	t.result = op.getChildNodes().item(0).getNodeValue().trim();
}
 
Example #18
Source File: YaBlocksEditor.java    From appinventor-extensions with Apache License 2.0 5 votes vote down vote up
public Set<String> getBlockTypeSet() {
  Set<String> blockTypes = new HashSet<String>();
  String xmlString = blocksArea.getBlocksContent();
  Document blockDoc = XMLParser.parse(xmlString);
  NodeList blockElements = blockDoc.getElementsByTagName("block");
  for (int i = 0; i < blockElements.getLength(); ++i) {
    Element blockElem = (Element) blockElements.item(i);
    blockTypes.add(blockElem.getAttribute("type"));
  }
  return blockTypes;
}
 
Example #19
Source File: DOMUtils.java    From core with GNU Lesser General Public License v2.1 4 votes vote down vote up
public static Element createElementNS(Document doc, String ns, String name)
{
    return (Element)NodeImpl.build(_createElementNS(getJSObj(doc), ns, name));
}
 
Example #20
Source File: XmlDebugPanel.java    From core with GNU Lesser General Public License v2.1 4 votes vote down vote up
public void valueChanged(Object node, int columnIndex) {
  Element element = nodes.get(node);
  element.setAttribute(getAttributeName(columnIndex), getAttributeValue(node, columnIndex));
  updateTextArea();
}
 
Example #21
Source File: TestReader.java    From jts with GNU Lesser General Public License v2.1 4 votes vote down vote up
public TestRun read(String s) {

		Document doc = XMLParser.parse(s);
		TestRun tr = new TestRun();

		Element run = doc.getDocumentElement();

		NodeList runChildren = run.getChildNodes();
		for (int i = 0; i < runChildren.getLength(); i++) {
			Node runChild = runChildren.item(i);
			String name = runChild.getNodeName();

			switch (name) {
			case "desc":
				tr.description = trim(runChild.getChildNodes().item(0)
						.getNodeValue());
				break;
			case "precisionModel":
				tr.precisionModel = trim(((Element) runChild)
						.getAttribute("type"));
				break;
			case "resultMatcher":
				tr.resultMatcher = trim(runChild.getChildNodes().item(0)
						.getNodeValue());
				break;
			case "geometryOperation":
				tr.geometryOperation = trim(runChild.getChildNodes().item(0)
						.getNodeValue());
				break;
			case "case":
				TestCase tc = new TestCase();
				tr.testCases.add(tc);
				parseTestCase(runChild, tc);
				break;
			default:
				// sLogger.severe("-------" + name + "-------");
				break;
			}
		}

		return tr;
	}
 
Example #22
Source File: ElementAdapter.java    From core with GNU Lesser General Public License v2.1 votes vote down vote up
Element toXML(Document doc, T unit);