IDEMPIERE-4917:Inject Context Variables from Menu to Info Window (#843)

Co-authored-by: jpiere <h.hagiwara@compiere-distribution-lab.net>
This commit is contained in:
HideakiHagiwara 2021-09-03 14:31:36 +09:00 committed by GitHub
parent 48c6dd40d4
commit bb35dbd8ce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 200 additions and 14 deletions

View File

@ -111,10 +111,9 @@ public abstract class TabbedDesktop extends AbstractDesktop {
*/ */
@Override @Override
public void openInfo(int infoId) { public void openInfo(int infoId) {
InfoPanel infoPanel = InfoManager.create(infoId); InfoPanel infoPanel = InfoManager.create(infoId, getPredefinedContextVariables());
if (infoPanel != null) { if (infoPanel != null) {
Env.setPredefinedVariables(Env.getCtx(), infoPanel.getWindowNo(), getPredefinedContextVariables());
DesktopTabpanel tabPanel = new DesktopTabpanel(); DesktopTabpanel tabPanel = new DesktopTabpanel();
infoPanel.setParent(tabPanel); infoPanel.setParent(tabPanel);
String title = infoPanel.getTitle(); String title = infoPanel.getTitle();

View File

@ -50,17 +50,24 @@ public class DefaultInfoFactory implements IInfoFactory {
@Override @Override
public InfoPanel create(int WindowNo, String tableName, String keyColumn, public InfoPanel create(int WindowNo, String tableName, String keyColumn,
String value, boolean multiSelection, String whereClause, int AD_InfoWindow_ID, boolean lookup) { String value, boolean multiSelection, String whereClause, int AD_InfoWindow_ID, boolean lookup) {
return create(WindowNo, tableName, keyColumn,
value, multiSelection, whereClause, AD_InfoWindow_ID, lookup, null);
}
public InfoPanel create(int WindowNo, String tableName, String keyColumn,
String value, boolean multiSelection, String whereClause, int AD_InfoWindow_ID, boolean lookup, String predefinedContextVariables) {
InfoPanel info = null; InfoPanel info = null;
setSOTrxBasedOnDocType(WindowNo); setSOTrxBasedOnDocType(WindowNo);
if (tableName.equals("C_BPartner")) { if (tableName.equals("C_BPartner")) {
info = new InfoBPartnerWindow(WindowNo, tableName, keyColumn, value, multiSelection, whereClause, AD_InfoWindow_ID, lookup); info = new InfoBPartnerWindow(WindowNo, tableName, keyColumn, value, multiSelection, whereClause, AD_InfoWindow_ID, lookup, predefinedContextVariables);
if (!info.loadedOK()) { if (!info.loadedOK()) {
info = new InfoBPartnerPanel (value,WindowNo, !Env.getContext(Env.getCtx(), WindowNo, "IsSOTrx").equals("N"), info = new InfoBPartnerPanel (value,WindowNo, !Env.getContext(Env.getCtx(), WindowNo, "IsSOTrx").equals("N"),
multiSelection, whereClause, lookup); multiSelection, whereClause, lookup);
} }
} else if (tableName.equals("M_Product")) { } else if (tableName.equals("M_Product")) {
info = new InfoProductWindow(WindowNo, tableName, keyColumn, value, multiSelection, whereClause, AD_InfoWindow_ID, lookup); info = new InfoProductWindow(WindowNo, tableName, keyColumn, value, multiSelection, whereClause, AD_InfoWindow_ID, lookup, predefinedContextVariables);
if (!info.loadedOK()) { if (!info.loadedOK()) {
info = new InfoProductPanel ( WindowNo, info = new InfoProductPanel ( WindowNo,
Env.getContextAsInt(Env.getCtx(), WindowNo, "M_Warehouse_ID"), Env.getContextAsInt(Env.getCtx(), WindowNo, "M_Warehouse_ID"),
@ -68,31 +75,31 @@ public class DefaultInfoFactory implements IInfoFactory {
multiSelection, value,whereClause, lookup); multiSelection, value,whereClause, lookup);
} }
} else if (tableName.equals("C_Invoice")) { } else if (tableName.equals("C_Invoice")) {
info = new InfoInvoiceWindow(WindowNo, tableName, keyColumn, value, multiSelection, whereClause, AD_InfoWindow_ID, lookup); info = new InfoInvoiceWindow(WindowNo, tableName, keyColumn, value, multiSelection, whereClause, AD_InfoWindow_ID, lookup, predefinedContextVariables);
if (!info.loadedOK()) { if (!info.loadedOK()) {
info = new InfoInvoicePanel ( WindowNo, value, info = new InfoInvoicePanel ( WindowNo, value,
multiSelection, whereClause, lookup); multiSelection, whereClause, lookup);
} }
} else if (tableName.equals("A_Asset")) { } else if (tableName.equals("A_Asset")) {
info = new InfoAssetWindow(WindowNo, tableName, keyColumn, value, multiSelection, whereClause, AD_InfoWindow_ID, lookup); info = new InfoAssetWindow(WindowNo, tableName, keyColumn, value, multiSelection, whereClause, AD_InfoWindow_ID, lookup, predefinedContextVariables);
if (!info.loadedOK()) { if (!info.loadedOK()) {
info = new InfoAssetPanel (WindowNo, 0, value, info = new InfoAssetPanel (WindowNo, 0, value,
multiSelection, whereClause, lookup); multiSelection, whereClause, lookup);
} }
} else if (tableName.equals("C_Order")) { } else if (tableName.equals("C_Order")) {
info = new InfoOrderWindow(WindowNo, tableName, keyColumn, value, multiSelection, whereClause, AD_InfoWindow_ID, lookup); info = new InfoOrderWindow(WindowNo, tableName, keyColumn, value, multiSelection, whereClause, AD_InfoWindow_ID, lookup, predefinedContextVariables);
if (!info.loadedOK()) { if (!info.loadedOK()) {
info = new InfoOrderPanel ( WindowNo, value, info = new InfoOrderPanel ( WindowNo, value,
multiSelection, whereClause, lookup); multiSelection, whereClause, lookup);
} }
} else if (tableName.equals("M_InOut")) { } else if (tableName.equals("M_InOut")) {
info = new InfoInOutWindow(WindowNo, tableName, keyColumn, value, multiSelection, whereClause, AD_InfoWindow_ID, lookup); info = new InfoInOutWindow(WindowNo, tableName, keyColumn, value, multiSelection, whereClause, AD_InfoWindow_ID, lookup, predefinedContextVariables);
if (!info.loadedOK()) { if (!info.loadedOK()) {
info = new InfoInOutPanel (WindowNo, value, info = new InfoInOutPanel (WindowNo, value,
multiSelection, whereClause, lookup); multiSelection, whereClause, lookup);
} }
} else if (tableName.equals("C_Payment")) { } else if (tableName.equals("C_Payment")) {
info = new InfoPaymentWindow(WindowNo, tableName, keyColumn, value, multiSelection, whereClause, AD_InfoWindow_ID, lookup); info = new InfoPaymentWindow(WindowNo, tableName, keyColumn, value, multiSelection, whereClause, AD_InfoWindow_ID, lookup, predefinedContextVariables);
if (!info.loadedOK()) { if (!info.loadedOK()) {
info = new InfoPaymentPanel (WindowNo, value, multiSelection, whereClause, lookup); info = new InfoPaymentPanel (WindowNo, value, multiSelection, whereClause, lookup);
} }
@ -100,13 +107,13 @@ public class DefaultInfoFactory implements IInfoFactory {
info = new InfoCashLinePanel (WindowNo, value, info = new InfoCashLinePanel (WindowNo, value,
multiSelection, whereClause, lookup); multiSelection, whereClause, lookup);
} else if (tableName.equals("S_ResourceAssignment")) { } else if (tableName.equals("S_ResourceAssignment")) {
info = new InfoAssignmentWindow(WindowNo, tableName, keyColumn, value, multiSelection, whereClause, AD_InfoWindow_ID, lookup); info = new InfoAssignmentWindow(WindowNo, tableName, keyColumn, value, multiSelection, whereClause, AD_InfoWindow_ID, lookup, predefinedContextVariables);
if (!info.loadedOK()) { if (!info.loadedOK()) {
info = new InfoAssignmentPanel (WindowNo, value, info = new InfoAssignmentPanel (WindowNo, value,
multiSelection, whereClause, lookup); multiSelection, whereClause, lookup);
} }
} else { } else {
info = new InfoWindow(WindowNo, tableName, keyColumn, value, multiSelection, whereClause, AD_InfoWindow_ID, lookup); info = new InfoWindow(WindowNo, tableName, keyColumn, value, multiSelection, whereClause, AD_InfoWindow_ID, lookup, null, predefinedContextVariables);
if (!info.loadedOK()) { if (!info.loadedOK()) {
info = new InfoGeneralPanel (value, WindowNo, info = new InfoGeneralPanel (value, WindowNo,
tableName, keyColumn, tableName, keyColumn,
@ -176,10 +183,16 @@ public class DefaultInfoFactory implements IInfoFactory {
@Override @Override
public InfoWindow create(int AD_InfoWindow_ID) { public InfoWindow create(int AD_InfoWindow_ID) {
return create(AD_InfoWindow_ID, null);
}
@Override
public InfoWindow create(int AD_InfoWindow_ID, String predefinedContextVariables) {
MInfoWindow infoWindow = new MInfoWindow(Env.getCtx(), AD_InfoWindow_ID, (String)null); MInfoWindow infoWindow = new MInfoWindow(Env.getCtx(), AD_InfoWindow_ID, (String)null);
String tableName = infoWindow.getAD_Table().getTableName(); String tableName = infoWindow.getAD_Table().getTableName();
String keyColumn = tableName + "_ID"; String keyColumn = tableName + "_ID";
InfoPanel info = create(-1, tableName, keyColumn, null, false, null, AD_InfoWindow_ID, false); InfoPanel info = create(-1, tableName, keyColumn, null, false, null, AD_InfoWindow_ID, false, predefinedContextVariables);
if (info instanceof InfoWindow) if (info instanceof InfoWindow)
return (InfoWindow) info; return (InfoWindow) info;
else else

View File

@ -34,4 +34,8 @@ public interface IInfoFactory {
boolean multiSelection, String whereClause, int AD_InfoWindow_ID); boolean multiSelection, String whereClause, int AD_InfoWindow_ID);
public InfoWindow create (int AD_InfoWindow_ID); public InfoWindow create (int AD_InfoWindow_ID);
public default InfoWindow create (int AD_InfoWindow_ID, String predefinedContextVariables) {
return create (AD_InfoWindow_ID);
}
} }

View File

@ -155,6 +155,18 @@ public class InfoManager
* @return {@link InfoWindow} * @return {@link InfoWindow}
*/ */
public static InfoWindow create (int AD_InfoWindow_ID) public static InfoWindow create (int AD_InfoWindow_ID)
{
return create (AD_InfoWindow_ID, null);
}
/**
*
* @param AD_InfoWindow_ID
* @param predefinedContextVariables
* @return {@link InfoWindow}
*/
public static InfoWindow create (int AD_InfoWindow_ID, String predefinedContextVariables)
{ {
InfoWindow info = null; InfoWindow info = null;
@ -167,7 +179,7 @@ public class InfoManager
IInfoFactory service = serviceReference.getService(); IInfoFactory service = serviceReference.getService();
if (service != null) { if (service != null) {
visitedIds.add(key); visitedIds.add(key);
info = service.create(AD_InfoWindow_ID); info = service.create(AD_InfoWindow_ID ,predefinedContextVariables);
if (info != null) if (info != null)
return info; return info;
} else { } else {
@ -187,7 +199,7 @@ public class InfoManager
if (service != null) if (service != null)
{ {
s_infoFactoryCache.put(serviceId, serviceReference); s_infoFactoryCache.put(serviceId, serviceReference);
info = service.create(AD_InfoWindow_ID); info = service.create(AD_InfoWindow_ID, predefinedContextVariables);
if (info != null) if (info != null)
break; break;
} }

View File

@ -50,6 +50,24 @@ public class InfoAssetWindow extends InfoWindow {
// TODO Auto-generated constructor stub // TODO Auto-generated constructor stub
} }
/**
* @param WindowNo
* @param tableName
* @param keyColumn
* @param queryValue
* @param multipleSelection
* @param whereClause
* @param AD_InfoWindow_ID
* @param lookup
* @param predefinedContextVariables
*/
public InfoAssetWindow(int WindowNo, String tableName, String keyColumn,
String queryValue, boolean multipleSelection, String whereClause,
int AD_InfoWindow_ID, boolean lookup, String predefinedContextVariables) {
super(WindowNo, tableName, keyColumn, queryValue, multipleSelection,
whereClause, AD_InfoWindow_ID, lookup, null, predefinedContextVariables);
}
@Override @Override
protected void saveSelectionDetail() { protected void saveSelectionDetail() {
int row = contentPanel.getSelectedRow(); int row = contentPanel.getSelectedRow();

View File

@ -47,4 +47,21 @@ public class InfoAssignmentWindow extends InfoWindow {
whereClause, AD_InfoWindow_ID, lookup); whereClause, AD_InfoWindow_ID, lookup);
} }
/**
* @param WindowNo
* @param tableName
* @param keyColumn
* @param queryValue
* @param multipleSelection
* @param whereClause
* @param AD_InfoWindow_ID
* @param lookup
* @param predefinedContextVariables
*/
public InfoAssignmentWindow(int WindowNo, String tableName,
String keyColumn, String queryValue, boolean multipleSelection,
String whereClause, int AD_InfoWindow_ID, boolean lookup, String predefinedContextVariables) {
super(WindowNo, tableName, keyColumn, queryValue, multipleSelection,
whereClause, AD_InfoWindow_ID, lookup, null, predefinedContextVariables);
}
} }

View File

@ -48,6 +48,24 @@ public class InfoBPartnerWindow extends InfoWindow {
super(WindowNo, tableName, keyColumn, queryValue, multipleSelection, super(WindowNo, tableName, keyColumn, queryValue, multipleSelection,
whereClause, AD_InfoWindow_ID, lookup); whereClause, AD_InfoWindow_ID, lookup);
} }
/**
* @param WindowNo
* @param tableName
* @param keyColumn
* @param queryValue
* @param multipleSelection
* @param whereClause
* @param AD_InfoWindow_ID
* @param lookup
* @param predefinedContextVariables
*/
public InfoBPartnerWindow(int WindowNo, String tableName, String keyColumn,
String queryValue, boolean multipleSelection, String whereClause,
int AD_InfoWindow_ID, boolean lookup, String predefinedContextVariables) {
super(WindowNo, tableName, keyColumn, queryValue, multipleSelection,
whereClause, AD_InfoWindow_ID, lookup, null, predefinedContextVariables);
}
/** /**
* Has History * Has History

View File

@ -46,4 +46,21 @@ public class InfoInOutWindow extends InfoWindow {
whereClause, AD_InfoWindow_ID, lookup); whereClause, AD_InfoWindow_ID, lookup);
} }
/**
* @param WindowNo
* @param tableName
* @param keyColumn
* @param queryValue
* @param multipleSelection
* @param whereClause
* @param AD_InfoWindow_ID
* @param lookup
* @param predefinedContextVariables
*/
public InfoInOutWindow(int WindowNo, String tableName, String keyColumn,
String queryValue, boolean multipleSelection, String whereClause,
int AD_InfoWindow_ID, boolean lookup, String predefinedContextVariables) {
super(WindowNo, tableName, keyColumn, queryValue, multipleSelection,
whereClause, AD_InfoWindow_ID, lookup, null, predefinedContextVariables);
}
} }

View File

@ -48,6 +48,24 @@ public class InfoInvoiceWindow extends InfoWindow {
whereClause, AD_InfoWindow_ID, lookup); whereClause, AD_InfoWindow_ID, lookup);
} }
/**
* @param WindowNo
* @param tableName
* @param keyColumn
* @param queryValue
* @param multipleSelection
* @param whereClause
* @param AD_InfoWindow_ID
* @param lookup
* @param predefinedContextVariables
*/
public InfoInvoiceWindow(int WindowNo, String tableName, String keyColumn,
String queryValue, boolean multipleSelection, String whereClause,
int AD_InfoWindow_ID, boolean lookup, String predefinedContextVariables) {
super(WindowNo, tableName, keyColumn, queryValue, multipleSelection,
whereClause, AD_InfoWindow_ID, lookup, null, predefinedContextVariables);
}
@Override @Override
protected void saveSelectionDetail() { protected void saveSelectionDetail() {
int row = contentPanel.getSelectedRow(); int row = contentPanel.getSelectedRow();

View File

@ -45,5 +45,23 @@ public class InfoOrderWindow extends InfoWindow {
super(WindowNo, tableName, keyColumn, queryValue, multipleSelection, super(WindowNo, tableName, keyColumn, queryValue, multipleSelection,
whereClause, AD_InfoWindow_ID, lookup); whereClause, AD_InfoWindow_ID, lookup);
} }
/**
* @param WindowNo
* @param tableName
* @param keyColumn
* @param queryValue
* @param multipleSelection
* @param whereClause
* @param AD_InfoWindow_ID
* @param lookup
* @param predefinedContextVariables
*/
public InfoOrderWindow(int WindowNo, String tableName, String keyColumn,
String queryValue, boolean multipleSelection, String whereClause,
int AD_InfoWindow_ID, boolean lookup, String predefinedContextVariables) {
super(WindowNo, tableName, keyColumn, queryValue, multipleSelection,
whereClause, AD_InfoWindow_ID, lookup, null, predefinedContextVariables);
}
} }

View File

@ -46,4 +46,22 @@ public class InfoPaymentWindow extends InfoWindow {
whereClause, AD_InfoWindow_ID, lookup); whereClause, AD_InfoWindow_ID, lookup);
} }
/**
* @param WindowNo
* @param tableName
* @param keyColumn
* @param queryValue
* @param multipleSelection
* @param whereClause
* @param AD_InfoWindow_ID
* @param lookup
* @param predefinedContextVariables
*/
public InfoPaymentWindow(int WindowNo, String tableName, String keyColumn,
String queryValue, boolean multipleSelection, String whereClause,
int AD_InfoWindow_ID, boolean lookup, String predefinedContextVariables) {
super(WindowNo, tableName, keyColumn, queryValue, multipleSelection,
whereClause, AD_InfoWindow_ID, lookup, null, predefinedContextVariables);
}
} }

View File

@ -114,6 +114,24 @@ public class InfoProductWindow extends InfoWindow {
super(WindowNo, tableName, keyColumn, queryValue, multipleSelection, super(WindowNo, tableName, keyColumn, queryValue, multipleSelection,
whereClause, AD_InfoWindow_ID, lookup); whereClause, AD_InfoWindow_ID, lookup);
} }
/**
* @param WindowNo
* @param tableName
* @param keyColumn
* @param queryValue
* @param multipleSelection
* @param whereClause
* @param AD_InfoWindow_ID
* @param lookup
* @param predefinedContextVariables
*/
public InfoProductWindow(int WindowNo, String tableName, String keyColumn,
String queryValue, boolean multipleSelection, String whereClause,
int AD_InfoWindow_ID, boolean lookup, String predefinedContextVariables) {
super(WindowNo, tableName, keyColumn, queryValue, multipleSelection,
whereClause, AD_InfoWindow_ID, lookup, null, predefinedContextVariables);
}
@Override @Override
protected String getSQLWhere() { protected String getSQLWhere() {

View File

@ -215,6 +215,21 @@ public class InfoWindow extends InfoPanel implements ValueChangeListener, EventL
*/ */
public InfoWindow(int WindowNo, String tableName, String keyColumn, String queryValue, public InfoWindow(int WindowNo, String tableName, String keyColumn, String queryValue,
boolean multipleSelection, String whereClause, int AD_InfoWindow_ID, boolean lookup, GridField field) { boolean multipleSelection, String whereClause, int AD_InfoWindow_ID, boolean lookup, GridField field) {
this(WindowNo, tableName, keyColumn, queryValue, multipleSelection, whereClause, AD_InfoWindow_ID, lookup, field, null);
}
/**
* @param WindowNo
* @param tableName
* @param keyColumn
* @param multipleSelection
* @param whereClause
* @param lookup
* @param gridfield
* @param predefinedContextVariables
*/
public InfoWindow(int WindowNo, String tableName, String keyColumn, String queryValue,
boolean multipleSelection, String whereClause, int AD_InfoWindow_ID, boolean lookup, GridField field, String predefinedContextVariables) {
super(WindowNo, tableName, keyColumn, multipleSelection, whereClause, super(WindowNo, tableName, keyColumn, multipleSelection, whereClause,
lookup, AD_InfoWindow_ID, queryValue); lookup, AD_InfoWindow_ID, queryValue);
this.m_gridfield = field; this.m_gridfield = field;
@ -240,6 +255,7 @@ public class InfoWindow extends InfoPanel implements ValueChangeListener, EventL
} }
}); //xolali --end- }); //xolali --end-
Env.setPredefinedVariables(Env.getCtx(), getWindowNo(), predefinedContextVariables);
infoContext = new Properties(Env.getCtx()); infoContext = new Properties(Env.getCtx());
p_loadedOK = loadInfoDefinition(); p_loadedOK = loadInfoDefinition();