Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
FilterEvent |
|
| 1.1428571428571428;1.143 |
1 | /** | |
2 | * Copyright 2010 The Kuali Foundation Licensed under the | |
3 | * Educational Community License, Version 2.0 (the "License"); you may | |
4 | * not use this file except in compliance with the License. You may | |
5 | * obtain a copy of the License at | |
6 | * | |
7 | * http://www.osedu.org/licenses/ECL-2.0 | |
8 | * | |
9 | * Unless required by applicable law or agreed to in writing, | |
10 | * software distributed under the License is distributed on an "AS IS" | |
11 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express | |
12 | * or implied. See the License for the specific language governing | |
13 | * permissions and limitations under the License. | |
14 | */ | |
15 | ||
16 | package org.kuali.student.common.ui.client.widgets.filter; | |
17 | ||
18 | import java.util.List; | |
19 | import java.util.Map; | |
20 | ||
21 | import com.google.gwt.event.shared.GwtEvent; | |
22 | ||
23 | 0 | public class FilterEvent extends GwtEvent<FilterEventHandler>{ |
24 | 0 | public static final Type<FilterEventHandler> TYPE = new Type<FilterEventHandler>(); |
25 | ||
26 | private boolean initialSelect; | |
27 | ||
28 | private boolean selected; | |
29 | private String filterKey; | |
30 | private String filterValue; | |
31 | ||
32 | private Map<String, List<String>> selections; | |
33 | ||
34 | 0 | public FilterEvent(Map<String, List<String>> selections, boolean selected, boolean initialSelect, String key, String value){ |
35 | 0 | this.selected = selected; |
36 | 0 | this.filterKey = key; |
37 | 0 | this.filterValue = value; |
38 | 0 | this.initialSelect = initialSelect; |
39 | 0 | this.selections = selections; |
40 | 0 | } |
41 | ||
42 | /** | |
43 | * @return Filter key of latest selected filter option. | |
44 | */ | |
45 | public String getFilterKey() { | |
46 | 0 | return filterKey; |
47 | } | |
48 | ||
49 | /** | |
50 | * @return Value of the latest filter option checked | |
51 | */ | |
52 | public String getFilterValue() { | |
53 | 0 | return filterValue; |
54 | } | |
55 | ||
56 | /** | |
57 | * Use this to check if this is the first filter option to be selected. When true, the selections map should | |
58 | * of size 1 with the associated list entry of size 1. | |
59 | * | |
60 | * @return true if this is the first filter item to be selected | |
61 | */ | |
62 | public boolean isInitialSelect() { | |
63 | 0 | return initialSelect; |
64 | } | |
65 | ||
66 | /** | |
67 | * @return List of all filter options selected with map key = filter option key amd map value a list of filter option values | |
68 | * selected for that key. | |
69 | */ | |
70 | public Map<String, List<String>> getSelections() { | |
71 | 0 | return selections; |
72 | } | |
73 | ||
74 | @Override | |
75 | protected void dispatch(FilterEventHandler handler) { | |
76 | 0 | if (selected){ |
77 | 0 | handler.onSelect(this); |
78 | } else { | |
79 | 0 | handler.onDeselect(this); |
80 | } | |
81 | 0 | } |
82 | ||
83 | @Override | |
84 | public Type<FilterEventHandler> getAssociatedType() { | |
85 | 0 | return TYPE; |
86 | } | |
87 | ||
88 | ||
89 | } |