diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/component/Label.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/component/Label.java index dfa4355622..5881d68023 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/component/Label.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/component/Label.java @@ -28,8 +28,8 @@ import org.zkoss.zk.ui.Component; */ public class Label extends org.zkoss.zul.Label { - /** - * + /** + * */ private static final long serialVersionUID = -6818124304324329510L; @@ -105,16 +105,5 @@ 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; - } - + } } diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WAccountEditor.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WAccountEditor.java index 4b2c1529b6..dc79d0f9d8 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WAccountEditor.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WAccountEditor.java @@ -218,5 +218,14 @@ public class WAccountEditor extends WEditor implements ContextMenuListener } } + @Override + public boolean isNullOrEmpty() { + Object value = getValue(); + if (value != null && ((Integer) value).intValue() == 0) + value = null; + + return value == null; + } + } diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WEditor.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WEditor.java index 0d2a1d168b..fdf8f4c933 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WEditor.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WEditor.java @@ -47,7 +47,7 @@ import org.zkoss.zul.Image; */ 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; @@ -490,21 +490,28 @@ public abstract class WEditor implements EventListener, PropertyChangeListener hasFocus = b; } - public void setMandatoryLabels() { - Object value = getValue(); - if (this instanceof WAccountEditor && value != null && ((Integer) value).intValue() == 0) // special case - value = null; + public void updateLabelStyle() { if (getLabel() != null) { - markMandatory(mandatory && !readOnly && getGridField().isEditable(true) && (value == null || value.toString().trim().length() == 0)); + boolean mandatoryStyle = mandatory && !readOnly && getGridField().isEditable(true) && isNullOrEmpty(); + getLabel().setStyle( (isZoomable() ? STYLE_ZOOMABLE_LABEL : "") + (mandatoryStyle ? STYLE_EMPTY_MANDATORY_LABEL : STYLE_NORMAL_LABEL)); + } + } + + public boolean isNullOrEmpty() { + Object value = getValue(); + return value == null || value.toString().trim().length() == 0; + } + + public boolean isZoomable() { + WEditorPopupMenu menu = getPopupMenu(); + if (menu != null && menu.isZoomEnabled() && this instanceof IZoomableEditor) { + return true; + } else { + return false; } } 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_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)); - } - } diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/ADTabpanel.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/ADTabpanel.java index 55a34e05c0..c960dad21a 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/ADTabpanel.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/ADTabpanel.java @@ -479,7 +479,6 @@ DataStatusListener, IADTabpanel, VetoableChangeListener Label label = editor.getLabel(); if (popupMenu.isZoomEnabled() && editor instanceof IZoomableEditor) { - label.setZoomable(true); label.addEventListener(Events.ON_CLICK, new ZoomListener((IZoomableEditor) editor)); } @@ -542,7 +541,7 @@ DataStatusListener, IADTabpanel, VetoableChangeListener for (WEditor comp : editors) { - comp.setMandatoryLabels(); + comp.updateLabelStyle(); } // Selective