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.

ColumnVisibilityChangeEvent.java 2.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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.v7.client.widget.grid.events;
  17. import com.google.gwt.event.shared.GwtEvent;
  18. import com.vaadin.v7.client.widgets.Grid.Column;
  19. /**
  20. * An event for notifying that the columns in the Grid's have changed
  21. * visibility.
  22. *
  23. * @param <T>
  24. * The row type of the grid. The row type is the POJO type from where
  25. * the data is retrieved into the column cells.
  26. * @since 7.5.0
  27. * @author Vaadin Ltd
  28. */
  29. public class ColumnVisibilityChangeEvent<T>
  30. extends GwtEvent<ColumnVisibilityChangeHandler<T>> {
  31. private static final Type<ColumnVisibilityChangeHandler<?>> TYPE = new Type<ColumnVisibilityChangeHandler<?>>();
  32. public static final Type<ColumnVisibilityChangeHandler<?>> getType() {
  33. return TYPE;
  34. }
  35. private final Column<?, T> column;
  36. private final boolean userOriginated;
  37. private final boolean hidden;
  38. public ColumnVisibilityChangeEvent(Column<?, T> column, boolean hidden,
  39. boolean userOriginated) {
  40. this.column = column;
  41. this.hidden = hidden;
  42. this.userOriginated = userOriginated;
  43. }
  44. /**
  45. * Returns the column where the visibility change occurred.
  46. *
  47. * @return the column where the visibility change occurred.
  48. */
  49. public Column<?, T> getColumn() {
  50. return column;
  51. }
  52. /**
  53. * Was the column set hidden or visible.
  54. *
  55. * @return <code>true</code> if the column was hidden <code>false</code> if
  56. * it was set visible
  57. */
  58. public boolean isHidden() {
  59. return hidden;
  60. }
  61. /**
  62. * Is the visibility change triggered by user.
  63. *
  64. * @return <code>true</code> if the change was triggered by user,
  65. * <code>false</code> if not
  66. */
  67. public boolean isUserOriginated() {
  68. return userOriginated;
  69. }
  70. @SuppressWarnings({ "rawtypes", "unchecked" })
  71. @Override
  72. public com.google.gwt.event.shared.GwtEvent.Type<ColumnVisibilityChangeHandler<T>> getAssociatedType() {
  73. return (Type) TYPE;
  74. }
  75. @Override
  76. protected void dispatch(ColumnVisibilityChangeHandler<T> handler) {
  77. handler.onVisibilityChange(this);
  78. }
  79. }