| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
package org.kuali.student.common.ui.client.configurable.mvc.sections; |
| 17 | |
|
| 18 | |
import org.kuali.student.common.ui.client.widgets.KSLabel; |
| 19 | |
import org.kuali.student.common.ui.client.widgets.layout.VerticalFlowPanel; |
| 20 | |
import org.kuali.student.common.ui.client.widgets.menus.KSListPanel; |
| 21 | |
|
| 22 | |
import com.google.gwt.user.client.ui.Composite; |
| 23 | |
import com.google.gwt.user.client.ui.Widget; |
| 24 | |
|
| 25 | |
|
| 26 | |
|
| 27 | |
|
| 28 | |
|
| 29 | |
|
| 30 | |
|
| 31 | |
|
| 32 | |
public class ValidationMessagePanel extends Composite{ |
| 33 | |
|
| 34 | 0 | private VerticalFlowPanel container = new VerticalFlowPanel(); |
| 35 | 0 | private KSListPanel errorListPanel = new KSListPanel(); |
| 36 | 0 | private KSListPanel warnListPanel = new KSListPanel(); |
| 37 | 0 | private int warnCount = 0; |
| 38 | 0 | private int errorCount = 0; |
| 39 | 0 | private boolean topMargin = true; |
| 40 | |
|
| 41 | 0 | public ValidationMessagePanel(){ |
| 42 | 0 | this.initWidget(container); |
| 43 | 0 | container.add(errorListPanel); |
| 44 | 0 | container.add(warnListPanel); |
| 45 | 0 | errorListPanel.addStyleName("ks-form-module-validation-errors"); |
| 46 | 0 | warnListPanel.addStyleName("ks-form-module-validation-warnings"); |
| 47 | 0 | } |
| 48 | |
|
| 49 | 0 | public ValidationMessagePanel(boolean topMargin){ |
| 50 | 0 | this.initWidget(errorListPanel); |
| 51 | 0 | this.topMargin = topMargin; |
| 52 | 0 | } |
| 53 | |
|
| 54 | |
public void addErrorMessage(KSLabel message){ |
| 55 | 0 | if(getMessageCount() == 0 && topMargin){ |
| 56 | 0 | message.addStyleName("ks-form-module-single-line-margin"); |
| 57 | |
} |
| 58 | 0 | errorListPanel.add(message); |
| 59 | 0 | errorCount++; |
| 60 | 0 | } |
| 61 | |
|
| 62 | |
public void addWarnMessage(Widget message){ |
| 63 | 0 | if(getMessageCount() == 0 && topMargin){ |
| 64 | 0 | message.addStyleName("ks-form-module-single-line-margin"); |
| 65 | |
} |
| 66 | 0 | warnListPanel.add(message); |
| 67 | 0 | warnCount++; |
| 68 | 0 | } |
| 69 | |
|
| 70 | |
public boolean hasWarnings(){ |
| 71 | 0 | return (warnCount > 0); |
| 72 | |
} |
| 73 | |
|
| 74 | |
public void clearErrors(){ |
| 75 | 0 | errorListPanel.clear(); |
| 76 | 0 | errorCount = 0; |
| 77 | 0 | } |
| 78 | |
|
| 79 | |
public void clearWarnings(){ |
| 80 | 0 | warnListPanel.clear(); |
| 81 | 0 | warnCount = 0; |
| 82 | 0 | } |
| 83 | |
|
| 84 | |
public int getMessageCount(){ |
| 85 | 0 | return errorCount + warnCount; |
| 86 | |
} |
| 87 | |
} |