Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*
  2. * Copyright 2000-2018 Vaadin Ltd.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  5. * use this file except in compliance with the License. You may obtain a copy of
  6. * the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  12. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  13. * License for the specific language governing permissions and limitations under
  14. * the License.
  15. */
  16. package com.vaadin.server;
  17. import java.io.Serializable;
  18. import com.vaadin.server.PaintTarget.PaintStatus;
  19. import com.vaadin.ui.Component;
  20. import com.vaadin.ui.LegacyComponent;
  21. public class LegacyPaint implements Serializable {
  22. /**
  23. *
  24. * <p>
  25. * Paints the Paintable into a UIDL stream. This method creates the UIDL
  26. * sequence describing it and outputs it to the given UIDL stream.
  27. * </p>
  28. *
  29. * <p>
  30. * It is called when the contents of the component should be painted in
  31. * response to the component first being shown or having been altered so
  32. * that its visual representation is changed.
  33. * </p>
  34. *
  35. * <p>
  36. * <b>Do not override this to paint your component.</b> Override
  37. * {@link LegacyComponent#paintContent(PaintTarget)} instead.
  38. * </p>
  39. *
  40. *
  41. * @param target
  42. * the target UIDL stream where the component should paint itself
  43. * to.
  44. * @throws PaintException
  45. * if the paint operation failed.
  46. */
  47. public static void paint(Component component, PaintTarget target)
  48. throws PaintException {
  49. // Only paint content of visible components.
  50. if (!LegacyCommunicationManager.isComponentVisibleToClient(component)) {
  51. return;
  52. }
  53. final String tag = target.getTag(component);
  54. final PaintStatus status = target.startPaintable(component, tag);
  55. if (PaintStatus.CACHED == status) {
  56. // nothing to do but flag as cached and close the paintable tag
  57. target.addAttribute("cached", true);
  58. } else {
  59. // Paint the contents of the component
  60. if (component instanceof LegacyComponent) {
  61. ((LegacyComponent) component).paintContent(target);
  62. }
  63. }
  64. target.endPaintable(component);
  65. }
  66. private LegacyPaint() {
  67. }
  68. }