Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

ButtonRenderer.java 2.1KB

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