1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.kuali.student.common.ui.client.widgets.dialog; |
17 | |
|
18 | |
import org.kuali.student.common.ui.client.configurable.mvc.SectionTitle; |
19 | |
import org.kuali.student.common.ui.client.widgets.KSButton; |
20 | |
import org.kuali.student.common.ui.client.widgets.KSLabel; |
21 | |
import org.kuali.student.common.ui.client.widgets.KSLightBox; |
22 | |
import org.kuali.student.common.ui.client.widgets.KSButtonAbstract.ButtonStyle; |
23 | |
import org.kuali.student.common.ui.client.widgets.layout.HorizontalBlockFlowPanel; |
24 | |
|
25 | |
import com.google.gwt.event.dom.client.ClickEvent; |
26 | |
import com.google.gwt.event.dom.client.ClickHandler; |
27 | |
import com.google.gwt.event.logical.shared.CloseHandler; |
28 | |
import com.google.gwt.event.shared.HandlerRegistration; |
29 | |
import com.google.gwt.user.client.ui.FlowPanel; |
30 | |
|
31 | 0 | public class ConfirmationDialog { |
32 | |
private KSLightBox dialog; |
33 | |
|
34 | 0 | private KSButton cancel = new KSButton("Cancel", ButtonStyle.ANCHOR_LARGE_CENTERED); |
35 | 0 | private KSButton confirm = new KSButton("Confirm", ButtonStyle.PRIMARY_SMALL); |
36 | 0 | private HorizontalBlockFlowPanel buttonPanel = new HorizontalBlockFlowPanel(); |
37 | 0 | private KSLabel messageLabel = new KSLabel(); |
38 | 0 | private SectionTitle title = SectionTitle.generateH3Title(""); |
39 | |
|
40 | 0 | private FlowPanel layout = new FlowPanel(); |
41 | |
|
42 | 0 | public ConfirmationDialog(String titleText, String message){ |
43 | 0 | setupLayout(titleText, message); |
44 | 0 | } |
45 | |
|
46 | 0 | public ConfirmationDialog(String titleText, String message, String confirmText){ |
47 | 0 | confirm.setText(confirmText); |
48 | 0 | setupLayout(titleText, message); |
49 | 0 | } |
50 | |
|
51 | |
private void setupLayout(String titleText, String message){ |
52 | |
|
53 | 0 | dialog = new KSLightBox(titleText); |
54 | |
|
55 | 0 | cancel.addClickHandler(new ClickHandler(){ |
56 | |
|
57 | |
@Override |
58 | |
public void onClick(ClickEvent event) { |
59 | 0 | dialog.hide(); |
60 | 0 | } |
61 | |
}); |
62 | |
|
63 | 0 | messageLabel.setText(message); |
64 | 0 | dialog.addButton(confirm); |
65 | 0 | dialog.addButton(cancel); |
66 | 0 | layout.add(messageLabel); |
67 | 0 | layout.add(buttonPanel); |
68 | 0 | layout.addStyleName("ks-confirmation-message-layout"); |
69 | 0 | messageLabel.setStyleName("ks-confirmation-message-label"); |
70 | 0 | dialog.setWidget(layout); |
71 | 0 | dialog.setSize(600, 100); |
72 | 0 | } |
73 | |
|
74 | |
public void show(){ |
75 | 0 | dialog.show(); |
76 | 0 | } |
77 | |
|
78 | |
public void hide(){ |
79 | 0 | dialog.hide(); |
80 | 0 | } |
81 | |
|
82 | |
public void removeCloseLink(){ |
83 | 0 | dialog.removeCloseLink(); |
84 | 0 | } |
85 | |
|
86 | |
public HandlerRegistration addCloseHandler(CloseHandler handler){ |
87 | 0 | return dialog.addCloseHandler(handler); |
88 | |
} |
89 | |
|
90 | |
public void setMessageText(String text){ |
91 | 0 | messageLabel.setText(text); |
92 | 0 | } |
93 | |
|
94 | |
public KSButton getConfirmButton(){ |
95 | 0 | return confirm; |
96 | |
} |
97 | |
|
98 | |
public KSButton getCancelButton(){ |
99 | 0 | return cancel; |
100 | |
} |
101 | |
} |