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.

AbstractEmbedded.java 2.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /*
  2. @VaadinApache2LicenseForJavaFiles@
  3. */
  4. package com.vaadin.ui;
  5. import com.vaadin.server.Resource;
  6. import com.vaadin.server.ResourceReference;
  7. import com.vaadin.shared.ui.AbstractEmbeddedState;
  8. /**
  9. * Abstract base for embedding components.
  10. *
  11. * @author Vaadin Ltd.
  12. * @version
  13. * @VERSION@
  14. * @since 7.0
  15. */
  16. @SuppressWarnings("serial")
  17. public abstract class AbstractEmbedded extends AbstractComponent {
  18. @Override
  19. public AbstractEmbeddedState getState() {
  20. return (AbstractEmbeddedState) super.getState();
  21. }
  22. /**
  23. * Sets the object source resource. The dimensions are assumed if possible.
  24. * The type is guessed from resource.
  25. *
  26. * @param source
  27. * the source to set.
  28. */
  29. public void setSource(Resource source) {
  30. if (source == null) {
  31. getState().setSource(null);
  32. } else {
  33. getState().setSource(new ResourceReference(source));
  34. }
  35. requestRepaint();
  36. }
  37. /**
  38. * Get the object source resource.
  39. *
  40. * @return the source
  41. */
  42. public Resource getSource() {
  43. ResourceReference ref = ((ResourceReference) getState().getSource());
  44. if (ref == null) {
  45. return null;
  46. } else {
  47. return ref.getResource();
  48. }
  49. }
  50. /**
  51. * Sets this component's alternate text that can be presented instead of the
  52. * component's normal content for accessibility purposes.
  53. *
  54. * @param altText
  55. * A short, human-readable description of this component's
  56. * content.
  57. */
  58. public void setAlternateText(String altText) {
  59. if (altText != getState().getAlternateText()
  60. || (altText != null && !altText.equals(getState()
  61. .getAlternateText()))) {
  62. getState().setAlternateText(altText);
  63. requestRepaint();
  64. }
  65. }
  66. /**
  67. * Gets this component's alternate text that can be presented instead of the
  68. * component's normal content for accessibility purposes.
  69. *
  70. * @returns Alternate text
  71. */
  72. public String getAlternateText() {
  73. return getState().getAlternateText();
  74. }
  75. }