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.

ButtonState.java 3.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. /*
  2. @VaadinApache2LicenseForJavaFiles@
  3. */
  4. package com.vaadin.shared.ui.button;
  5. import com.vaadin.shared.ComponentState;
  6. import com.vaadin.shared.ui.TabIndexState;
  7. import com.vaadin.ui.Button;
  8. /**
  9. * Shared state for Button and NativeButton.
  10. *
  11. * @see ComponentState
  12. *
  13. * @since 7.0
  14. */
  15. public class ButtonState extends ComponentState implements TabIndexState {
  16. private boolean disableOnClick = false;
  17. private int clickShortcutKeyCode = 0;
  18. /**
  19. * The tab order number of this field.
  20. */
  21. private int tabIndex = 0;
  22. /**
  23. * If caption should be rendered in HTML
  24. */
  25. private boolean htmlContentAllowed = false;
  26. /**
  27. * Checks whether the button should be disabled on the client side on next
  28. * click.
  29. *
  30. * @return true if the button should be disabled on click
  31. */
  32. public boolean isDisableOnClick() {
  33. return disableOnClick;
  34. }
  35. /**
  36. * Sets whether the button should be disabled on the client side on next
  37. * click.
  38. *
  39. * @param disableOnClick
  40. * true if the button should be disabled on click
  41. */
  42. public void setDisableOnClick(boolean disableOnClick) {
  43. this.disableOnClick = disableOnClick;
  44. }
  45. /**
  46. * Returns the key code for activating the button via a keyboard shortcut.
  47. *
  48. * See {@link Button#setClickShortcut(int, int...)} for more information.
  49. *
  50. * @return key code or 0 for none
  51. */
  52. public int getClickShortcutKeyCode() {
  53. return clickShortcutKeyCode;
  54. }
  55. /**
  56. * Sets the key code for activating the button via a keyboard shortcut.
  57. *
  58. * See {@link Button#setClickShortcut(int, int...)} for more information.
  59. *
  60. * @param clickShortcutKeyCode
  61. * key code or 0 for none
  62. */
  63. public void setClickShortcutKeyCode(int clickShortcutKeyCode) {
  64. this.clickShortcutKeyCode = clickShortcutKeyCode;
  65. }
  66. /**
  67. * Set whether the caption text is rendered as HTML or not. You might need
  68. * to retheme button to allow higher content than the original text style.
  69. *
  70. * If set to true, the captions are passed to the browser as html and the
  71. * developer is responsible for ensuring no harmful html is used. If set to
  72. * false, the content is passed to the browser as plain text.
  73. *
  74. * @param htmlContentAllowed
  75. * <code>true</code> if caption is rendered as HTML,
  76. * <code>false</code> otherwise
  77. */
  78. public void setHtmlContentAllowed(boolean htmlContentAllowed) {
  79. this.htmlContentAllowed = htmlContentAllowed;
  80. }
  81. /**
  82. * Return HTML rendering setting.
  83. *
  84. * @return <code>true</code> if the caption text is to be rendered as HTML,
  85. * <code>false</code> otherwise
  86. */
  87. public boolean isHtmlContentAllowed() {
  88. return htmlContentAllowed;
  89. }
  90. /*
  91. * (non-Javadoc)
  92. *
  93. * @see com.vaadin.terminal.gwt.client.ui.TabIndexState#getTabIndex()
  94. */
  95. @Override
  96. public int getTabIndex() {
  97. return tabIndex;
  98. }
  99. /*
  100. * (non-Javadoc)
  101. *
  102. * @see com.vaadin.terminal.gwt.client.ui.TabIndexState#setTabIndex(int)
  103. */
  104. @Override
  105. public void setTabIndex(int tabIndex) {
  106. this.tabIndex = tabIndex;
  107. }
  108. }