IDEMPIERE-3617 Styles not working in master mode after navigate to another record

This commit is contained in:
Carlos Ruiz 2018-01-24 13:54:21 +01:00
parent 44ef536af6
commit ffcd468f13
3 changed files with 57 additions and 11 deletions

View File

@ -15,16 +15,18 @@ import org.compiere.util.Env;
* *
*/ */
public class MStyle extends X_AD_Style { public class MStyle extends X_AD_Style {
/** /**
* *
*/ */
private static final long serialVersionUID = -5183438249097292583L; private static final long serialVersionUID = 4988653330824933725L;
/** Cache */ /** Cache */
private static CCache<Integer,MStyle> s_cache = new CCache<Integer,MStyle>(Table_Name, 30, 60); private static CCache<Integer,MStyle> s_cache = new CCache<Integer,MStyle>(Table_Name, 30, 60);
private X_AD_StyleLine[] m_lines = null; private X_AD_StyleLine[] m_lines = null;
public static final String SCLASS_PREFIX = "@sclass=";
public static final String ZCLASS_PREFIX = "@zclass=";
public MStyle(Properties ctx, int AD_Style_ID, String trxName) { public MStyle(Properties ctx, int AD_Style_ID, String trxName) {
super(ctx, AD_Style_ID, trxName); super(ctx, AD_Style_ID, trxName);
} }

View File

@ -299,7 +299,28 @@ public class GridTabRowRenderer implements RowRenderer<Object[]>, RowRendererExt
styleBuilder.append("; "); styleBuilder.append("; ");
styleBuilder.append(inlineStyle); styleBuilder.append(inlineStyle);
} }
component.setStyle(styleBuilder.toString()); setComponentStyle(component, styleBuilder.toString());
}
protected void setComponentStyle(HtmlBasedComponent component, String style) {
if (style != null && style.startsWith(MStyle.SCLASS_PREFIX)) {
String sclass = style.substring(MStyle.SCLASS_PREFIX.length());
if (component instanceof EditorBox)
((EditorBox)component).getTextbox().setSclass(sclass);
else
component.setSclass(sclass);
} else if (style != null && style.startsWith(MStyle.ZCLASS_PREFIX)) {
String zclass = style.substring(MStyle.ZCLASS_PREFIX.length());
if (component instanceof EditorBox)
((EditorBox)component).getTextbox().setZclass(zclass);
else
component.setZclass(zclass);
} else {
if (component instanceof EditorBox)
((EditorBox)component).getTextbox().setStyle(style);
else
component.setStyle(style);
}
} }
/** /**

View File

@ -593,9 +593,18 @@ public abstract class WEditor implements EventListener<Event>, PropertyChangeLis
} }
} }
protected void setLabelStyle(String style) { protected void setLabelStyle(String style) {
if (label != null) if (label != null) {
label.setStyle(style); if (style != null && style.toLowerCase().startsWith(MStyle.SCLASS_PREFIX)) {
String sclass = style.substring(MStyle.SCLASS_PREFIX.length());
label.setSclass(sclass);
} else if (style != null && style.toLowerCase().startsWith(MStyle.ZCLASS_PREFIX)) {
String zclass = style.substring(MStyle.ZCLASS_PREFIX.length());
label.setZclass(zclass);
} else {
label.setStyle(style);
}
}
} }
protected void applyFieldStyles(boolean applyDictionaryStyle) { protected void applyFieldStyles(boolean applyDictionaryStyle) {
@ -607,12 +616,26 @@ public abstract class WEditor implements EventListener<Event>, PropertyChangeLis
setFieldStyle(style); setFieldStyle(style);
} }
protected void setFieldStyle(String style) { protected void setFieldStyle(String style) {
HtmlBasedComponent component = (HtmlBasedComponent) getComponent(); HtmlBasedComponent component = (HtmlBasedComponent) getComponent();
if (component instanceof EditorBox) if (style != null && style.startsWith(MStyle.SCLASS_PREFIX)) {
((EditorBox)component).getTextbox().setStyle(style); String sclass = style.substring(MStyle.SCLASS_PREFIX.length());
else if (component instanceof EditorBox)
component.setStyle(style); ((EditorBox)component).getTextbox().setSclass(sclass);
else
component.setSclass(sclass);
} else if (style != null && style.startsWith(MStyle.ZCLASS_PREFIX)) {
String zclass = style.substring(MStyle.ZCLASS_PREFIX.length());
if (component instanceof EditorBox)
((EditorBox)component).getTextbox().setZclass(zclass);
else
component.setZclass(zclass);
} else {
if (component instanceof EditorBox)
((EditorBox)component).getTextbox().setStyle(style);
else
component.setStyle(style);
}
} }
protected String buildStyle(int AD_Style_ID) { protected String buildStyle(int AD_Style_ID) {