IDEMPIERE-1969:Contextual Menu for Info Window Parameters

meged all patch to one
This commit is contained in:
hieplq 2015-01-14 09:37:19 -05:00
parent bf81fe07a4
commit cf32e66554
17 changed files with 455 additions and 83 deletions

View File

@ -0,0 +1,33 @@
SET SQLBLANKLINES ON
SET DEFINE OFF
-- Sep 17, 2014 11:44:24 AM ICT
-- I forgot to set the DICTIONARY_ID_COMMENTS System Configurator
INSERT INTO AD_Column (SeqNoSelection,IsSyncDatabase,Version,AD_Column_ID,IsMandatory,IsTranslated,IsIdentifier,SeqNo,IsParent,FieldLength,IsSelectionColumn,IsKey,IsAutocomplete,IsAllowLogging,AD_Column_UU,IsUpdateable,ColumnName,Description,Help,Name,IsAllowCopy,Updated,CreatedBy,AD_Org_ID,IsActive,Created,UpdatedBy,IsToolbarButton,IsAlwaysUpdateable,AD_Client_ID,EntityType,IsEncrypted,IsSecure,FKConstraintName,FKConstraintType,AD_Element_ID,AD_Reference_ID,AD_Table_ID) VALUES (0,'N',0,211766,'N','N','N',0,'N',10,'N','N','N','Y','d32e78d0-660c-4e82-9797-52a00ce3042f','N','AD_InfoWindow_ID','Info and search/select Window','The Info window is used to search and select records as well as display information relevant to the selection.','Info Window','Y',TO_DATE('2014-09-17 11:44:23','YYYY-MM-DD HH24:MI:SS'),100,0,'Y',TO_DATE('2014-09-17 11:44:23','YYYY-MM-DD HH24:MI:SS'),100,'N','N',0,'D','N','N','ad_infowindow_preference','N',3068,19,195)
;
-- Sep 17, 2014 11:44:56 AM ICT
UPDATE AD_Column SET IsUpdateable='Y',Updated=TO_DATE('2014-09-17 11:44:56','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=211766
;
-- Sep 17, 2014 11:47:56 AM ICT
ALTER TABLE AD_Preference ADD AD_InfoWindow_ID NUMBER(10) DEFAULT NULL
;
-- Sep 17, 2014 11:47:57 AM ICT
ALTER TABLE AD_Preference ADD CONSTRAINT ad_infowindow_preference FOREIGN KEY (AD_InfoWindow_ID) REFERENCES ad_infowindow(ad_infowindow_id) DEFERRABLE INITIALLY DEFERRED
;
-- Sep 17, 2014 11:48:37 AM ICT
INSERT INTO AD_IndexColumn (AD_Client_ID,AD_Org_ID,AD_IndexColumn_ID,AD_IndexColumn_UU,Created,CreatedBy,IsActive,Updated,UpdatedBy,AD_TableIndex_ID,SeqNo,AD_Column_ID,EntityType) VALUES (0,0,201253,'c07256ab-8778-4487-978a-d9aa59ef165f',TO_DATE('2014-09-17 11:48:36','YYYY-MM-DD HH24:MI:SS'),100,'Y',TO_DATE('2014-09-17 11:48:36','YYYY-MM-DD HH24:MI:SS'),100,200141,0,211766,'D')
;
-- Sep 17, 2014 11:48:56 AM ICT
DROP INDEX ad_preference_attribute
;
-- Sep 17, 2014 11:48:56 AM ICT
CREATE UNIQUE INDEX ad_preference_attribute ON AD_Preference (PreferenceFor,AD_InfoWindow_ID,AD_Process_ID,AD_Client_ID,AD_Org_ID,AD_Window_ID,AD_User_ID,Attribute)
;
SELECT register_migration_script('201417091982-IDEMPIERE-1969.sql') FROM dual
;

View File

@ -0,0 +1,30 @@
-- Sep 17, 2014 11:44:24 AM ICT
-- I forgot to set the DICTIONARY_ID_COMMENTS System Configurator
INSERT INTO AD_Column (SeqNoSelection,IsSyncDatabase,Version,AD_Column_ID,IsMandatory,IsTranslated,IsIdentifier,SeqNo,IsParent,FieldLength,IsSelectionColumn,IsKey,IsAutocomplete,IsAllowLogging,AD_Column_UU,IsUpdateable,ColumnName,Description,Help,Name,IsAllowCopy,Updated,CreatedBy,AD_Org_ID,IsActive,Created,UpdatedBy,IsToolbarButton,IsAlwaysUpdateable,AD_Client_ID,EntityType,IsEncrypted,IsSecure,FKConstraintName,FKConstraintType,AD_Element_ID,AD_Reference_ID,AD_Table_ID) VALUES (0,'N',0,211766,'N','N','N',0,'N',10,'N','N','N','Y','d32e78d0-660c-4e82-9797-52a00ce3042f','N','AD_InfoWindow_ID','Info and search/select Window','The Info window is used to search and select records as well as display information relevant to the selection.','Info Window','Y',TO_TIMESTAMP('2014-09-17 11:44:23','YYYY-MM-DD HH24:MI:SS'),100,0,'Y',TO_TIMESTAMP('2014-09-17 11:44:23','YYYY-MM-DD HH24:MI:SS'),100,'N','N',0,'D','N','N','ad_infowindow_preference','N',3068,19,195)
;
-- Sep 17, 2014 11:44:56 AM ICT
UPDATE AD_Column SET IsUpdateable='Y',Updated=TO_TIMESTAMP('2014-09-17 11:44:56','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=211766
;
-- Sep 17, 2014 11:47:56 AM ICT
ALTER TABLE AD_Preference ADD COLUMN AD_InfoWindow_ID NUMERIC(10) DEFAULT NULL
;
-- Sep 17, 2014 11:47:57 AM ICT
ALTER TABLE AD_Preference ADD CONSTRAINT ad_infowindow_preference FOREIGN KEY (AD_InfoWindow_ID) REFERENCES ad_infowindow(ad_infowindow_id) DEFERRABLE INITIALLY DEFERRED
;
-- Sep 17, 2014 11:48:37 AM ICT
INSERT INTO AD_IndexColumn (AD_Client_ID,AD_Org_ID,AD_IndexColumn_ID,AD_IndexColumn_UU,Created,CreatedBy,IsActive,Updated,UpdatedBy,AD_TableIndex_ID,SeqNo,AD_Column_ID,EntityType) VALUES (0,0,201253,'c07256ab-8778-4487-978a-d9aa59ef165f',TO_TIMESTAMP('2014-09-17 11:48:36','YYYY-MM-DD HH24:MI:SS'),100,'Y',TO_TIMESTAMP('2014-09-17 11:48:36','YYYY-MM-DD HH24:MI:SS'),100,200141,0,211766,'D')
;
-- Sep 17, 2014 11:48:56 AM ICT
DROP INDEX ad_preference_attribute
;
-- Sep 17, 2014 11:48:56 AM ICT
CREATE UNIQUE INDEX ad_preference_attribute ON AD_Preference (PreferenceFor,AD_InfoWindow_ID,AD_Process_ID,AD_Client_ID,AD_Org_ID,AD_Window_ID,AD_User_ID,Attribute)
;
SELECT register_migration_script('201417091982-IDEMPIERE-1969.sql') FROM dual
;

View File

@ -81,7 +81,7 @@ public class GridField
/**
*
*/
private static final long serialVersionUID = -757531553169088955L;
private static final long serialVersionUID = 8596059010377209016L;
/**
* Field Constructor.
@ -660,7 +660,46 @@ public class GridField
} // Default value
if (getAD_Process_ID_Of_Panel() > 0){
defStr = Env.getPreference (m_vo.ctx, getAD_Window_ID_Of_Panel(), getAD_Process_ID_Of_Panel(), m_vo.ColumnName);
defStr = Env.getPreference (m_vo.ctx, getAD_Window_ID_Of_Panel(), getAD_Infowindow_ID(), getAD_Process_ID_Of_Panel(), m_vo.ColumnName);
// when have no preference set for field, and field lie in process dialog call from infoWindow
if (defStr.equals("") && getAD_Infowindow_ID() > 0){
// try get preference for current infoWindow but all process
defStr = Env.getPreference (m_vo.ctx, Env.adWindowDummyID, getAD_Infowindow_ID(), 0, m_vo.ColumnName);
if (defStr.equals("")){
// try get preference for current process but all infoWindow
defStr = Env.getPreference (m_vo.ctx, Env.adWindowDummyID, 0, getAD_Process_ID_Of_Panel(), m_vo.ColumnName);
}
if (defStr.equals("")){
// try get preference for all infoWindow and all process
defStr = Env.getPreference (m_vo.ctx, Env.adWindowDummyID, 0, 0, m_vo.ColumnName);
}
}
if (defStr.equals("")){
// try get preference apply for all process and current window
defStr = Env.getPreference (m_vo.ctx, getAD_Window_ID_Of_Panel(), 0, 0, m_vo.ColumnName);
}
if (defStr.equals("")){
// try get preference apply for all window and this process
defStr = Env.getPreference (m_vo.ctx, 0, 0, getAD_Process_ID_Of_Panel(), m_vo.ColumnName);
}
if (defStr.equals("")){
// try get preference apply for all process and all window
defStr = Env.getPreference (m_vo.ctx, 0, 0, 0, m_vo.ColumnName);
}
if (!defStr.equals("")){
if (log.isLoggable(Level.FINE)) log.fine("[Process Parameter Preference] " + m_vo.ColumnName + "=" + defStr);
return createDefault(defStr);
}
// <- End of suggested changes
} else if (getAD_Infowindow_ID() > 0){
defStr = Env.getPreference (m_vo.ctx, getAD_Window_ID_Of_Panel(), getAD_Infowindow_ID(), m_vo.ColumnName);
if (!defStr.equals(""))
{
if (log.isLoggable(Level.FINE)) log.fine("[Process Parameter Preference] " + m_vo.ColumnName + "=" + defStr);
@ -1080,6 +1119,10 @@ public class GridField
return m_vo.AD_Window_ID_Of_Panel > 0 ? m_vo.AD_Window_ID_Of_Panel : m_vo.AD_Window_ID;
}
public int getAD_Infowindow_ID(){
return m_vo.AD_Infowindow_ID;
}
/** get AD_Chart_ID
* @return chart id
*/

View File

@ -47,7 +47,7 @@ public class GridFieldVO implements Serializable
/**
*
*/
private static final long serialVersionUID = 4367399601545064219L;
private static final long serialVersionUID = -7001013190366328211L;
/**
* Return the SQL statement used for the MFieldVO.create
@ -318,7 +318,7 @@ public class GridFieldVO implements Serializable
* @param rs result set AD_Process_Para
* @return MFieldVO
*/
public static GridFieldVO createParameter (Properties ctx, int WindowNo, int ProcessIDOfPanel, int WindowIDOfPanel, ResultSet rs)
public static GridFieldVO createParameter (Properties ctx, int WindowNo, int ProcessIDOfPanel, int WindowIDOfPanel, int adInfoPaneId, ResultSet rs)
{
GridFieldVO vo = new GridFieldVO (ctx, WindowNo, 0, 0, 0, false);
vo.isProcess = true;
@ -327,6 +327,7 @@ public class GridFieldVO implements Serializable
vo.IsUpdateable = true;
vo.AD_Process_ID_Of_Panel = ProcessIDOfPanel;
vo.AD_Window_ID_Of_Panel = WindowIDOfPanel;
vo.AD_Infowindow_ID = adInfoPaneId;
try
{
@ -411,7 +412,20 @@ public class GridFieldVO implements Serializable
return voT;
} // createParameter
public static GridFieldVO createParameter (Properties ctx, int WindowNo,
/**
* Create parameter for infoWindow
* @param ctx
* @param WindowNo
* @param AD_Column_ID
* @param ColumnName
* @param Name
* @param AD_Reference_ID
* @param AD_Reference_Value_ID
* @param IsMandatory
* @param IsEncrypted
* @return
*/
public static GridFieldVO createParameter (Properties ctx, int WindowNo, int WindowIDOfPanel, int infoWindowID,
int AD_Column_ID, String ColumnName, String Name, int AD_Reference_ID, int AD_Reference_Value_ID,
boolean IsMandatory, boolean IsEncrypted)
{
@ -428,6 +442,8 @@ public class GridFieldVO implements Serializable
vo.AD_Reference_Value_ID = AD_Reference_Value_ID;
vo.IsMandatory = IsMandatory;
vo.IsEncryptedField= IsEncrypted;
vo.AD_Infowindow_ID = infoWindowID;
vo.AD_Window_ID_Of_Panel = WindowIDOfPanel;
//
vo.initFinish();
return vo;
@ -499,7 +515,14 @@ public class GridFieldVO implements Serializable
* it's difference with AD_Process_ID
*/
public int AD_Process_ID_Of_Panel;
/**
* ad_window_id of window show process dialog or infoWindow dialog
*/
public int AD_Window_ID_Of_Panel;
/**
* AD_Infowindow_ID call process. user in case from info window call process.
*/
public int AD_Infowindow_ID;
/** AD_Tab_ID */
public int AD_Tab_ID;
/** Is the Tab Read Only */
@ -771,6 +794,7 @@ public class GridFieldVO implements Serializable
clone.DefaultValue2 = DefaultValue2;
clone.AD_Process_ID_Of_Panel = AD_Process_ID_Of_Panel;
clone.AD_Window_ID_Of_Panel = AD_Window_ID_Of_Panel;
clone.AD_Infowindow_ID = AD_Infowindow_ID;
return clone;
} // clone

View File

@ -49,6 +49,21 @@ public interface I_AD_Preference
*/
public int getAD_Client_ID();
/** Column name AD_InfoWindow_ID */
public static final String COLUMNNAME_AD_InfoWindow_ID = "AD_InfoWindow_ID";
/** Set Info Window.
* Info and search/select Window
*/
public void setAD_InfoWindow_ID (int AD_InfoWindow_ID);
/** Get Info Window.
* Info and search/select Window
*/
public int getAD_InfoWindow_ID();
public org.compiere.model.I_AD_InfoWindow getAD_InfoWindow() throws RuntimeException;
/** Column name AD_Org_ID */
public static final String COLUMNNAME_AD_Org_ID = "AD_Org_ID";

View File

@ -74,6 +74,34 @@ public class X_AD_Preference extends PO implements I_AD_Preference, I_Persistent
return sb.toString();
}
public org.compiere.model.I_AD_InfoWindow getAD_InfoWindow() throws RuntimeException
{
return (org.compiere.model.I_AD_InfoWindow)MTable.get(getCtx(), org.compiere.model.I_AD_InfoWindow.Table_Name)
.getPO(getAD_InfoWindow_ID(), get_TrxName()); }
/** Set Info Window.
@param AD_InfoWindow_ID
Info and search/select Window
*/
public void setAD_InfoWindow_ID (int AD_InfoWindow_ID)
{
if (AD_InfoWindow_ID < 1)
set_Value (COLUMNNAME_AD_InfoWindow_ID, null);
else
set_Value (COLUMNNAME_AD_InfoWindow_ID, Integer.valueOf(AD_InfoWindow_ID));
}
/** Get Info Window.
@return Info and search/select Window
*/
public int getAD_InfoWindow_ID ()
{
Integer ii = (Integer)get_Value(COLUMNNAME_AD_InfoWindow_ID);
if (ii == null)
return 0;
return ii.intValue();
}
/** Set Preference.
@param AD_Preference_ID
Personal Value Preference

View File

@ -43,7 +43,7 @@ public class ProcessInfo implements Serializable
/**
*
*/
private static final long serialVersionUID = -3654748247858779823L;
private static final long serialVersionUID = -1084726411940456050L;
/**
* Constructor
@ -94,6 +94,7 @@ public class ProcessInfo implements Serializable
/** Process Instance ID */
private int m_AD_PInstance_ID = 0;
private int m_InfoWindowID = 0;
/** Summary of Execution */
private String m_Summary = "";
/** Execution had an error */
@ -343,6 +344,23 @@ public class ProcessInfo implements Serializable
m_AD_PInstance_ID = AD_PInstance_ID;
}
/**
*
* @return int
*/
public int getAD_InfoWindow_ID()
{
return m_InfoWindowID;
}
/**
*
* @param AD_PInstance_ID int
*/
public void setAD_InfoWindow_ID(int infoWindowID)
{
m_InfoWindowID = infoWindowID;
}
/**
* Method getAD_Process_ID
* @return int

View File

@ -96,6 +96,8 @@ public final class Env
private static List<IEnvEventListener> eventListeners = new ArrayList<IEnvEventListener>();
public static int adWindowDummyID =200054;
/** Logger */
private static CLogger log = CLogger.getCLogger(Env.class);
@ -960,13 +962,41 @@ public final class Env
return (retValue == null ? "" : retValue);
} // getPreference
public static String getPreference (Properties ctx, int AD_Window_ID, int AD_Process_ID_Of_Panel, String context)
/**
* get preference of process from env
* @param ctx
* @param AD_Window_ID
* @param AD_InfoWindow
* @param AD_Process_ID_Of_Panel
* @param context
* @return
*/
public static String getPreference (Properties ctx, int AD_Window_ID, int AD_InfoWindow, int AD_Process_ID_Of_Panel, String context)
{
if (ctx == null || context == null)
throw new IllegalArgumentException ("Require Context");
String retValue = null;
retValue = ctx.getProperty("P"+AD_Window_ID+"|"+ AD_Process_ID_Of_Panel + "|" + context);
retValue = ctx.getProperty("P"+AD_Window_ID+"|"+ AD_InfoWindow + "|" + AD_Process_ID_Of_Panel + "|" + context);
return (retValue == null ? "" : retValue);
} // getPreference
/**
* get preference of info window from env
* @param ctx
* @param AD_Window_ID
* @param AD_InfoWindow
* @param context
* @return
*/
public static String getPreference (Properties ctx, int AD_Window_ID, int AD_InfoWindow, String context)
{
if (ctx == null || context == null)
throw new IllegalArgumentException ("Require Context");
String retValue = null;
retValue = ctx.getProperty("P"+AD_Window_ID+"|"+ AD_InfoWindow + "|" + context);
return (retValue == null ? "" : retValue);
} // getPreference

View File

@ -928,7 +928,7 @@ public class Login
// This reads all relevant window neutral defaults
// overwriting superseeded ones. Window specific is read in Mainain
sql = "SELECT Attribute, Value, AD_Window_ID, AD_Process_ID, PreferenceFor "
sql = "SELECT Attribute, Value, AD_Window_ID, AD_Process_ID, AD_InfoWindow_ID, PreferenceFor "
+ "FROM AD_Preference "
+ "WHERE AD_Client_ID IN (0, @#AD_Client_ID@)"
+ " AND AD_Org_ID IN (0, @#AD_Org_ID@)"
@ -948,7 +948,8 @@ public class Login
int AD_Window_ID = rs.getInt(3);
boolean isAllWindow = rs.wasNull();
int AD_Process_ID = rs.getInt(4);
String PreferenceFor = rs.getString(5);
int AD_InfoWindow_ID = rs.getInt(5);
String PreferenceFor = rs.getString(6);
String at = "";
// preference for window
@ -959,7 +960,9 @@ public class Login
at = "P" + AD_Window_ID + "|" + rs.getString(1);
}else if ("P".equals(PreferenceFor)){ // preference for processs
// when apply for all window or all process format is "P0|0|m_Attribute;
at = "P" + AD_Window_ID + "|" + AD_Process_ID + "|" + rs.getString(1);
at = "P" + AD_Window_ID + "|" + AD_InfoWindow_ID + "|" + AD_Process_ID + "|" + rs.getString(1);
}else if ("I".equals(PreferenceFor)){ // preference for infoWindow
at = "P" + AD_Window_ID + "|" + AD_InfoWindow_ID + "|" + rs.getString(1);
}
String va = rs.getString(2);

View File

@ -296,7 +296,7 @@ public class ProcessParameter extends CDialog
private void createField (ResultSet rs)
{
// Create Field
GridFieldVO voF = GridFieldVO.createParameter(Env.getCtx(), m_WindowNo, m_processInfo.getAD_Process_ID(), m_AD_Window_ID, rs);
GridFieldVO voF = GridFieldVO.createParameter(Env.getCtx(), m_WindowNo, m_processInfo.getAD_Process_ID(), m_AD_Window_ID, 0, rs);
GridField mField = new GridField (voF);
m_mFields.add(mField); // add to Fields

View File

@ -63,6 +63,7 @@ import org.compiere.util.Msg;
* @version 2006-12-01
*/
public class ProcessParameterPanel extends CPanel implements VetoableChangeListener, IProcessParameter {
/**
*
*/
@ -286,7 +287,7 @@ public class ProcessParameterPanel extends CPanel implements VetoableChangeListe
private void createField (ResultSet rs)
{
// Create Field
GridFieldVO voF = GridFieldVO.createParameter(Env.getCtx(), m_WindowNo, m_processInfo.getAD_Process_ID(), m_AD_Window_ID, rs);
GridFieldVO voF = GridFieldVO.createParameter(Env.getCtx(), m_WindowNo, m_processInfo.getAD_Process_ID(), m_AD_Window_ID, m_processInfo.getAD_InfoWindow_ID(),rs);
GridField mField = new GridField (voF);
m_mFields.add(mField); // add to Fields

View File

@ -42,6 +42,7 @@ import org.compiere.util.CLogger;
import org.compiere.util.DB;
import org.compiere.util.DisplayType;
import org.compiere.util.Env;
import org.compiere.util.Login;
import org.compiere.util.Msg;
import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.Page;
@ -121,7 +122,7 @@ public class ValuePreference extends Window implements EventListener<Event>
// Create Editor
@SuppressWarnings("unused")
ValuePreference vp = new ValuePreference (WindowNo,
AD_Client_ID, AD_Org_ID, AD_User_ID, AD_Window_ID, mField.getAD_Process_ID_Of_Panel(),
AD_Client_ID, AD_Org_ID, AD_User_ID, AD_Window_ID, mField.getAD_Process_ID_Of_Panel(), mField.getAD_Infowindow_ID(),
Attribute, DisplayAttribute, Value, DisplayValue,
displayType, AD_Reference_ID, ref);
} // create
@ -183,7 +184,7 @@ public class ValuePreference extends Window implements EventListener<Event>
* @param ref
*/
public ValuePreference (int WindowNo,
int AD_Client_ID, int AD_Org_ID, int AD_User_ID, int AD_Window_ID, int AD_Process_ID_Of_Panel,
int AD_Client_ID, int AD_Org_ID, int AD_User_ID, int AD_Window_ID, int AD_Process_ID_Of_Panel, int AD_Infowindow_ID,
String Attribute, String DisplayAttribute, String Value, String DisplayValue,
int displayType, int AD_Reference_ID, Component ref)
{
@ -207,8 +208,13 @@ public class ValuePreference extends Window implements EventListener<Event>
m_DisplayValue = DisplayValue;
m_DisplayType = displayType;
m_AD_Process_ID_Of_Panel = AD_Process_ID_Of_Panel;
m_AD_Infowindow_ID = AD_Infowindow_ID;
//
m_role = MRole.getDefault();
if (m_AD_Infowindow_ID > 0 && m_AD_Process_ID_Of_Panel > 0)
isProcessInIW = true;
try
{
init();
@ -229,6 +235,7 @@ public class ValuePreference extends Window implements EventListener<Event>
} else {
AEnv.showCenterScreen(this);
}
} // ValuePreference
private AbstractADWindowContent findADWindowContent(Component comp) {
@ -249,6 +256,7 @@ public class ValuePreference extends Window implements EventListener<Event>
private int m_DisplayType;
private MRole m_role;
private int m_AD_Process_ID_Of_Panel;
private int m_AD_Infowindow_ID;
// Display
private Panel setPanel = new Panel();
@ -265,11 +273,17 @@ public class ValuePreference extends Window implements EventListener<Event>
private Checkbox cbUser = new Checkbox();
private Checkbox cbWindow = new Checkbox();
private Checkbox cbProcess = new Checkbox();
private Checkbox cbInfowindow = new Checkbox();
private Label lExplanation = new Label();
private ConfirmPanel confirmPanel = new ConfirmPanel(true);
private Button bDelete;
/**
* is true when value preference for a field of process call by info window
*/
private boolean isProcessInIW = false;
/**
* Static Layout
* @throws Exception
@ -288,6 +302,8 @@ public class ValuePreference extends Window implements EventListener<Event>
cbWindow.setChecked(true);
cbProcess.setLabel(Msg.translate(m_ctx, "AD_Process_ID"));
cbProcess.setChecked(true);
cbInfowindow.setLabel(Msg.translate(m_ctx, "AD_InfoWindow_ID"));
cbInfowindow.setChecked(true);
//
setPanel.appendChild(setLayout);
setPanel.setHflex("1");
@ -334,10 +350,23 @@ public class ValuePreference extends Window implements EventListener<Event>
chlayout.appendChild(cbClient);
chlayout.appendChild(cbOrg);
chlayout.appendChild(cbUser);
if(isProcessInIW){
// in case show process in info window, don't show checkbox window in value preference dialog.
// must set is checked to save current windowID (dummy) with value preference other it will save null,
// make data conflic with case save for all window
cbWindow.setChecked(true);
}else{
chlayout.appendChild(cbWindow);
}
if(m_AD_Infowindow_ID > 0){
chlayout.appendChild(cbInfowindow);
}
if(m_AD_Process_ID_Of_Panel > 0){
chlayout.appendChild(cbProcess);
}
row.appendCellChild(chlayout, 5);
rows.appendChild(row);
@ -402,6 +431,7 @@ public class ValuePreference extends Window implements EventListener<Event>
// Can change all/specific
cbWindow.addEventListener(Events.ON_CHECK, this);
cbProcess.addEventListener(Events.ON_CHECK, this);
cbInfowindow.addEventListener(Events.ON_CHECK, this);
// Other
confirmPanel.addComponentsLeft(confirmPanel.createButton("Delete"));
@ -473,6 +503,13 @@ public class ValuePreference extends Window implements EventListener<Event>
else
expl.append(" and all Process");
}
//
if (m_AD_Infowindow_ID > 0){
if (cbInfowindow.isChecked())
expl.append(" and this Info Window");
else
expl.append(" and all Info Window");
}
//
if (Env.getLanguage(Env.getCtx()).isBaseLanguage())
@ -501,19 +538,35 @@ public class ValuePreference extends Window implements EventListener<Event>
else
sql.append(" AND AD_Window_ID IS NULL");
if (m_AD_Process_ID_Of_Panel > 0){
// preference for process parameter
sql.append(" AND PreferenceFor = 'P'");
if (cbProcess.isChecked())
// set where for Process
if (m_AD_Process_ID_Of_Panel > 0 && cbProcess.isChecked()){
// case set for a process
sql.append(" AND AD_Process_ID=").append(m_AD_Process_ID_Of_Panel);
else
sql.append(" AND AD_Process_ID IS NULL");
}else{
// preference for process window
sql.append(" AND PreferenceFor = 'W'");
// case set for a all process or non set for process (set for window or infowindow)
sql.append(" AND AD_Process_ID IS NULL");
}
// set where for infoWindow
if (m_AD_Infowindow_ID > 0 && cbInfowindow.isChecked()){
// case set for a info window
sql.append(" AND AD_InfoWindow_ID=").append(m_AD_Infowindow_ID);
}else{
// case set for a all process or non set for process (set for window or infowindow)
sql.append(" AND AD_InfoWindow_ID IS NULL");
}
if (m_AD_Process_ID_Of_Panel > 0){
// in case Preference for process, set PreferenceFor = P
sql.append(" AND PreferenceFor = 'P'");
}else if (m_AD_Infowindow_ID > 0){
// in case Preference for info window, set PreferenceFor = I
sql.append(" AND PreferenceFor = 'I'");
}else {
// in case Preference for window, set PreferenceFor = W
sql.append(" AND PreferenceFor = 'W'");
}
sql.append(" AND Attribute='").append(m_Attribute).append("'");
//
if (log.isLoggable(Level.FINE)) log.fine( sql.toString());
@ -525,17 +578,40 @@ public class ValuePreference extends Window implements EventListener<Event>
/**
* Get Context Key
* preferences in context update follow key.
* they load when login, and update when change.
* @see Login#loadPreferences(org.compiere.util.KeyNamePair, org.compiere.util.KeyNamePair, java.sql.Timestamp, String)
* and set to field when display field, {@link GridField#getDefault()}
* @return Context Key
*/
private String getContextKey()
{
if (m_AD_Process_ID_Of_Panel > 0){
if (cbProcess.isChecked())
return "P" + m_AD_Window_ID + "|" + m_AD_Process_ID_Of_Panel + "|" + m_Attribute;
else{
return "P" + m_AD_Window_ID + "|0|" + m_Attribute;
}
// add window id info in case have process or field in info window parameter
StringBuilder preferencesContextKey = new StringBuilder ("P") ;
if (m_AD_Window_ID > 0){
preferencesContextKey.append(m_AD_Window_ID);
}else{
preferencesContextKey.append("0");
}
// add info window info in case have process or field in info window parameter
if (cbInfowindow.isChecked()){
preferencesContextKey.append("|").append(m_AD_Infowindow_ID);
}else{
preferencesContextKey.append("|0");
}
if (m_AD_Process_ID_Of_Panel > 0){
// add info process info and field info in case have process
if (cbProcess.isChecked())
return preferencesContextKey.append("|").append(m_AD_Process_ID_Of_Panel).append("|").append(m_Attribute).toString();
else{
return preferencesContextKey.append("|0|").append(m_Attribute).toString();
}
}else if (m_AD_Infowindow_ID > 0){
// add field info in case lie in info window parameter
return preferencesContextKey.append("|").append(m_Attribute).toString();
}else{
// key in case lie in standard window
if (cbWindow.isChecked())
return "P" + m_AD_Window_ID + "|" + m_Attribute;
else
@ -575,7 +651,7 @@ public class ValuePreference extends Window implements EventListener<Event>
//
StringBuilder sql = new StringBuilder ("INSERT INTO AD_Preference ("
+ "AD_Preference_ID, AD_Preference_UU, AD_Client_ID, AD_Org_ID, IsActive, Created,CreatedBy,Updated,UpdatedBy,"
+ "AD_Window_ID, AD_Process_ID, PreferenceFor, AD_User_ID, Attribute, Value) VALUES (");
+ "AD_Window_ID, AD_Process_ID, AD_InfoWindow_ID, PreferenceFor, AD_User_ID, Attribute, Value) VALUES (");
sql.append(AD_Preference_ID).append(",").append(DB.TO_STRING(UUID.randomUUID().toString())).append(",").append(Client_ID).append(",").append(Org_ID)
.append(", 'Y',SysDate,").append(m_AD_User_ID).append(",SysDate,").append(m_AD_User_ID).append(", ");
@ -585,18 +661,30 @@ public class ValuePreference extends Window implements EventListener<Event>
sql.append("NULL,") ;
// set value for AD_Process_ID and PreferenceFor
if(m_AD_Process_ID_Of_Panel > 0){
if (cbProcess.isChecked()){
if(m_AD_Process_ID_Of_Panel > 0 && cbProcess.isChecked()){
sql.append(m_AD_Process_ID_Of_Panel).append(",");
}else{
sql.append("NULL,");
}
// in case Preference for process, set PreferenceFor = P
sql.append("'P',");
}else{
// in case Preference for window, AD_Process_ID always null
sql.append("NULL,");
// in case Preference for window, set PreferenceFor = P
}
// set info window id
if (m_AD_Infowindow_ID > 0 && cbInfowindow.isChecked()){
sql.append(m_AD_Infowindow_ID).append(",");
}else {
sql.append("NULL,");
}
if (m_AD_Process_ID_Of_Panel > 0){
// in case Preference for process, set PreferenceFor = P
sql.append("'P',");
}else if (m_AD_Infowindow_ID > 0){
// in case Preference for info window, set PreferenceFor = I
sql.append("'I',");
}else {
// in case Preference for window, set PreferenceFor = W
sql.append("'W',");
}

View File

@ -34,8 +34,10 @@ import java.util.logging.Level;
import javax.servlet.ServletRequest;
import org.adempiere.webui.adwindow.ADWindow;
import org.adempiere.webui.component.Window;
import org.adempiere.webui.desktop.IDesktop;
import org.adempiere.webui.info.InfoWindow;
import org.adempiere.webui.session.SessionManager;
import org.adempiere.webui.theme.ThemeManager;
import org.adempiere.webui.util.IServerPushCallback;
@ -760,4 +762,29 @@ public final class AEnv
IDesktop appDesktop = SessionManager.getAppDesktop();
return appDesktop != null ? appDesktop.getClientInfo().tablet : false;
}
/**
* Get adWindowId below gridField
* when field lie in window, it's id of this window
* when field lie in process parameter dialog it's ad_window_id of window open this process
* when field lie in process parameter open in a standalone window (run process from menu) return id of dummy window
* @param mField
* @return
*/
public static int getADWindowID (int windowNo){
int adWindowID = 0;
// form process parameter panel
Object window = SessionManager.getAppDesktop().findWindow(windowNo);
// case show a process dialog, window is below window of process dialog
if (window != null && window instanceof ADWindow){
adWindowID = ((ADWindow)window).getAD_Window_ID();
}else if (window != null && (window instanceof ProcessDialog || window instanceof InfoWindow)){
// dummy window is use in case process or infoWindow open in stand-alone window
// it help we separate case save preference for all window (windowId = 0, null) and case open in stand-alone (windowId = 200054)
adWindowID = Env.adWindowDummyID;// dummy window
}
return adWindowID;
}
} // AEnv

View File

@ -23,7 +23,6 @@ import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import org.adempiere.webui.adwindow.ADWindow;
import org.adempiere.webui.component.Column;
import org.adempiere.webui.component.Columns;
import org.adempiere.webui.component.EditorBox;
@ -106,36 +105,14 @@ public class ProcessParameterPanel extends Panel implements
//
m_WindowNo = WindowNo;
m_processInfo = pi;
m_AD_Window_ID = getADWindowID (WindowNo);
m_AD_Window_ID = AEnv.getADWindowID (WindowNo);
this.width = width;
this.m_InfoWindowID = pi.getAD_InfoWindow_ID();
//
initComponent();
addEventListener("onDynamicDisplay", this);
} // ProcessParameterPanel
/**
* Get adWindowId below gridField
* when field lie in window, it's id of this window
* when field lie in process parameter dialog it's ad_window_id of window open this process
* when field lie in process parameter open in a standalone window (run process from menu) return id of dummy window
* @param mField
* @return
*/
public static int getADWindowID (int windowNo){
int adWindowID = 0;
// form process parameter panel
Object window = SessionManager.getAppDesktop().findWindow(windowNo);
// case show a process dialog, window is below window of process dialog
if (window != null && window instanceof ADWindow){
adWindowID = ((ADWindow)window).getAD_Window_ID();
}else if (window != null && window instanceof ProcessDialog){
adWindowID = 200054;// dummy window
}
return adWindowID;
}
private void initComponent() {
centerPanel = GridFactory.newGridLayout();
centerPanel.setInnerWidth(width);
@ -156,6 +133,8 @@ public class ProcessParameterPanel extends Panel implements
private ProcessInfo m_processInfo;
// AD_Window of window below this dialog in case show parameter dialog panel
private int m_AD_Window_ID = 0;
// infoWindowID of infoWindow below this dialog in case call process from infoWindow
private int m_InfoWindowID = 0;
/** Logger */
private static CLogger log = CLogger
.getCLogger(ProcessParameterPanel.class);
@ -307,7 +286,7 @@ public class ProcessParameterPanel extends Panel implements
*/
private void createField(ResultSet rs, Rows rows) {
// Create Field
GridFieldVO voF = GridFieldVO.createParameter(Env.getCtx(), m_WindowNo, m_processInfo.getAD_Process_ID(), m_AD_Window_ID,
GridFieldVO voF = GridFieldVO.createParameter(Env.getCtx(), m_WindowNo, m_processInfo.getAD_Process_ID(), m_AD_Window_ID, m_InfoWindowID,
rs);
GridField mField = new GridField(voF);
m_mFields.add(mField); // add to Fields

View File

@ -32,6 +32,7 @@ import org.adempiere.webui.component.EditorBox;
import org.adempiere.webui.component.Label;
import org.adempiere.webui.component.NumberBox;
import org.adempiere.webui.component.Paymentbox;
import org.adempiere.webui.event.ContextMenuListener;
import org.adempiere.webui.event.ValueChangeEvent;
import org.adempiere.webui.event.ValueChangeListener;
import org.adempiere.webui.theme.ThemeManager;
@ -53,6 +54,7 @@ import org.zkoss.zul.Image;
import org.zkoss.zul.Menuitem;
import org.zkoss.zul.Textbox;
import org.zkoss.zul.impl.InputElement;
import org.zkoss.zul.impl.XulElement;
/**
*
@ -94,6 +96,48 @@ public abstract class WEditor implements EventListener<Event>, PropertyChangeLis
private boolean isProcessParameter;
/**
* call to show context menu of this field.
* must call after append component of this field to parent
*/
public void showMenu() {
if (popupMenu == null)
return;
// handle standard menu item (log, preference) reply to data type of this field.
if (ContextMenuListener.class.isInstance(this))
popupMenu.addMenuListener((ContextMenuListener)this);
//popupMenu.setId(mField.getColumnName()+"-popup");
this.component.getParent().appendChild(popupMenu);
// when field have label, add action zoom when click to label, and show menu when right click to label
if (!gridField.isFieldOnly())
{
if (popupMenu.isZoomEnabled() && this instanceof IZoomableEditor)
{
// add action zoom when click to label
label.addEventListener(Events.ON_CLICK, new EventListener<Event> (){
public void onEvent(Event event) throws Exception {
if (Events.ON_CLICK.equals(event.getName())) {
((IZoomableEditor)WEditor.this).actionZoom();
}
}
});
}
// show menu when right click to label
popupMenu.addContextElement(label);
if (component instanceof XulElement)
{
popupMenu.addContextElement((XulElement) component);
}
}
}
public WEditor(Component comp, GridField gridField) {
this(comp, gridField, -1);
}

View File

@ -18,6 +18,7 @@ import org.adempiere.model.IInfoColumn;
import org.adempiere.model.MInfoProcess;
import org.adempiere.model.MInfoRelated;
import org.adempiere.webui.AdempiereWebUI;
import org.adempiere.webui.apps.AEnv;
import org.adempiere.webui.component.Borderlayout;
import org.adempiere.webui.component.Button;
import org.adempiere.webui.component.Column;
@ -475,7 +476,7 @@ public class InfoWindow extends InfoPanel implements ValueChangeListener, EventL
String columnName = infoColumn.getColumnName();
/*!m_lookup && infoColumn.isMandatory():apply Mandatory only case open as window and only for criteria field*/
boolean isMandatory = !m_lookup && infoColumn.isMandatory() && infoColumn.isQueryCriteria();
GridFieldVO vo = GridFieldVO.createParameter(infoContext, p_WindowNo, 0,
GridFieldVO vo = GridFieldVO.createParameter(infoContext, p_WindowNo, AEnv.getADWindowID(p_WindowNo), infoWindow.getAD_InfoWindow_ID(), 0,
columnName, infoColumn.get_Translation("Name"), infoColumn.getAD_Reference_ID(),
infoColumn.getAD_Reference_Value_ID(), isMandatory, false);
if (infoColumn.getAD_Val_Rule_ID() > 0) {
@ -1221,6 +1222,9 @@ public class InfoWindow extends InfoPanel implements ValueChangeListener, EventL
addSearchParameter(label, fieldEditor);
editors.add(editor);
editor.showMenu();
if (infoColumn.isIdentifier()) {
identifiers.add(editor);
}
@ -1229,7 +1233,7 @@ public class InfoWindow extends InfoPanel implements ValueChangeListener, EventL
mField.addPropertyChangeListener(editor);
if (! Util.isEmpty(mField.getVO().DefaultValue, true)) {
if (!Util.isEmpty(mField.getVO().DefaultValue, true)) {
// set default value
mField.setValue(mField.getDefault(), true);
}
@ -1272,7 +1276,11 @@ public class InfoWindow extends InfoPanel implements ValueChangeListener, EventL
} else {
panel.appendChild(new Space());
}
panel.appendChild(fieldEditor);
// add out parent to add menu for this field, without outerDiv, a new cell will auto make for menu.
Div outerParent = new Div();
outerParent.appendChild(fieldEditor);
panel.appendChild(outerParent);
}
protected void createAndCheckbox() {
@ -1743,7 +1751,7 @@ public class InfoWindow extends InfoPanel implements ValueChangeListener, EventL
*/
protected GridField getGridField(MInfoColumn infoColumn){
String columnName = infoColumn.getColumnName();
GridFieldVO vo = GridFieldVO.createParameter(infoContext, p_WindowNo, 0,
GridFieldVO vo = GridFieldVO.createParameter(infoContext, p_WindowNo, AEnv.getADWindowID(p_WindowNo), AD_InfoWindow_ID, 0,
columnName, infoColumn.get_Translation("Name"), infoColumn.getAD_Reference_ID(),
infoColumn.getAD_Reference_Value_ID(), false, false);
if (infoColumn.getAD_Val_Rule_ID() > 0) {

View File

@ -1531,6 +1531,7 @@ public abstract class InfoPanel extends Window implements EventListener<Event>,
final int pInstanceID = instance.getAD_PInstance_ID();
// Execute Process
m_pi.setAD_PInstance_ID(pInstanceID);
m_pi.setAD_InfoWindow_ID(infoWindow.getAD_InfoWindow_ID());
//HengSin - to let process end with message and requery
WProcessCtl.process(p_WindowNo, m_pi, (Trx)null, new EventListener<Event>() {