From 6c939f1c7ec2572fc8c68138d02c788c5e4518dc Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Sun, 2 Jun 2013 19:46:03 -0500 Subject: [PATCH] IDEMPIERE-1010 Thousands grouping separator is used for integers values / Implemented FormatPattern support for zk edition on numbers --- db/ddlutils/oracle/views/AD_FIELD_V.sql | 3 +- db/ddlutils/oracle/views/AD_FIELD_VT.sql | 3 +- db/ddlutils/postgresql/views/AD_FIELD_V.sql | 3 +- db/ddlutils/postgresql/views/AD_FIELD_VT.sql | 3 +- .../oracle/201306021150_IDEMPIERE-1010.sql | 80 +++++++++++++++++++ .../201306021150_IDEMPIERE-1010.sql | 66 +++++++++++++++ .../src/org/compiere/model/GridField.java | 12 ++- .../src/org/compiere/model/GridFieldVO.java | 9 ++- .../src/org/compiere/model/MColumn.java | 36 +++++++-- .../adempiere/webui/component/NumberBox.java | 10 +-- .../adempiere/webui/editor/WNumberEditor.java | 5 +- 11 files changed, 209 insertions(+), 21 deletions(-) create mode 100644 migration/i1.0b-release/oracle/201306021150_IDEMPIERE-1010.sql create mode 100644 migration/i1.0b-release/postgresql/201306021150_IDEMPIERE-1010.sql diff --git a/db/ddlutils/oracle/views/AD_FIELD_V.sql b/db/ddlutils/oracle/views/AD_FIELD_V.sql index 67134ef926..a3d519f0ac 100644 --- a/db/ddlutils/oracle/views/AD_FIELD_V.sql +++ b/db/ddlutils/oracle/views/AD_FIELD_V.sql @@ -23,7 +23,8 @@ CREATE OR REPLACE VIEW AD_FIELD_V AS f.isdisplayedgrid, f.seqnogrid, c.seqnoselection, f.xposition, f.columnspan, f.numlines, - COALESCE(f.istoolbarbutton , c.istoolbarbutton ) As istoolbarbutton + COALESCE(f.istoolbarbutton , c.istoolbarbutton ) As istoolbarbutton, + c.FormatPattern FROM AD_FIELD f INNER JOIN AD_TAB t ON (f.AD_Tab_ID = t.AD_Tab_ID) LEFT OUTER JOIN AD_FIELDGROUP fg ON (f.AD_FieldGroup_ID = fg.AD_FieldGroup_ID) diff --git a/db/ddlutils/oracle/views/AD_FIELD_VT.sql b/db/ddlutils/oracle/views/AD_FIELD_VT.sql index 896f74b808..078ea01e23 100644 --- a/db/ddlutils/oracle/views/AD_FIELD_VT.sql +++ b/db/ddlutils/oracle/views/AD_FIELD_VT.sql @@ -22,7 +22,8 @@ CREATE OR REPLACE VIEW AD_FIELD_VT AS f.isdisplayedgrid, f.seqnogrid, c.seqnoselection, f.xposition, f.columnspan, f.numlines, - COALESCE(f.istoolbarbutton , c.istoolbarbutton ) As istoolbarbutton + COALESCE(f.istoolbarbutton , c.istoolbarbutton ) As istoolbarbutton, + c.FormatPattern FROM AD_FIELD f INNER JOIN AD_FIELD_TRL trl ON (f.AD_Field_ID = trl.AD_Field_ID) INNER JOIN AD_TAB t ON (f.AD_Tab_ID = t.AD_Tab_ID) diff --git a/db/ddlutils/postgresql/views/AD_FIELD_V.sql b/db/ddlutils/postgresql/views/AD_FIELD_V.sql index 40299e4f51..897aa1bdaa 100644 --- a/db/ddlutils/postgresql/views/AD_FIELD_V.sql +++ b/db/ddlutils/postgresql/views/AD_FIELD_V.sql @@ -19,7 +19,8 @@ CREATE OR REPLACE VIEW ad_field_v AS f.isdisplayedgrid, f.seqnogrid, c.seqnoselection, f.xposition, f.columnspan, f.numlines, - COALESCE(f.istoolbarbutton , c.istoolbarbutton ) As istoolbarbutton + COALESCE(f.istoolbarbutton , c.istoolbarbutton ) As istoolbarbutton, + c.FormatPattern FROM ad_field f JOIN ad_tab t ON f.ad_tab_id = t.ad_tab_id LEFT JOIN ad_fieldgroup fg ON f.ad_fieldgroup_id = fg.ad_fieldgroup_id diff --git a/db/ddlutils/postgresql/views/AD_FIELD_VT.sql b/db/ddlutils/postgresql/views/AD_FIELD_VT.sql index 30bc3a340c..9e0d1fd25f 100644 --- a/db/ddlutils/postgresql/views/AD_FIELD_VT.sql +++ b/db/ddlutils/postgresql/views/AD_FIELD_VT.sql @@ -15,7 +15,8 @@ CREATE OR REPLACE VIEW ad_field_vt AS f.isdisplayedgrid, f.seqnogrid, c.seqnoselection, f.xposition, f.columnspan, f.numlines, - COALESCE(f.istoolbarbutton , c.istoolbarbutton ) As istoolbarbutton + COALESCE(f.istoolbarbutton , c.istoolbarbutton ) As istoolbarbutton, + c.FormatPattern FROM ad_field f JOIN ad_field_trl trl ON f.ad_field_id = trl.ad_field_id JOIN ad_tab t ON f.ad_tab_id = t.ad_tab_id diff --git a/migration/i1.0b-release/oracle/201306021150_IDEMPIERE-1010.sql b/migration/i1.0b-release/oracle/201306021150_IDEMPIERE-1010.sql new file mode 100644 index 0000000000..d3314fdd30 --- /dev/null +++ b/migration/i1.0b-release/oracle/201306021150_IDEMPIERE-1010.sql @@ -0,0 +1,80 @@ +-- IDEMPIERE-1010 Thousands grouping separator is used for integers values +CREATE OR REPLACE VIEW AD_FIELD_V AS + SELECT t.AD_Window_ID, f.AD_Tab_ID, f.AD_Field_ID, tbl.AD_Table_ID, f.AD_Column_ID, + f.NAME, f.Description, f.Help, f.IsDisplayed, f.DisplayLogic, f.DisplayLength, + f.SeqNo, f.SortNo, f.IsSameLine, f.IsHeading, f.IsFieldOnly, f.IsReadOnly, + f.IsEncrypted AS IsEncryptedField, f.ObscureType, + c.ColumnName, c.ColumnSQL, c.FieldLength, c.VFormat, + COALESCE(f.DefaultValue, c.DefaultValue) AS DefaultValue, + c.IsKey, c.IsParent, + COALESCE(f.IsMandatory, c.IsMandatory) AS IsMandatory, + c.IsIdentifier, c.IsTranslated, COALESCE(f.AD_Reference_Value_ID, c.AD_Reference_Value_ID) AS AD_Reference_Value_ID, + c.Callout, COALESCE(f.AD_Reference_ID, c.AD_Reference_ID) AS AD_Reference_ID, + COALESCE(f.AD_Val_Rule_ID, c.AD_Val_Rule_ID) AS AD_Val_Rule_ID, c.AD_Process_ID, + COALESCE(f.Isalwaysupdateable , C.Isalwaysupdateable) As Isalwaysupdateable, + COALESCE(f.Readonlylogic, c.Readonlylogic ) As Readonlylogic, + COALESCE(f.Mandatorylogic , C.Mandatorylogic) As Mandatorylogic, + COALESCE(f.isupdateable, c.isupdateable) AS isupdateable, c.IsEncrypted AS IsEncryptedColumn, + c.IsSelectionColumn, + tbl.TableName, c.ValueMin, c.ValueMax, + fg.NAME AS FieldGroup, vr.Code AS ValidationCode, + f.Included_Tab_ID, fg.FieldGroupType, fg.IsCollapsedByDefault, + COALESCE(f.InfoFactoryClass, c.InfoFactoryClass) as InfoFactoryClass, + c.IsAutocomplete, COALESCE(f.IsAllowCopy, c.IsAllowCopy) AS IsAllowCopy, + f.isdisplayedgrid, + f.seqnogrid, + c.seqnoselection, f.xposition, f.columnspan, f.numlines, + COALESCE(f.istoolbarbutton , c.istoolbarbutton ) As istoolbarbutton, + c.FormatPattern +FROM AD_FIELD f + INNER JOIN AD_TAB t ON (f.AD_Tab_ID = t.AD_Tab_ID) + LEFT OUTER JOIN AD_FIELDGROUP fg ON (f.AD_FieldGroup_ID = fg.AD_FieldGroup_ID) + LEFT OUTER JOIN AD_COLUMN c ON (f.AD_Column_ID = c.AD_Column_ID) + INNER JOIN AD_TABLE tbl ON (c.AD_Table_ID = tbl.AD_Table_ID) + LEFT OUTER JOIN AD_VAL_RULE vr ON (vr.AD_Val_Rule_ID = COALESCE(f.AD_Val_Rule_ID, c.AD_Val_Rule_ID)) +WHERE f.IsActive = 'Y' + AND c.IsActive = 'Y' +; + +CREATE OR REPLACE VIEW AD_FIELD_VT AS + SELECT trl.AD_LANGUAGE, t.AD_Window_ID, f.AD_Tab_ID, f.AD_Field_ID, tbl.AD_Table_ID, f.AD_Column_ID, + trl.NAME, trl.Description, trl.Help, f.IsDisplayed, f.DisplayLogic, f.DisplayLength, + f.SeqNo, f.SortNo, f.IsSameLine, f.IsHeading, f.IsFieldOnly, f.IsReadOnly, + f.IsEncrypted AS IsEncryptedField, f.ObscureType, + c.ColumnName, c.ColumnSQL, c.FieldLength, c.VFormat, + COALESCE(f.DefaultValue, c.DefaultValue) AS DefaultValue, + c.IsKey, c.IsParent, + COALESCE(f.IsMandatory, c.IsMandatory) AS IsMandatory, + c.IsIdentifier, c.IsTranslated, COALESCE(f.AD_Reference_Value_ID, c.AD_Reference_Value_ID) AS AD_Reference_Value_ID, + c.Callout, COALESCE(f.AD_Reference_ID, c.AD_Reference_ID) AS AD_Reference_ID, + COALESCE(f.AD_Val_Rule_ID, c.AD_Val_Rule_ID) as AD_Val_Rule_ID, c.AD_Process_ID, + COALESCE(f.Isalwaysupdateable , C.Isalwaysupdateable) As Isalwaysupdateable, + COALESCE(f.Readonlylogic, c.Readonlylogic ) As Readonlylogic, + COALESCE(f.Mandatorylogic , C.Mandatorylogic) As Mandatorylogic, + COALESCE(f.isupdateable, c.isupdateable) AS isupdateable, c.IsEncrypted AS IsEncryptedColumn, c.IsSelectionColumn, + tbl.TableName, c.ValueMin, c.ValueMax, + fgt.NAME AS FieldGroup, vr.Code AS ValidationCode, + f.Included_Tab_ID, fg.FieldGroupType, fg.IsCollapsedByDefault, + COALESCE(f.InfoFactoryClass, c.InfoFactoryClass) as InfoFactoryClass, + c.IsAutocomplete, COALESCE(f.IsAllowCopy, c.IsAllowCopy) AS IsAllowCopy, + f.isdisplayedgrid, + f.seqnogrid, + c.seqnoselection, f.xposition, f.columnspan, f.numlines, + COALESCE(f.istoolbarbutton , c.istoolbarbutton ) As istoolbarbutton, + c.FormatPattern + FROM AD_FIELD f + INNER JOIN AD_FIELD_TRL trl ON (f.AD_Field_ID = trl.AD_Field_ID) + INNER JOIN AD_TAB t ON (f.AD_Tab_ID = t.AD_Tab_ID) + LEFT OUTER JOIN AD_FIELDGROUP fg ON (f.AD_FieldGroup_ID = fg.AD_FieldGroup_ID) + LEFT OUTER JOIN AD_FIELDGROUP_TRL fgt ON + (f.AD_FieldGroup_ID = fgt.AD_FieldGroup_ID AND trl.AD_LANGUAGE=fgt.AD_LANGUAGE) + LEFT OUTER JOIN AD_COLUMN c ON (f.AD_Column_ID = c.AD_Column_ID) + INNER JOIN AD_TABLE tbl ON (c.AD_Table_ID = tbl.AD_Table_ID) + LEFT OUTER JOIN AD_VAL_RULE vr ON (vr.AD_Val_Rule_ID=COALESCE(f.AD_Val_Rule_ID, c.AD_Val_Rule_ID)) + WHERE f.IsActive = 'Y' + AND c.IsActive = 'Y' +; + +SELECT register_migration_script('201306021150_IDEMPIERE-1010.sql') FROM dual +; + diff --git a/migration/i1.0b-release/postgresql/201306021150_IDEMPIERE-1010.sql b/migration/i1.0b-release/postgresql/201306021150_IDEMPIERE-1010.sql new file mode 100644 index 0000000000..2b46d71c17 --- /dev/null +++ b/migration/i1.0b-release/postgresql/201306021150_IDEMPIERE-1010.sql @@ -0,0 +1,66 @@ +-- IDEMPIERE-1010 Thousands grouping separator is used for integers values +CREATE OR REPLACE VIEW ad_field_v AS + SELECT t.ad_window_id, f.ad_tab_id, f.ad_field_id, tbl.ad_table_id, f.ad_column_id, + f.name, f.description, f.help, f.isdisplayed, f.displaylogic, f.displaylength, f.seqno, + f.sortno, f.issameline, f.isheading, f.isfieldonly, f.isreadonly, f.isencrypted AS isencryptedfield, + f.obscuretype, c.columnname, c.columnsql, c.fieldlength, c.vformat, + COALESCE(f.defaultvalue, c.defaultvalue) AS defaultvalue, c.iskey, c.isparent, + COALESCE(f.ismandatory, c.ismandatory) AS ismandatory, c.isidentifier, c.istranslated, + COALESCE(f.ad_reference_value_id, c.ad_reference_value_id) AS ad_reference_value_id, c.callout, + COALESCE(f.ad_reference_id, c.ad_reference_id) AS ad_reference_id, + COALESCE(f.ad_val_rule_id, c.ad_val_rule_id) AS ad_val_rule_id, c.ad_process_id, + COALESCE(f.Isalwaysupdateable , C.Isalwaysupdateable) As Isalwaysupdateable, + COALESCE(f.Readonlylogic, c.Readonlylogic ) As Readonlylogic, + COALESCE(f.Mandatorylogic , C.Mandatorylogic) As Mandatorylogic, + COALESCE(f.isupdateable, c.isupdateable) AS isupdateable, + c.isencrypted AS isencryptedcolumn, c.isselectioncolumn, tbl.tablename, c.valuemin, c.valuemax, + fg.name AS fieldgroup, vr.code AS validationcode, f.included_tab_id, fg.fieldgrouptype, fg.iscollapsedbydefault, + COALESCE(f.infofactoryclass, c.infofactoryclass) AS infofactoryclass, c.isautocomplete, + COALESCE(f.IsAllowCopy, c.IsAllowCopy) AS IsAllowCopy, + f.isdisplayedgrid, + f.seqnogrid, + c.seqnoselection, f.xposition, f.columnspan, f.numlines, + COALESCE(f.istoolbarbutton , c.istoolbarbutton ) As istoolbarbutton, + c.FormatPattern + FROM ad_field f + JOIN ad_tab t ON f.ad_tab_id = t.ad_tab_id + LEFT JOIN ad_fieldgroup fg ON f.ad_fieldgroup_id = fg.ad_fieldgroup_id + LEFT JOIN ad_column c ON f.ad_column_id = c.ad_column_id + JOIN ad_table tbl ON c.ad_table_id = tbl.ad_table_id + LEFT JOIN ad_val_rule vr ON vr.ad_val_rule_id = COALESCE(f.ad_val_rule_id, c.ad_val_rule_id) + WHERE f.isactive = 'Y'::bpchar AND c.isactive = 'Y'::bpchar +; + +CREATE OR REPLACE VIEW ad_field_vt AS + SELECT trl.ad_language, t.ad_window_id, f.ad_tab_id, f.ad_field_id, tbl.ad_table_id, f.ad_column_id, trl.name, trl.description, + trl.help, f.isdisplayed, f.displaylogic, f.displaylength, f.seqno, f.sortno, f.issameline, f.isheading, f.isfieldonly, f.isreadonly, + f.isencrypted AS isencryptedfield, f.obscuretype, c.columnname, c.columnsql, c.fieldlength, c.vformat, COALESCE(f.defaultvalue, c.defaultvalue) AS defaultvalue, + c.iskey, c.isparent, COALESCE(f.ismandatory, c.ismandatory) AS ismandatory, c.isidentifier, c.istranslated, + COALESCE(f.ad_reference_value_id, c.ad_reference_value_id) AS ad_reference_value_id, c.callout, COALESCE(f.ad_reference_id, c.ad_reference_id) AS ad_reference_id, + COALESCE(f.ad_val_rule_id,c.ad_val_rule_id) AS ad_val_rule_id, c.ad_process_id, + COALESCE(f.Isalwaysupdateable,C.Isalwaysupdateable) As Isalwaysupdateable, + COALESCE(f.Readonlylogic,c.Readonlylogic) As Readonlylogic, + COALESCE(f.Mandatorylogic , C.Mandatorylogic) As Mandatorylogic, + COALESCE(f.isupdateable, c.isupdateable) AS isupdateable, + c.isencrypted AS isencryptedcolumn, c.isselectioncolumn, tbl.tablename, c.valuemin, c.valuemax, fgt.name AS fieldgroup, vr.code AS validationcode, + f.included_tab_id, fg.fieldgrouptype, fg.iscollapsedbydefault, COALESCE(f.infofactoryclass, c.infofactoryclass) AS infofactoryclass, c.isautocomplete, + COALESCE(f.IsAllowCopy, c.IsAllowCopy) AS IsAllowCopy, + f.isdisplayedgrid, + f.seqnogrid, + c.seqnoselection, f.xposition, f.columnspan, f.numlines, + COALESCE(f.istoolbarbutton , c.istoolbarbutton ) As istoolbarbutton, + c.FormatPattern + FROM ad_field f + JOIN ad_field_trl trl ON f.ad_field_id = trl.ad_field_id + JOIN ad_tab t ON f.ad_tab_id = t.ad_tab_id + LEFT JOIN ad_fieldgroup fg ON f.ad_fieldgroup_id = fg.ad_fieldgroup_id + LEFT JOIN ad_fieldgroup_trl fgt ON f.ad_fieldgroup_id = fgt.ad_fieldgroup_id AND trl.ad_language::text = fgt.ad_language::text + LEFT JOIN ad_column c ON f.ad_column_id = c.ad_column_id + JOIN ad_table tbl ON c.ad_table_id = tbl.ad_table_id + LEFT JOIN ad_val_rule vr ON vr.ad_val_rule_id = COALESCE(f.ad_val_rule_id, c.ad_val_rule_id) + WHERE f.isactive = 'Y'::bpchar AND c.isactive = 'Y'::bpchar +; + +SELECT register_migration_script('201306021150_IDEMPIERE-1010.sql') FROM dual +; + diff --git a/org.adempiere.base/src/org/compiere/model/GridField.java b/org.adempiere.base/src/org/compiere/model/GridField.java index 73122f87e3..b4b281a41e 100644 --- a/org.adempiere.base/src/org/compiere/model/GridField.java +++ b/org.adempiere.base/src/org/compiere/model/GridField.java @@ -76,12 +76,10 @@ import org.compiere.util.Evaluator; public class GridField implements Serializable, Evaluatee, Cloneable { - - /** * */ - private static final long serialVersionUID = -2384947306143518488L; + private static final long serialVersionUID = -4907605626586089308L; /** * Field Constructor. @@ -1197,6 +1195,13 @@ public class GridField { return m_vo.VFormat; } + /** + * Get Format Pattern + * @return format pattern + */ + public String getFormatPattern() { + return m_vo.FormatPattern; + } /** * Get Value Min * @return min @@ -2005,4 +2010,5 @@ public class GridField } } + } // MField diff --git a/org.adempiere.base/src/org/compiere/model/GridFieldVO.java b/org.adempiere.base/src/org/compiere/model/GridFieldVO.java index c55d62b8db..43716718be 100644 --- a/org.adempiere.base/src/org/compiere/model/GridFieldVO.java +++ b/org.adempiere.base/src/org/compiere/model/GridFieldVO.java @@ -45,7 +45,7 @@ public class GridFieldVO implements Serializable /** * */ - private static final long serialVersionUID = 542767511640866058L; + private static final long serialVersionUID = -6098724121324445114L; /** * Return the SQL statement used for the MFieldVO.create @@ -144,6 +144,8 @@ public class GridFieldVO implements Serializable vo.FieldLength = rs.getInt (i); else if (columnName.equalsIgnoreCase("VFormat")) vo.VFormat = rs.getString (i); + else if (columnName.equalsIgnoreCase("FormatPattern")) + vo.FormatPattern = rs.getString (i); else if (columnName.equalsIgnoreCase("ValueMin")) vo.ValueMin = rs.getString (i); else if (columnName.equalsIgnoreCase("ValueMax")) @@ -311,6 +313,7 @@ public class GridFieldVO implements Serializable vo.DefaultValue = rs.getString("DefaultValue"); vo.DefaultValue2 = rs.getString("DefaultValue2"); vo.VFormat = rs.getString("VFormat"); + vo.FormatPattern = rs.getString("FormatPattern"); vo.ValueMin = rs.getString("ValueMin"); vo.ValueMax = rs.getString("ValueMax"); vo.isRange = rs.getString("IsRange").equals("Y"); @@ -359,6 +362,7 @@ public class GridFieldVO implements Serializable voT.DisplayLength = voF.FieldLength; voT.DefaultValue = voF.DefaultValue2; voT.VFormat = voF.VFormat; + voT.FormatPattern = voF.FormatPattern; voT.ValueMin = voF.ValueMin; voT.ValueMax = voF.ValueMax; voT.isRange = voF.isRange; @@ -519,6 +523,8 @@ public class GridFieldVO implements Serializable public int FieldLength = 0; /** Format enforcement */ public String VFormat = ""; + /** Format pattern */ + public String FormatPattern; /** Min. Value */ public String ValueMin = ""; /** Max. Value */ @@ -696,6 +702,7 @@ public class GridFieldVO implements Serializable clone.SortNo = SortNo; clone.FieldLength = FieldLength; clone.VFormat = VFormat; + clone.FormatPattern = FormatPattern; clone.ValueMin = ValueMin; clone.ValueMax = ValueMax; clone.FieldGroup = FieldGroup; diff --git a/org.adempiere.base/src/org/compiere/model/MColumn.java b/org.adempiere.base/src/org/compiere/model/MColumn.java index 769be5cb51..f4e867ac9a 100644 --- a/org.adempiere.base/src/org/compiere/model/MColumn.java +++ b/org.adempiere.base/src/org/compiere/model/MColumn.java @@ -20,6 +20,11 @@ import java.math.BigDecimal; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; +import java.text.DateFormat; +import java.text.DecimalFormat; +import java.text.NumberFormat; +import java.text.SimpleDateFormat; +import java.util.Locale; import java.util.Properties; import java.util.logging.Level; @@ -39,11 +44,10 @@ import org.compiere.util.Util; */ public class MColumn extends X_AD_Column { - /** * */ - private static final long serialVersionUID = 6543789555737635129L; + private static final long serialVersionUID = -3366954463322356334L; /** * Get MColumn from Cache @@ -305,11 +309,33 @@ public class MColumn extends X_AD_Column ) setIsAllowCopy(false); } - + + // validate FormatPattern + String pattern = getFormatPattern(); + if (! Util.isEmpty(pattern, true)) { + if (DisplayType.isNumeric(getAD_Reference_ID())) { + DecimalFormat format = (DecimalFormat)NumberFormat.getNumberInstance(Locale.US); + try { + format.applyPattern(pattern); + } catch (IllegalArgumentException e) { + log.saveError("SaveError", "Invalid number format: " + pattern); + return false; + } + } else if (DisplayType.isDate(getAD_Reference_ID())) { + SimpleDateFormat format = (SimpleDateFormat)DateFormat.getInstance(); + try { + format.applyPattern(pattern); + } catch (IllegalArgumentException e) { + log.saveError("SaveError", "Invalid date pattern: " + pattern); + return false; + } + } else { + setFormatPattern(null); + } + } + return true; } // beforeSave - - /** * After Save diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/component/NumberBox.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/component/NumberBox.java index fd7d1713b2..8e37667080 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/component/NumberBox.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/component/NumberBox.java @@ -45,10 +45,10 @@ import org.zkoss.zul.Vbox; */ public class NumberBox extends Div { - /** + /** * */ - private static final long serialVersionUID = 7089099079981906933L; + private static final long serialVersionUID = -3548087521669052891L; private Textbox txtCalc = new Textbox(); @@ -145,11 +145,7 @@ public class NumberBox extends Div { BigDecimal value = decimalBox.getValue(); if (value == null) return null; - - if (format != null) - return format.format(value); - else - return value.toPlainString(); + return decimalBox.getText(); } /** diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WNumberEditor.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WNumberEditor.java index ce363f4688..28466f34bc 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WNumberEditor.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WNumberEditor.java @@ -138,7 +138,10 @@ public class WNumberEditor extends WEditor implements ContextMenuListener // IDEMPIERE-989 Language lang = AEnv.getLanguage(Env.getCtx()); DecimalFormat format = DisplayType.getNumberFormat(displayType, lang); - getComponent().getDecimalbox().setFormat(format.toPattern()); + if (gridField != null && gridField.getFormatPattern() != null) + getComponent().getDecimalbox().setFormat(gridField.getFormatPattern()); + else + getComponent().getDecimalbox().setFormat(format.toPattern()); getComponent().getDecimalbox().setLocale(lang.getLocale()); getComponent().setFormat(format);