1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
package org.kuali.student.common.ui.client.widgets.dialog; |
10 | |
|
11 | |
import org.kuali.student.common.ui.client.application.Application; |
12 | |
import org.kuali.student.common.ui.client.configurable.mvc.SectionTitle; |
13 | |
import org.kuali.student.common.ui.client.mvc.Callback; |
14 | |
import org.kuali.student.common.ui.client.util.ExportUtils; |
15 | |
import org.kuali.student.common.ui.client.widgets.KSLabel; |
16 | |
import org.kuali.student.common.ui.client.widgets.KSLightBox; |
17 | |
import org.kuali.student.common.ui.client.widgets.buttongroups.ButtonEnumerations; |
18 | |
import org.kuali.student.common.ui.client.widgets.buttongroups.ButtonEnumerations.ButtonEnum; |
19 | |
import org.kuali.student.common.ui.client.widgets.field.layout.button.ActionCancelGroup; |
20 | |
import org.kuali.student.common.ui.client.widgets.layout.HorizontalBlockFlowPanel; |
21 | |
import org.kuali.student.common.ui.client.widgets.layout.VerticalFlowPanel; |
22 | |
import org.kuali.student.common.ui.client.widgets.list.impl.KSRadioButtonListImpl; |
23 | |
import org.kuali.student.common.ui.client.widgets.list.impl.SimpleListItems; |
24 | |
|
25 | |
import com.google.gwt.core.client.GWT; |
26 | |
|
27 | 0 | public class ReportExportDialog { |
28 | |
|
29 | 0 | private VerticalFlowPanel layout = new VerticalFlowPanel(); |
30 | |
private KSLightBox dialog; |
31 | |
|
32 | 0 | private KSRadioButtonListImpl selectItemWidget = GWT.create(KSRadioButtonListImpl.class); |
33 | |
|
34 | 0 | private ActionCancelGroup actionButtons = new ActionCancelGroup(ButtonEnumerations.ExportCancelEnum.EXPORT, ButtonEnumerations.ExportCancelEnum.CANCEL); |
35 | |
|
36 | 0 | public ReportExportDialog() { |
37 | |
|
38 | 0 | dialog = new KSLightBox(); |
39 | 0 | layout.addStyleName("KS-Advanced-Search-Buttons"); |
40 | 0 | SectionTitle sectionTitle = SectionTitle.generateH2Title(this.getMessage("exportTitle")); |
41 | 0 | layout.add(sectionTitle); |
42 | |
|
43 | |
|
44 | 0 | KSLabel exportLabel = new KSLabel("Select the document type to export as (Export appears in a new page, please disable pop-up blockers.):"); |
45 | 0 | layout.add(exportLabel); |
46 | |
|
47 | |
|
48 | 0 | HorizontalBlockFlowPanel radioPanel = new HorizontalBlockFlowPanel(); |
49 | 0 | radioPanel.setHeight("90px"); |
50 | 0 | SimpleListItems formatList = new SimpleListItems(); |
51 | 0 | formatList.addItem(ExportUtils.PDF, this.getMessage("pdfFormat")); |
52 | 0 | formatList.addItem(ExportUtils.DOC, this.getMessage("docFormat")); |
53 | 0 | selectItemWidget.setListItems(formatList); |
54 | 0 | selectItemWidget.selectItem(ExportUtils.PDF); |
55 | 0 | radioPanel.add(selectItemWidget); |
56 | 0 | layout.add(radioPanel); |
57 | |
|
58 | |
|
59 | 0 | this.addCancelCompleteCallback(); |
60 | 0 | layout.add(actionButtons); |
61 | |
|
62 | 0 | dialog.setMaxHeight(200); |
63 | 0 | dialog.setMaxWidth(250); |
64 | 0 | } |
65 | |
|
66 | |
public void show() { |
67 | 0 | dialog.setWidget(layout); |
68 | 0 | dialog.show(); |
69 | 0 | } |
70 | |
|
71 | |
public void hide() { |
72 | 0 | dialog.hide(); |
73 | 0 | } |
74 | |
|
75 | |
public void addSelectCompleteCallback(final Callback<String> callback) { |
76 | 0 | actionButtons.addCallback(new Callback<ButtonEnumerations.ButtonEnum>() { |
77 | |
@Override |
78 | |
public void exec(ButtonEnum result) { |
79 | 0 | if (result == ButtonEnumerations.ExportCancelEnum.EXPORT) { |
80 | 0 | if (selectItemWidget.getSelectedItem() != null) { |
81 | 0 | if (callback != null) { |
82 | 0 | callback.exec(selectItemWidget.getSelectedItem()); |
83 | |
} |
84 | 0 | dialog.hide(); |
85 | |
} |
86 | |
} |
87 | 0 | } |
88 | |
}); |
89 | 0 | } |
90 | |
|
91 | |
public void addCancelCompleteCallback() { |
92 | 0 | actionButtons.addCallback(new Callback<ButtonEnumerations.ButtonEnum>() { |
93 | |
@Override |
94 | |
public void exec(ButtonEnum result) { |
95 | 0 | if (result == ButtonEnumerations.ExportCancelEnum.CANCEL) { |
96 | 0 | dialog.hide(); |
97 | |
} |
98 | 0 | } |
99 | |
}); |
100 | 0 | } |
101 | |
|
102 | |
private String getMessage(final String msgKey) { |
103 | 0 | return Application.getApplicationContext().getMessage(msgKey); |
104 | |
} |
105 | |
|
106 | |
} |