当前位置: 首页>>代码示例>>Java>>正文


Java Env.setContext方法代码示例

本文整理汇总了Java中org.compiere.util.Env.setContext方法的典型用法代码示例。如果您正苦于以下问题:Java Env.setContext方法的具体用法?Java Env.setContext怎么用?Java Env.setContext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.compiere.util.Env的用法示例。


在下文中一共展示了Env.setContext方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: verifyLanguageAndSet

import org.compiere.util.Env; //导入方法依赖的package包/类
/**
 * @param lang
 * @return previous language
 */
String verifyLanguageAndSet(final Language lang)
{
	final Properties ctx = getCtx();
	final String adLanguageOld = Env.getContext(ctx, Env.CTXNAME_AD_Language);

	//
	// Check the language (and update it if needed)
	Env.verifyLanguage(lang);

	//
	// Actual update
	final String adLanguageNew = lang.getAD_Language();
	Env.setContext(ctx, Env.CTXNAME_AD_Language, adLanguageNew);
	this.locale = lang.getLocale();
	UserSession.logger.info("Changed AD_Language: {} -> {}, {}", adLanguageOld, adLanguageNew, lang);

	return adLanguageOld;
}
 
开发者ID:metasfresh,项目名称:metasfresh-webui-api,代码行数:23,代码来源:InternalUserSessionData.java

示例2: saveSelectionDetail

import org.compiere.util.Env; //导入方法依赖的package包/类
/**
 *	Save Selection Settings
 */
@Override
protected void saveSelectionDetail()
{
	//  publish for Callout to read
	final int p_WindowNo = getWindowNo();
	Integer ID = getSelectedRowKey();
	Env.setContext(Env.getCtx(), p_WindowNo, Env.TAB_INFO, "C_Invoice_ID", ID == null ? "0" : ID.toString());
	//
	int C_InvoicePaySchedule_ID = 0;
	int row = p_table.getSelectedRow();
	if (row >= 0)
	{
		Object value = p_table.getValueAt(row, INDEX_PAYSCHEDULE);
		if (value != null && value instanceof KeyNamePair)
			C_InvoicePaySchedule_ID = ((KeyNamePair)value).getKey();
	}
	if (C_InvoicePaySchedule_ID <= 0)	//	not selected
		Env.setContext(Env.getCtx(), p_WindowNo, Env.TAB_INFO, "C_InvoicePaySchedule_ID", "0");
	else
		Env.setContext(Env.getCtx(), p_WindowNo, Env.TAB_INFO, "C_InvoicePaySchedule_ID", String.valueOf(C_InvoicePaySchedule_ID));
}
 
开发者ID:metasfresh,项目名称:metasfresh,代码行数:25,代码来源:InfoInvoice.java

示例3: delete

import org.compiere.util.Env; //导入方法依赖的package包/类
/**
 *  Delete Preference
 *  @return number of rows deleted
 */
public int delete()
{
	log.info("");

	StringBuffer sql = new StringBuffer ("DELETE FROM AD_Preference WHERE ");
	sql.append("AD_Client_ID=").append(cbClient.isSelected() ? m_AD_Client_ID : 0);
	sql.append(" AND AD_Org_ID=").append(cbOrg.isSelected() ? m_AD_Org_ID : 0);
	if (cbUser.isSelected())
		sql.append(" AND AD_User_ID=").append(m_AD_User_ID);
	else
		sql.append(" AND AD_User_ID IS NULL");
	if (cbWindow.isSelected())
		sql.append(" AND AD_Window_ID=").append(m_AD_Window_ID);
	else
		sql.append(" AND AD_Window_ID IS NULL");
	sql.append(" AND Attribute='").append(m_Attribute).append("'");
	//
	log.debug( sql.toString());
	int no = DB.executeUpdate(sql.toString(), null);
	if (no > 0)
		Env.setContext(m_ctx, getContextKey(), (String)null);
	return no;
}
 
开发者ID:metasfresh,项目名称:metasfresh,代码行数:28,代码来源:ValuePreference.java

示例4: init

import org.compiere.util.Env; //导入方法依赖的package包/类
/**
 * Initialize Panel
 *
 * @param WindowNo window
 * @param frame frame
 */
@Override
public void init(final int WindowNo, final FormFrame frame)
{
	setWindowNo(WindowNo);
	m_frame = frame;
	Env.setContext(getCtx(), WindowNo, "IsSOTrx", true); // defaults to no
	try
	{
		dynInit();
		jbInit();
		frame.getContentPane().add(mainPanel, BorderLayout.CENTER);
		frame.getContentPane().add(statusBar, BorderLayout.SOUTH);

		updateInfos(true); // re-query
	}
	catch (final Exception e)
	{
		logger.error(e.getLocalizedMessage(), e);
	}
}
 
开发者ID:metasfresh,项目名称:metasfresh,代码行数:27,代码来源:ReadPaymentForm.java

示例5: save

import org.compiere.util.Env; //导入方法依赖的package包/类
@Override
public void save(final Properties ctx, final String attribute, final Object value, final int adClientId, final int adOrgId, final int adUserId, final int adWindowId)
{
	logger.info("");

	final String trxName = null;

	I_AD_Preference preference = fetch(ctx, attribute, adClientId, adOrgId, adUserId, adWindowId);
	if (preference == null)
	{
		preference = InterfaceWrapperHelper.create(ctx, I_AD_Preference.class, trxName);
		preference.setAttribute(attribute);
		// preference.setAD_Client_ID(adClientId);
		preference.setAD_Org_ID(adOrgId);
		preference.setAD_User_ID(adUserId);
		preference.setAD_Window_ID(adWindowId);
	}

	final String valueStr = coerceToString(value);

	preference.setValue(valueStr);
	InterfaceWrapperHelper.save(preference);
	Env.setContext(ctx, getContextKey(preference), valueStr);
}
 
开发者ID:metasfresh,项目名称:metasfresh,代码行数:25,代码来源:ValuePreferenceDAO.java

示例6: setClientIdAndCheck

import org.compiere.util.Env; //导入方法依赖的package包/类
/**
 * Set's <code>adClientId</code> in global context and checks if it was configured correctly
 *
 * @param adClientId
 */
private void setClientIdAndCheck(final int adClientId)
{
	final int expectedClientId;
	final Properties ctx = Env.getCtx();
	if (adClientId < 0)
	{
		Env.setContext(ctx, "#AD_Client_ID", "");
		expectedClientId = 0;
	}
	else
	{
		Env.setContext(Env.getCtx(), "#AD_Client_ID", adClientId);
		expectedClientId = adClientId;
	}

	final int actualClientId = Env.getAD_Client_ID(ctx);
	Assert.assertEquals("AD_Client_ID=" + adClientId + " was not set correctly in the context",
			expectedClientId, actualClientId);
}
 
开发者ID:metasfresh,项目名称:metasfresh,代码行数:25,代码来源:LogicExpressionCompilerTests.java

示例7: InternalUserSessionData

import org.compiere.util.Env; //导入方法依赖的package包/类
public InternalUserSessionData()
{
	final RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes();
	sessionId = requestAttributes.getSessionId();

	userPreference = new UserPreference();
	loggedIn = false;

	// Context
	ctx = new Properties();
	Env.setContext(ctx, WebRestApiContextProvider.CTXNAME_IsServerContext, false);
	Env.setContext(ctx, WebRestApiContextProvider.CTXNAME_IsWebUI, true);

	UserSession.logger.trace("User session created: {}", this);
}
 
开发者ID:metasfresh,项目名称:metasfresh-webui-api,代码行数:16,代码来源:InternalUserSessionData.java

示例8: WebRestApiContextProvider

import org.compiere.util.Env; //导入方法依赖的package包/类
public WebRestApiContextProvider()
{
	super();

	//
	// Create the server context
	serverCtx = new Properties();
	Env.setContext(serverCtx, CTXNAME_IsServerContext, true);
	Env.setContext(serverCtx, CTXNAME_IsWebUI, true);
}
 
开发者ID:metasfresh,项目名称:metasfresh-webui-api,代码行数:11,代码来源:WebRestApiContextProvider.java

示例9: Table_Period

import org.compiere.util.Env; //导入方法依赖的package包/类
/**
	 *	Table_Period.  Used to set the Manual Period Field.  This allows
	 *	the Spread Field to be displayed when there is a code that
	 *  has been setup as Yearly. 
	 *  The string in the Callout field is: 
	 *  <code>com.compiere.custom.CalloutEngine.Table_Period</code> 
	 *
	 *  @param ctx      Context
	 *  @param WindowNo current Window No
	 *  @param mTab     Model Tab
	 *  @param mField   Model Field
	 *  @param value    The new value
	 *  @param oldValue The old value
	 *	@return error message or "" if OK
	 */
	public String Table_Period (Properties ctx, int WindowNo,
			GridTab mTab, GridField mField, Object value, Object oldValue)
		{
		Integer A_Depreciation_Table_Header_ID = (Integer)value;
			
			try
			{
				if (A_Depreciation_Table_Header_ID != null){
				String SQL = "SELECT A_Term "
					+ "FROM A_Depreciation_Table_Header "
					+ "WHERE A_Depreciation_Table_Header_ID='"
					+A_Depreciation_Table_Header_ID
					+"'";
				
				PreparedStatement pstmt = DB.prepareStatement(SQL,null);				
				ResultSet rs = pstmt.executeQuery();
				if (rs.next())
				{
//					Charges - Set Context
						Env.setContext(ctx, WindowNo, "A_DEPRECIATION_MANUAL_PERIOD", rs.getString("A_Term"));					
						mTab.setValue ("A_DEPRECIATION_MANUAL_PERIOD", rs.getString("A_Term"));
		
				}
				rs.close();
				pstmt.close();
				}
			}
			catch (SQLException e)
			{
				log.info("PeriodType "+ e);
				return e.getLocalizedMessage();
			}
			return "";
		}
 
开发者ID:metasfresh,项目名称:metasfresh,代码行数:50,代码来源:CalloutFA.java

示例10: WebSessionCtx

import org.compiere.util.Env; //导入方法依赖的package包/类
/**************************************************************************
 * 	Web Session Context
 * 	@param request request
 */
private WebSessionCtx (HttpServletRequest request, int W_Store_ID)
{
	log.info(request.getContextPath() + " (" + request.getRemoteAddr() 
		+ " - " + request.getLocale() + ") #" + counter);
	ctx = Env.newTemporaryCtx();
	setLanguage(request);
	
	HttpSession session = request.getSession(false);
	
	//	Add Servlet Init Parameters (webStore/src/web/WEB-INF/web.xml)
	ServletContext sc = session.getServletContext();
	Enumeration<?> en = sc.getInitParameterNames();
	while (en.hasMoreElements())
	{
		String key = (String)en.nextElement();
		String value = sc.getInitParameter(key);
		ctx.setProperty(key, value);
		log.info(key + "=" + value); 
	}

	setWStore (W_Store_ID);
	ctx = getDefaults ();
	
	//	ServerContext	- dev2/wstore
	Env.setContext(ctx, CTX_SERVER_CONTEXT, request.getServerName() + request.getContextPath());
	//	Make Context directly availabe to jsp's
	session.setAttribute("ctx", ctx);
	//
	log.debug("#" + ctx.size());
}
 
开发者ID:metasfresh,项目名称:metasfresh,代码行数:35,代码来源:WebSessionCtx.java

示例11: updateContextFromRecord

import org.compiere.util.Env; //导入方法依赖的package包/类
/**
 * Populate given context (AD_Client_ID, AD_Org_ID) from given record.
 * 
 * @param ctx
 * @param adTableId record's AD_Table_ID
 * @param recordId record's ID
 */
private static final void updateContextFromRecord(final ProcessInfo processInfo)
{
	if(!processInfo.isRecordSet())
	{
		return;
	}

	try
	{
		final Properties ctx = processInfo.getCtx();
		final Object record = processInfo.getRecord(Object.class);
		final Integer adClientId = InterfaceWrapperHelper.getValueOrNull(record, "AD_Client_ID");
		if (adClientId != null)
		{
			Env.setContext(ctx, Env.CTXNAME_AD_Client_ID, adClientId);
		}
		final Integer adOrgId = InterfaceWrapperHelper.getValueOrNull(record, "AD_Org_ID");
		if (adOrgId != null)
		{
			Env.setContext(ctx, Env.CTXNAME_AD_Org_ID, adOrgId);
		}
	}
	catch (final Exception ex)
	{
		logger.warn("Failed while populating the context from record. Ignored. \n ProcessInfo: {}", processInfo, ex);
	}
}
 
开发者ID:metasfresh,项目名称:metasfresh,代码行数:35,代码来源:LocalJasperServer.java

示例12: findWarehouse

import org.compiere.util.Env; //导入方法依赖的package包/类
/**
 * Find Warehouse and update context
 *
 * @return M_Warehousen_ID
 */
// TODO keep in sync with org.adempiere.webui.panel.InfoProductPanel
private int findWarehouse()
{
	final Properties ctx = getCtx();
	final int p_WindowNo = getWindowNo();

	int M_Warehouse_ID = Env.getContextAsInt(ctx, "M_Warehouse_ID");
	if (M_Warehouse_ID <= 0)
	{
		M_Warehouse_ID = new Query(ctx, org.compiere.model.I_M_Warehouse.Table_Name, "", ITrx.TRXNAME_None)
				.setClient_ID()
				.setApplyAccessFilter(true)
				.setLimit(1)
				.setOrderBy(org.compiere.model.I_M_Warehouse.COLUMNNAME_Name)
				.firstId();
		if (M_Warehouse_ID > 0)
		{
			Env.setContext(ctx, p_WindowNo, "M_Warehouse_ID", M_Warehouse_ID);
		}

		return M_Warehouse_ID;
	}

	Env.setContext(ctx, p_WindowNo, "M_Warehouse_ID", M_Warehouse_ID);
	return M_Warehouse_ID;
}
 
开发者ID:metasfresh,项目名称:metasfresh,代码行数:32,代码来源:InfoProduct.java

示例13: login

import org.compiere.util.Env; //导入方法依赖的package包/类
@Override
public String login(final int AD_Org_ID, final int AD_Role_ID, final int AD_User_ID)
{
	final Properties ctx = Env.getCtx();

	final I_AD_OrgInfo orgInfo = InterfaceWrapperHelper.create(MOrgInfo.get(ctx, AD_Org_ID, null), I_AD_OrgInfo.class);
	final String ccStoreMode = orgInfo.getStoreCreditCardData();

	Env.setContext(ctx, ENV_ORG_INFO_STORE_CC_DATA, ccStoreMode);

	return null;
}
 
开发者ID:metasfresh,项目名称:metasfresh,代码行数:13,代码来源:OrgInfo.java

示例14: setContextValue

import org.compiere.util.Env; //导入方法依赖的package包/类
@Override
public void setContextValue(final String contextName, final int valueInt)
{
	final int windowNo = getWindowNo();
	if (windowNo <= 0)
	{
		logger.warn("Skip setting context {}={} because WindowNo={}", contextName, valueInt, windowNo);
		return;
	}

	final Properties ctx = getCtx();

	// set a particular property in the context
	Env.setContext(ctx, windowNo, contextName, valueInt);
}
 
开发者ID:metasfresh,项目名称:metasfresh,代码行数:16,代码来源:TerminalContext.java

示例15: linkReferenceNo

import org.compiere.util.Env; //导入方法依赖的package包/类
@Override
public void linkReferenceNo(final PO po, final IReferenceNoGeneratorInstance instance)
{
	final IReferenceNoDAO dao = Services.get(IReferenceNoDAO.class);

	final Properties localCtx = Env.deriveCtx(po.getCtx());
	Env.setContext(localCtx, "#AD_Client_ID", po.getAD_Client_ID());
	Env.setContext(localCtx, "#AD_Org_ID", po.getAD_Org_ID());

	final String trxName = po.get_TrxName();
	final int tableId = po.get_Table_ID();
	final int recordId = po.get_ID();

	final String referenceNoStr = instance.generateReferenceNo(po);
	if (IReferenceNoGenerator.REFERENCENO_None == referenceNoStr)
	{
		logger.debug("Instance {} did not generate any referenceNo for '{}'. Skip.", new Object[] { instance, po });
		return;
	}

	final I_C_ReferenceNo referenceNo = dao.getCreateReferenceNo(localCtx, instance.getType(), referenceNoStr, trxName);
	dao.getCreateReferenceNoDoc(referenceNo, tableId, recordId);

	
	// 04153 : mark the reference numbers with 'referenceNoStr' created by the system with isManual = N
	if(referenceNo != null)
	{
		referenceNo.setIsManual(false);
		InterfaceWrapperHelper.save(referenceNo); // make sure the flag is saved
	}

	if (logger.isDebugEnabled())
	{
		logger.debug("Created reference " + referenceNoStr + " for " + po);
	}
}
 
开发者ID:metasfresh,项目名称:metasfresh,代码行数:37,代码来源:ReferenceNoBL.java


注:本文中的org.compiere.util.Env.setContext方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。