1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.kuali.student.common.ui.client.widgets.search; |
17 | |
|
18 | |
import java.util.List; |
19 | |
|
20 | |
import org.kuali.student.common.ui.client.mvc.Callback; |
21 | |
import org.kuali.student.common.ui.client.widgets.KSLightBox; |
22 | |
import org.kuali.student.common.ui.client.widgets.buttongroups.ButtonEnumerations; |
23 | |
import org.kuali.student.common.ui.client.widgets.buttongroups.ButtonEnumerations.ButtonEnum; |
24 | |
import org.kuali.student.common.ui.client.widgets.field.layout.button.ActionCancelGroup; |
25 | |
import org.kuali.student.common.ui.client.widgets.field.layout.button.ButtonGroup; |
26 | |
import org.kuali.student.common.ui.client.widgets.layout.VerticalFlowPanel; |
27 | |
import org.kuali.student.core.search.dto.SearchRequest; |
28 | |
|
29 | 0 | public class AdvancedSearchWindow { |
30 | |
|
31 | 0 | private VerticalFlowPanel layout = new VerticalFlowPanel(); |
32 | |
private KSLightBox dialog; |
33 | |
private SearchPanel searchPanel; |
34 | |
|
35 | 0 | private ActionCancelGroup actionCancelButtons = new ActionCancelGroup(ButtonEnumerations.SearchCancelEnum.SEARCH, ButtonEnumerations.SearchCancelEnum.CANCEL); |
36 | |
|
37 | |
public List<SelectedResults> getSelectedValues() { |
38 | 0 | return searchPanel.getSelectedValues(); |
39 | |
} |
40 | |
|
41 | |
public SearchRequest getSearchRequest() { |
42 | 0 | return searchPanel.getSearchRequest(); |
43 | |
} |
44 | |
|
45 | |
public String getSelectedLookupName() { |
46 | 0 | return searchPanel.getSelectedLookupName(); |
47 | |
} |
48 | |
|
49 | 0 | public AdvancedSearchWindow(String title, SearchPanel panel){ |
50 | |
|
51 | 0 | actionCancelButtons.addStyleName("KS-Advanced-Search-Buttons"); |
52 | 0 | addCancelCompleteCallback(null); |
53 | 0 | searchPanel = panel; |
54 | 0 | searchPanel.setActionCancelButtonGroup(actionCancelButtons); |
55 | 0 | searchPanel.setupButtons(); |
56 | |
|
57 | 0 | dialog = new KSLightBox(title); |
58 | 0 | layout.addStyleName("KS-Advanced-Search-Window"); |
59 | 0 | layout.add(panel); |
60 | 0 | layout.add(actionCancelButtons); |
61 | |
|
62 | 0 | dialog.setMaxHeight(600); |
63 | 0 | ButtonGroup buttons = panel.getButtons(); |
64 | 0 | buttons.removeFromParent(); |
65 | 0 | dialog.addButtonGroup(buttons); |
66 | 0 | } |
67 | |
|
68 | |
public void show(){ |
69 | 0 | searchPanel.setupSearch(); |
70 | 0 | dialog.setWidget(layout); |
71 | 0 | dialog.setMaxHeight(600); |
72 | 0 | dialog.show(); |
73 | 0 | } |
74 | |
|
75 | |
public void hide(){ |
76 | 0 | dialog.hide(); |
77 | 0 | } |
78 | |
|
79 | |
public void addCancelCompleteCallback(final Callback<Boolean> callback){ |
80 | |
|
81 | 0 | actionCancelButtons.addCallback(new Callback<ButtonEnumerations.ButtonEnum>(){ |
82 | |
@Override |
83 | |
public void exec(ButtonEnum result) { |
84 | 0 | if (result == ButtonEnumerations.SearchCancelEnum.CANCEL) { |
85 | 0 | if (callback != null) { |
86 | 0 | callback.exec(true); |
87 | |
} |
88 | 0 | dialog.hide(); |
89 | |
} |
90 | 0 | } |
91 | |
}); |
92 | 0 | } |
93 | |
|
94 | |
public void addActionCompleteCallback(Callback<Boolean> callback){ |
95 | 0 | searchPanel.addActionCompleteCallback(callback); |
96 | 0 | } |
97 | |
} |