本文整理汇总了Java中org.compiere.util.Env.getContextAsInt方法的典型用法代码示例。如果您正苦于以下问题:Java Env.getContextAsInt方法的具体用法?Java Env.getContextAsInt怎么用?Java Env.getContextAsInt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.compiere.util.Env
的用法示例。
在下文中一共展示了Env.getContextAsInt方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: product
import org.compiere.util.Env; //导入方法依赖的package包/类
/**
* Product modified
* Set Attribute Set Instance
*
* @param ctx Context
* @param WindowNo current Window No
* @param GridTab Model Tab
* @param GridField Model Field
* @param value The new value
* @return Error message or ""
*/
public String product (Properties ctx, int WindowNo, GridTab mTab, GridField mField, Object value)
{
Integer M_Product_ID = (Integer)value;
if (M_Product_ID == null || M_Product_ID.intValue() == 0)
return "";
// Set Attribute
if (Env.getContextAsInt(ctx, WindowNo, Env.TAB_INFO, "M_Product_ID") == M_Product_ID.intValue()
&& Env.getContextAsInt(ctx, WindowNo, Env.TAB_INFO, "M_AttributeSetInstance_ID") != 0)
mTab.setValue("M_AttributeSetInstance_ID", Env.getContextAsInt(ctx, WindowNo, Env.TAB_INFO, "M_AttributeSetInstance_ID"));
else
mTab.setValue("M_AttributeSetInstance_ID", null);
checkQtyAvailable(ctx, mTab, WindowNo, M_Product_ID, null);
return "";
}
示例2: findChargeElementID
import org.compiere.util.Env; //导入方法依赖的package包/类
/**
* Finds the Element Identifier for the current charge.
*
*/
public void findChargeElementID()
{
m_C_AcctSchema_ID = Env.getContextAsInt(Env.getCtx(), "$C_AcctSchema_ID");
// get Element
String sql = "SELECT C_Element_ID "
+ "FROM C_AcctSchema_Element "
+ "WHERE ElementType='AC' AND C_AcctSchema_ID=?";
try
{
PreparedStatement pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, m_C_AcctSchema_ID);
ResultSet rs = pstmt.executeQuery();
if (rs.next())
{
m_C_Element_ID = rs.getInt(1);
}
rs.close();
pstmt.close();
}
catch (SQLException exception)
{
log.error(sql, exception);
}
}
示例3: checkQtyAvailable
import org.compiere.util.Env; //导入方法依赖的package包/类
/**
* Check available qty
*
* @param ctx context
* @param mTab Model Tab
* @param WindowNo current Window No
* @param M_Product_ID product ID
* @param MovementQty movement qty (if null will be get from context "MovementQty")
*/
private void checkQtyAvailable(Properties ctx, GridTab mTab, int WindowNo, int M_Product_ID, BigDecimal MovementQty) {
// Begin Armen 2006/10/01
if (M_Product_ID != 0) {
MProduct product = MProduct.get(ctx, M_Product_ID);
if (Services.get(IProductBL.class).isStocked(product)) {
if (MovementQty == null)
MovementQty = (BigDecimal) mTab.getValue("MovementQty");
int M_Locator_ID = Env.getContextAsInt(ctx, WindowNo, "M_Locator_ID");
// If no locator, don't check anything and assume is ok
if (M_Locator_ID <= 0)
return;
int M_AttributeSetInstance_ID = Env.getContextAsInt(ctx, WindowNo, "M_AttributeSetInstance_ID");
BigDecimal available = MStorage.getQtyAvailable(0, M_Locator_ID, M_Product_ID, M_AttributeSetInstance_ID, null);
if (available == null)
available = Env.ZERO;
if (available.signum() == 0)
mTab.fireDataStatusEEvent("NoQtyAvailable", "0", false);
else if (available.compareTo(MovementQty) < 0)
mTab.fireDataStatusEEvent("InsufficientQtyAvailable", available.toString(), false);
}
}
// End Armen
}
示例4: planned
import org.compiere.util.Env; //导入方法依赖的package包/类
/**
* Project Planned - Price + Qty.
* - called from PlannedPrice, PlannedQty
* - calculates PlannedAmt (same as Trigger)
* @param ctx context
* @param WindowNo current Window No
* @param mTab Grid Tab
* @param mField Grid Field
* @param value New Value
* @return null or error message
*/
public String planned (Properties ctx, int WindowNo, GridTab mTab, GridField mField, Object value)
{
if (isCalloutActive() || value == null)
return "";
BigDecimal PlannedQty, PlannedPrice;
int StdPrecision = Env.getContextAsInt(ctx, WindowNo, "StdPrecision");
// get values
PlannedQty = (BigDecimal)mTab.getValue("PlannedQty");
if (PlannedQty == null)
PlannedQty = Env.ONE;
PlannedPrice = ((BigDecimal)mTab.getValue("PlannedPrice"));
if (PlannedPrice == null)
PlannedPrice = Env.ZERO;
//
BigDecimal PlannedAmt = PlannedQty.multiply(PlannedPrice);
if (PlannedAmt.scale() > StdPrecision)
PlannedAmt = PlannedAmt.setScale(StdPrecision, BigDecimal.ROUND_HALF_UP);
//
log.debug("PlannedQty=" + PlannedQty + " * PlannedPrice=" + PlannedPrice + " -> PlannedAmt=" + PlannedAmt + " (Precision=" + StdPrecision+ ")");
mTab.setValue("PlannedAmt", PlannedAmt);
return "";
}
示例5: getParentTabNo
import org.compiere.util.Env; //导入方法依赖的package包/类
/**
* get Parent Tab No
*
* @return Tab No
*/
// metas: changed from private to public
public int getParentTabNo()
{
int tabNo = getTabNo();
int currentLevel = getTabLevel();
// usually, the parent tab's level is currentLevel - 1, but sometimes the "level-gap" might be larger, like e.g. in the Rechnung window (MatchInv-level is 2, parent tab's level is 0)
final int parentLevelMax = currentLevel - 1;
if (parentLevelMax < 0)
{
return tabNo;
}
while (parentLevelMax < currentLevel)
{
if (tabNo < 0)
{
log.warn("No parent TabNo found for '{}'. Expected parent TabLevel={}", this, parentLevelMax);
break;
}
tabNo--;
currentLevel = Env.getContextAsInt(getCtx(), m_vo.WindowNo, tabNo, GridTab.CTX_TabLevel);
}
return tabNo;
}
示例6: buildDocumentNo
import org.compiere.util.Env; //导入方法依赖的package包/类
/**
* Convenient method to builds Document Number for current window context document. <br>
* - first search for DocType based Document No - then Search for DocumentNo based on TableName
*
* @param ctx context
* @param WindowNo window
* @param TableName table
* @param onlyDocType Do not search for document no based on TableName
* @return DocumentNo or null, if no doc number defined
*/
private static String buildDocumentNo(final Properties ctx, final int WindowNo, final String TableName, final boolean onlyDocType)
{
if (ctx == null || TableName == null || TableName.length() == 0)
{
throw new IllegalArgumentException("Required parameter missing");
}
final int AD_Client_ID = Env.getContextAsInt(ctx, WindowNo, "AD_Client_ID");
// metas: User AD_Org_ID as additional parameter
final int AD_Org_ID = Env.getAD_Org_ID(ctx);
// metas end
// Get C_DocType_ID from context - NO Defaults -
int C_DocType_ID = Env.getContextAsInt(ctx, WindowNo + "|C_DocTypeTarget_ID");
if (C_DocType_ID <= 0)
{
C_DocType_ID = Env.getContextAsInt(ctx, WindowNo + "|C_DocType_ID");
}
final IDocumentNoBuilderFactory documentNoFactory = Services.get(IDocumentNoBuilderFactory.class);
if (C_DocType_ID <= 0)
{
log.debug("Window=" + WindowNo
+ " - Target=" + Env.getContextAsInt(ctx, WindowNo + "|C_DocTypeTarget_ID") + "/" + Env.getContextAsInt(ctx, WindowNo, "C_DocTypeTarget_ID")
+ " - Actual=" + Env.getContextAsInt(ctx, WindowNo + "|C_DocType_ID") + "/" + Env.getContextAsInt(ctx, WindowNo, "C_DocType_ID"));
return documentNoFactory.forTableName(TableName, AD_Client_ID, AD_Org_ID)
.build();
}
final String retValue = documentNoFactory.forDocType(C_DocType_ID, false) // useDefiniteSequence=false
.setFailOnError(false)
.build();
if (!onlyDocType && retValue == null)
{
return documentNoFactory.forTableName(TableName, AD_Client_ID, AD_Org_ID)
.build();
}
return retValue;
}
示例7: amt
import org.compiere.util.Env; //导入方法依赖的package包/类
/**
* Requisition line - Qty
* - Price, LineNetAmt
* @param ctx context
* @param WindowNo current Window No
* @param mTab Grid Tab
* @param mField Grid Field
* @param value New Value
* @return null or error message
*/
public String amt (Properties ctx, int WindowNo, GridTab mTab, GridField mField, Object value)
{
if (isCalloutActive() || value == null)
return "";
final I_M_RequisitionLine line = InterfaceWrapperHelper.create(mTab, I_M_RequisitionLine.class);
final I_M_Requisition req = line.getM_Requisition();
// Qty changed - recalc price
if (mField.getColumnName().equals(I_M_RequisitionLine.COLUMNNAME_Qty)
&& "Y".equals(Env.getContext(ctx, WindowNo, "DiscountSchema")))
{
setPrice(ctx, WindowNo, req, line);
}
int StdPrecision = Env.getContextAsInt(ctx, WindowNo, "StdPrecision");
BigDecimal Qty = line.getQty();
BigDecimal PriceActual = line.getPriceActual();
log.debug("amt - Qty=" + Qty + ", Price=" + PriceActual + ", Precision=" + StdPrecision);
// Multiply
BigDecimal LineNetAmt = Qty.multiply(PriceActual);
if (LineNetAmt.scale() > StdPrecision)
LineNetAmt = LineNetAmt.setScale(StdPrecision, BigDecimal.ROUND_HALF_UP);
line.setLineNetAmt(LineNetAmt);
log.info("amt - LineNetAmt=" + LineNetAmt);
//
return "";
}
示例8: setDocumentInfo
import org.compiere.util.Env; //导入方法依赖的package包/类
private void setDocumentInfo()
{
if (m_AD_Table_ID > 0 && m_Record_ID > 0)
{
return;
}
//
final int windowNo = getWindowNo();
if (windowNo < 0)
{
return;
}
//
m_AD_Table_ID = Env.getContextAsInt(Env.getCtx(), windowNo, 0, GridTab.CTX_AD_Table_ID);
if (m_AD_Table_ID <= 0)
{
return;
}
final String keyColumnName = Env.getContext(Env.getCtx(), windowNo, 0, GridTab.CTX_KeyColumnName);
if (Check.isEmpty(keyColumnName))
{
return;
}
m_Record_ID = Env.getContextAsInt(Env.getCtx(), windowNo, keyColumnName);
if (m_Record_ID <= 0)
{
return;
}
}
示例9: isIndirectParentValue
import org.compiere.util.Env; //导入方法依赖的package包/类
/**
* bug[1637757] Check whether is indirect parent.
*
* @return boolean
*/
private boolean isIndirectParentValue()
{
final Properties ctx = getGridFieldContext();
boolean result = false;
int tabNo = m_vo.TabNo;
int currentLevel = Env.getContextAsInt(ctx, m_vo.WindowNo, tabNo, GridTab.CTX_TabLevel);
if (tabNo > 1 && currentLevel > 1)
{
while (tabNo >= 1 && !result)
{
tabNo--;
int level = Env.getContextAsInt(ctx, m_vo.WindowNo, tabNo, GridTab.CTX_TabLevel);
if (level > 0 && level < currentLevel)
{
String linkColumn = Env.getContext(ctx, m_vo.WindowNo, tabNo, GridTab.CTX_LinkColumnName);
if (m_vo.getColumnName().equals(linkColumn))
{
result = true;
log.info(result
+ " - Link(" + linkColumn + ", W=" + m_vo.WindowNo + ",T=" + m_vo.TabNo
+ ") = " + m_vo.getColumnName());
}
currentLevel = level;
}
}
}
return result;
}
示例10: InfoProduct
import org.compiere.util.Env; //导入方法依赖的package包/类
/**
* Standard Constructor
*
* @param frame
* frame
* @param modal
* modal
* @param WindowNo
* window no
* @param M_Warehouse_ID
* warehouse
* @param M_PriceList_ID
* price list
* @param value
* Query Value or Name if enclosed in @
* @param multiSelection
* multiple selections
* @param whereClause
* where clause
*/
public InfoProduct(Frame frame, boolean modal, int WindowNo,
int M_Warehouse_ID, int M_PriceList_ID, String value,
boolean multiSelection, String whereClause)
{
super(frame, modal, WindowNo, "p", "M_Product_ID", multiSelection,
whereClause);
log.info(value + ", Wh=" + M_Warehouse_ID + ", PL=" + M_PriceList_ID
+ ", WHERE=" + whereClause);
loadResult = MSysConfig.getBooleanValue(LOAD_ALL_RECORDS_INFOPRODUCT, false); // metas: [email protected]
setTitle(Msg.getMsg(Env.getCtx(), "InfoProduct"));
//
statInit();
initInfo(value, M_Warehouse_ID, M_PriceList_ID);
m_C_BPartner_ID = Env.getContextAsInt(Env.getCtx(), WindowNo,
"C_BPartner_ID");
//
int no = p_table.getRowCount();
setStatusLine(Integer.toString(no) + " "
+ Msg.getMsg(Env.getCtx(), "SearchRows_EnterQuery"), false);
setStatusDB(Integer.toString(no));
// AutoQuery
if (value != null && value.length() > 0)
executeQueryOnInit();
p_loadedOK = true;
// Focus
fieldValue.requestFocus();
// Begin - fer_luck @ centuryon
mWindowNo = WindowNo;
// End - fer_luck @ centuryon
AEnv.positionCenterWindow(frame, getWindow());
if (loadResult) // metas: [email protected]
executeQueryOnInit(); // metas-2009_0021_AP1_CR046
}
示例11: extractLanguageFromWindowContext
import org.compiere.util.Env; //导入方法依赖的package包/类
private static final Language extractLanguageFromWindowContext(final Properties ctx, final int windowNo)
{
if (!Env.isRegularWindowNo(windowNo))
{
return null;
}
//
// Get Language directly from window context, if any (08966)
{
// Note: onlyWindow is true, otherwise the login language would be returned if no other language was found
final String languageString = Env.getContext(ctx, windowNo, "AD_Language", true);
if (!Env.isPropertyValueNull("AD_Language", languageString))
{
return Language.getLanguage(languageString);
}
}
//
// Get Language from the BPartner set in window context, if any (03040)
{
final int bpartnerId = Env.getContextAsInt(ctx, windowNo, "C_BPartner_ID");
if (bpartnerId > 0)
{
final Language lang = Services.get(IBPartnerBL.class).getLanguage(ctx, bpartnerId);
if (lang != null)
{
return lang;
}
}
}
return null;
}
示例12: actionPerformed
import org.compiere.util.Env; //导入方法依赖的package包/类
@Override
public void actionPerformed(final ActionEvent e)
{
// Query Product Attribute Instance
final int row = p_table.getSelectedRow();
if (e.getSource().equals(m_PAttributeButton) && row != -1)
{
final int productId = getM_Product_ID();
if (productId <= 0)
{
return;
}
final int warehouseId = getContextVariableAsInt("M_Warehouse_ID");
if (warehouseId <= 0)
{
return;
}
final int p_WindowNo = getWindowNo();
final int bpartnerId = Env.getContextAsInt(Env.getCtx(), p_WindowNo, "C_BPartner_ID");
final String productName = getProductName();
final String title = productName;
final PAttributeInstance pai = new PAttributeInstance(getWindow(), title,
warehouseId,
0, // locatorId
productId,
bpartnerId);
final int M_AttributeSetInstance_ID = pai.getM_AttributeSetInstance_ID();
setCtxAttribute(ATTR_M_AttributeSetInstance_ID, M_AttributeSetInstance_ID);
// m_M_Locator_ID = pai.getM_Locator_ID();
if (M_AttributeSetInstance_ID != -1)
{
dispose(true);
}
return;
}
//
super.actionPerformed(e);
}
示例13: initBPartner
import org.compiere.util.Env; //导入方法依赖的package包/类
/**************************************************************************
* Load BPartner Field
* @param forInvoice true if Invoices are to be created, false receipts
* @throws Exception if Lookups cannot be initialized
*/
protected void initBPartner (boolean forInvoice) throws Exception
{
// load BPartner
int AD_Column_ID = 3499; // C_Invoice.C_BPartner_ID
MLookup lookup = MLookupFactory.get (Env.getCtx(), p_WindowNo, 0, AD_Column_ID, DisplayType.Search);
bPartnerField = new VLookup ("C_BPartner_ID", true, false, true, lookup);
//
int C_BPartner_ID = Env.getContextAsInt(Env.getCtx(), p_WindowNo, "C_BPartner_ID");
bPartnerField.setValue(new Integer(C_BPartner_ID));
}
示例14: getAD_Tree_ID
import org.compiere.util.Env; //导入方法依赖的package包/类
private int getAD_Tree_ID()
{
final String keyColumnName = m_mTab.getKeyColumnName();
String treeName = "AD_Tree_ID";
// determine the tree name (FIXME should be done via some SPI mechanism)
if (keyColumnName.startsWith("CM"))
{
if (keyColumnName.equals("CM_Container_ID"))
{
treeName = "AD_TreeCMC_ID";
}
else if (keyColumnName.equals("CM_CStage_ID"))
{
treeName = "AD_TreeCMS_ID";
}
else if (keyColumnName.equals("CM_Template_ID"))
{
treeName = "AD_TreeCMT_ID";
}
else if (keyColumnName.equals("CM_Media_ID"))
{
treeName = "AD_TreeCMM_ID";
}
}
// look for the AD_Tree_ID in the context (=>if parent tab has an AD_Field, it should be there)
int AD_Tree_ID = Env.getContextAsInt (Env.getCtx(), m_WindowNo, treeName);
if (AD_Tree_ID <= 0)
{
// get the default tree for the current AD_Client and column name
AD_Tree_ID = MTree.getDefaultAD_Tree_ID(
Env.getAD_Client_ID(Env.getCtx()),
m_mTab.getKeyColumnName());
}
return AD_Tree_ID;
}
示例15: getContextAsInt
import org.compiere.util.Env; //导入方法依赖的package包/类
@Override
public int getContextAsInt(final String name)
{
return Env.getContextAsInt(Env.getCtx(), windowNo, name);
}