IDEMPIERE-3000 Automatic opening of menu entries at login
This commit is contained in:
parent
ccaa5462d2
commit
67d46b541a
|
@ -17,12 +17,8 @@
|
|||
|
||||
package org.adempiere.webui;
|
||||
|
||||
import static org.compiere.model.SystemIDs.TREE_MENUPRIMARY;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
@ -45,7 +41,6 @@ import org.adempiere.webui.session.SessionManager;
|
|||
import org.adempiere.webui.theme.ThemeManager;
|
||||
import org.adempiere.webui.util.BrowserToken;
|
||||
import org.adempiere.webui.util.UserPreference;
|
||||
import org.compiere.model.MMenu;
|
||||
import org.compiere.model.MRole;
|
||||
import org.compiere.model.MSession;
|
||||
import org.compiere.model.MSysConfig;
|
||||
|
@ -54,7 +49,6 @@ import org.compiere.model.MTable;
|
|||
import org.compiere.model.MUser;
|
||||
import org.compiere.model.MUserPreference;
|
||||
import org.compiere.util.CLogger;
|
||||
import org.compiere.util.DB;
|
||||
import org.compiere.util.Env;
|
||||
import org.compiere.util.Language;
|
||||
import org.compiere.util.Msg;
|
||||
|
@ -85,7 +79,6 @@ import org.zkoss.zul.Window;
|
|||
*/
|
||||
public class AdempiereWebUI extends Window implements EventListener<Event>, IWebClient
|
||||
{
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
@ -290,7 +283,6 @@ public class AdempiereWebUI extends Window implements EventListener<Event>, IWeb
|
|||
Env.setContext(ctx, "#LocalHttpAddr", localHttpAddr.toString());
|
||||
Clients.response(new AuScript("zAu.cmd0.clearBusy()"));
|
||||
|
||||
automaticOpen();
|
||||
processParameters();
|
||||
}
|
||||
|
||||
|
@ -550,69 +542,4 @@ public class AdempiereWebUI extends Window implements EventListener<Event>, IWeb
|
|||
}
|
||||
return uploadSetting.toString();
|
||||
}
|
||||
|
||||
int getMenuID()
|
||||
{
|
||||
int AD_Role_ID = Env.getAD_Role_ID(Env.getCtx());
|
||||
int AD_Tree_ID = DB.getSQLValue(null,
|
||||
"SELECT COALESCE(r.AD_Tree_Menu_ID, ci.AD_Tree_Menu_ID)"
|
||||
+ "FROM AD_ClientInfo ci"
|
||||
+ " INNER JOIN AD_Role r ON (ci.AD_Client_ID=r.AD_Client_ID) "
|
||||
+ "WHERE AD_Role_ID=?", AD_Role_ID);
|
||||
if (AD_Tree_ID <= 0)
|
||||
AD_Tree_ID = TREE_MENUPRIMARY; // Menu
|
||||
|
||||
return AD_Tree_ID;
|
||||
}
|
||||
|
||||
private void automaticOpen() {
|
||||
|
||||
StringBuilder sql = new StringBuilder("SELECT m.Action, COALESCE(m.AD_Window_ID, m.AD_Process_ID, m.AD_Form_ID, m.AD_Workflow_ID, m.AD_Task_ID, AD_InfoWindow_ID) ")
|
||||
.append(" FROM AD_TreeBar tb")
|
||||
.append(" INNER JOIN AD_Menu m ON (tb.Node_ID = m.AD_Menu_ID)")
|
||||
.append(" WHERE tb.AD_Tree_ID = ").append(getMenuID())
|
||||
.append(" AND tb.AD_User_ID = ").append(Env.getAD_User_ID(Env.getCtx()))
|
||||
.append(" AND tb.IsActive = 'Y' AND tb.LoginOpenSeqNo > 0")
|
||||
.append(" ORDER BY tb.LoginOpenSeqNo");
|
||||
|
||||
List<List<Object>> rows = DB.getSQLArrayObjectsEx(null, sql.toString());
|
||||
if (rows != null && rows.size() > 0) {
|
||||
for (List<Object> row : rows) {
|
||||
|
||||
String action = (String) row.get(0);
|
||||
int recordID = ((BigDecimal) row.get(1)).intValue();
|
||||
|
||||
if (action.equals(MMenu.ACTION_Form)) {
|
||||
Boolean access = MRole.getDefault().getFormAccess(recordID);
|
||||
if (access != null && access)
|
||||
SessionManager.getAppDesktop().openForm(recordID);
|
||||
}
|
||||
else if (action.equals(MMenu.ACTION_Info)) {
|
||||
Boolean access = MRole.getDefault().getInfoAccess(recordID);
|
||||
if (access != null && access)
|
||||
SessionManager.getAppDesktop().openInfo(recordID);
|
||||
}
|
||||
else if (action.equals(MMenu.ACTION_Process) || action.equals(MMenu.ACTION_Report)) {
|
||||
Boolean access = MRole.getDefault().getProcessAccess(recordID);
|
||||
if (access != null && access)
|
||||
SessionManager.getAppDesktop().openProcessDialog(recordID, DB.getSQLValueStringEx(null, "SELECT IsSOTrx FROM AD_Menu WHERE AD_Menu_ID = ?", recordID).equals("Y"));
|
||||
}
|
||||
else if (action.equals(MMenu.ACTION_Task)) {
|
||||
Boolean access = MRole.getDefault().getTaskAccess(recordID);
|
||||
if (access != null && access)
|
||||
SessionManager.getAppDesktop().openTask(recordID);
|
||||
}
|
||||
else if (action.equals(MMenu.ACTION_Window)) {
|
||||
Boolean access = MRole.getDefault().getWindowAccess(recordID);
|
||||
if (access != null && access)
|
||||
SessionManager.getAppDesktop().openWindow(recordID, null);
|
||||
}
|
||||
else if (action.equals(MMenu.ACTION_WorkFlow)) {
|
||||
Boolean access = MRole.getDefault().getWorkflowAccess(recordID);
|
||||
if (access != null && access)
|
||||
SessionManager.getAppDesktop().openWorkflow(recordID);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,7 +17,10 @@
|
|||
|
||||
package org.adempiere.webui.desktop;
|
||||
|
||||
import static org.compiere.model.SystemIDs.TREE_MENUPRIMARY;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
@ -60,6 +63,7 @@ import org.compiere.Adempiere;
|
|||
import org.compiere.model.GridField;
|
||||
import org.compiere.model.GridTab;
|
||||
import org.compiere.model.I_AD_Preference;
|
||||
import org.compiere.model.MMenu;
|
||||
import org.compiere.model.MPreference;
|
||||
import org.compiere.model.MQuery;
|
||||
import org.compiere.model.MRole;
|
||||
|
@ -68,6 +72,7 @@ import org.compiere.model.Query;
|
|||
import org.compiere.model.SystemIDs;
|
||||
import org.compiere.model.X_AD_CtxHelp;
|
||||
import org.compiere.util.CLogger;
|
||||
import org.compiere.util.DB;
|
||||
import org.compiere.util.Env;
|
||||
import org.compiere.util.Msg;
|
||||
import org.compiere.util.Util;
|
||||
|
@ -111,7 +116,7 @@ public class DefaultDesktop extends TabbedDesktop implements MenuListener, Seria
|
|||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 6775071898539380777L;
|
||||
private static final long serialVersionUID = 7189914859100400758L;
|
||||
|
||||
private static final String IMAGES_UPARROW_PNG = "images/collapse-header.png";
|
||||
|
||||
|
@ -322,6 +327,7 @@ public class DefaultDesktop extends TabbedDesktop implements MenuListener, Seria
|
|||
try {
|
||||
ServerContext.setCurrentInstance(ctx);
|
||||
renderHomeTab();
|
||||
automaticOpen(ctx);
|
||||
} finally {
|
||||
ServerContext.dispose();
|
||||
}
|
||||
|
@ -891,6 +897,68 @@ public class DefaultDesktop extends TabbedDesktop implements MenuListener, Seria
|
|||
Clients.response(new AuScript(script));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
int getMenuID()
|
||||
{
|
||||
int AD_Role_ID = Env.getAD_Role_ID(Env.getCtx());
|
||||
int AD_Tree_ID = DB.getSQLValue(null,
|
||||
"SELECT COALESCE(r.AD_Tree_Menu_ID, ci.AD_Tree_Menu_ID)"
|
||||
+ "FROM AD_ClientInfo ci"
|
||||
+ " INNER JOIN AD_Role r ON (ci.AD_Client_ID=r.AD_Client_ID) "
|
||||
+ "WHERE AD_Role_ID=?", AD_Role_ID);
|
||||
if (AD_Tree_ID <= 0)
|
||||
AD_Tree_ID = TREE_MENUPRIMARY; // Menu
|
||||
|
||||
return AD_Tree_ID;
|
||||
}
|
||||
private void automaticOpen(Properties ctx) {
|
||||
|
||||
StringBuilder sql = new StringBuilder("SELECT m.Action, COALESCE(m.AD_Window_ID, m.AD_Process_ID, m.AD_Form_ID, m.AD_Workflow_ID, m.AD_Task_ID, AD_InfoWindow_ID) ")
|
||||
.append(" FROM AD_TreeBar tb")
|
||||
.append(" INNER JOIN AD_Menu m ON (tb.Node_ID = m.AD_Menu_ID)")
|
||||
.append(" WHERE tb.AD_Tree_ID = ").append(getMenuID())
|
||||
.append(" AND tb.AD_User_ID = ").append(Env.getAD_User_ID(ctx))
|
||||
.append(" AND tb.IsActive = 'Y' AND tb.LoginOpenSeqNo > 0")
|
||||
.append(" ORDER BY tb.LoginOpenSeqNo");
|
||||
|
||||
List<List<Object>> rows = DB.getSQLArrayObjectsEx(null, sql.toString());
|
||||
if (rows != null && rows.size() > 0) {
|
||||
for (List<Object> row : rows) {
|
||||
|
||||
String action = (String) row.get(0);
|
||||
int recordID = ((BigDecimal) row.get(1)).intValue();
|
||||
|
||||
if (action.equals(MMenu.ACTION_Form)) {
|
||||
Boolean access = MRole.getDefault().getFormAccess(recordID);
|
||||
if (access != null && access)
|
||||
SessionManager.getAppDesktop().openForm(recordID);
|
||||
}
|
||||
else if (action.equals(MMenu.ACTION_Info)) {
|
||||
Boolean access = MRole.getDefault().getInfoAccess(recordID);
|
||||
if (access != null && access)
|
||||
SessionManager.getAppDesktop().openInfo(recordID);
|
||||
}
|
||||
else if (action.equals(MMenu.ACTION_Process) || action.equals(MMenu.ACTION_Report)) {
|
||||
Boolean access = MRole.getDefault().getProcessAccess(recordID);
|
||||
if (access != null && access)
|
||||
SessionManager.getAppDesktop().openProcessDialog(recordID, DB.getSQLValueStringEx(null, "SELECT IsSOTrx FROM AD_Menu WHERE AD_Menu_ID = ?", recordID).equals("Y"));
|
||||
}
|
||||
else if (action.equals(MMenu.ACTION_Task)) {
|
||||
Boolean access = MRole.getDefault().getTaskAccess(recordID);
|
||||
if (access != null && access)
|
||||
SessionManager.getAppDesktop().openTask(recordID);
|
||||
}
|
||||
else if (action.equals(MMenu.ACTION_Window)) {
|
||||
Boolean access = MRole.getDefault().getWindowAccess(recordID);
|
||||
if (access != null && access)
|
||||
SessionManager.getAppDesktop().openWindow(recordID, null);
|
||||
}
|
||||
else if (action.equals(MMenu.ACTION_WorkFlow)) {
|
||||
Boolean access = MRole.getDefault().getWorkflowAccess(recordID);
|
||||
if (access != null && access)
|
||||
SessionManager.getAppDesktop().openWorkflow(recordID);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue