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.

LinkConnector.java 3.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /*
  2. @VaadinApache2LicenseForJavaFiles@
  3. */
  4. package com.vaadin.terminal.gwt.client.ui;
  5. import com.google.gwt.core.client.GWT;
  6. import com.google.gwt.user.client.DOM;
  7. import com.google.gwt.user.client.ui.Widget;
  8. import com.vaadin.terminal.gwt.client.ApplicationConnection;
  9. import com.vaadin.terminal.gwt.client.UIDL;
  10. public class LinkConnector extends AbstractComponentConnector {
  11. @Override
  12. protected boolean delegateCaptionHandling() {
  13. return false;
  14. }
  15. @Override
  16. public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
  17. // Ensure correct implementation,
  18. // but don't let container manage caption etc.
  19. super.updateFromUIDL(uidl, client);
  20. if (!isRealUpdate(uidl)) {
  21. return;
  22. }
  23. getWidget().client = client;
  24. getWidget().enabled = !getState().isDisabled();
  25. getWidget().readonly = getState().isReadOnly();
  26. if (uidl.hasAttribute("name")) {
  27. getWidget().target = uidl.getStringAttribute("name");
  28. getWidget().anchor.setAttribute("target", getWidget().target);
  29. }
  30. if (uidl.hasAttribute("src")) {
  31. getWidget().src = client.translateVaadinUri(uidl
  32. .getStringAttribute("src"));
  33. getWidget().anchor.setAttribute("href", getWidget().src);
  34. }
  35. if (uidl.hasAttribute("border")) {
  36. if ("none".equals(uidl.getStringAttribute("border"))) {
  37. getWidget().borderStyle = VLink.BORDER_STYLE_NONE;
  38. } else {
  39. getWidget().borderStyle = VLink.BORDER_STYLE_MINIMAL;
  40. }
  41. } else {
  42. getWidget().borderStyle = VLink.BORDER_STYLE_DEFAULT;
  43. }
  44. getWidget().targetHeight = uidl.hasAttribute("targetHeight") ? uidl
  45. .getIntAttribute("targetHeight") : -1;
  46. getWidget().targetWidth = uidl.hasAttribute("targetWidth") ? uidl
  47. .getIntAttribute("targetWidth") : -1;
  48. // Set link caption
  49. getWidget().captionElement.setInnerText(getState().getCaption());
  50. // handle error
  51. if (uidl.hasAttribute("error")) {
  52. if (getWidget().errorIndicatorElement == null) {
  53. getWidget().errorIndicatorElement = DOM.createDiv();
  54. DOM.setElementProperty(getWidget().errorIndicatorElement,
  55. "className", "v-errorindicator");
  56. }
  57. DOM.insertChild(getWidget().getElement(),
  58. getWidget().errorIndicatorElement, 0);
  59. } else if (getWidget().errorIndicatorElement != null) {
  60. DOM.setStyleAttribute(getWidget().errorIndicatorElement, "display",
  61. "none");
  62. }
  63. if (uidl.hasAttribute(ATTRIBUTE_ICON)) {
  64. if (getWidget().icon == null) {
  65. getWidget().icon = new Icon(client);
  66. getWidget().anchor.insertBefore(getWidget().icon.getElement(),
  67. getWidget().captionElement);
  68. }
  69. getWidget().icon.setUri(uidl.getStringAttribute(ATTRIBUTE_ICON));
  70. }
  71. }
  72. @Override
  73. protected Widget createWidget() {
  74. return GWT.create(VLink.class);
  75. }
  76. @Override
  77. public VLink getWidget() {
  78. return (VLink) super.getWidget();
  79. }
  80. }