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

@ -28,10 +28,10 @@ import org.zkoss.zk.ui.Component;
*/ */
public class Label extends org.zkoss.zul.Label public class Label extends org.zkoss.zul.Label
{ {
/** /**
* *
*/ */
private static final long serialVersionUID = 1912498227823474678L; private static final long serialVersionUID = -6818124304324329510L;
private Component decorator; private Component decorator;
@ -106,4 +106,15 @@ public class Label extends org.zkoss.zul.Label
public Component rightAlign() { public Component rightAlign() {
return LayoutUtils.makeRightAlign(this); 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

@ -47,7 +47,7 @@ import org.zkoss.zul.Image;
*/ */
public abstract class WEditor implements EventListener, PropertyChangeListener public abstract class WEditor implements EventListener, PropertyChangeListener
{ {
private static final String[] lISTENER_EVENTS = {}; private static final String[] lISTENER_EVENTS = {};
public static final int MAX_DISPLAY_LENGTH = 35; public static final int MAX_DISPLAY_LENGTH = 35;
@ -489,4 +489,22 @@ public abstract class WEditor implements EventListener, PropertyChangeListener
public void setHasFocus(boolean b) { public void setHasFocus(boolean b) {
hasFocus = 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(); Label label = editor.getLabel();
if (popupMenu.isZoomEnabled() && editor instanceof IZoomableEditor) 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)); label.addEventListener(Events.ON_CLICK, new ZoomListener((IZoomableEditor) editor));
} }
@ -540,6 +540,11 @@ DataStatusListener, IADTabpanel, VetoableChangeListener
return; return;
} }
for (WEditor comp : editors)
{
comp.setMandatoryLabels();
}
// Selective // Selective
if (col > 0) if (col > 0)
{ {