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.

VLinkPaintable.java 3.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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 VLinkPaintable 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",
  29. getWidget().target);
  30. }
  31. if (uidl.hasAttribute("src")) {
  32. getWidget().src = client.translateVaadinUri(uidl
  33. .getStringAttribute("src"));
  34. getWidget().anchor.setAttribute("href",
  35. getWidget().src);
  36. }
  37. if (uidl.hasAttribute("border")) {
  38. if ("none".equals(uidl.getStringAttribute("border"))) {
  39. getWidget().borderStyle = VLink.BORDER_STYLE_NONE;
  40. } else {
  41. getWidget().borderStyle = VLink.BORDER_STYLE_MINIMAL;
  42. }
  43. } else {
  44. getWidget().borderStyle = VLink.BORDER_STYLE_DEFAULT;
  45. }
  46. getWidget().targetHeight = uidl
  47. .hasAttribute("targetHeight") ? uidl
  48. .getIntAttribute("targetHeight") : -1;
  49. getWidget().targetWidth = uidl.hasAttribute("targetWidth") ? uidl
  50. .getIntAttribute("targetWidth") : -1;
  51. // Set link caption
  52. getWidget().captionElement.setInnerText(getState()
  53. .getCaption());
  54. // handle error
  55. if (uidl.hasAttribute("error")) {
  56. if (getWidget().errorIndicatorElement == null) {
  57. getWidget().errorIndicatorElement = DOM.createDiv();
  58. DOM.setElementProperty(
  59. getWidget().errorIndicatorElement,
  60. "className", "v-errorindicator");
  61. }
  62. DOM.insertChild(getWidget().getElement(),
  63. getWidget().errorIndicatorElement, 0);
  64. } else if (getWidget().errorIndicatorElement != null) {
  65. DOM.setStyleAttribute(
  66. getWidget().errorIndicatorElement, "display",
  67. "none");
  68. }
  69. if (uidl.hasAttribute(ATTRIBUTE_ICON)) {
  70. if (getWidget().icon == null) {
  71. getWidget().icon = new Icon(client);
  72. getWidget().anchor.insertBefore(
  73. getWidget().icon.getElement(),
  74. getWidget().captionElement);
  75. }
  76. getWidget().icon.setUri(uidl
  77. .getStringAttribute(ATTRIBUTE_ICON));
  78. }
  79. }
  80. @Override
  81. protected Widget createWidget() {
  82. return GWT.create(VLink.class);
  83. }
  84. @Override
  85. public VLink getWidget() {
  86. return (VLink) super.getWidget();
  87. }
  88. }