Usability on zkwebui:

* Red color whole label of empty mandatory fields
This commit is contained in:
Carlos Ruiz 2011-03-25 23:04:01 -05:00
parent d69c6ebded
commit a2a86c75ca
3 changed files with 39 additions and 5 deletions

View File

@ -31,7 +31,7 @@ public class Label extends org.zkoss.zul.Label
/**
*
*/
private static final long serialVersionUID = 1912498227823474678L;
private static final long serialVersionUID = -6818124304324329510L;
private Component decorator;
@ -106,4 +106,15 @@ public class Label extends org.zkoss.zul.Label
public Component rightAlign() {
return LayoutUtils.makeRightAlign(this);
}
private boolean m_zoomable = false;
public boolean isZoomable() {
return m_zoomable;
}
public void setZoomable(boolean zoomable) {
m_zoomable = zoomable;
}
}

View File

@ -489,4 +489,22 @@ public abstract class WEditor implements EventListener, PropertyChangeListener
public void setHasFocus(boolean b) {
hasFocus = b;
}
public void setMandatoryLabels() {
Object value = getValue();
if (this instanceof WAccountEditor && value != null && ((Integer) value).intValue() == 0) // special case
value = null;
if (getLabel() != null) {
markMandatory(mandatory && !readOnly && getGridField().isEditable(true) && (value == null || value.toString().trim().length() == 0));
}
}
private static final String STYLE_ZOOMABLE_LABEL = "cursor: pointer; text-decoration: underline;";
private static final String STYLE_NORMAL_LABEL = "color:black;";
private static final String STYLE_EMPTY_MANDATORY_LABEL = "color: red;";
private void markMandatory(boolean mandatory) {
getLabel().setStyle( (getLabel().isZoomable() ? STYLE_ZOOMABLE_LABEL : "") + (mandatory ? STYLE_EMPTY_MANDATORY_LABEL : STYLE_NORMAL_LABEL));
}
}

View File

@ -479,7 +479,7 @@ DataStatusListener, IADTabpanel, VetoableChangeListener
Label label = editor.getLabel();
if (popupMenu.isZoomEnabled() && editor instanceof IZoomableEditor)
{
label.setStyle("cursor: pointer; text-decoration: underline;");
label.setZoomable(true);
label.addEventListener(Events.ON_CLICK, new ZoomListener((IZoomableEditor) editor));
}
@ -540,6 +540,11 @@ DataStatusListener, IADTabpanel, VetoableChangeListener
return;
}
for (WEditor comp : editors)
{
comp.setMandatoryLabels();
}
// Selective
if (col > 0)
{