Idempiere 4058 (#312)
* IDEMPIERE-4058 - tab editor: new options for editing and customizing fields (window customization) * IDEMPIERE-4058 tab editor: new options for editing and customizing fields (window customization) Fix issues with migration scripts Co-authored-by: muriloht <muriloht@devcoffee.com.br>
This commit is contained in:
parent
82a5897bb4
commit
014b45246f
|
@ -0,0 +1,43 @@
|
|||
SET SQLBLANKLINES ON
|
||||
SET DEFINE OFF
|
||||
|
||||
-- IDEMPIERE-4058 tab editor: new options for editing and customizing fields (window customization)
|
||||
-- Oct 8, 2019, 1:34:57 PM BRT
|
||||
UPDATE AD_Process SET AccessLevel='7',Updated=TO_DATE('2019-10-08 13:34:57','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=0 WHERE AD_Process_ID=200015
|
||||
;
|
||||
|
||||
-- Oct 8, 2019, 1:35:16 PM BRT
|
||||
INSERT INTO AD_ToolBarButton (AD_Client_ID,AD_Org_ID,Created,CreatedBy,ComponentName,IsActive,AD_ToolBarButton_ID,Name,Updated,UpdatedBy,IsCustomization,AD_ToolBarButton_UU,Action,AD_Tab_ID,AD_Process_ID,DisplayLogic,SeqNo,EntityType) VALUES (0,0,TO_DATE('2019-10-08 13:35:16','YYYY-MM-DD HH24:MI:SS'),0,'Tab Editor','Y',200109,'Tab Editor',TO_DATE('2019-10-08 13:35:16','YYYY-MM-DD HH24:MI:SS'),0,'N','3efa5e1a-99f1-4316-9724-7cc6f5b694eb','W',394,200015,'@IsActive@=Y',10,'D')
|
||||
;
|
||||
|
||||
-- Oct 8, 2019, 1:37:02 PM BRT
|
||||
INSERT INTO AD_Column (AD_Column_ID,Version,Name,Description,Help,AD_Table_ID,ColumnName,FieldLength,IsKey,IsParent,IsMandatory,IsTranslated,IsIdentifier,SeqNo,IsEncrypted,AD_Reference_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,IsHtml) VALUES (214327,0,'Field Group','Logical grouping of fields','The Field Group indicates the logical group that this field belongs to (History, Amounts, Quantities)',464,'AD_FieldGroup_ID',22,'N','N','N','N','N',0,'N',19,0,0,'Y',TO_DATE('2019-10-08 13:37:02','YYYY-MM-DD HH24:MI:SS'),0,TO_DATE('2019-10-08 13:37:02','YYYY-MM-DD HH24:MI:SS'),0,1500,'Y','N','D','N','N','N','Y','f69f9b76-94c6-466e-b7b7-5bd86ae339ba','Y',0,'N','N','N')
|
||||
;
|
||||
|
||||
-- Oct 8, 2019, 1:37:07 PM BRT
|
||||
UPDATE AD_Column SET FKConstraintName='ADFieldGroup_ADUserDefField', FKConstraintType='N',Updated=TO_DATE('2019-10-08 13:37:07','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=0 WHERE AD_Column_ID=214327
|
||||
;
|
||||
|
||||
-- Oct 8, 2019, 1:37:07 PM BRT
|
||||
ALTER TABLE AD_UserDef_Field ADD AD_FieldGroup_ID NUMBER(10) DEFAULT NULL
|
||||
;
|
||||
|
||||
-- Oct 8, 2019, 1:37:07 PM BRT
|
||||
ALTER TABLE AD_UserDef_Field ADD CONSTRAINT ADFieldGroup_ADUserDefField FOREIGN KEY (AD_FieldGroup_ID) REFERENCES ad_fieldgroup(ad_fieldgroup_id) DEFERRABLE INITIALLY DEFERRED
|
||||
;
|
||||
|
||||
-- Oct 8, 2019, 1:37:45 PM BRT
|
||||
INSERT INTO AD_Field (AD_Field_ID,Name,Description,Help,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 (206521,'Field Group','Logical grouping of fields','The Field Group indicates the logical group that this field belongs to (History, Amounts, Quantities)',395,214327,'Y',22,330,'N','N','N','N',0,0,'Y',TO_DATE('2019-10-08 13:37:45','YYYY-MM-DD HH24:MI:SS'),0,TO_DATE('2019-10-08 13:37:45','YYYY-MM-DD HH24:MI:SS'),0,'N','Y','D','6f71bd66-6a96-40ad-a016-42f74fcb3c95','Y',330,2)
|
||||
;
|
||||
|
||||
-- Oct 8, 2019, 1:38:59 PM BRT
|
||||
UPDATE AD_Field SET SeqNo=155, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_DATE('2019-10-08 13:38:59','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=0 WHERE AD_Field_ID=206521
|
||||
;
|
||||
|
||||
-- Oct 9, 2020, 8:40:22 AM BRT
|
||||
INSERT INTO AD_Message (MsgType,MsgText,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,AD_Message_ID,Value,EntityType,AD_Message_UU) VALUES ('I','Window customization Language != Session Language',0,0,'Y',TO_DATE('2020-10-09 08:40:22','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2020-10-09 08:40:22','YYYY-MM-DD HH24:MI:SS'),100,200641,'TabEditorWrongLanguage','D','dcf44ca0-91e1-4c26-a684-6c645ef11eeb')
|
||||
;
|
||||
|
||||
SELECT register_migration_script('202010211353_IDEMPIERE-4058.sql') FROM dual
|
||||
;
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
-- IDEMPIERE-4058 tab editor: new options for editing and customizing fields (window customization)
|
||||
-- Oct 8, 2019, 1:34:57 PM BRT
|
||||
UPDATE AD_Process SET AccessLevel='7',Updated=TO_TIMESTAMP('2019-10-08 13:34:57','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=0 WHERE AD_Process_ID=200015
|
||||
;
|
||||
|
||||
-- Oct 8, 2019, 1:35:16 PM BRT
|
||||
INSERT INTO AD_ToolBarButton (AD_Client_ID,AD_Org_ID,Created,CreatedBy,ComponentName,IsActive,AD_ToolBarButton_ID,Name,Updated,UpdatedBy,IsCustomization,AD_ToolBarButton_UU,"action",AD_Tab_ID,AD_Process_ID,DisplayLogic,SeqNo,EntityType) VALUES (0,0,TO_TIMESTAMP('2019-10-08 13:35:16','YYYY-MM-DD HH24:MI:SS'),0,'Tab Editor','Y',200109,'Tab Editor',TO_TIMESTAMP('2019-10-08 13:35:16','YYYY-MM-DD HH24:MI:SS'),0,'N','3efa5e1a-99f1-4316-9724-7cc6f5b694eb','W',394,200015,'@IsActive@=Y',10,'D')
|
||||
;
|
||||
|
||||
-- Oct 8, 2019, 1:37:02 PM BRT
|
||||
INSERT INTO AD_Column (AD_Column_ID,Version,Name,Description,Help,AD_Table_ID,ColumnName,FieldLength,IsKey,IsParent,IsMandatory,IsTranslated,IsIdentifier,SeqNo,IsEncrypted,AD_Reference_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,IsHtml) VALUES (214327,0,'Field Group','Logical grouping of fields','The Field Group indicates the logical group that this field belongs to (History, Amounts, Quantities)',464,'AD_FieldGroup_ID',22,'N','N','N','N','N',0,'N',19,0,0,'Y',TO_TIMESTAMP('2019-10-08 13:37:02','YYYY-MM-DD HH24:MI:SS'),0,TO_TIMESTAMP('2019-10-08 13:37:02','YYYY-MM-DD HH24:MI:SS'),0,1500,'Y','N','D','N','N','N','Y','f69f9b76-94c6-466e-b7b7-5bd86ae339ba','Y',0,'N','N','N')
|
||||
;
|
||||
|
||||
-- Oct 8, 2019, 1:37:07 PM BRT
|
||||
UPDATE AD_Column SET FKConstraintName='ADFieldGroup_ADUserDefField', FKConstraintType='N',Updated=TO_TIMESTAMP('2019-10-08 13:37:07','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=0 WHERE AD_Column_ID=214327
|
||||
;
|
||||
|
||||
-- Oct 8, 2019, 1:37:07 PM BRT
|
||||
ALTER TABLE AD_UserDef_Field ADD COLUMN AD_FieldGroup_ID NUMERIC(10) DEFAULT NULL
|
||||
;
|
||||
|
||||
-- Oct 8, 2019, 1:37:07 PM BRT
|
||||
ALTER TABLE AD_UserDef_Field ADD CONSTRAINT ADFieldGroup_ADUserDefField FOREIGN KEY (AD_FieldGroup_ID) REFERENCES ad_fieldgroup(ad_fieldgroup_id) DEFERRABLE INITIALLY DEFERRED
|
||||
;
|
||||
|
||||
-- Oct 8, 2019, 1:37:45 PM BRT
|
||||
INSERT INTO AD_Field (AD_Field_ID,Name,Description,Help,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 (206521,'Field Group','Logical grouping of fields','The Field Group indicates the logical group that this field belongs to (History, Amounts, Quantities)',395,214327,'Y',22,330,'N','N','N','N',0,0,'Y',TO_TIMESTAMP('2019-10-08 13:37:45','YYYY-MM-DD HH24:MI:SS'),0,TO_TIMESTAMP('2019-10-08 13:37:45','YYYY-MM-DD HH24:MI:SS'),0,'N','Y','D','6f71bd66-6a96-40ad-a016-42f74fcb3c95','Y',330,2)
|
||||
;
|
||||
|
||||
-- Oct 8, 2019, 1:38:59 PM BRT
|
||||
UPDATE AD_Field SET SeqNo=155, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2019-10-08 13:38:59','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=0 WHERE AD_Field_ID=206521
|
||||
;
|
||||
|
||||
-- Oct 9, 2020, 8:40:22 AM BRT
|
||||
INSERT INTO AD_Message (MsgType,MsgText,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,AD_Message_ID,Value,EntityType,AD_Message_UU) VALUES ('I','Window customization Language != Session Language',0,0,'Y',TO_TIMESTAMP('2020-10-09 08:40:22','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2020-10-09 08:40:22','YYYY-MM-DD HH24:MI:SS'),100,200641,'TabEditorWrongLanguage','D','dcf44ca0-91e1-4c26-a684-6c645ef11eeb')
|
||||
;
|
||||
|
||||
SELECT register_migration_script('202010211353_IDEMPIERE-4058.sql') FROM dual
|
||||
;
|
||||
|
|
@ -186,6 +186,14 @@ public class GridFieldVO implements Serializable, Cloneable
|
|||
if (userDef.getPlaceholder() != null)
|
||||
vo.Placeholder = userDef.getPlaceholder();
|
||||
|
||||
//devCoffee 8535
|
||||
if (userDef.getAD_FieldGroup_ID() > 0)
|
||||
{
|
||||
vo.FieldGroup = ((X_AD_FieldGroup)userDef.getAD_FieldGroup()).get_Translation(I_AD_FieldGroup.COLUMNNAME_Name);
|
||||
vo.FieldGroupType = userDef.getAD_FieldGroup().getFieldGroupType();
|
||||
}
|
||||
//fim devCoffee 8535
|
||||
|
||||
if (userDef.getIsAutocomplete() != null)
|
||||
vo.IsAutocomplete = "Y".equals(userDef.getIsAutocomplete());
|
||||
}
|
||||
|
|
|
@ -49,6 +49,21 @@ public interface I_AD_UserDef_Field
|
|||
*/
|
||||
public int getAD_Client_ID();
|
||||
|
||||
/** Column name AD_FieldGroup_ID */
|
||||
public static final String COLUMNNAME_AD_FieldGroup_ID = "AD_FieldGroup_ID";
|
||||
|
||||
/** Set Field Group.
|
||||
* Logical grouping of fields
|
||||
*/
|
||||
public void setAD_FieldGroup_ID (int AD_FieldGroup_ID);
|
||||
|
||||
/** Get Field Group.
|
||||
* Logical grouping of fields
|
||||
*/
|
||||
public int getAD_FieldGroup_ID();
|
||||
|
||||
public org.compiere.model.I_AD_FieldGroup getAD_FieldGroup() throws RuntimeException;
|
||||
|
||||
/** Column name AD_Field_ID */
|
||||
public static final String COLUMNNAME_AD_Field_ID = "AD_Field_ID";
|
||||
|
||||
|
|
|
@ -110,6 +110,20 @@ public class MUserDefField extends X_AD_UserDef_Field implements ImmutablePOSupp
|
|||
* @return
|
||||
*/
|
||||
public static MUserDefField get (Properties ctx, int AD_Field_ID, int AD_Tab_ID, int AD_Window_ID )
|
||||
{
|
||||
return get(ctx, AD_Field_ID, AD_Tab_ID, AD_Window_ID, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get matching MUserDefField related to current field and user definition for window and tab
|
||||
* @param ctx
|
||||
* @param AD_Field_ID
|
||||
* @param AD_Tab_ID
|
||||
* @param AD_Window_ID
|
||||
* @param reload
|
||||
* @return
|
||||
*/
|
||||
public static MUserDefField get (Properties ctx, int AD_Field_ID, int AD_Tab_ID, int AD_Window_ID , boolean reload)
|
||||
{
|
||||
|
||||
MUserDefWin userdefWin = MUserDefWin.getBestMatch(ctx, AD_Window_ID);
|
||||
|
@ -123,7 +137,7 @@ public class MUserDefField extends X_AD_UserDef_Field implements ImmutablePOSupp
|
|||
String key = new StringBuilder().append(AD_Field_ID).append("_")
|
||||
.append(userdefTab.getAD_UserDef_Tab_ID())
|
||||
.toString();
|
||||
if (s_cache.containsKey(key))
|
||||
if (!reload && s_cache.containsKey(key))
|
||||
return s_cache.get(ctx, key, e -> new MUserDefField(ctx, e));
|
||||
|
||||
MUserDefField retValue = null;
|
||||
|
|
|
@ -74,6 +74,34 @@ public class X_AD_UserDef_Field extends PO implements I_AD_UserDef_Field, I_Pers
|
|||
return sb.toString();
|
||||
}
|
||||
|
||||
public org.compiere.model.I_AD_FieldGroup getAD_FieldGroup() throws RuntimeException
|
||||
{
|
||||
return (org.compiere.model.I_AD_FieldGroup)MTable.get(getCtx(), org.compiere.model.I_AD_FieldGroup.Table_Name)
|
||||
.getPO(getAD_FieldGroup_ID(), get_TrxName()); }
|
||||
|
||||
/** Set Field Group.
|
||||
@param AD_FieldGroup_ID
|
||||
Logical grouping of fields
|
||||
*/
|
||||
public void setAD_FieldGroup_ID (int AD_FieldGroup_ID)
|
||||
{
|
||||
if (AD_FieldGroup_ID < 1)
|
||||
set_ValueNoCheck (COLUMNNAME_AD_FieldGroup_ID, null);
|
||||
else
|
||||
set_ValueNoCheck (COLUMNNAME_AD_FieldGroup_ID, Integer.valueOf(AD_FieldGroup_ID));
|
||||
}
|
||||
|
||||
/** Get Field Group.
|
||||
@return Logical grouping of fields
|
||||
*/
|
||||
public int getAD_FieldGroup_ID ()
|
||||
{
|
||||
Integer ii = (Integer)get_Value(COLUMNNAME_AD_FieldGroup_ID);
|
||||
if (ii == null)
|
||||
return 0;
|
||||
return ii.intValue();
|
||||
}
|
||||
|
||||
public org.compiere.model.I_AD_Field getAD_Field() throws RuntimeException
|
||||
{
|
||||
return (org.compiere.model.I_AD_Field)MTable.get(getCtx(), org.compiere.model.I_AD_Field.Table_Name)
|
||||
|
|
|
@ -37,6 +37,7 @@ import org.adempiere.webui.component.ListItem;
|
|||
import org.adempiere.webui.component.Listbox;
|
||||
import org.adempiere.webui.component.Row;
|
||||
import org.adempiere.webui.component.Rows;
|
||||
import org.adempiere.webui.component.Textbox;
|
||||
import org.adempiere.webui.editor.WEditor;
|
||||
import org.adempiere.webui.editor.WImageEditor;
|
||||
import org.adempiere.webui.editor.WNumberEditor;
|
||||
|
@ -51,11 +52,14 @@ import org.adempiere.webui.panel.IFormController;
|
|||
import org.adempiere.webui.panel.WTabEditorForm;
|
||||
import org.adempiere.webui.session.SessionManager;
|
||||
import org.adempiere.webui.util.ZKUpdateUtil;
|
||||
import org.adempiere.webui.window.FDialog;
|
||||
import org.compiere.apps.form.TabEditor;
|
||||
import org.compiere.model.GridField;
|
||||
import org.compiere.model.MColumn;
|
||||
import org.compiere.model.MField;
|
||||
import org.compiere.model.MLookup;
|
||||
import org.compiere.model.MLookupFactory;
|
||||
import org.compiere.model.MUserDefTab;
|
||||
import org.compiere.model.X_AD_FieldGroup;
|
||||
import org.compiere.util.DisplayType;
|
||||
import org.compiere.util.Env;
|
||||
|
@ -103,12 +107,20 @@ public class WTabEditor extends TabEditor implements IFormController, EventListe
|
|||
private ConfirmPanel confirmPanel = new ConfirmPanel(true);
|
||||
|
||||
WEditor editorName = null;
|
||||
WEditor editorDescription = null;
|
||||
WEditor editorHelp = null;
|
||||
WEditor editorPlaceholder = null;
|
||||
WEditor editorAD_FieldGroup_ID = null;
|
||||
WEditor editorIsDisplayed = null;
|
||||
WEditor editorSeqNo = null;
|
||||
WEditor editorXPosition = null;
|
||||
WEditor editorColumnSpan = null;
|
||||
WEditor editorNumLines = null;
|
||||
WEditor editorDisplayLogic = null;
|
||||
WEditor editorMandatoryLogic = null;
|
||||
WEditor editorReadOnlyLogic = null;
|
||||
WEditor editorColumn = null;
|
||||
WYesNoEditor editorIsReadOnly = null;
|
||||
|
||||
private Listbox visible = new Listbox();
|
||||
private Listbox invisible = new Listbox();
|
||||
|
@ -135,7 +147,25 @@ public class WTabEditor extends TabEditor implements IFormController, EventListe
|
|||
public void initForm() {
|
||||
try
|
||||
{
|
||||
initMFields(tabform.getWindowNo(), tabform.getProcessInfo().getRecord_ID());
|
||||
int Table_ID = tabform.getProcessInfo().getTable_ID();
|
||||
int Record_ID = tabform.getProcessInfo().getRecord_ID();
|
||||
// check if the editor is running from system or client (tab customization)
|
||||
if (Table_ID == MUserDefTab.Table_ID)
|
||||
{
|
||||
MUserDefTab udt = new MUserDefTab(Env.getCtx(), Record_ID, null);
|
||||
|
||||
if (udt.getAD_UserDef_Win().getAD_Language() != null && !udt.getAD_UserDef_Win().getAD_Language().equals(Env.getAD_Language(Env.getCtx())))
|
||||
{
|
||||
FDialog.error(m_WindowNo, "TabEditorWrongLanguage");
|
||||
tabform.detach();
|
||||
return;
|
||||
}
|
||||
|
||||
Record_ID = udt.getAD_Tab_ID();
|
||||
isSystem = false;
|
||||
AD_UserDef_Tab_ID = tabform.getProcessInfo().getRecord_ID();
|
||||
}
|
||||
initMFields(tabform.getWindowNo(), Record_ID);
|
||||
dynList();
|
||||
jbInit();
|
||||
LayoutUtils.sendDeferLayoutEvent(mainLayout, 100);
|
||||
|
@ -211,6 +241,10 @@ public class WTabEditor extends TabEditor implements IFormController, EventListe
|
|||
if (!gridField.isDisplayed() || gridField.isToolbarOnlyButton())
|
||||
continue;
|
||||
|
||||
// when the field is at client level reload with customization
|
||||
if (!isSystem && !field.is_Changed())
|
||||
field = loadUserDefField(field);
|
||||
|
||||
// field group
|
||||
String fieldGroup = gridField.getFieldGroup();
|
||||
if (!Util.isEmpty(fieldGroup) && !fieldGroup.equals(currentFieldGroup)) // group changed
|
||||
|
@ -398,9 +432,12 @@ public class WTabEditor extends TabEditor implements IFormController, EventListe
|
|||
//
|
||||
Columns columns = new Columns();
|
||||
gridView.appendChild(columns);
|
||||
gridView.setVflex(true);
|
||||
gridView.setStyle("overflow-h: hidden");
|
||||
//
|
||||
Column column = new Column();
|
||||
columns.appendChild(column);
|
||||
|
||||
ZKUpdateUtil.setHflex(column, "min");
|
||||
column.setAlign("right");
|
||||
|
||||
|
@ -414,28 +451,74 @@ public class WTabEditor extends TabEditor implements IFormController, EventListe
|
|||
|
||||
row = new Row();
|
||||
Group group = new Group(Msg.getMsg(Env.getCtx(), "Property"));
|
||||
//group.setStyle("padding-right: 15px");
|
||||
Cell cell = (Cell) group.getFirstChild();
|
||||
cell.setSclass("z-group-inner");
|
||||
cell.setColspan(2);
|
||||
group.setOpen(true);
|
||||
|
||||
rows.appendChild(group);
|
||||
|
||||
row = new Row();
|
||||
Label labelName = new Label(Msg.getElement(Env.getCtx(), MField.COLUMNNAME_Name));
|
||||
editorName = new WStringEditor(MField.COLUMNNAME_Name, false, true, false, 0, 0, null, null);
|
||||
editorName = new WStringEditor(MField.COLUMNNAME_Name, false, false, true, 1000, 1000, null, null);
|
||||
ZKUpdateUtil.setHflex(((WStringEditor) editorName).getComponent(), "1");
|
||||
row.appendChild(labelName.rightAlign());
|
||||
row.appendChild(editorName.getComponent());
|
||||
// editorName.addValueChangeListener(this);
|
||||
editorName.addValueChangeListener(this);
|
||||
row.setGroup(group);
|
||||
rows.appendChild(row);
|
||||
|
||||
row = new Row();
|
||||
Label labelDescription = new Label(Msg.getElement(Env.getCtx(), MField.COLUMNNAME_Description));
|
||||
editorDescription = new WStringEditor(MField.COLUMNNAME_Description, false, false, false, 1000, 1000, null,
|
||||
null);
|
||||
((Textbox) editorDescription.getComponent()).setMultiline(true);
|
||||
row.appendChild(labelDescription.rightAlign());
|
||||
row.appendChild(editorDescription.getComponent());
|
||||
//ZKUpdateUtil.setWidth((HtmlBasedComponent) row.getLastChild(), "100%");
|
||||
//ZKUpdateUtil.setHeight((HtmlBasedComponent) row.getLastChild(), "80px");
|
||||
editorDescription.addValueChangeListener(this);
|
||||
row.setGroup(group);
|
||||
rows.appendChild(row);
|
||||
|
||||
row = new Row();
|
||||
Label labelHelp = new Label(Msg.getElement(Env.getCtx(), MField.COLUMNNAME_Help));
|
||||
editorHelp = new WStringEditor(MField.COLUMNNAME_Help, false, false, false, 0, 0, null, null);
|
||||
((Textbox) editorHelp.getComponent()).setMultiline(true);
|
||||
row.appendChild(labelHelp.rightAlign());
|
||||
row.appendChild(editorHelp.getComponent());
|
||||
//ZKUpdateUtil.setWidth((HtmlBasedComponent) row.getLastChild(), "100%");
|
||||
//ZKUpdateUtil.setHeight((HtmlBasedComponent) row.getLastChild(), "80px");
|
||||
editorHelp.addValueChangeListener(this);
|
||||
row.setGroup(group);
|
||||
rows.appendChild(row);
|
||||
|
||||
row = new Row();
|
||||
Label labelPlaceholder = new Label(Msg.getElement(Env.getCtx(), MField.COLUMNNAME_Placeholder));
|
||||
editorPlaceholder = new WStringEditor(MField.COLUMNNAME_Placeholder, false, false, true, 1000, 1000, null,
|
||||
null);
|
||||
ZKUpdateUtil.setHflex(((WStringEditor) editorPlaceholder).getComponent(), "1");
|
||||
row.appendChild(labelPlaceholder.rightAlign());
|
||||
row.appendChild(editorPlaceholder.getComponent());
|
||||
editorPlaceholder.addValueChangeListener(this);
|
||||
row.setGroup(group);
|
||||
rows.appendChild(row);
|
||||
|
||||
row = new Row();
|
||||
Label labelColumn = new Label(Msg.getElement(Env.getCtx(), MField.COLUMNNAME_AD_Column_ID));
|
||||
editorColumn = new WStringEditor(MField.COLUMNNAME_AD_Column_ID, false, true, false, 0, 0, null, null);
|
||||
row.appendChild(labelColumn.rightAlign());
|
||||
row.appendChild(editorColumn.getComponent());
|
||||
row.setGroup(group);
|
||||
rows.appendChild(row);
|
||||
|
||||
row = new Row();
|
||||
Label labelIsDisplayed = new Label(Msg.getElement(Env.getCtx(), MField.COLUMNNAME_IsDisplayed));
|
||||
editorIsDisplayed = new WYesNoEditor(MField.COLUMNNAME_IsDisplayed, "", labelIsDisplayed.getValue(), false, true, false);
|
||||
editorIsDisplayed = new WYesNoEditor(MField.COLUMNNAME_IsDisplayed, "", labelIsDisplayed.getValue(), false, false, false);
|
||||
row.appendChild(labelIsDisplayed.rightAlign());
|
||||
row.appendChild(editorIsDisplayed.getComponent());
|
||||
// editorIsDisplayed.addValueChangeListener(this);
|
||||
editorIsDisplayed.addValueChangeListener(this);
|
||||
row.setGroup(group);
|
||||
rows.appendChild(row);
|
||||
|
||||
|
@ -486,6 +569,54 @@ public class WTabEditor extends TabEditor implements IFormController, EventListe
|
|||
row.setGroup(group);
|
||||
rows.appendChild(row);
|
||||
|
||||
row = new Row();
|
||||
Label labelDisplayLogic = new Label(Msg.getElement(Env.getCtx(), MField.COLUMNNAME_DisplayLogic));
|
||||
editorDisplayLogic = new WStringEditor(MField.COLUMNNAME_DisplayLogic, false, false, true, 1000, 1000, null,
|
||||
null);
|
||||
((Textbox) editorDisplayLogic.getComponent()).setMultiline(true);
|
||||
row.appendChild(labelDisplayLogic.rightAlign());
|
||||
row.appendChild(editorDisplayLogic.getComponent());
|
||||
//ZKUpdateUtil.setWidth((HtmlBasedComponent) row.getLastChild(), "100%");
|
||||
//ZKUpdateUtil.setHeight((HtmlBasedComponent) row.getLastChild(), "80px");
|
||||
editorDisplayLogic.addValueChangeListener(this);
|
||||
row.setGroup(group);
|
||||
rows.appendChild(row);
|
||||
|
||||
row = new Row();
|
||||
Label labelMandatoryLogic = new Label(Msg.getElement(Env.getCtx(), MField.COLUMNNAME_MandatoryLogic));
|
||||
editorMandatoryLogic = new WStringEditor(MField.COLUMNNAME_MandatoryLogic, false, false, true, 1000, 1000, null,
|
||||
null);
|
||||
((Textbox) editorMandatoryLogic.getComponent()).setMultiline(true);
|
||||
row.appendChild(labelMandatoryLogic.rightAlign());
|
||||
row.appendChild(editorMandatoryLogic.getComponent());
|
||||
//ZKUpdateUtil.setWidth((HtmlBasedComponent) row.getLastChild(), "100%");
|
||||
//ZKUpdateUtil.setHeight((HtmlBasedComponent) row.getLastChild(), "80px");
|
||||
editorMandatoryLogic.addValueChangeListener(this);
|
||||
row.setGroup(group);
|
||||
rows.appendChild(row);
|
||||
|
||||
row = new Row();
|
||||
Label labelReadOnlyLogic = new Label(Msg.getElement(Env.getCtx(), MField.COLUMNNAME_ReadOnlyLogic));
|
||||
editorReadOnlyLogic = new WStringEditor(MField.COLUMNNAME_ReadOnlyLogic, false, false, true, 1000, 1000, null,
|
||||
null);
|
||||
((Textbox) editorReadOnlyLogic.getComponent()).setMultiline(true);
|
||||
row.appendChild(labelReadOnlyLogic.rightAlign());
|
||||
row.appendChild(editorReadOnlyLogic.getComponent());
|
||||
//ZKUpdateUtil.setWidth((HtmlBasedComponent) row.getLastChild(), "100%");
|
||||
//ZKUpdateUtil.setHeight((HtmlBasedComponent) row.getLastChild(), "80px");
|
||||
editorReadOnlyLogic.addValueChangeListener(this);
|
||||
row.setGroup(group);
|
||||
rows.appendChild(row);
|
||||
|
||||
row = new Row();
|
||||
Label labelIsReadOnly = new Label(Msg.getElement(Env.getCtx(), MField.COLUMNNAME_IsReadOnly));
|
||||
editorIsReadOnly = new WYesNoEditor(MField.COLUMNNAME_IsReadOnly, "", "", true, false, true);
|
||||
row.appendChild(labelIsReadOnly.rightAlign());
|
||||
row.appendChild(editorIsReadOnly.getComponent());
|
||||
editorIsReadOnly.addValueChangeListener(this);
|
||||
row.setGroup(group);
|
||||
rows.appendChild(row);
|
||||
|
||||
row = new Row();
|
||||
Separator esep = new Separator("horizontal");
|
||||
esep.setSpacing("10px");
|
||||
|
@ -525,6 +656,8 @@ public class WTabEditor extends TabEditor implements IFormController, EventListe
|
|||
mainLayout.appendChild(east);
|
||||
east.appendChild(propGrid);
|
||||
ZKUpdateUtil.setWidth(east, "320px");
|
||||
east.setCollapsible(true);
|
||||
east.setSplittable(true);
|
||||
|
||||
ListHead visibleHead = new ListHead();
|
||||
visibleHead.setParent(visible);
|
||||
|
@ -762,11 +895,17 @@ public class WTabEditor extends TabEditor implements IFormController, EventListe
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void setProperties(MField field) {
|
||||
String displayLogic = field.getDisplayLogic() == null ? "" : field.getDisplayLogic();
|
||||
String mandatoryLogic = field.getMandatoryLogic() == null ? "" : field.getMandatoryLogic();
|
||||
String readOnlyLogic = field.getReadOnlyLogic() == null ? "" : field.getReadOnlyLogic();
|
||||
|
||||
editorName.setValue(field.getName());
|
||||
editorDescription.setValue(field.getDescription());
|
||||
editorHelp.setValue(field.getHelp());
|
||||
editorPlaceholder.setValue(field.getPlaceholder());
|
||||
editorSeqNo.setValue(field.getSeqNo());
|
||||
editorIsDisplayed.setValue(field.isDisplayed());
|
||||
if (field.getAD_FieldGroup_ID() > 0)
|
||||
|
@ -776,20 +915,40 @@ public class WTabEditor extends TabEditor implements IFormController, EventListe
|
|||
editorXPosition.setValue(field.getXPosition());
|
||||
editorColumnSpan.setValue(field.getColumnSpan());
|
||||
editorNumLines.setValue(field.getNumLines());
|
||||
editorDisplayLogic.setValue(displayLogic);
|
||||
editorMandatoryLogic.setValue(mandatoryLogic);
|
||||
editorReadOnlyLogic.setValue(readOnlyLogic);
|
||||
editorIsReadOnly.setValue(field.isReadOnly());
|
||||
editorColumn.setValue(MColumn.getColumnName(Env.getCtx(), field.getAD_Column_ID()));
|
||||
|
||||
GridField gridField = getGridField(field);
|
||||
String fieldGroup = "";
|
||||
String fieldGroupType = "";
|
||||
if (field.getAD_FieldGroup_ID() > 0) {
|
||||
if (isBaseLang)
|
||||
{
|
||||
fieldGroup = field.getAD_FieldGroup().getName();
|
||||
}
|
||||
else
|
||||
{
|
||||
fieldGroup = ((X_AD_FieldGroup) field.getAD_FieldGroup()).get_Translation(X_AD_FieldGroup.COLUMNNAME_Name);
|
||||
}
|
||||
fieldGroupType = field.getAD_FieldGroup().getFieldGroupType();
|
||||
}
|
||||
gridField.getVO().Header = field.getName();
|
||||
gridField.getVO().Description = field.getDescription();
|
||||
gridField.getVO().Help = field.getHelp();
|
||||
gridField.getVO().Placeholder = field.getPlaceholder();
|
||||
gridField.getVO().IsDisplayed = field.isDisplayed();
|
||||
gridField.getVO().FieldGroup = fieldGroup;
|
||||
gridField.getVO().FieldGroupType = fieldGroupType;
|
||||
gridField.getVO().XPosition = field.getXPosition();
|
||||
gridField.getVO().ColumnSpan = field.getColumnSpan();
|
||||
gridField.getVO().NumLines = field.getNumLines();
|
||||
gridField.getVO().DisplayLogic = displayLogic;
|
||||
gridField.getVO().MandatoryLogic = mandatoryLogic;
|
||||
gridField.getVO().ReadOnlyLogic = readOnlyLogic;
|
||||
gridField.getVO().IsReadOnly = field.isReadOnly();
|
||||
|
||||
}
|
||||
|
||||
|
@ -807,6 +966,11 @@ public class WTabEditor extends TabEditor implements IFormController, EventListe
|
|||
GridField gridField = getGridField(field);
|
||||
if (!field.isActive() || gridField.isToolbarOnlyButton())
|
||||
continue;
|
||||
|
||||
// when the field is at client level reload with customization
|
||||
if (!isSystem && !field.is_Changed())
|
||||
field = loadUserDefField(field);
|
||||
|
||||
KeyNamePair pair = new KeyNamePair(field.getAD_Field_ID(), field.getName());
|
||||
if (field.isDisplayed()) {
|
||||
visible.addItem(pair);
|
||||
|
@ -827,21 +991,53 @@ public class WTabEditor extends TabEditor implements IFormController, EventListe
|
|||
public void valueChange(ValueChangeEvent e) {
|
||||
// changed a value on the properties editors
|
||||
MField field = getActiveMField();
|
||||
// when the field is at client level reload with customization
|
||||
if (!isSystem && !field.is_Changed())
|
||||
field = loadUserDefField(field);
|
||||
|
||||
if (field != null) {
|
||||
String propertyName = e.getPropertyName();
|
||||
int intvalue = 0;
|
||||
int intValue = 0;
|
||||
String stringValue = "";
|
||||
Boolean booleanValue = false;
|
||||
if (e.getNewValue() != null)
|
||||
intvalue = (Integer) e.getNewValue();
|
||||
{
|
||||
if (String.class.isInstance(e.getNewValue()))
|
||||
stringValue = (String) e.getNewValue();
|
||||
else if (e.getNewValue() instanceof Boolean)
|
||||
booleanValue = (boolean) e.getNewValue();
|
||||
else
|
||||
intValue = (Integer) e.getNewValue();
|
||||
}
|
||||
|
||||
if (MField.COLUMNNAME_AD_FieldGroup_ID.equals(propertyName)) {
|
||||
field.setAD_FieldGroup_ID(intvalue);
|
||||
field.setAD_FieldGroup_ID(intValue);
|
||||
} else if (MField.COLUMNNAME_XPosition.equals(propertyName)) {
|
||||
field.setXPosition(intvalue);
|
||||
field.setXPosition(intValue);
|
||||
} else if (MField.COLUMNNAME_ColumnSpan.equals(propertyName)) {
|
||||
int prevcolspan = field.getColumnSpan();
|
||||
if (!field.set_ValueOfColumnReturningBoolean(MField.COLUMNNAME_ColumnSpan, intvalue))
|
||||
if (!field.set_ValueOfColumnReturningBoolean(MField.COLUMNNAME_ColumnSpan, intValue))
|
||||
field.setColumnSpan(prevcolspan);
|
||||
} else if (MField.COLUMNNAME_NumLines.equals(propertyName)) {
|
||||
field.setNumLines(intvalue);
|
||||
field.setNumLines(intValue);
|
||||
} else if (MField.COLUMNNAME_DisplayLogic.equals(propertyName)) {
|
||||
field.setDisplayLogic(stringValue);
|
||||
} else if (MField.COLUMNNAME_MandatoryLogic.equals(propertyName)) {
|
||||
field.setMandatoryLogic(stringValue);
|
||||
} else if (MField.COLUMNNAME_ReadOnlyLogic.equals(propertyName)) {
|
||||
field.setReadOnlyLogic(stringValue);
|
||||
} else if (MField.COLUMNNAME_IsReadOnly.equals(propertyName)) {
|
||||
field.setIsReadOnly(booleanValue);
|
||||
} else if (MField.COLUMNNAME_Name.equals(propertyName)) {
|
||||
field.setName(stringValue);
|
||||
} else if (MField.COLUMNNAME_IsDisplayed.equals(propertyName)) {
|
||||
field.setIsDisplayed(booleanValue);
|
||||
} else if (MField.COLUMNNAME_Description.equals(propertyName)) {
|
||||
field.setDescription(stringValue);
|
||||
} else if (MField.COLUMNNAME_Help.equals(propertyName)) {
|
||||
field.setHelp(stringValue);
|
||||
} else if (MField.COLUMNNAME_Placeholder.equals(propertyName)) {
|
||||
field.setPlaceholder(stringValue);
|
||||
}
|
||||
setProperties(field);
|
||||
repaintGrid();
|
||||
|
|
|
@ -14,17 +14,23 @@
|
|||
|
||||
package org.compiere.apps.form;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.compiere.model.GridField;
|
||||
import org.compiere.model.I_AD_Field;
|
||||
import org.compiere.model.MField;
|
||||
import org.compiere.model.MTab;
|
||||
import org.compiere.model.MUserDefField;
|
||||
import org.compiere.util.CLogger;
|
||||
import org.compiere.util.DB;
|
||||
import org.compiere.util.Env;
|
||||
|
||||
/**
|
||||
|
@ -51,6 +57,12 @@ public class TabEditor
|
|||
|
||||
private Map<Integer, GridField> mapGridField = new HashMap<Integer, GridField>();
|
||||
|
||||
protected boolean isBaseLang = Env.isBaseLanguage(Env.getCtx(), null);
|
||||
|
||||
protected boolean isSystem = true;
|
||||
|
||||
protected int AD_UserDef_Tab_ID;
|
||||
|
||||
public List<GridField> getGridFields() {
|
||||
return gridFields;
|
||||
}
|
||||
|
@ -60,6 +72,7 @@ public class TabEditor
|
|||
}
|
||||
|
||||
public List<MField> getMFields() {
|
||||
|
||||
return fields;
|
||||
}
|
||||
|
||||
|
@ -70,6 +83,36 @@ public class TabEditor
|
|||
gridFields.add(gridField);
|
||||
mapGridField.put(gridField.getAD_Field_ID(), gridField);
|
||||
MField field = new MField(Env.getCtx(), gridField.getAD_Field_ID(), null);
|
||||
|
||||
// load translated values and ovewrite field with it
|
||||
if (!isBaseLang)
|
||||
{
|
||||
field.setName(field.get_Translation(MField.COLUMNNAME_Name, Env.getLanguage(Env.getCtx()).getAD_Language(), true));
|
||||
field.setDescription(field.get_Translation(MField.COLUMNNAME_Description, Env.getLanguage(Env.getCtx()).getAD_Language(), true));
|
||||
field.setPlaceholder(field.get_Translation(MField.COLUMNNAME_Placeholder, Env.getLanguage(Env.getCtx()).getAD_Language(), true));
|
||||
field.setHelp(field.get_Translation(MField.COLUMNNAME_Help, Env.getLanguage(Env.getCtx()).getAD_Language(), true));
|
||||
gridField.getVO().Header = field.get_Translation(MField.COLUMNNAME_Name, Env.getLanguage(Env.getCtx()).getAD_Language(), true);
|
||||
gridField.getVO().Description = field.get_Translation(MField.COLUMNNAME_Description, Env.getLanguage(Env.getCtx()).getAD_Language(), true);
|
||||
gridField.getVO().Placeholder = field.get_Translation(MField.COLUMNNAME_Placeholder, Env.getLanguage(Env.getCtx()).getAD_Language(), true);
|
||||
gridField.getVO().Help = field.get_Translation(MField.COLUMNNAME_Help, Env.getLanguage(Env.getCtx()).getAD_Language(), true);
|
||||
}
|
||||
|
||||
// if not system level load customization values and field with it
|
||||
if (!isSystem) {
|
||||
field = loadUserDefField(field);
|
||||
if (field != null)
|
||||
{
|
||||
gridField.getVO().Header = field.getName();
|
||||
gridField.getVO().Description = field.getDescription();
|
||||
gridField.getVO().Placeholder = field.getPlaceholder();
|
||||
gridField.getVO().Help = field.getHelp();
|
||||
gridField.getVO().NumLines = field.getNumLines();
|
||||
gridField.getVO().XPosition = field.getXPosition();
|
||||
gridField.getVO().ColumnSpan = field.getColumnSpan();
|
||||
gridField.getVO().IsDisplayed = field.isDisplayed();
|
||||
}
|
||||
}
|
||||
|
||||
fields.add(field);
|
||||
mapField.put(field.getAD_Field_ID(), field);
|
||||
gridField.getVO().IsReadOnly = true;
|
||||
|
@ -82,8 +125,14 @@ public class TabEditor
|
|||
|
||||
public boolean cmd_save() {
|
||||
for (MField field : fields) {
|
||||
if (field.isActive())
|
||||
if (field.isActive()) {
|
||||
if (isSystem) {
|
||||
updateTrl(field);
|
||||
field.saveEx();
|
||||
} else {
|
||||
saveUserDefField(field);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -119,7 +168,8 @@ public class TabEditor
|
|||
return compare1.compareTo(compare2);
|
||||
}
|
||||
});
|
||||
|
||||
// only apply the SeqNo increment when running on system level
|
||||
if (isSystem) {
|
||||
int seq = 10;
|
||||
for (MField field : fields) {
|
||||
if (field.isDisplayed()) {
|
||||
|
@ -129,6 +179,7 @@ public class TabEditor
|
|||
field.setSeqNo(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Collections.sort(gridFields, new Comparator<GridField>() {
|
||||
@Override
|
||||
|
@ -149,4 +200,252 @@ public class TabEditor
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* Load MUserDefField data to MField
|
||||
*
|
||||
* @param field
|
||||
* @return MField
|
||||
*/
|
||||
protected MField loadUserDefField(MField field) {
|
||||
|
||||
if (field == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
MUserDefField userDefField = MUserDefField.get(Env.getCtx(), field.getAD_Field_ID(), m_tab.getAD_Tab_ID(), m_tab.getAD_Window_ID(), true);
|
||||
|
||||
if (userDefField != null) {
|
||||
if (userDefField.getName() != null)
|
||||
field.setName(userDefField.getName());
|
||||
|
||||
if (userDefField.getDescription() != null)
|
||||
field.setDescription(userDefField.getDescription());
|
||||
|
||||
if (userDefField.getHelp() != null)
|
||||
field.setHelp(userDefField.getHelp());
|
||||
|
||||
if (userDefField.getPlaceholder() != null)
|
||||
field.setPlaceholder(userDefField.getPlaceholder());
|
||||
|
||||
field.setIsActive(userDefField.isActive());
|
||||
field.setDisplayLogic(userDefField.getDisplayLogic());
|
||||
field.setDisplayLength(userDefField.getDisplayLength());
|
||||
field.setIsDisplayed(userDefField.getIsDisplayed() == null ? field.isDisplayed()
|
||||
: "Y".equals(userDefField.getIsDisplayed()));
|
||||
field.setIsReadOnly(userDefField.getIsReadOnly() == null ? field.isReadOnly()
|
||||
: "Y".equals(userDefField.getIsReadOnly()));
|
||||
field.setSeqNo(userDefField.getSeqNo() != 0 ? userDefField.getSeqNo() : field.getSeqNo());
|
||||
field.setXPosition(userDefField.getXPosition() > 0 ? userDefField.getXPosition():field.getXPosition());
|
||||
field.setNumLines(userDefField.getNumLines() > 0?userDefField.getNumLines():field.getNumLines());
|
||||
field.setColumnSpan(userDefField.getColumnSpan() > 0?userDefField.getColumnSpan():field.getColumnSpan());
|
||||
field.setSortNo(BigDecimal.valueOf(userDefField.getSortNo()));
|
||||
field.setReadOnlyLogic(userDefField.getReadOnlyLogic());
|
||||
field.setMandatoryLogic(userDefField.getMandatoryLogic());
|
||||
|
||||
if (userDefField.getAD_FieldGroup_ID() > 0)
|
||||
field.setAD_FieldGroup_ID(userDefField.getAD_FieldGroup_ID());
|
||||
|
||||
}
|
||||
|
||||
return field;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert MField to MUserDefField and save
|
||||
*
|
||||
* @param field
|
||||
*/
|
||||
protected void saveUserDefField(MField field) {
|
||||
|
||||
MField defaultField = new MField(Env.getCtx(), field.get_ID(), null);
|
||||
|
||||
// check if translated values was really changed and restore default value if not
|
||||
if (field.getName() != null && field.getName().equals(defaultField.get_Translation(MField.COLUMNNAME_Name, Env.getAD_Language(Env.getCtx()), true)))
|
||||
field.setName(defaultField.getName());
|
||||
if (field.getDescription() != null && field.getDescription().equals(defaultField.get_Translation(MField.COLUMNNAME_Description, Env.getAD_Language(Env.getCtx()), true)))
|
||||
field.setDescription(defaultField.getDescription());
|
||||
if (field.getHelp() != null && field.getHelp().equals(defaultField.get_Translation(MField.COLUMNNAME_Help, Env.getAD_Language(Env.getCtx()), true)))
|
||||
field.setHelp(defaultField.getHelp());
|
||||
if (field.getPlaceholder() != null && field.getPlaceholder().equals(defaultField.get_Translation(MField.COLUMNNAME_Placeholder, Env.getAD_Language(Env.getCtx()), true)))
|
||||
field.setPlaceholder(defaultField.getPlaceholder());
|
||||
|
||||
if (!field.is_Changed())
|
||||
return;
|
||||
|
||||
MUserDefField udfield = MUserDefField.get(Env.getCtx(), field.getAD_Field_ID(), m_tab.getAD_Tab_ID(), m_tab.getAD_Window_ID(), true);
|
||||
int AD_UserDef_Field_ID = 0;
|
||||
if (udfield != null)
|
||||
AD_UserDef_Field_ID = udfield.getAD_UserDef_Field_ID();
|
||||
|
||||
udfield = new MUserDefField(Env.getCtx(), AD_UserDef_Field_ID, null);
|
||||
|
||||
if (field.getName() != null)
|
||||
udfield.setName(field.getName());
|
||||
|
||||
if (field.getDescription() != null)
|
||||
udfield.setDescription(field.getDescription());
|
||||
|
||||
if (field.getHelp() != null)
|
||||
udfield.setHelp(field.getHelp());
|
||||
|
||||
if (field.getPlaceholder() != null)
|
||||
udfield.setPlaceholder(field.getPlaceholder());
|
||||
|
||||
udfield.setIsActive(field.isActive());
|
||||
udfield.setDisplayLogic(field.getDisplayLogic());
|
||||
udfield.setDisplayLength(field.getDisplayLength());
|
||||
udfield.setIsDisplayed(field.isDisplayed() ? "Y" : "N");
|
||||
udfield.setIsReadOnly(field.isReadOnly() ? "Y" : "N");
|
||||
udfield.setAD_Field_ID(field.get_ID());
|
||||
udfield.setSeqNo(field.getSeqNo());
|
||||
udfield.setXPosition(field.getXPosition());
|
||||
udfield.setNumLines(field.getNumLines());
|
||||
udfield.setColumnSpan(field.getColumnSpan());
|
||||
udfield.setAD_UserDef_Tab_ID(AD_UserDef_Tab_ID);
|
||||
udfield.setSortNo(field.getSortNo().intValue());
|
||||
udfield.setAD_Org_ID(m_tab.getAD_Org_ID());
|
||||
udfield.setMandatoryLogic(field.getMandatoryLogic());
|
||||
udfield.setReadOnlyLogic(field.getReadOnlyLogic());
|
||||
|
||||
if (field.getAD_FieldGroup_ID() > 0)
|
||||
udfield.setAD_FieldGroup_ID(field.getAD_FieldGroup_ID());
|
||||
else
|
||||
udfield.set_ValueOfColumn("ad_fieldgroup_id", null);
|
||||
|
||||
udfield.saveEx();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* When Tab Editor is called in System Role and not in Base Language, this
|
||||
* method saves changes in ad_field_trl table when some change is made on translated field
|
||||
*
|
||||
* @param field
|
||||
*/
|
||||
private void updateTrl(MField field) {
|
||||
|
||||
// only execute when is not base language
|
||||
if (isBaseLang)
|
||||
return;
|
||||
|
||||
// save current field values
|
||||
String name = field.getName();
|
||||
String description = field.getDescription();
|
||||
String help = field.getHelp();
|
||||
String placeholder = field.getPlaceholder();
|
||||
|
||||
// original values for compare
|
||||
MField dbField = new MField(Env.getCtx(), field.getAD_Field_ID(), null);
|
||||
String nameDB = isBaseLang ? dbField.getName() : dbField.get_Translation(MField.COLUMNNAME_Name, Env.getAD_Language(Env.getCtx()), true);
|
||||
String descriptionDB = isBaseLang ? dbField.getDescription() : dbField.get_Translation(MField.COLUMNNAME_Description, Env.getAD_Language(Env.getCtx()), true);
|
||||
String helpDB = isBaseLang ? dbField.getHelp() : dbField.get_Translation(MField.COLUMNNAME_Help, Env.getAD_Language(Env.getCtx()), true);
|
||||
String placeholderDB = isBaseLang ? dbField.getPlaceholder() : dbField.get_Translation(MField.COLUMNNAME_Placeholder, Env.getAD_Language(Env.getCtx()), true);
|
||||
|
||||
// always restore db field values to avoid wrong changes
|
||||
field.setName(dbField.getName());
|
||||
field.setDescription(dbField.getDescription());
|
||||
field.setHelp(dbField.getHelp());
|
||||
field.setPlaceholder(dbField.getPlaceholder());
|
||||
|
||||
// compare values when changed and restore the state if needed
|
||||
if (name != null && name.equals(nameDB))
|
||||
{
|
||||
name = null;
|
||||
}
|
||||
if (description != null && description.equals(descriptionDB))
|
||||
{
|
||||
description = null;
|
||||
}
|
||||
if (help != null && help.equals(helpDB))
|
||||
{
|
||||
help = null;
|
||||
}
|
||||
if (placeholder != null && placeholder.equals(placeholderDB))
|
||||
{
|
||||
placeholder = null;
|
||||
}
|
||||
|
||||
// nothing to do if all fields are not changed
|
||||
if (name == null && description == null && help == null && placeholder == null)
|
||||
return;
|
||||
|
||||
StringBuilder mainSQL = new StringBuilder("UPDATE ").append(field.get_TableName()).append("_Trl SET ");
|
||||
|
||||
StringBuilder setSQL = new StringBuilder();
|
||||
if (name != null)
|
||||
{
|
||||
setSQL.append(I_AD_Field.COLUMNNAME_Name).append("='").append(name).append("' ");
|
||||
}
|
||||
|
||||
if(description != null)
|
||||
{
|
||||
if (setSQL.length() > 0)
|
||||
setSQL.append(",");
|
||||
setSQL.append(I_AD_Field.COLUMNNAME_Description).append("='").append(description).append("' ");
|
||||
}
|
||||
|
||||
if(help != null)
|
||||
{
|
||||
if (setSQL.length() > 0)
|
||||
setSQL.append(",");
|
||||
setSQL.append(I_AD_Field.COLUMNNAME_Help).append("='").append(help).append("' ");
|
||||
}
|
||||
|
||||
if(placeholder != null)
|
||||
{
|
||||
if (setSQL.length() > 0)
|
||||
setSQL.append(",");
|
||||
setSQL.append(I_AD_Field.COLUMNNAME_Placeholder).append("='").append(placeholder).append("' ");
|
||||
}
|
||||
|
||||
if (setSQL.length() > 0)
|
||||
setSQL.append(",");
|
||||
|
||||
setSQL.append(I_AD_Field.COLUMNNAME_Updated).append("=").append(DB.TO_DATE(new Timestamp(System.currentTimeMillis()), false)).append(", ");
|
||||
setSQL.append(I_AD_Field.COLUMNNAME_UpdatedBy).append("=").append(Env.getAD_User_ID(Env.getCtx()));
|
||||
|
||||
mainSQL.append(setSQL.toString());
|
||||
|
||||
mainSQL.append(" WHERE ").append(I_AD_Field.COLUMNNAME_AD_Field_ID).append("=").append(field.getAD_Field_ID()).append(" AND AD_Language ='").append(Env.getAD_Language(Env.getCtx())).append("'");
|
||||
|
||||
// Execute
|
||||
int no = DB.executeUpdate(mainSQL.toString(), null);
|
||||
if (no == 1)
|
||||
{
|
||||
if (log.isLoggable(Level.FINE)) log.fine(mainSQL.toString());
|
||||
}
|
||||
else if (no == 0)
|
||||
log.warning ("Not Found - " + mainSQL.toString());
|
||||
else
|
||||
log.severe ("Update Rows=" + no + " (Should be 1) - " + mainSQL.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the current field list with new reloaded values for a field
|
||||
*
|
||||
* @param field
|
||||
*/
|
||||
public void updateFieldList(MField field) {
|
||||
for (MField lstField : fields) {
|
||||
if (lstField.getAD_Field_ID() == field.getAD_Field_ID()) {
|
||||
lstField.setName(field.getName());
|
||||
lstField.setDescription(field.getDescription());
|
||||
lstField.setHelp(field.getHelp());
|
||||
lstField.setPlaceholder(field.getPlaceholder());
|
||||
lstField.setIsActive(field.isActive());
|
||||
lstField.setDisplayLogic(field.getDisplayLogic());
|
||||
lstField.setDisplayLength(field.getDisplayLength());
|
||||
lstField.setIsDisplayed(field.isDisplayed());
|
||||
lstField.setIsReadOnly(field.isReadOnly());
|
||||
lstField.setSeqNo(field.getSeqNo());
|
||||
lstField.setXPosition(field.getXPosition());
|
||||
lstField.setNumLines(field.getNumLines());
|
||||
lstField.setColumnSpan(field.getColumnSpan());
|
||||
lstField.setSortNo(field.getSortNo());
|
||||
mapField.put(lstField.get_ID(), lstField);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // TabEditor
|
||||
|
|
Loading…
Reference in New Issue