You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

TkTextField.java 1.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. package com.itmill.toolkit.terminal.gwt.client.ui;
  2. import com.google.gwt.user.client.ui.TextBox;
  3. import com.google.gwt.user.client.ui.Widget;
  4. import com.google.gwt.xml.client.NamedNodeMap;
  5. import com.google.gwt.xml.client.Node;
  6. import com.google.gwt.xml.client.NodeList;
  7. import com.itmill.toolkit.terminal.gwt.client.Client;
  8. public class TkTextField extends Component {
  9. private TextBox tb;
  10. public TkTextField(Node uidl, Client cli) {
  11. super(getIdFromUidl(uidl),cli);
  12. tb = new TextBox();
  13. updateFromUidl(uidl);
  14. }
  15. public void updateFromUidl(Node n) {
  16. NodeList children = n.getChildNodes();
  17. String text = "";
  18. String description = null;
  19. for (int i = 0; i < children.getLength(); i++) {
  20. Node child = children.item(i);
  21. if(child.getNodeName().equals("description"))
  22. description = child.getNodeValue();
  23. else if(child.getNodeType() == Node.TEXT_NODE)
  24. text = child.toString();
  25. }
  26. NamedNodeMap attributes = n.getAttributes();
  27. Node caption = attributes.getNamedItem("caption");
  28. if(caption != null)
  29. text = caption.getNodeValue();
  30. tb.setText(text);
  31. if(description != null)
  32. tb.setTitle(description);
  33. }
  34. public Widget getWidget() {
  35. return tb;
  36. }
  37. }