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.

DebugButton.java 3.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /*
  2. * Copyright 2000-2014 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.client.debug.internal;
  17. import com.google.gwt.user.client.ui.Button;
  18. /**
  19. * Simple extension of {@link Button} that is preconfigured with for use in
  20. * {@link VDebugWindow}. Uses icon-font for icons, and allows title to be
  21. * specified in the constructor.
  22. *
  23. * @since 7.1
  24. * @author Vaadin Ltd
  25. */
  26. public class DebugButton extends Button {
  27. protected boolean active = false;
  28. /**
  29. * Creates a {@link Button} with the given icon-font icon. The icon id will
  30. * be used in the <i>data-icon</i> attribute of an <i>&lt;i&gt;</i> -tag.
  31. *
  32. * @param icon
  33. * Identifier for the desired icon in an icon-font
  34. */
  35. public DebugButton(Icon icon) {
  36. this(icon, null, null);
  37. }
  38. /*-
  39. public DebugButton(String caption) {
  40. this(null, null, caption);
  41. }
  42. public DebugButton(String caption, String title) {
  43. this(null, title, caption);
  44. }
  45. -*/
  46. /**
  47. * Creates a {@link Button} with the given icon-font icon and title
  48. * (tooltip). The icon id will be used in the <i>data-icon</i> attribute of
  49. * an <i>&lt;i&gt;</i> -tag.
  50. *
  51. * @param icon
  52. * Identifier for the desired icon in an icon-font
  53. * @param title
  54. * Button title (tooltip)
  55. *
  56. */
  57. public DebugButton(Icon icon, String title) {
  58. this(icon, title, null);
  59. }
  60. /**
  61. * Creates a {@link Button} with the given icon-font icon, title (tooltip),
  62. * and caption. The icon id will be used in the <i>data-icon</i> attribute
  63. * of an <i>&lt;i&gt;</i> -tag.
  64. *
  65. * @param icon
  66. * Identifier for the desired icon in an icon-font
  67. * @param title
  68. * Title (tooltip)
  69. * @param caption
  70. * Button baption
  71. */
  72. public DebugButton(Icon icon, String title, String caption) {
  73. super((icon != null ? icon : "") + (caption != null ? caption : ""));
  74. if (title != null) {
  75. setTitle(title);
  76. }
  77. setStylePrimaryName(VDebugWindow.STYLENAME_BUTTON);
  78. }
  79. /**
  80. * Adds or removes a stylename, indicating whether or not the button is in
  81. * it's active state.
  82. *
  83. * @param active
  84. */
  85. public void setActive(boolean active) {
  86. this.active = active;
  87. setStyleDependentName(VDebugWindow.STYLENAME_ACTIVE, active);
  88. }
  89. /**
  90. * Indicates wheter the Button is currently in its active state or not
  91. *
  92. * @return true if the Button is active, false otherwise
  93. */
  94. public boolean isActive() {
  95. return active;
  96. }
  97. }