[ 2471978 ] Window and tab label cache using the first login locale.

Remove unuse method copy from swing client, not applicable for zk client.
This commit is contained in:
Heng Sin Low 2008-12-28 04:44:10 +00:00
parent 3c96188fed
commit de943b693c
1 changed files with 31 additions and 51 deletions

View File

@ -27,7 +27,9 @@ import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.logging.Level;
@ -42,7 +44,6 @@ import org.compiere.interfaces.Server;
import org.compiere.model.GridWindowVO;
import org.compiere.model.Lookup;
import org.compiere.model.MQuery;
import org.compiere.model.MRole;
import org.compiere.util.CCache;
import org.compiere.util.CLogger;
import org.compiere.util.DB;
@ -191,43 +192,6 @@ public final class AEnv
}
/**
* Is Workflow Process view enabled.
* @return true if enabled
*/
public static boolean isWorkflowProcess ()
{
if (s_workflow == null)
{
s_workflow = Boolean.FALSE;
int AD_Table_ID = 645; // AD_WF_Process
if (MRole.getDefault().isTableAccess (AD_Table_ID, true)) // RO
s_workflow = Boolean.TRUE;
else
{
AD_Table_ID = 644; // AD_WF_Activity
if (MRole.getDefault().isTableAccess (AD_Table_ID, true)) // RO
s_workflow = Boolean.TRUE;
else
log.config(s_workflow.toString());
}
// Get Window
if (s_workflow.booleanValue())
{
s_workflow_Window_ID = DB.getSQLValue (null,
"SELECT AD_Window_ID FROM AD_Table WHERE AD_Table_ID=?", AD_Table_ID);
if (s_workflow_Window_ID == 0)
s_workflow_Window_ID = 297; // fallback HARDCODED
// s_workflow = Boolean.FALSE;
log.config(s_workflow + ", Window=" + s_workflow_Window_ID);
}
}
return s_workflow.booleanValue();
} // isWorkflowProcess
/**
* Start Workflow Process Window
* @param AD_Table_ID optional table
@ -235,13 +199,13 @@ public final class AEnv
*/
public static void startWorkflowProcess (int AD_Table_ID, int Record_ID)
{
if (s_workflow_Window_ID == 0)
if (s_workflow_Window_ID <= 0)
{
int AD_Window_ID = DB.getSQLValue(null, "SELECT AD_Window_ID FROM AD_Window WHERE Name = 'Workflow Process'");
s_workflow_Window_ID = AD_Window_ID;
}
if (s_workflow_Window_ID == 0)
if (s_workflow_Window_ID <= 0)
return;
MQuery query = new MQuery();
@ -253,9 +217,7 @@ public final class AEnv
/*************************************************************************/
/** Workflow Menu */
private static Boolean s_workflow = null;
/** Workflow Menu */
/** Workflow Window */
private static int s_workflow_Window_ID = 0;
/** Logger */
private static CLogger log = CLogger.getCLogger(AEnv.class);
@ -280,8 +242,7 @@ public final class AEnv
} // getServerVersion
/** Window Cache */
private static CCache<Integer,GridWindowVO> s_windows
= new CCache<Integer,GridWindowVO>("AD_Window", 10);
private static Map<String, CCache<Integer,GridWindowVO>> windowCache = new HashMap<String, CCache<Integer,GridWindowVO>>();
/**
* Get Window Model
@ -296,13 +257,21 @@ public final class AEnv
log.config("Window=" + WindowNo + ", AD_Window_ID=" + AD_Window_ID);
GridWindowVO mWindowVO = null;
String locale = Env.getLanguage(Env.getCtx()).getLocale().toString();
if (AD_Window_ID != 0 && Ini.isCacheWindow()) // try cache
{
mWindowVO = s_windows.get(AD_Window_ID);
if (mWindowVO != null)
{
synchronized (windowCache)
{
mWindowVO = mWindowVO.clone(WindowNo);
log.info("Cached=" + mWindowVO);
CCache<Integer,GridWindowVO> cache = windowCache.get(locale);
if (cache != null)
{
mWindowVO = cache.get(AD_Window_ID);
if (mWindowVO != null)
{
mWindowVO = mWindowVO.clone(WindowNo);
log.info("Cached=" + mWindowVO);
}
}
}
}
@ -312,7 +281,18 @@ public final class AEnv
log.config("create local");
mWindowVO = GridWindowVO.create (Env.getCtx(), WindowNo, AD_Window_ID, AD_Menu_ID);
if (mWindowVO != null)
s_windows.put(AD_Window_ID, mWindowVO);
{
synchronized (windowCache)
{
CCache<Integer,GridWindowVO> cache = windowCache.get(locale);
if (cache == null)
{
cache = new CCache<Integer, GridWindowVO>("AD_Window", 10);
windowCache.put(locale, cache);
}
cache.put(AD_Window_ID, mWindowVO);
}
}
} // from Client
if (mWindowVO == null)
return null;