-
Notifications
You must be signed in to change notification settings - Fork 51
/
FilterViewEvent.java
123 lines (104 loc) · 3.93 KB
/
FilterViewEvent.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
package org.zanata.webtrans.client.events;
import com.google.common.base.MoreObjects;
import org.zanata.webtrans.shared.model.GetTransUnitActionContext;
import org.zanata.webtrans.client.service.NavigationService;
import org.zanata.webtrans.shared.rpc.EditorFilter;
import com.google.common.base.Preconditions;
import com.google.gwt.event.shared.GwtEvent;
public class FilterViewEvent extends GwtEvent<FilterViewEventHandler> implements
NavigationService.UpdateContextCommand {
/**
* Handler type.
*/
private static final Type<FilterViewEventHandler> TYPE = new Type<>();
public static final FilterViewEvent DEFAULT = new FilterViewEvent(false,
false, false, false, false, false, false, EditorFilter.ALL, false);
/**
* Gets the type associated with this event.
*
* @return returns the handler type
*/
public static Type<FilterViewEventHandler> getType() {
return TYPE;
}
private boolean filterTranslated, filterFuzzy, filterUntranslated,
filterApproved, filterRejected, filterHasError, filterMT;
private boolean cancelFilter;
private EditorFilter editorFilter;
public FilterViewEvent(boolean filterTranslated, boolean filterFuzzy,
boolean filterUntranslated, boolean filterApproved,
boolean filterRejected, boolean filterHasError,
boolean filterMT, EditorFilter editorFilter, boolean cancelFilter) {
this.filterTranslated = filterTranslated;
this.filterFuzzy = filterFuzzy;
this.filterUntranslated = filterUntranslated;
this.filterApproved = filterApproved;
this.filterRejected = filterRejected;
this.filterHasError = filterHasError;
this.filterMT = filterMT;
this.editorFilter = editorFilter;
this.cancelFilter = cancelFilter;
}
@Override
protected void dispatch(FilterViewEventHandler handler) {
handler.onFilterView(this);
}
@Override
public Type<FilterViewEventHandler> getAssociatedType() {
return getType();
}
public boolean isFilterTranslated() {
return filterTranslated;
}
public boolean isFilterFuzzy() {
return filterFuzzy;
}
public boolean isFilterUntranslated() {
return filterUntranslated;
}
public boolean isFilterApproved() {
return filterApproved;
}
public boolean isFilterRejected() {
return filterRejected;
}
public boolean isCancelFilter() {
return cancelFilter;
}
public boolean isFilterHasError() {
return filterHasError;
}
public boolean isFilterMT() {
return filterMT;
}
public EditorFilter getEditorFilter() {
return editorFilter;
}
@Override
public GetTransUnitActionContext updateContext(
GetTransUnitActionContext currentContext) {
Preconditions.checkNotNull(currentContext,
"current context can not be null");
return currentContext.withFilterFuzzy(filterFuzzy)
.withFilterTranslated(filterTranslated)
.withFilterUntranslated(filterUntranslated)
.withFilterApproved(filterApproved)
.withFilterRejected(filterRejected)
.withFilterHasError(filterHasError)
.withFilterMT(filterMT)
.withEditorFilter(editorFilter);
}
@Override
public String toString() {
return MoreObjects.toStringHelper(this)
.add("filterTranslated", filterTranslated)
.add("filterFuzzy", filterFuzzy)
.add("filterUntranslated", filterUntranslated)
.add("filterApproved", filterApproved)
.add("filterRejected", filterRejected)
.add("filterHasError", filterHasError)
.add("filterMT", filterMT)
.add("editorFilter", editorFilter)
.add("cancelFilter", cancelFilter).toString();
}
}