IDEMPIERE-498 Make BP quick entry configurable

This commit is contained in:
Carlos Ruiz 2012-11-09 23:56:37 -05:00
parent f514eee8db
commit 99f2517034
10 changed files with 799 additions and 32 deletions

View File

@ -0,0 +1,88 @@
-- IDEMPIERE-498 Make BP quick entry configurable
-- Nov 1, 2012 12:10:18 PM COT
INSERT INTO AD_Element (ColumnName,AD_Element_ID,EntityType,Name,PrintName,AD_Element_UU,AD_Client_ID,Created,Updated,AD_Org_ID,CreatedBy,UpdatedBy,IsActive) VALUES ('IsQuickEntry',200216,'D','Quick Entry','Quick Entry','ba2d92ea-f8c5-438e-ba30-053965fdb1ff',0,TO_DATE('2012-11-01 12:10:15','YYYY-MM-DD HH24:MI:SS'),TO_DATE('2012-11-01 12:10:15','YYYY-MM-DD HH24:MI:SS'),0,0,0,'Y')
;
-- Nov 1, 2012 12:10:18 PM COT
INSERT INTO AD_Element_Trl (AD_Language,AD_Element_ID, Help,PO_Description,PO_Help,Name,Description,PrintName,PO_Name,PO_PrintName, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Element_Trl_UU ) SELECT l.AD_Language,t.AD_Element_ID, t.Help,t.PO_Description,t.PO_Help,t.Name,t.Description,t.PrintName,t.PO_Name,t.PO_PrintName, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Element t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Element_ID=200216 AND NOT EXISTS (SELECT * FROM AD_Element_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Element_ID=t.AD_Element_ID)
;
-- Nov 1, 2012 12:11:28 PM COT
INSERT INTO AD_Column (IsSyncDatabase,IsEncrypted,Version,AD_Table_ID,AD_Column_ID,EntityType,IsMandatory,DefaultValue,IsTranslated,IsIdentifier,SeqNo,IsParent,FieldLength,IsSelectionColumn,AD_Reference_ID,IsKey,AD_Element_ID,IsAutocomplete,IsAllowLogging,AD_Column_UU,IsUpdateable,IsAlwaysUpdateable,ColumnName,Name,IsAllowCopy,CreatedBy,Updated,AD_Org_ID,IsActive,Created,UpdatedBy,AD_Client_ID,SeqNoSelection,IsToolbarButton) VALUES ('N','N',0,107,200862,'D','Y','N','N','N',0,'N',1,'N',20,'N',200216,'N','Y','54666e5d-4260-4a97-8832-d5da6da8a5aa','Y','N','IsQuickEntry','Quick Entry','Y',0,TO_DATE('2012-11-01 12:11:25','YYYY-MM-DD HH24:MI:SS'),0,'Y',TO_DATE('2012-11-01 12:11:25','YYYY-MM-DD HH24:MI:SS'),0,0,0,'N')
;
-- Nov 1, 2012 12:11:28 PM COT
INSERT INTO AD_Column_Trl (AD_Language,AD_Column_ID, Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Column_Trl_UU ) SELECT l.AD_Language,t.AD_Column_ID, t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Column t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Column_ID=200862 AND NOT EXISTS (SELECT * FROM AD_Column_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Column_ID=t.AD_Column_ID)
;
-- Nov 1, 2012 2:26:31 PM COT
INSERT INTO AD_Field (NumLines,AD_Field_UU,SortNo,IsEncrypted,AD_Tab_ID,DisplayLength,IsSameLine,IsHeading,AD_Column_ID,SeqNo,IsCentrallyMaintained,AD_Field_ID,IsReadOnly,EntityType,Name,IsDisplayed,IsFieldOnly,UpdatedBy,AD_Org_ID,Created,AD_Client_ID,CreatedBy,Updated,IsActive,IsDisplayedGrid,SeqNoGrid,XPosition,ColumnSpan) VALUES (1,'222ea356-f257-413d-9724-c2b59077b94f',0,'N',107,0,'N','N',200862,305,'Y',200771,'N','D','Quick Entry','Y','N',0,0,TO_DATE('2012-11-01 14:26:30','YYYY-MM-DD HH24:MI:SS'),0,0,TO_DATE('2012-11-01 14:26:30','YYYY-MM-DD HH24:MI:SS'),'Y','Y',305,2,1)
;
-- Nov 1, 2012 2:27:37 PM COT
ALTER TABLE AD_Field ADD (IsQuickEntry CHAR(1) DEFAULT 'N' CHECK (IsQuickEntry IN ('Y','N')) NOT NULL)
;
-- Nov 1, 2012 2:28:01 PM COT
INSERT INTO AD_Field_Trl (AD_Language,AD_Field_ID, Help,Description,Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Field_Trl_UU ) SELECT l.AD_Language,t.AD_Field_ID, t.Help,t.Description,t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Field t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Field_ID=200772 AND NOT EXISTS (SELECT * FROM AD_Field_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Field_ID=t.AD_Field_ID)
;
-- Nov 1, 2012 2:50:40 PM COT
UPDATE AD_Field SET IsQuickEntry='Y',Updated=TO_DATE('2012-11-01 14:50:40','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=0 WHERE AD_Field_ID=2156
;
-- Nov 1, 2012 2:51:33 PM COT
UPDATE AD_Field SET IsQuickEntry='Y',Updated=TO_DATE('2012-11-01 14:51:33','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=0 WHERE AD_Field_ID=3261
;
-- Nov 1, 2012 2:52:09 PM COT
UPDATE AD_Field SET IsQuickEntry='Y',Updated=TO_DATE('2012-11-01 14:52:09','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=0 WHERE AD_Field_ID=2145
;
-- Nov 1, 2012 2:52:20 PM COT
UPDATE AD_Field SET IsQuickEntry='Y',Updated=TO_DATE('2012-11-01 14:52:20','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=0 WHERE AD_Field_ID=3228
;
-- Nov 1, 2012 3:10:08 PM COT
UPDATE AD_Field SET IsQuickEntry='Y',Updated=TO_DATE('2012-11-01 15:10:08','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=0 WHERE AD_Field_ID=7010
;
-- Nov 1, 2012 3:11:02 PM COT
UPDATE AD_Field SET IsQuickEntry='Y',Updated=TO_DATE('2012-11-01 15:11:02','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=0 WHERE AD_Field_ID=7020
;
-- Nov 1, 2012 3:12:08 PM COT
UPDATE AD_Field SET IsQuickEntry='Y',Updated=TO_DATE('2012-11-01 15:12:08','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=0 WHERE AD_Field_ID=7028
;
-- Nov 1, 2012 3:12:51 PM COT
UPDATE AD_Field SET IsQuickEntry='Y',Updated=TO_DATE('2012-11-01 15:12:51','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=0 WHERE AD_Field_ID=7017
;
-- Nov 1, 2012 3:13:38 PM COT
UPDATE AD_Field SET IsQuickEntry='Y',Updated=TO_DATE('2012-11-01 15:13:38','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=0 WHERE AD_Field_ID=7024
;
-- Nov 1, 2012 3:13:49 PM COT
UPDATE AD_Field SET IsQuickEntry='Y',Updated=TO_DATE('2012-11-01 15:13:49','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=0 WHERE AD_Field_ID=7021
;
-- Nov 1, 2012 3:14:07 PM COT
UPDATE AD_Field SET IsQuickEntry='Y',Updated=TO_DATE('2012-11-01 15:14:07','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=0 WHERE AD_Field_ID=7025
;
-- Nov 1, 2012 3:16:56 PM COT
UPDATE AD_Field SET IsQuickEntry='Y',Updated=TO_DATE('2012-11-01 15:16:56','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=0 WHERE AD_Field_ID=2185
;
-- Nov 2, 2012 3:39:54 PM COT
UPDATE AD_Field SET DisplayLogic='@AD_Tab_ID@=220 || @AD_Tab_ID@=496 || @AD_Tab_ID@=222',Updated=TO_DATE('2012-11-02 15:39:54','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=0 WHERE AD_Field_ID=200772
;
-- Nov 9, 2012 9:25:56 PM COT
UPDATE AD_Column SET Callout='org.adempiere.model.CalloutBPartnerLocation.formatPhone;org.adempiere.model.CalloutBPartnerLocation.quickEntryMandatory',Updated=TO_DATE('2012-11-09 21:25:56','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=2959
;
SELECT register_migration_script('201211091853_IDEMPIERE-498.sql') FROM dual
;

View File

@ -0,0 +1,88 @@
-- IDEMPIERE-498 Make BP quick entry configurable
-- Nov 1, 2012 12:10:18 PM COT
INSERT INTO AD_Element (ColumnName,AD_Element_ID,EntityType,Name,PrintName,AD_Element_UU,AD_Client_ID,Created,Updated,AD_Org_ID,CreatedBy,UpdatedBy,IsActive) VALUES ('IsQuickEntry',200216,'D','Quick Entry','Quick Entry','ba2d92ea-f8c5-438e-ba30-053965fdb1ff',0,TO_TIMESTAMP('2012-11-01 12:10:15','YYYY-MM-DD HH24:MI:SS'),TO_TIMESTAMP('2012-11-01 12:10:15','YYYY-MM-DD HH24:MI:SS'),0,0,0,'Y')
;
-- Nov 1, 2012 12:10:18 PM COT
INSERT INTO AD_Element_Trl (AD_Language,AD_Element_ID, Help,PO_Description,PO_Help,Name,Description,PrintName,PO_Name,PO_PrintName, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Element_Trl_UU ) SELECT l.AD_Language,t.AD_Element_ID, t.Help,t.PO_Description,t.PO_Help,t.Name,t.Description,t.PrintName,t.PO_Name,t.PO_PrintName, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Element t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Element_ID=200216 AND NOT EXISTS (SELECT * FROM AD_Element_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Element_ID=t.AD_Element_ID)
;
-- Nov 1, 2012 12:11:28 PM COT
INSERT INTO AD_Column (IsSyncDatabase,IsEncrypted,Version,AD_Table_ID,AD_Column_ID,EntityType,IsMandatory,DefaultValue,IsTranslated,IsIdentifier,SeqNo,IsParent,FieldLength,IsSelectionColumn,AD_Reference_ID,IsKey,AD_Element_ID,IsAutocomplete,IsAllowLogging,AD_Column_UU,IsUpdateable,IsAlwaysUpdateable,ColumnName,Name,IsAllowCopy,CreatedBy,Updated,AD_Org_ID,IsActive,Created,UpdatedBy,AD_Client_ID,SeqNoSelection,IsToolbarButton) VALUES ('N','N',0,107,200862,'D','Y','N','N','N',0,'N',1,'N',20,'N',200216,'N','Y','54666e5d-4260-4a97-8832-d5da6da8a5aa','Y','N','IsQuickEntry','Quick Entry','Y',0,TO_TIMESTAMP('2012-11-01 12:11:25','YYYY-MM-DD HH24:MI:SS'),0,'Y',TO_TIMESTAMP('2012-11-01 12:11:25','YYYY-MM-DD HH24:MI:SS'),0,0,0,'N')
;
-- Nov 1, 2012 12:11:28 PM COT
INSERT INTO AD_Column_Trl (AD_Language,AD_Column_ID, Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Column_Trl_UU ) SELECT l.AD_Language,t.AD_Column_ID, t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Column t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Column_ID=200862 AND NOT EXISTS (SELECT * FROM AD_Column_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Column_ID=t.AD_Column_ID)
;
-- Nov 1, 2012 2:26:31 PM COT
INSERT INTO AD_Field (NumLines,AD_Field_UU,SortNo,IsEncrypted,AD_Tab_ID,DisplayLength,IsSameLine,IsHeading,AD_Column_ID,SeqNo,IsCentrallyMaintained,AD_Field_ID,IsReadOnly,EntityType,Name,IsDisplayed,IsFieldOnly,UpdatedBy,AD_Org_ID,Created,AD_Client_ID,CreatedBy,Updated,IsActive,IsDisplayedGrid,SeqNoGrid,XPosition,ColumnSpan) VALUES (1,'222ea356-f257-413d-9724-c2b59077b94f',0,'N',107,0,'N','N',200862,305,'Y',200771,'N','D','Quick Entry','Y','N',0,0,TO_TIMESTAMP('2012-11-01 14:26:30','YYYY-MM-DD HH24:MI:SS'),0,0,TO_TIMESTAMP('2012-11-01 14:26:30','YYYY-MM-DD HH24:MI:SS'),'Y','Y',305,2,1)
;
-- Nov 1, 2012 2:27:37 PM COT
ALTER TABLE AD_Field ADD COLUMN IsQuickEntry CHAR(1) DEFAULT 'N' CHECK (IsQuickEntry IN ('Y','N')) NOT NULL
;
-- Nov 1, 2012 2:28:01 PM COT
INSERT INTO AD_Field_Trl (AD_Language,AD_Field_ID, Help,Description,Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Field_Trl_UU ) SELECT l.AD_Language,t.AD_Field_ID, t.Help,t.Description,t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Field t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Field_ID=200772 AND NOT EXISTS (SELECT * FROM AD_Field_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Field_ID=t.AD_Field_ID)
;
-- Nov 1, 2012 2:50:40 PM COT
UPDATE AD_Field SET IsQuickEntry='Y',Updated=TO_TIMESTAMP('2012-11-01 14:50:40','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=0 WHERE AD_Field_ID=2156
;
-- Nov 1, 2012 2:51:33 PM COT
UPDATE AD_Field SET IsQuickEntry='Y',Updated=TO_TIMESTAMP('2012-11-01 14:51:33','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=0 WHERE AD_Field_ID=3261
;
-- Nov 1, 2012 2:52:09 PM COT
UPDATE AD_Field SET IsQuickEntry='Y',Updated=TO_TIMESTAMP('2012-11-01 14:52:09','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=0 WHERE AD_Field_ID=2145
;
-- Nov 1, 2012 2:52:20 PM COT
UPDATE AD_Field SET IsQuickEntry='Y',Updated=TO_TIMESTAMP('2012-11-01 14:52:20','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=0 WHERE AD_Field_ID=3228
;
-- Nov 1, 2012 3:10:08 PM COT
UPDATE AD_Field SET IsQuickEntry='Y',Updated=TO_TIMESTAMP('2012-11-01 15:10:08','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=0 WHERE AD_Field_ID=7010
;
-- Nov 1, 2012 3:11:02 PM COT
UPDATE AD_Field SET IsQuickEntry='Y',Updated=TO_TIMESTAMP('2012-11-01 15:11:02','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=0 WHERE AD_Field_ID=7020
;
-- Nov 1, 2012 3:12:08 PM COT
UPDATE AD_Field SET IsQuickEntry='Y',Updated=TO_TIMESTAMP('2012-11-01 15:12:08','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=0 WHERE AD_Field_ID=7028
;
-- Nov 1, 2012 3:12:51 PM COT
UPDATE AD_Field SET IsQuickEntry='Y',Updated=TO_TIMESTAMP('2012-11-01 15:12:51','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=0 WHERE AD_Field_ID=7017
;
-- Nov 1, 2012 3:13:38 PM COT
UPDATE AD_Field SET IsQuickEntry='Y',Updated=TO_TIMESTAMP('2012-11-01 15:13:38','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=0 WHERE AD_Field_ID=7024
;
-- Nov 1, 2012 3:13:49 PM COT
UPDATE AD_Field SET IsQuickEntry='Y',Updated=TO_TIMESTAMP('2012-11-01 15:13:49','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=0 WHERE AD_Field_ID=7021
;
-- Nov 1, 2012 3:14:07 PM COT
UPDATE AD_Field SET IsQuickEntry='Y',Updated=TO_TIMESTAMP('2012-11-01 15:14:07','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=0 WHERE AD_Field_ID=7025
;
-- Nov 1, 2012 3:16:56 PM COT
UPDATE AD_Field SET IsQuickEntry='Y',Updated=TO_TIMESTAMP('2012-11-01 15:16:56','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=0 WHERE AD_Field_ID=2185
;
-- Nov 2, 2012 3:39:54 PM COT
UPDATE AD_Field SET DisplayLogic='@AD_Tab_ID@=220 || @AD_Tab_ID@=496 || @AD_Tab_ID@=222',Updated=TO_TIMESTAMP('2012-11-02 15:39:54','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=0 WHERE AD_Field_ID=200772
;
-- Nov 9, 2012 9:25:56 PM COT
UPDATE AD_Column SET Callout='org.adempiere.model.CalloutBPartnerLocation.formatPhone;org.adempiere.model.CalloutBPartnerLocation.quickEntryMandatory',Updated=TO_TIMESTAMP('2012-11-09 21:25:56','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=2959
;
SELECT register_migration_script('201211091853_IDEMPIERE-498.sql') FROM dual
;

View File

@ -25,6 +25,7 @@ import org.compiere.model.MBPartnerLocation;
import org.compiere.model.MColumn; import org.compiere.model.MColumn;
import org.compiere.util.DB; import org.compiere.util.DB;
import org.compiere.util.Env; import org.compiere.util.Env;
import org.compiere.util.Msg;
/** /**
* BPartnerLocation Callouts. * BPartnerLocation Callouts.
@ -82,4 +83,17 @@ public class CalloutBPartnerLocation extends CalloutEngine
return ""; return "";
} // formatPhone } // formatPhone
public String quickEntryMandatory (Properties ctx, int WindowNo,
GridTab mTab, GridField mField, Object value, Object oldValue)
{
// this callout is just for quick entry window
if ("Y".equals(Env.getContext(ctx, WindowNo, "_QUICK_ENTRY_MODE_"))) {
if (value == null) {
return Msg.getMsg(ctx, "FillMandatory") + " " + Msg.getElement(ctx, mField.getColumnName());
}
}
return "";
}
} // CalloutBPartnerLocation } // CalloutBPartnerLocation

View File

@ -426,6 +426,15 @@ public interface I_AD_Field
*/ */
public String getIsMandatory(); public String getIsMandatory();
/** Column name IsQuickEntry */
public static final String COLUMNNAME_IsQuickEntry = "IsQuickEntry";
/** Set Quick Entry */
public void setIsQuickEntry (boolean IsQuickEntry);
/** Get Quick Entry */
public boolean isQuickEntry();
/** Column name IsReadOnly */ /** Column name IsReadOnly */
public static final String COLUMNNAME_IsReadOnly = "IsReadOnly"; public static final String COLUMNNAME_IsReadOnly = "IsReadOnly";

View File

@ -32,7 +32,7 @@ public class X_AD_Field extends PO implements I_AD_Field, I_Persistent
/** /**
* *
*/ */
private static final long serialVersionUID = 20121031L; private static final long serialVersionUID = 20121101L;
/** Standard Constructor */ /** Standard Constructor */
public X_AD_Field (Properties ctx, int AD_Field_ID, String trxName) public X_AD_Field (Properties ctx, int AD_Field_ID, String trxName)
@ -52,6 +52,8 @@ public class X_AD_Field extends PO implements I_AD_Field, I_Persistent
setIsEncrypted (false); setIsEncrypted (false);
setIsFieldOnly (false); setIsFieldOnly (false);
setIsHeading (false); setIsHeading (false);
setIsQuickEntry (false);
// N
setIsReadOnly (false); setIsReadOnly (false);
setIsSameLine (false); setIsSameLine (false);
setName (null); setName (null);
@ -653,6 +655,27 @@ public class X_AD_Field extends PO implements I_AD_Field, I_Persistent
return (String)get_Value(COLUMNNAME_IsMandatory); return (String)get_Value(COLUMNNAME_IsMandatory);
} }
/** Set Quick Entry.
@param IsQuickEntry Quick Entry */
public void setIsQuickEntry (boolean IsQuickEntry)
{
set_Value (COLUMNNAME_IsQuickEntry, Boolean.valueOf(IsQuickEntry));
}
/** Get Quick Entry.
@return Quick Entry */
public boolean isQuickEntry ()
{
Object oo = get_Value(COLUMNNAME_IsQuickEntry);
if (oo != null)
{
if (oo instanceof Boolean)
return ((Boolean)oo).booleanValue();
return "Y".equals(oo);
}
return false;
}
/** Set Read Only. /** Set Read Only.
@param IsReadOnly @param IsReadOnly
Field is read only Field is read only

View File

@ -22,6 +22,9 @@ import java.util.ArrayList;
import org.adempiere.webui.component.Menupopup; import org.adempiere.webui.component.Menupopup;
import org.adempiere.webui.event.ContextMenuEvent; import org.adempiere.webui.event.ContextMenuEvent;
import org.adempiere.webui.event.ContextMenuListener; import org.adempiere.webui.event.ContextMenuListener;
import org.compiere.model.Lookup;
import org.compiere.model.MRole;
import org.compiere.util.DB;
import org.compiere.util.Env; import org.compiere.util.Env;
import org.compiere.util.Msg; import org.compiere.util.Msg;
import org.compiere.util.Util; import org.compiere.util.Util;
@ -41,7 +44,8 @@ public class WEditorPopupMenu extends Menupopup implements EventListener<Event>
/** /**
* *
*/ */
private static final long serialVersionUID = 5813878069049398656L; private static final long serialVersionUID = 7826535512581441259L;
public static final String EVENT_ATTRIBUTE = "EVENT"; public static final String EVENT_ATTRIBUTE = "EVENT";
public static final String ZOOM_EVENT = "ZOOM"; public static final String ZOOM_EVENT = "ZOOM";
public static final String REQUERY_EVENT = "REQUERY"; public static final String REQUERY_EVENT = "REQUERY";
@ -70,20 +74,37 @@ public class WEditorPopupMenu extends Menupopup implements EventListener<Event>
public WEditorPopupMenu(boolean zoom, boolean requery, boolean preferences) public WEditorPopupMenu(boolean zoom, boolean requery, boolean preferences)
{ {
this(zoom, requery, preferences, false, false, false); this(zoom, requery, preferences, false, false, false, null); // no check zoom
} }
@Deprecated
public WEditorPopupMenu(boolean zoom, boolean requery, boolean preferences, boolean newRecord) public WEditorPopupMenu(boolean zoom, boolean requery, boolean preferences, boolean newRecord)
{ {
this(zoom, requery, preferences, newRecord, false, false); this(zoom, requery, preferences, newRecord, false, false, null);
} }
@Deprecated
public WEditorPopupMenu(boolean zoom, boolean requery, boolean preferences, boolean newRecord, boolean updateRecord) public WEditorPopupMenu(boolean zoom, boolean requery, boolean preferences, boolean newRecord, boolean updateRecord)
{ {
this(zoom, requery, preferences, newRecord, updateRecord, false); this(zoom, requery, preferences, newRecord, updateRecord, false, null);
} }
@Deprecated
public WEditorPopupMenu(boolean zoom, boolean requery, boolean preferences, boolean newRecord, boolean updateRecord, boolean showLocation) public WEditorPopupMenu(boolean zoom, boolean requery, boolean preferences, boolean newRecord, boolean updateRecord, boolean showLocation)
{
this(zoom, requery, preferences, newRecord, updateRecord, false, null);
}
/**
* @param zoom - enable zoom in menu - disabled if the lookup cannot zoom
* @param requery - enable requery in menu
* @param preferences - enable preferences in menu
* @param newRecord - enable new record (ignored and recalculated if lookup is received)
* @param updateRecord - enable update record (ignored and recalculated if lookup is received)
* @param showLocation - enable show location in menu
* @param lookup - when this parameter is received then new and update are calculated based on the zoom and quickentry
*/
public WEditorPopupMenu(boolean zoom, boolean requery, boolean preferences, boolean newRecord, boolean updateRecord, boolean showLocation, Lookup lookup)
{ {
super(); super();
this.zoomEnabled = zoom; this.zoomEnabled = zoom;
@ -92,6 +113,33 @@ public class WEditorPopupMenu extends Menupopup implements EventListener<Event>
this.newEnabled = newRecord; this.newEnabled = newRecord;
this.updateEnabled = updateRecord; // Elaine 2009/02/16 - update record this.updateEnabled = updateRecord; // Elaine 2009/02/16 - update record
this.showLocation = showLocation; this.showLocation = showLocation;
if (lookup != null) {
int winID = lookup.getZoom();
Boolean canAccess = MRole.getDefault().getWindowAccess(winID);
if (winID <= 0 || canAccess == null || ! canAccess) {
this.zoomEnabled = false;
this.newEnabled = false;
this.updateEnabled = false;
} else {
int cnt = DB.getSQLValueEx(null,
"SELECT COUNT(*) "
+ "FROM AD_Field f "
+ " JOIN AD_Tab t "
+ " ON ( t.AD_Tab_ID = f.AD_Tab_ID ) "
+ "WHERE t.AD_Window_ID = ? "
+ " AND f.IsActive = 'Y' "
+ " AND t.IsActive = 'Y' "
+ " AND f.IsQuickEntry = 'Y' ",
winID);
if (cnt > 0) {
this.newEnabled = true;
this.updateEnabled = true;
} else {
this.newEnabled = false;
this.updateEnabled = false;
}
}
}
init(); init();
} }

View File

@ -17,6 +17,9 @@
package org.adempiere.webui.editor; package org.adempiere.webui.editor;
import static org.compiere.model.SystemIDs.COLUMN_C_INVOICELINE_M_PRODUCT_ID;
import static org.compiere.model.SystemIDs.COLUMN_C_INVOICE_C_BPARTNER_ID;
import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeEvent;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
@ -32,7 +35,7 @@ import org.adempiere.webui.event.DialogEvents;
import org.adempiere.webui.event.ValueChangeEvent; import org.adempiere.webui.event.ValueChangeEvent;
import org.adempiere.webui.event.ValueChangeListener; import org.adempiere.webui.event.ValueChangeListener;
import org.adempiere.webui.factory.InfoManager; import org.adempiere.webui.factory.InfoManager;
import org.adempiere.webui.grid.WBPartner; import org.adempiere.webui.grid.WQuickEntry;
import org.adempiere.webui.panel.InfoPanel; import org.adempiere.webui.panel.InfoPanel;
import org.adempiere.webui.window.WFieldRecordInfo; import org.adempiere.webui.window.WFieldRecordInfo;
import org.compiere.model.GridField; import org.compiere.model.GridField;
@ -40,7 +43,6 @@ import org.compiere.model.Lookup;
import org.compiere.model.MLookup; import org.compiere.model.MLookup;
import org.compiere.model.MLookupFactory; import org.compiere.model.MLookupFactory;
import org.compiere.model.MRole; import org.compiere.model.MRole;
import static org.compiere.model.SystemIDs.*;
import org.compiere.util.CLogger; import org.compiere.util.CLogger;
import org.compiere.util.DB; import org.compiere.util.DB;
import org.compiere.util.DisplayType; import org.compiere.util.DisplayType;
@ -151,17 +153,17 @@ public class WSearchEditor extends WEditor implements ContextMenuListener, Value
columnName = this.getColumnName(); columnName = this.getColumnName();
if (columnName.equals("C_BPartner_ID")) if (columnName.equals("C_BPartner_ID"))
{ {
popupMenu = new WEditorPopupMenu(true, true, isShowPreference(), true, true); popupMenu = new WEditorPopupMenu(true, true, isShowPreference(), true, true, false, lookup);
getComponent().setButtonImage("/images/BPartner10.png"); getComponent().setButtonImage("/images/BPartner10.png");
} }
else if (columnName.equals("M_Product_ID")) else if (columnName.equals("M_Product_ID"))
{ {
popupMenu = new WEditorPopupMenu(true, true, isShowPreference(), false, false); popupMenu = new WEditorPopupMenu(true, true, isShowPreference(), false, false, false, lookup);
getComponent().setButtonImage("/images/Product10.png"); getComponent().setButtonImage("/images/Product10.png");
} }
else else
{ {
popupMenu = new WEditorPopupMenu(true, true, isShowPreference(), false, false); popupMenu = new WEditorPopupMenu(true, true, isShowPreference(), false, false, false, lookup);
getComponent().setButtonImage("/images/PickOpen10.png"); getComponent().setButtonImage("/images/PickOpen10.png");
} }
@ -293,7 +295,7 @@ public class WSearchEditor extends WEditor implements ContextMenuListener, Value
infoPanel.detach(); infoPanel.detach();
infoPanel = null; infoPanel = null;
} }
actionBPartner(true); actionQuickEntry(true);
} }
// Elaine 2009/02/16 - update record // Elaine 2009/02/16 - update record
else if (WEditorPopupMenu.UPDATE_EVENT.equals(evt.getContextEvent())) else if (WEditorPopupMenu.UPDATE_EVENT.equals(evt.getContextEvent()))
@ -303,7 +305,7 @@ public class WSearchEditor extends WEditor implements ContextMenuListener, Value
infoPanel.detach(); infoPanel.detach();
infoPanel = null; infoPanel = null;
} }
actionBPartner(false); actionQuickEntry(false);
} }
else if (WEditorPopupMenu.CHANGE_LOG_EVENT.equals(evt.getContextEvent())) else if (WEditorPopupMenu.CHANGE_LOG_EVENT.equals(evt.getContextEvent()))
{ {
@ -437,40 +439,40 @@ public class WSearchEditor extends WEditor implements ContextMenuListener, Value
} // actionCombo } // actionCombo
/** /**
* Action - Special BPartner Screen * Action - Special Quick Entry Screen
* @param newRecord true if new record should be created * @param newRecord true if new record should be created
*/ */
private void actionBPartner (boolean newRecord) private void actionQuickEntry (boolean newRecord)
{ {
if(!getComponent().isEnabled()) if(!getComponent().isEnabled())
return; return;
final WBPartner vbp = new WBPartner (lookup.getWindowNo()); final WQuickEntry vqe = new WQuickEntry (lookup.getWindowNo(), lookup.getZoom());
int BPartner_ID = 0; int Record_ID = 0;
// if update, get current value // if update, get current value
if (!newRecord) if (!newRecord)
{ {
if (value instanceof Integer) if (value instanceof Integer)
BPartner_ID = ((Integer)value).intValue(); Record_ID = ((Integer)value).intValue();
else if (value != null) else if (value != null && "".compareTo(value.toString())!= 0)
BPartner_ID = Integer.parseInt(value.toString()); Record_ID = Integer.parseInt(value.toString());
} }
vbp.loadBPartner (BPartner_ID); vqe.loadRecord (Record_ID);
final int finalBPartner_ID = BPartner_ID; final int finalRecord_ID = Record_ID;
vbp.addEventListener(DialogEvents.ON_WINDOW_CLOSE, new EventListener<Event>() { vqe.addEventListener(DialogEvents.ON_WINDOW_CLOSE, new EventListener<Event>() {
@Override @Override
public void onEvent(Event event) throws Exception { public void onEvent(Event event) throws Exception {
// get result // get result
int result = vbp.getC_BPartner_ID(); int result = vqe.getRecord_ID();
if (result == 0 // 0 = not saved if (result == 0 // 0 = not saved
&& result == finalBPartner_ID) // the same && result == finalRecord_ID) // the same
return; return;
// Maybe new BPartner - put in cache // Maybe new Record - put in cache
lookup.getDirect(new Integer(result), false, true); lookup.getDirect(new Integer(result), false, true);
setValue(new Integer(result)); setValue(new Integer(result));
actionCombo (new Integer(result)); // data binding actionCombo (new Integer(result)); // data binding
@ -479,9 +481,9 @@ public class WSearchEditor extends WEditor implements ContextMenuListener, Value
} }
}); });
vbp.setVisible(true); vqe.setVisible(true);
AEnv.showWindow(vbp); AEnv.showWindow(vqe);
} // actionBPartner } // actionQuickEntry
private void actionButton(String queryValue) private void actionButton(String queryValue)
{ {

View File

@ -27,7 +27,9 @@ import org.adempiere.webui.apps.AEnv;
import org.adempiere.webui.component.Combobox; import org.adempiere.webui.component.Combobox;
import org.adempiere.webui.event.ContextMenuEvent; import org.adempiere.webui.event.ContextMenuEvent;
import org.adempiere.webui.event.ContextMenuListener; import org.adempiere.webui.event.ContextMenuListener;
import org.adempiere.webui.event.DialogEvents;
import org.adempiere.webui.event.ValueChangeEvent; import org.adempiere.webui.event.ValueChangeEvent;
import org.adempiere.webui.grid.WQuickEntry;
import org.adempiere.webui.window.WFieldRecordInfo; import org.adempiere.webui.window.WFieldRecordInfo;
import org.adempiere.webui.window.WLocationDialog; import org.adempiere.webui.window.WLocationDialog;
import org.compiere.model.GridField; import org.compiere.model.GridField;
@ -42,6 +44,7 @@ import org.compiere.util.Msg;
import org.compiere.util.NamePair; import org.compiere.util.NamePair;
import org.compiere.util.ValueNamePair; import org.compiere.util.ValueNamePair;
import org.zkoss.zk.ui.event.Event; import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zk.ui.event.Events; import org.zkoss.zk.ui.event.Events;
import org.zkoss.zul.Comboitem; import org.zkoss.zul.Comboitem;
@ -151,9 +154,9 @@ ContextMenuListener, IZoomableEditor
|| (columnName.toUpperCase().equals("BILL_LOCATION_ID")) || (columnName.toUpperCase().equals("BILL_LOCATION_ID"))
|| (columnName.toUpperCase().equals("DROPSHIP_LOCATION_ID"))) || (columnName.toUpperCase().equals("DROPSHIP_LOCATION_ID")))
{ {
popupMenu = new WEditorPopupMenu(true, true, isShowPreference(), false, false, true); popupMenu = new WEditorPopupMenu(true, true, isShowPreference(), false, false, true, lookup);
} else { } else {
popupMenu = new WEditorPopupMenu(zoom, true, isShowPreference()); popupMenu = new WEditorPopupMenu(zoom, true, isShowPreference(), false, false, false, lookup);
} }
addChangeLogMenu(popupMenu); addChangeLogMenu(popupMenu);
} }
@ -389,6 +392,55 @@ ContextMenuListener, IZoomableEditor
AEnv.actionZoom(lookup, getValue()); AEnv.actionZoom(lookup, getValue());
} }
/**
* Action - Special Quick Entry Screen
* @param newRecord true if new record should be created
*/
private void actionQuickEntry (boolean newRecord)
{
if(!getComponent().isEnabled())
return;
final WQuickEntry vqe = new WQuickEntry (lookup.getWindowNo(), lookup.getZoom());
int Record_ID = 0;
Object value = getValue();
// if update, get current value
if (!newRecord)
{
if (value instanceof Integer)
Record_ID = ((Integer)value).intValue();
else if (value != null && "".compareTo(value.toString())!= 0)
Record_ID = Integer.parseInt(value.toString());
}
vqe.loadRecord (Record_ID);
final int finalRecord_ID = Record_ID;
vqe.addEventListener(DialogEvents.ON_WINDOW_CLOSE, new EventListener<Event>() {
@Override
public void onEvent(Event event) throws Exception {
// get result
int result = vqe.getRecord_ID();
if (result == 0 // 0 = not saved
&& result == finalRecord_ID) // the same
return;
// Maybe new Record - put in cache
Object newValue = new Integer(result);
lookup.getDirect(newValue, false, true);
setValue(new Integer(result));
ValueChangeEvent changeEvent = new ValueChangeEvent(this, getColumnName(), oldValue, newValue);
fireValueChange(changeEvent);
oldValue = newValue;
}
});
vqe.setVisible(true);
AEnv.showWindow(vqe);
} // actionQuickEntry
private void actionLocation() { private void actionLocation() {
int BPLocation_ID = 0; int BPLocation_ID = 0;
Object value = getValue(); Object value = getValue();
@ -425,6 +477,14 @@ ContextMenuListener, IZoomableEditor
ValuePreference.start (this.getGridField(), getValue()); ValuePreference.start (this.getGridField(), getValue());
return; return;
} }
else if (WEditorPopupMenu.NEW_EVENT.equals(evt.getContextEvent()))
{
actionQuickEntry(true);
}
else if (WEditorPopupMenu.UPDATE_EVENT.equals(evt.getContextEvent()))
{
actionQuickEntry(false);
}
else if (WEditorPopupMenu.CHANGE_LOG_EVENT.equals(evt.getContextEvent())) else if (WEditorPopupMenu.CHANGE_LOG_EVENT.equals(evt.getContextEvent()))
{ {
WFieldRecordInfo.start(gridField); WFieldRecordInfo.start(gridField);

View File

@ -59,6 +59,7 @@ import org.zkoss.zul.Vlayout;
* *
*/ */
@Deprecated /* use WQuickEntry instead */
public class WBPartner extends Window implements EventListener, ValueChangeListener public class WBPartner extends Window implements EventListener, ValueChangeListener
{ {
/** /**

View File

@ -0,0 +1,434 @@
/******************************************************************************
* Copyright (C) 2012 Trek Global *
* Product: iDempiere ERP & CRM Smart Business Solution *
* This program is free software; you can redistribute it and/or modify it *
* under the terms version 2 of the GNU General Public License as published *
* by the Free Software Foundation. This program is distributed in the hope *
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU General Public License for more details. *
* You should have received a copy of the GNU General Public License along *
* with this program; if not, write to the Free Software Foundation, Inc., *
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
*****************************************************************************/
package org.adempiere.webui.grid;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import org.adempiere.webui.component.ConfirmPanel;
import org.adempiere.webui.component.Label;
import org.adempiere.webui.component.Window;
import org.adempiere.webui.editor.WEditor;
import org.adempiere.webui.editor.WebEditorFactory;
import org.adempiere.webui.event.ValueChangeEvent;
import org.adempiere.webui.event.ValueChangeListener;
import org.adempiere.webui.session.SessionManager;
import org.adempiere.webui.window.FDialog;
import org.compiere.model.GridField;
import org.compiere.model.GridTab;
import org.compiere.model.GridWindow;
import org.compiere.model.MField;
import org.compiere.model.MRole;
import org.compiere.model.MTable;
import org.compiere.model.PO;
import org.compiere.util.CLogger;
import org.compiere.util.DisplayType;
import org.compiere.util.Env;
import org.compiere.util.Msg;
import org.compiere.util.Util;
import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.HtmlBasedComponent;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zk.ui.event.Events;
import org.zkoss.zul.Hlayout;
import org.zkoss.zul.Separator;
import org.zkoss.zul.Span;
import org.zkoss.zul.Vlayout;
/**
* Quick Entry Window
* Author: Carlos Ruiz
*/
public class WQuickEntry extends Window implements EventListener, ValueChangeListener
{
/**
*
*/
private static final long serialVersionUID = -4121297375382998263L;
public static final String QUICK_ENTRY_MODE = "_QUICK_ENTRY_MODE_";
private static CLogger log = CLogger.getCLogger(WQuickEntry.class);
private int m_WindowNo;
private int parent_WindowNo;
List<GridField> quickFields = new ArrayList<GridField>();
List<WEditor> quickEditors = new ArrayList<WEditor>();
List<Object> initialValues = new ArrayList<Object>();
List<GridTab> quickTabs = new ArrayList<GridTab>();
List<PO> quickPOs = new ArrayList<PO>();
/** Read Only */
private boolean m_readOnly = false;
private Vlayout centerPanel = new Vlayout();
private ConfirmPanel confirmPanel = new ConfirmPanel(true, false, false, false, false, false);
private int m_AD_Window_ID;
/**
* Constructor.
* Requires call loadRecord
* @param WindowNo Window No
* @param AD_Window_ID
*/
public WQuickEntry(int WindowNo, int AD_Window_ID)
{
super();
m_AD_Window_ID = AD_Window_ID;
parent_WindowNo = WindowNo;
m_WindowNo = SessionManager.getAppDesktop().registerWindow(this);
log.info("R/O=" + m_readOnly);
try
{
jbInit();
}
catch(Exception ex)
{
log.log(Level.SEVERE, ex.getMessage());
}
Env.setContext(Env.getCtx(), m_WindowNo, QUICK_ENTRY_MODE, "Y");
initPOs();
} // WQuickEntry
/**
* Static Init
* @throws Exception
*/
void jbInit() throws Exception
{
this.setWidth("350px");
this.setBorder("normal");
this.setClosable(true);
this.setSizable(true);
this.appendChild(centerPanel);
this.appendChild(confirmPanel);
centerPanel.setWidth("100%");
confirmPanel.addActionListener(Events.ON_CLICK, this);
}
/**
* Dynamic Init
*/
private void initPOs()
{
GridWindow gridwindow = GridWindow.get(Env.getCtx(), m_WindowNo, m_AD_Window_ID);
this.setTitle(gridwindow.getName());
boolean newTab = false;
for (int i=0; i < gridwindow.getTabCount(); i++) {
GridTab gridtab = gridwindow.getTab(i);
if (i == 0) {
m_readOnly = !MRole.getDefault().canUpdate(
Env.getAD_Client_ID(Env.getCtx()), Env.getAD_Org_ID(Env.getCtx()),
gridtab.getAD_Table_ID(), 0, false);
}
if (!gridtab.isLoadComplete())
gridwindow.initTab(i);
for (GridField gridfield : gridtab.getFields()) {
MField field = new MField(Env.getCtx(), gridfield.getAD_Field_ID(), null);
if (field.isQuickEntry()) {
if (! isValidQuickEntryType(field.getAD_Reference_ID()))
continue;
WEditor editor = WebEditorFactory.getEditor(gridfield, false);
if (m_readOnly)
editor.setReadWrite(false);
if (gridfield.isMandatory(false))
editor.setMandatory(true);
createLine(editor, newTab, gridtab);
quickFields.add(gridfield);
quickEditors.add(editor);
editor.addValueChangeListener(this);
if (! quickTabs.contains(gridtab)) {
quickTabs.add(gridtab);
}
newTab = false;
}
}
newTab = true;
}
} // initPOs
private boolean isValidQuickEntryType(int refID) {
boolean valid =
! (
refID == DisplayType.Button
|| refID == DisplayType.Binary
|| refID == DisplayType.ID
);
return valid;
}
private void createLine(WEditor editor, boolean newTab, GridTab gt) {
if (newTab) {
Separator sep = new Separator();
centerPanel.appendChild(sep);
Label tabLabel = new Label(gt.getName());
centerPanel.appendChild(tabLabel);
Separator sepl = new Separator();
sepl.setBar(true);
centerPanel.appendChild(sepl);
}
Component field = editor.getComponent();
Hlayout layout = new Hlayout();
layout.setHflex("10");
Span span = new Span();
span.setHflex("3");
layout.appendChild(span);
Label label = editor.getLabel();
span.appendChild(label);
label.setSclass("field-label");
layout.appendChild(field);
((HtmlBasedComponent)field).setHflex("7");
centerPanel.appendChild(layout);
}
/**
* Load Record_ID
* @param Record_ID - existing Record or 0 for new
* @return true if loaded
*/
public boolean loadRecord (int Record_ID)
{
String parentColumn = null;
for (int idxt = 0; idxt < quickTabs.size(); idxt++) {
GridTab gridtab = quickTabs.get(idxt);
int id = 0;
if (idxt == 0) {
id = Record_ID;
parentColumn = gridtab.getTableName() + "_ID";
} else {
if (Record_ID > 0) {
String columnname = gridtab.getTableName() + "_ID";
id = Env.getContextAsInt(Env.getCtx(), parent_WindowNo, columnname);
}
}
MTable table = MTable.get(Env.getCtx(), gridtab.getTableName());
PO po = table.getPO(id, null);
if (idxt > 0) {
// check the detail record is a child of parent
int parentid = po.get_ValueAsInt(parentColumn);
if (parentid != Record_ID) {
po = table.getPO(0, null);
}
}
quickPOs.add(po);
}
log.config("Record_ID=" + Record_ID);
// New record
if (Record_ID == 0)
{
// set defaults on editors
for (int idxf = 0; idxf < quickFields.size(); idxf++) {
GridField field = quickFields.get(idxf);
WEditor editor = quickEditors.get(idxf);
Object value = field.getDefault();
if (value != null) {
editor.setValue(value);
field.setValue(value, true);
field.getGridTab().processCallout(field);
}
initialValues.add(editor.getValue());
}
return true;
}
if (quickPOs.get(0).get_ID() == 0)
{
FDialog.error(m_WindowNo, this, "RecordNotFound");
return false;
}
for (int idxf = 0; idxf < quickFields.size(); idxf++) {
GridField field = quickFields.get(idxf);
WEditor editor = quickEditors.get(idxf);
int idxt = quickTabs.indexOf(field.getGridTab());
PO po = quickPOs.get(idxt);
Object value = po.get_Value(field.getColumnName());
editor.setValue(value);
field.setValue(value, false);
initialValues.add(editor.getValue());
}
return true;
} // loadRecord
/**
* Save.
* @return true if saved
*/
private boolean actionSave()
{
log.config("");
boolean anyChange = false;
for (int idxf = 0; idxf < quickEditors.size(); idxf++) {
WEditor editor = quickEditors.get(idxf);
Object value = editor.getValue();
Object initialValue = initialValues.get(idxf);
boolean changed = (value != null && initialValue == null)
|| (value == null && initialValue != null)
|| (value != null && initialValue != null && ! value.equals(initialValue));
if (changed) {
anyChange = true;
}
}
if (anyChange) {
// Call all callouts to allow quick entry special behavior
for (GridField field : quickFields) {
String msg = field.getGridTab().processCallout(field);
if (! Util.isEmpty(msg)) {
FDialog.error(m_WindowNo, this, "", msg);
return false;
}
}
}
int parentID = 0;
String parentColumn = null;
for (int idxt = 0; idxt < quickTabs.size(); idxt++) {
GridTab gridtab = quickTabs.get(idxt);
PO po = quickPOs.get(idxt);
if (idxt == 0) {
parentColumn = gridtab.getTableName() + "_ID";
}
boolean savePO = false;
boolean fillMandatoryError = false;
StringBuilder mandatoryFields = new StringBuilder();
for (int idxf = 0; idxf < quickFields.size(); idxf++) {
GridField field = quickFields.get(idxf);
if (field.getGridTab() != gridtab)
continue;
WEditor editor = quickEditors.get(idxf);
Object value = editor.getValue();
Object initialValue = initialValues.get(idxf);
boolean changed = (value != null && initialValue == null)
|| (value == null && initialValue != null)
|| (value != null && initialValue != null && value != initialValue);
boolean thisMandatoryError = false;
if (field.isMandatory(true)) {
if (value == null || value.toString().length() == 0) {
fillMandatoryError = true;
thisMandatoryError = true;
if (mandatoryFields.length() > 0)
mandatoryFields.append(", ");
mandatoryFields.append(Msg.getElement(Env.getCtx(), field.getColumnName()));
}
}
po.set_ValueOfColumn(field.getColumnName(), value);
if (changed && ! thisMandatoryError) {
savePO = true;
}
}
if (savePO && fillMandatoryError) {
FDialog.error(m_WindowNo, this, "FillMandatory", mandatoryFields.toString());
return false;
}
if (savePO) {
if (idxt > 0) {
int actualID = po.get_ValueAsInt(parentColumn);
if (actualID != parentID) {
po.set_ValueOfColumn(parentColumn, parentID);
}
}
po.saveEx();
}
if (idxt == 0) {
parentID = po.get_ID();
}
}
return true;
} // actionSave
/**
* Returns Record_ID
* @return Record_ID (0 = not saved)
*/
public int getRecord_ID()
{
if (quickPOs.get(0) == null)
return 0;
return quickPOs.get(0).get_ID();
} // getRecord_ID
public void onEvent(Event e) throws Exception
{
if (m_readOnly)
this.detach();
// OK pressed
else if ((e.getTarget() == confirmPanel.getButton("Ok")) && actionSave())
this.detach();
// Cancel pressed
else if (e.getTarget() == confirmPanel.getButton("Cancel"))
this.detach();
}
@Override
public void detach() {
super.detach();
SessionManager.getAppDesktop().unregisterWindow(m_WindowNo);
}
public void valueChange(ValueChangeEvent evt)
{
if (evt.getSource() instanceof WEditor) {
int idx = quickEditors.indexOf(evt.getSource());
if (idx >= 0) {
GridField field = quickFields.get(idx);
// process dependencies and callouts for the changed field
field.setValue(evt.getNewValue(), true);
field.getGridTab().processFieldChange(field);
}
}
}
} // WQuickEntry