IDEMPIERE-1010 Thousands grouping separator is used for integers values / Implemented FormatPattern support for zk edition on numbers

This commit is contained in:
Carlos Ruiz 2013-06-02 19:46:03 -05:00
parent 9ff4a4874d
commit 6c939f1c7e
11 changed files with 209 additions and 21 deletions

View File

@ -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)

View File

@ -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)

View File

@ -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

View File

@ -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

View File

@ -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
;

View File

@ -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
;

View File

@ -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

View File

@ -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;

View File

@ -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

View File

@ -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();
}
/**

View File

@ -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);