| 1 | |
package org.kuali.student.common.ui.client.widgets.dialog; |
| 2 | |
|
| 3 | |
import org.kuali.student.common.ui.client.configurable.mvc.SectionTitle; |
| 4 | |
import org.kuali.student.common.ui.client.widgets.KSLabel; |
| 5 | |
import org.kuali.student.common.ui.client.widgets.KSLightBox; |
| 6 | |
import org.kuali.student.common.ui.client.widgets.buttongroups.ButtonEnumerations.ButtonEnum; |
| 7 | |
import org.kuali.student.common.ui.client.widgets.field.layout.button.ButtonGroup; |
| 8 | |
|
| 9 | |
import com.google.gwt.event.dom.client.ClickHandler; |
| 10 | |
import com.google.gwt.event.logical.shared.CloseHandler; |
| 11 | |
import com.google.gwt.event.shared.HandlerRegistration; |
| 12 | |
import com.google.gwt.user.client.ui.FlowPanel; |
| 13 | |
|
| 14 | |
public class ButtonMessageDialog<T extends ButtonEnum> { |
| 15 | |
|
| 16 | 0 | private KSLabel messageLabel = new KSLabel(); |
| 17 | 0 | private SectionTitle title = SectionTitle.generateH3Title(""); |
| 18 | |
|
| 19 | 0 | private FlowPanel layout = new FlowPanel(); |
| 20 | |
|
| 21 | |
private KSLightBox dialog; |
| 22 | |
private ButtonGroup<T> buttons; |
| 23 | |
|
| 24 | 0 | public ButtonMessageDialog(String titleText, String message, ButtonGroup<T> buttons){ |
| 25 | 0 | this.buttons = buttons; |
| 26 | 0 | setupLayout(titleText, message); |
| 27 | 0 | } |
| 28 | |
|
| 29 | |
private void setupLayout(String titleText, String message){ |
| 30 | |
|
| 31 | 0 | dialog = new KSLightBox(); |
| 32 | 0 | SectionTitle sectionTitle = SectionTitle.generateH2Title(titleText); |
| 33 | 0 | layout.add(sectionTitle); |
| 34 | 0 | messageLabel.setText(message); |
| 35 | 0 | layout.add(messageLabel); |
| 36 | 0 | dialog.addButtonGroup(buttons); |
| 37 | 0 | layout.addStyleName("ks-confirmation-message-layout"); |
| 38 | 0 | messageLabel.setStyleName("ks-confirmation-message-label"); |
| 39 | 0 | dialog.setWidget(layout); |
| 40 | 0 | dialog.setSize(600, 120); |
| 41 | 0 | } |
| 42 | |
|
| 43 | |
public void show(){ |
| 44 | 0 | dialog.show(); |
| 45 | 0 | } |
| 46 | |
|
| 47 | |
public void hide(){ |
| 48 | 0 | dialog.hide(); |
| 49 | 0 | } |
| 50 | |
|
| 51 | |
public void removeCloseLink(){ |
| 52 | 0 | dialog.removeCloseLink(); |
| 53 | 0 | } |
| 54 | |
|
| 55 | |
public HandlerRegistration addCloseLinkClickHandler(ClickHandler clickHandler) { |
| 56 | 0 | return dialog.addCloseLinkClickHandler(clickHandler); |
| 57 | |
} |
| 58 | |
|
| 59 | |
public HandlerRegistration addCloseHandler(CloseHandler handler){ |
| 60 | 0 | return dialog.addCloseHandler(handler); |
| 61 | |
} |
| 62 | |
|
| 63 | |
public void setMessageText(String text){ |
| 64 | 0 | messageLabel.setText(text); |
| 65 | 0 | } |
| 66 | |
|
| 67 | |
public ButtonGroup<T> getButtonGroup(){ |
| 68 | 0 | return buttons; |
| 69 | |
} |
| 70 | |
} |