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 public class ConfirmationDialog {
32 private KSLightBox dialog;
33
34 private KSButton cancel = new KSButton("Cancel", ButtonStyle.ANCHOR_LARGE_CENTERED);
35 private KSButton confirm = new KSButton("Confirm", ButtonStyle.PRIMARY_SMALL);
36 private HorizontalBlockFlowPanel buttonPanel = new HorizontalBlockFlowPanel();
37 private KSLabel messageLabel = new KSLabel();
38 private SectionTitle title = SectionTitle.generateH3Title("");
39
40 private FlowPanel layout = new FlowPanel();
41
42 public ConfirmationDialog(String titleText, String message){
43 setupLayout(titleText, message);
44 }
45
46 public ConfirmationDialog(String titleText, String message, String confirmText){
47 confirm.setText(confirmText);
48 setupLayout(titleText, message);
49 }
50
51 private void setupLayout(String titleText, String message){
52
53 dialog = new KSLightBox(titleText);
54
55 cancel.addClickHandler(new ClickHandler(){
56
57 @Override
58 public void onClick(ClickEvent event) {
59 dialog.hide();
60 }
61 });
62
63 messageLabel.setText(message);
64 dialog.addButton(confirm);
65 dialog.addButton(cancel);
66 layout.add(messageLabel);
67 layout.add(buttonPanel);
68 layout.addStyleName("ks-confirmation-message-layout");
69 messageLabel.setStyleName("ks-confirmation-message-label");
70 dialog.setWidget(layout);
71 dialog.setSize(600, 130);
72 }
73
74 public void show(){
75 dialog.show();
76 }
77
78 public void hide(){
79 dialog.hide();
80 }
81
82 public void removeCloseLink(){
83 dialog.removeCloseLink();
84 }
85
86 public HandlerRegistration addCloseHandler(CloseHandler handler){
87 return dialog.addCloseHandler(handler);
88 }
89
90 public void setMessageText(String text){
91 messageLabel.setText(text);
92 }
93
94 public KSButton getConfirmButton(){
95 return confirm;
96 }
97
98 public KSButton getCancelButton(){
99 return cancel;
100 }
101 }