From ce5a67c2204f15bac6a802e342454c04c7066ceb Mon Sep 17 00:00:00 2001 From: Dirk Niemeyer Date: Wed, 10 Jul 2013 16:41:55 +0200 Subject: [PATCH] IDEMPIERE-1120 Implement Field SeqNo customization --- .../src/org/compiere/model/GridField.java | 2 ++ .../src/org/compiere/model/GridFieldVO.java | 29 +++++++++++++++++-- .../src/org/compiere/model/GridTabVO.java | 2 ++ 3 files changed, 30 insertions(+), 3 deletions(-) diff --git a/org.adempiere.base/src/org/compiere/model/GridField.java b/org.adempiere.base/src/org/compiere/model/GridField.java index 7d3276ac0f..635aec55e3 100644 --- a/org.adempiere.base/src/org/compiere/model/GridField.java +++ b/org.adempiere.base/src/org/compiere/model/GridField.java @@ -28,6 +28,7 @@ import java.sql.Timestamp; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Calendar; +import java.util.Collections; import java.util.Date; import java.util.List; import java.util.Properties; @@ -1782,6 +1783,7 @@ public class GridField AD_Window_ID, AD_Tab_ID, readOnly, rs); listVO.add(vo); } + Collections.sort(listVO, new GridFieldVO.SeqNoComparator()); } catch (Exception e) { diff --git a/org.adempiere.base/src/org/compiere/model/GridFieldVO.java b/org.adempiere.base/src/org/compiere/model/GridFieldVO.java index 43716718be..c7158efb93 100644 --- a/org.adempiere.base/src/org/compiere/model/GridFieldVO.java +++ b/org.adempiere.base/src/org/compiere/model/GridFieldVO.java @@ -21,6 +21,7 @@ import java.io.Serializable; import java.sql.ResultSet; import java.sql.ResultSetMetaData; import java.sql.SQLException; +import java.util.Comparator; import java.util.Properties; import java.util.logging.Level; @@ -66,6 +67,7 @@ public class GridFieldVO implements Serializable return sql.toString(); } // getSQL + /** * Create Field Value Object * @param ctx context @@ -112,6 +114,8 @@ public class GridFieldVO implements Serializable vo.IsDisplayed = "Y".equals(rs.getString (i)); else if (columnName.equalsIgnoreCase("IsDisplayedGrid")) vo.IsDisplayedGrid = "Y".equals(rs.getString (i)); + else if (columnName.equalsIgnoreCase("SeqNo")) + vo.SeqNo = rs.getInt (i); else if (columnName.equalsIgnoreCase("SeqNoGrid")) vo.SeqNoGrid = rs.getInt (i); else if (columnName.equalsIgnoreCase("DisplayLogic")) @@ -275,7 +279,11 @@ public class GridFieldVO implements Serializable if (userDef.getNumLines() > 0) vo.NumLines=userDef.getNumLines(); if (userDef.getIsToolbarButton() != null) - vo.IsToolbarButton = "Y".equals(userDef.getIsToolbarButton()); + vo.IsToolbarButton = "Y".equals(userDef.getIsToolbarButton()); + //IDEMPIERE-1120 Implement Field SeqNo customization + if (userDef.getSeqNo() > 0) + vo.SeqNo = userDef.getSeqNo(); + } } // @@ -491,8 +499,10 @@ public class GridFieldVO implements Serializable public boolean IsDisplayed = false; /** Displayed Grid */ public boolean IsDisplayedGrid = false; + /** Position */ + public int SeqNo = 0; /** Grid Display sequence */ - public int SeqNoGrid = 0; + public int SeqNoGrid = 0; /** Dislay Logic */ public String DisplayLogic = ""; /** Default Value */ @@ -684,6 +694,7 @@ public class GridFieldVO implements Serializable clone.IsDisplayed = IsDisplayed; clone.IsDisplayedGrid = IsDisplayedGrid; clone.AD_Field_ID = AD_Field_ID; + clone.SeqNo = SeqNo; clone.SeqNoGrid = SeqNoGrid; clone.DisplayLogic = DisplayLogic; clone.DefaultValue = DefaultValue; @@ -741,4 +752,16 @@ public class GridFieldVO implements Serializable return sb.toString (); } // toString -} // MFieldVO + /** + * + * @author a42niem + * IDEMPIERE-1120 Implement Field SeqNo customization + */ + public static class SeqNoComparator implements Comparator { + @Override + public int compare(GridFieldVO gf1, GridFieldVO gf2) { + return (new Integer(gf1.SeqNo)).compareTo(new Integer(gf2.SeqNo)); + } + } + +} // GridFieldVO diff --git a/org.adempiere.base/src/org/compiere/model/GridTabVO.java b/org.adempiere.base/src/org/compiere/model/GridTabVO.java index 963ffe0f4d..5b1a6d25c6 100644 --- a/org.adempiere.base/src/org/compiere/model/GridTabVO.java +++ b/org.adempiere.base/src/org/compiere/model/GridTabVO.java @@ -21,6 +21,7 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; +import java.util.Collections; import java.util.Properties; import java.util.logging.Level; @@ -314,6 +315,7 @@ public class GridTabVO implements Evaluatee, Serializable pstmt = null; } + Collections.sort(mTabVO.Fields, new GridFieldVO.SeqNoComparator()); mTabVO.initFields = true; return mTabVO.Fields.size() != 0;