|
| 1 | +/* |
| 2 | + * Copyright © 2019 Dominokit |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of 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, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | +package org.dominokit.domino.ui.datatable.events; |
| 17 | + |
| 18 | +import org.dominokit.domino.ui.datatable.ColumnConfig; |
| 19 | + |
| 20 | +/** |
| 21 | + * This event will be fired when a column gets resized |
| 22 | + * |
| 23 | + * <p>Event type: <b>COLUMN_RESIZED -> 'column-resized'</b> |
| 24 | + */ |
| 25 | +public class ColumnResizingEvent implements TableEvent { |
| 26 | + /** Constant <code>COLUMN_RESIZED="column-resized"</code> */ |
| 27 | + public static final String COLUMN_RESIZING = "column-resizing"; |
| 28 | + |
| 29 | + private final ColumnConfig<?> column; |
| 30 | + private final double sizeDiff; |
| 31 | + private final boolean completed; |
| 32 | + |
| 33 | + /** |
| 34 | + * Factory method to create a new Event instance |
| 35 | + * |
| 36 | + * @param column a {@link ColumnConfig} |
| 37 | + * @param sizeDiff a double |
| 38 | + * @return a {@link ColumnResizingEvent} |
| 39 | + */ |
| 40 | + public static ColumnResizingEvent of(ColumnConfig<?> column, double sizeDiff) { |
| 41 | + return new ColumnResizingEvent(column, sizeDiff); |
| 42 | + } |
| 43 | + |
| 44 | + /** |
| 45 | + * Factory method to create a new Event instance |
| 46 | + * |
| 47 | + * @param column a {@link ColumnConfig} |
| 48 | + * @param sizeDiff a double |
| 49 | + * @param completed a boolean |
| 50 | + * @return a {@link ColumnResizingEvent} |
| 51 | + */ |
| 52 | + public static ColumnResizingEvent of(ColumnConfig<?> column, double sizeDiff, boolean completed) { |
| 53 | + return new ColumnResizingEvent(column, sizeDiff, completed); |
| 54 | + } |
| 55 | + |
| 56 | + /** |
| 57 | + * Creates a new Event instance |
| 58 | + * |
| 59 | + * @param column a {@link ColumnConfig} |
| 60 | + * @param sizeDiff a double |
| 61 | + */ |
| 62 | + public ColumnResizingEvent(ColumnConfig<?> column, double sizeDiff) { |
| 63 | + this(column, sizeDiff, false); |
| 64 | + } |
| 65 | + |
| 66 | + /** |
| 67 | + * Creates a new Event instance |
| 68 | + * |
| 69 | + * @param column a {@link ColumnConfig} |
| 70 | + * @param sizeDiff a double |
| 71 | + * @param completed a boolean |
| 72 | + */ |
| 73 | + public ColumnResizingEvent(ColumnConfig<?> column, double sizeDiff, boolean completed) { |
| 74 | + this.column = column; |
| 75 | + this.sizeDiff = sizeDiff; |
| 76 | + this.completed = completed; |
| 77 | + } |
| 78 | + |
| 79 | + /** |
| 80 | + * Getter for the field <code>column</code>. |
| 81 | + * |
| 82 | + * @return a {@link ColumnConfig} |
| 83 | + */ |
| 84 | + public ColumnConfig<?> getColumn() { |
| 85 | + return column; |
| 86 | + } |
| 87 | + |
| 88 | + /** |
| 89 | + * Getter for the field <code>sizeDiff</code>. |
| 90 | + * |
| 91 | + * @return a double |
| 92 | + */ |
| 93 | + public double getSizeDiff() { |
| 94 | + return sizeDiff; |
| 95 | + } |
| 96 | + |
| 97 | + /** |
| 98 | + * isCompleted. |
| 99 | + * |
| 100 | + * @return a boolean |
| 101 | + */ |
| 102 | + public boolean isCompleted() { |
| 103 | + return completed; |
| 104 | + } |
| 105 | + |
| 106 | + /** {@inheritDoc} */ |
| 107 | + @Override |
| 108 | + public String getType() { |
| 109 | + return COLUMN_RESIZING; |
| 110 | + } |
| 111 | +} |
0 commit comments