IDEMPIERE-3831 info column style

This commit is contained in:
Murilo Habermann Torquato 2019-09-17 23:47:21 -03:00
parent 09e7bf992c
commit 73c05c3828
8 changed files with 236 additions and 8 deletions

View File

@ -0,0 +1,32 @@
SET SQLBLANKLINES ON
SET DEFINE OFF
-- IDEMPIERE-3831 Implement AD_FieldStyle for Info Windows
-- Sep 17, 2019, 3:25:02 PM BRT
INSERT INTO AD_Column (AD_Column_ID,Version,Name,Description,AD_Table_ID,ColumnName,FieldLength,IsKey,IsParent,IsMandatory,IsTranslated,IsIdentifier,SeqNo,IsEncrypted,AD_Reference_ID,AD_Reference_Value_ID,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,AD_Element_ID,IsUpdateable,IsSelectionColumn,EntityType,IsSyncDatabase,IsAlwaysUpdateable,IsAutocomplete,IsAllowLogging,AD_Column_UU,IsAllowCopy,SeqNoSelection,IsToolbarButton,IsSecure,FKConstraintType,IsHtml) VALUES (214051,0,'Field Style','Field CSS Style ',897,'AD_FieldStyle_ID',10,'N','N','N','N','N',0,'N',18,200121,0,0,'Y',TO_DATE('2019-09-17 15:25:02','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2019-09-17 15:25:02','YYYY-MM-DD HH24:MI:SS'),100,203012,'Y','N','D','N','N','N','Y','f70da853-fe44-41e9-9c68-62638cfc90d8','Y',0,'N','N','N','N')
;
-- Sep 17, 2019, 3:25:08 PM BRT
UPDATE AD_Column SET FKConstraintName='ADFieldStyle_ADInfoColumn', FKConstraintType='N',Updated=TO_DATE('2019-09-17 15:25:08','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=214051
;
-- Sep 17, 2019, 3:25:08 PM BRT
ALTER TABLE AD_InfoColumn ADD AD_FieldStyle_ID NUMBER(10) DEFAULT NULL
;
-- Sep 17, 2019, 3:25:08 PM BRT
ALTER TABLE AD_InfoColumn ADD CONSTRAINT ADFieldStyle_ADInfoColumn FOREIGN KEY (AD_FieldStyle_ID) REFERENCES ad_style(ad_style_id) DEFERRABLE INITIALLY DEFERRED
;
-- Sep 17, 2019, 3:26:02 PM BRT
UPDATE AD_Column SET EntityType='D',Updated=TO_DATE('2019-09-17 15:26:02','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=214051
;
-- Sep 17, 2019, 3:26:12 PM BRT
INSERT INTO AD_Field (AD_Field_ID,Name,Description,AD_Tab_ID,AD_Column_ID,IsDisplayed,DisplayLength,SeqNo,IsSameLine,IsHeading,IsFieldOnly,IsEncrypted,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,IsReadOnly,IsCentrallyMaintained,EntityType,AD_Field_UU,IsDisplayedGrid,SeqNoGrid,ColumnSpan) VALUES (206178,'Field Style','Field CSS Style ',844,214051,'Y',10,310,'N','N','N','N',0,0,'Y',TO_DATE('2019-09-17 15:26:12','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2019-09-17 15:26:12','YYYY-MM-DD HH24:MI:SS'),100,'N','Y','D','d6b6f5e1-1436-49fc-b57a-12bb4b0c247c','Y',10280,2)
;
SELECT register_migration_script('201909121529_IDEMPIERE-3831.sql') FROM dual
;

View File

@ -0,0 +1,29 @@
-- IDEMPIERE-3831 Implement AD_FieldStyle for Info Windows
-- Sep 17, 2019, 3:25:02 PM BRT
INSERT INTO AD_Column (AD_Column_ID,Version,Name,Description,AD_Table_ID,ColumnName,FieldLength,IsKey,IsParent,IsMandatory,IsTranslated,IsIdentifier,SeqNo,IsEncrypted,AD_Reference_ID,AD_Reference_Value_ID,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,AD_Element_ID,IsUpdateable,IsSelectionColumn,EntityType,IsSyncDatabase,IsAlwaysUpdateable,IsAutocomplete,IsAllowLogging,AD_Column_UU,IsAllowCopy,SeqNoSelection,IsToolbarButton,IsSecure,FKConstraintType,IsHtml) VALUES (214051,0,'Field Style','Field CSS Style ',897,'AD_FieldStyle_ID',10,'N','N','N','N','N',0,'N',18,200121,0,0,'Y',TO_TIMESTAMP('2019-09-17 15:25:02','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2019-09-17 15:25:02','YYYY-MM-DD HH24:MI:SS'),100,203012,'Y','N','D','N','N','N','Y','f70da853-fe44-41e9-9c68-62638cfc90d8','Y',0,'N','N','N','N')
;
-- Sep 17, 2019, 3:25:08 PM BRT
UPDATE AD_Column SET FKConstraintName='ADFieldStyle_ADInfoColumn', FKConstraintType='N',Updated=TO_TIMESTAMP('2019-09-17 15:25:08','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=214051
;
-- Sep 17, 2019, 3:25:08 PM BRT
ALTER TABLE AD_InfoColumn ADD COLUMN AD_FieldStyle_ID NUMERIC(10) DEFAULT NULL
;
-- Sep 17, 2019, 3:25:08 PM BRT
ALTER TABLE AD_InfoColumn ADD CONSTRAINT ADFieldStyle_ADInfoColumn FOREIGN KEY (AD_FieldStyle_ID) REFERENCES ad_style(ad_style_id) DEFERRABLE INITIALLY DEFERRED
;
-- Sep 17, 2019, 3:26:02 PM BRT
UPDATE AD_Column SET EntityType='D',Updated=TO_TIMESTAMP('2019-09-17 15:26:02','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=214051
;
-- Sep 17, 2019, 3:26:12 PM BRT
INSERT INTO AD_Field (AD_Field_ID,Name,Description,AD_Tab_ID,AD_Column_ID,IsDisplayed,DisplayLength,SeqNo,IsSameLine,IsHeading,IsFieldOnly,IsEncrypted,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,IsReadOnly,IsCentrallyMaintained,EntityType,AD_Field_UU,IsDisplayedGrid,SeqNoGrid,ColumnSpan) VALUES (206178,'Field Style','Field CSS Style ',844,214051,'Y',10,310,'N','N','N','N',0,0,'Y',TO_TIMESTAMP('2019-09-17 15:26:12','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2019-09-17 15:26:12','YYYY-MM-DD HH24:MI:SS'),100,'N','Y','D','d6b6f5e1-1436-49fc-b57a-12bb4b0c247c','Y',10280,2)
;
SELECT register_migration_script('201909121529_IDEMPIERE-3831.sql') FROM dual
;

View File

@ -64,6 +64,21 @@ public interface I_AD_InfoColumn
public org.compiere.model.I_AD_Element getAD_Element() throws RuntimeException;
/** Column name AD_FieldStyle_ID */
public static final String COLUMNNAME_AD_FieldStyle_ID = "AD_FieldStyle_ID";
/** Set Field Style.
* Field CSS Style
*/
public void setAD_FieldStyle_ID (int AD_FieldStyle_ID);
/** Get Field Style.
* Field CSS Style
*/
public int getAD_FieldStyle_ID();
public org.compiere.model.I_AD_Style getAD_FieldStyle() throws RuntimeException;
/** Column name AD_InfoColumn_ID */
public static final String COLUMNNAME_AD_InfoColumn_ID = "AD_InfoColumn_ID";

View File

@ -30,7 +30,7 @@ public class X_AD_InfoColumn extends PO implements I_AD_InfoColumn, I_Persistent
/**
*
*/
private static final long serialVersionUID = 20190106L;
private static final long serialVersionUID = 20190917L;
/** Standard Constructor */
public X_AD_InfoColumn (Properties ctx, int AD_InfoColumn_ID, String trxName)
@ -118,6 +118,34 @@ public class X_AD_InfoColumn extends PO implements I_AD_InfoColumn, I_Persistent
return ii.intValue();
}
public org.compiere.model.I_AD_Style getAD_FieldStyle() throws RuntimeException
{
return (org.compiere.model.I_AD_Style)MTable.get(getCtx(), org.compiere.model.I_AD_Style.Table_Name)
.getPO(getAD_FieldStyle_ID(), get_TrxName()); }
/** Set Field Style.
@param AD_FieldStyle_ID
Field CSS Style
*/
public void setAD_FieldStyle_ID (int AD_FieldStyle_ID)
{
if (AD_FieldStyle_ID < 1)
set_Value (COLUMNNAME_AD_FieldStyle_ID, null);
else
set_Value (COLUMNNAME_AD_FieldStyle_ID, Integer.valueOf(AD_FieldStyle_ID));
}
/** Get Field Style.
@return Field CSS Style
*/
public int getAD_FieldStyle_ID ()
{
Integer ii = (Integer)get_Value(COLUMNNAME_AD_FieldStyle_ID);
if (ii == null)
return 0;
return ii.intValue();
}
/** Set Info Column.
@param AD_InfoColumn_ID
Info Window Column

View File

@ -28,11 +28,18 @@ import org.adempiere.webui.editor.WebEditorFactory;
import org.adempiere.webui.event.ValueChangeEvent;
import org.adempiere.webui.event.ValueChangeListener;
import org.adempiere.webui.info.InfoWindow;
import org.adempiere.webui.theme.ThemeManager;
import org.compiere.minigrid.ColumnInfo;
import org.compiere.minigrid.IDColumn;
import org.compiere.model.GridField;
import org.compiere.model.MInfoColumn;
import org.compiere.model.MStyle;
import org.compiere.model.X_AD_StyleLine;
import org.compiere.util.Env;
import org.compiere.util.Evaluatee;
import org.compiere.util.Evaluator;
import org.compiere.util.KeyNamePair;
import org.compiere.util.Util;
import org.zkoss.zul.Listcell;
public class WInfoWindowListItemRenderer extends WListItemRenderer
@ -72,16 +79,19 @@ public class WInfoWindowListItemRenderer extends WListItemRenderer
Object obj = model.get(rowIndex);
MInfoColumn infoColumn = gridDisplayedInfoColumns[columnIndex];
if (infoColumn != null)
{
if(model.isSelected(obj) && infoColumn != null) // First index may be null
final GridField gridField = gridDisplayedColumnInfos[columnIndex].getGridField();
final WEditor editor = WebEditorFactory.getEditor(gridField, false);
if(model.isSelected(obj)) // First index may be null
{
if(infoColumn.isReadOnly() == false
&& columnIndex > 0)
{
ListCell listCell = new ListCell();
final GridField gridField = gridDisplayedColumnInfos[columnIndex].getGridField();
final WEditor editor = WebEditorFactory.getEditor(gridField, false);
// Set editor value
@ -114,10 +124,120 @@ public class WInfoWindowListItemRenderer extends WListItemRenderer
}
}
if(listcell == null)
listcell = super.getCellComponent(table, field, rowIndex, columnIndex);
if (gridField.getAD_FieldStyle_ID() > 0)
{
MStyle style = MStyle.get(Env.getCtx(), gridField.getAD_FieldStyle_ID());
X_AD_StyleLine[] lines = style.getStyleLines();
StringBuilder styleBuilder = new StringBuilder();
for (X_AD_StyleLine line : lines)
{
String inlineStyle = line.getInlineStyle().trim();
String displayLogic = line.getDisplayLogic();
String theme = line.getTheme();
if (!Util.isEmpty(theme)) {
if (!ThemeManager.getTheme().equals(theme))
continue;
}
if (!Util.isEmpty(displayLogic))
{
Evaluatee ev = new Evaluatee() {
@Override
public String get_ValueAsString(String variableName) {
String value = null;
int idx = 0;
for (MInfoColumn ic : gridDisplayedInfoColumns)
{
if (ic != null && ic.getColumnName().equals(variableName))
{
value = String.valueOf(table.getValueAt(rowIndex, idx));
break;
}
idx++;
}
return value;
}
};
if (!Evaluator.evaluateLogic(ev, displayLogic))
continue;
}
if (styleBuilder.length() > 0 && !(styleBuilder.charAt(styleBuilder.length()-1)==';'))
styleBuilder.append("; ");
styleBuilder.append(inlineStyle);
}
//devCoffee #5960
String styleStr = styleBuilder.toString();
if (styleStr != null && styleStr.startsWith(MStyle.SCLASS_PREFIX)) {
String sclass = styleStr.substring(MStyle.SCLASS_PREFIX.length());
listcell.setSclass(sclass);
} else if (style != null && styleStr.startsWith(MStyle.ZCLASS_PREFIX)) {
String zclass = styleStr.substring(MStyle.ZCLASS_PREFIX.length());
listcell.setZclass(zclass);
} else {
listcell.setStyle(styleStr);
}
}
}
if(listcell == null)
listcell = super.getCellComponent(table, field, rowIndex, columnIndex);
return listcell;
}
//
// //devCoffee #5960 - Get CSS Style if pass through display logic.
// private String getStatusStyle(ListCell listcell, PO po) {
// if(po instanceof MInfoWindow) {
// if(po.get_ValueAsInt("AD_FieldStyle_ID") != 0 && listcell != null) {
// try {
// MTable t = new MTable(Env.getCtx(), po.get_ValueAsInt("AD_Table_ID"), null);
// PO recordPO = (PO) new Query(Env.getCtx(), t.getTableName(), t.getTableName() + "_ID =" + listcell.getValue(), null).first();
//
// List<X_AD_StyleLine> lines = new Query(Env.getCtx(), X_AD_StyleLine.Table_Name, "AD_Style_ID = " + po.get_ValueAsInt("AD_FieldStyle_ID"), null).list();
//
// StringBuilder styleBuilder = new StringBuilder();
// for (X_AD_StyleLine line : lines)
// {
// String inlineStyle = line.getInlineStyle().trim();
// String displayLogic = line.getDisplayLogic();
// String theme = line.getTheme();
// if (!Util.isEmpty(theme)) {
// if (!ThemeManager.getTheme().equals(theme))
// continue;
// }
// if (!Util.isEmpty(displayLogic))
// {
// if (!Evaluator.evaluateLogic(recordPO, displayLogic))
// continue;
// }
// if (styleBuilder.length() > 0 && !(styleBuilder.charAt(styleBuilder.length()-1)==';'))
// styleBuilder.append("; ");
//
// styleBuilder.append(inlineStyle);
// }
//
// //listcell.setStyle(styleBuilder.toString());
// return styleBuilder.toString();
// } catch (Exception e) {
// throw new AdempiereException(e.getMessage());
// }
// }
// }
//
// return "";
// }
}

View File

@ -328,7 +328,7 @@ public class WListItemRenderer implements ListitemRenderer<Object>, EventListene
AImage aImage = new AImage(url);
Image image = new Image();
image.setContent(aImage);
image.setStyle("width: 48px; height: 48px;");
image.setStyle("width: 16px; height: 16px; display: block;");
listcell.appendChild(image);
listcell.setStyle("text-align: center;");
} catch (MalformedURLException e) {

View File

@ -603,6 +603,7 @@ public class InfoWindow extends InfoPanel implements ValueChangeListener, EventL
vo.Description = desc != null ? desc : "";
String help = infoColumn.get_Translation("Help");
vo.Help = help != null ? help : "";
vo.AD_FieldStyle_ID = infoColumn.getAD_FieldStyle_ID();
GridField gridField = new GridField(vo);
gridFields.add(gridField);
}
@ -628,14 +629,15 @@ public class InfoWindow extends InfoPanel implements ValueChangeListener, EventL
}
}
if(hasEditable)
{
}
infoWindowListItemRenderer = new WInfoWindowListItemRenderer(this);
contentPanel.setItemRenderer(infoWindowListItemRenderer);
if(hasEditable)
{
contentPanel.setAllowIDColumnForReadWrite(true);
infoWindowListItemRenderer.addTableValueChangeListener(contentPanel); // Replicated from WListbox constructor
}
}
StringBuilder builder = new StringBuilder(p_whereClause != null ? p_whereClause.trim() : "");
String infoWhereClause = infoWindow.getWhereClause();
@ -2067,6 +2069,7 @@ public class InfoWindow extends InfoPanel implements ValueChangeListener, EventL
vo.Description = desc != null ? desc : "";
String help = infoColumn.get_Translation("Help");
vo.Help = help != null ? help : "";
vo.AD_FieldStyle_ID = infoColumn.getAD_FieldStyle_ID();
GridField gridField = new GridField(vo);
return gridField;

View File

@ -2142,6 +2142,7 @@ public abstract class InfoPanel extends Window implements EventListener<Event>,
null);
saveResultSelection(getInfoColumnIDFromProcess(processModalDialog.getAD_Process_ID()));
createT_Selection_InfoWindow(pInstanceID);
recordSelectedData.clear();
}else if (ProcessModalDialog.ON_WINDOW_CLOSE.equals(event.getName())){
if (processModalDialog.isCancel()){
//clear back