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.

ButtonRenderer.java 2.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /*
  2. * Copyright 2000-2016 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.ui.renderers;
  17. import elemental.json.JsonValue;
  18. /**
  19. * A Renderer that displays a button with a textual caption. The value of the
  20. * corresponding property is used as the caption. Click listeners can be added
  21. * to the renderer, invoked when any of the rendered buttons is clicked.
  22. *
  23. * @since 7.4
  24. * @author Vaadin Ltd
  25. */
  26. public class ButtonRenderer extends ClickableRenderer<String> {
  27. /**
  28. * Creates a new button renderer.
  29. *
  30. * @param nullRepresentation
  31. * the textual representation of {@code null} value
  32. */
  33. public ButtonRenderer(String nullRepresentation) {
  34. super(String.class, nullRepresentation);
  35. }
  36. /**
  37. * Creates a new button renderer and adds the given click listener to it.
  38. *
  39. * @param listener
  40. * the click listener to register
  41. * @param nullRepresentation
  42. * the textual representation of {@code null} value
  43. */
  44. public ButtonRenderer(RendererClickListener listener,
  45. String nullRepresentation) {
  46. this(nullRepresentation);
  47. addClickListener(listener);
  48. }
  49. /**
  50. * Creates a new button renderer.
  51. */
  52. public ButtonRenderer() {
  53. this("");
  54. }
  55. /**
  56. * Creates a new button renderer and adds the given click listener to it.
  57. *
  58. * @param listener
  59. * the click listener to register
  60. */
  61. public ButtonRenderer(RendererClickListener listener) {
  62. this(listener, "");
  63. }
  64. @Override
  65. public String getNullRepresentation() {
  66. return super.getNullRepresentation();
  67. }
  68. }