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.

TooltipInfo.java 2.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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.client;
  17. import com.vaadin.shared.util.SharedUtil;
  18. public class TooltipInfo {
  19. private String title;
  20. private String errorMessageHtml;
  21. // Contains the tooltip's identifier. If a tooltip's contents and this
  22. // identifier haven't changed, the tooltip won't be updated in subsequent
  23. // events.
  24. private Object identifier;
  25. public TooltipInfo() {
  26. }
  27. public TooltipInfo(String tooltip) {
  28. setTitle(tooltip);
  29. }
  30. public TooltipInfo(String tooltip, String errorMessage) {
  31. this(tooltip, errorMessage, null);
  32. }
  33. public TooltipInfo(String tooltip, String errorMessage, Object identifier) {
  34. setIdentifier(identifier);
  35. setTitle(tooltip);
  36. setErrorMessage(errorMessage);
  37. }
  38. public void setIdentifier(Object identifier) {
  39. this.identifier = identifier;
  40. }
  41. public Object getIdentifier() {
  42. return identifier;
  43. }
  44. public String getTitle() {
  45. return title;
  46. }
  47. public void setTitle(String title) {
  48. this.title = title;
  49. }
  50. public String getErrorMessage() {
  51. return errorMessageHtml;
  52. }
  53. public void setErrorMessage(String errorMessage) {
  54. errorMessageHtml = errorMessage;
  55. }
  56. /**
  57. * Checks is a message has been defined for the tooltip.
  58. *
  59. * @return true if title or error message is present, false if both are
  60. * empty
  61. */
  62. public boolean hasMessage() {
  63. return (title != null && !title.isEmpty())
  64. || (errorMessageHtml != null && !errorMessageHtml.isEmpty());
  65. }
  66. public boolean equals(TooltipInfo other) {
  67. return (other != null && SharedUtil.equals(other.title, title)
  68. && SharedUtil.equals(other.errorMessageHtml, errorMessageHtml)
  69. && other.identifier == identifier);
  70. }
  71. }