IDEMPIERE-4300 DashboardPanel subclass should not cache Env Ctx (#70)
Remove Env.getCtx() cache
This commit is contained in:
parent
c5038a33ca
commit
5550a9633c
|
@ -90,7 +90,6 @@ public class DPCalendar extends DashboardPanel implements EventListener<Event>,
|
|||
private static final String ON_REQUEST_CHANGED_TOPIC = "onRequestChanged";
|
||||
|
||||
private EventWindow eventWin;
|
||||
private Properties ctx;
|
||||
private WeakReference<Desktop> desktop;
|
||||
private ArrayList<ADCalendarEvent> events;
|
||||
private DesktopCleanup listener;
|
||||
|
@ -103,9 +102,6 @@ public class DPCalendar extends DashboardPanel implements EventListener<Event>,
|
|||
public DPCalendar() {
|
||||
super();
|
||||
|
||||
ctx = new Properties();
|
||||
ctx.putAll(Env.getCtx());
|
||||
|
||||
Component component = Executions.createComponents(ThemeManager.getThemeResource("zul/calendar/calendar_mini.zul"), this, null);
|
||||
|
||||
calendars = (Calendars) component.getFellow("cal");
|
||||
|
@ -439,7 +435,7 @@ public class DPCalendar extends DashboardPanel implements EventListener<Event>,
|
|||
}
|
||||
|
||||
private void refreshModel() {
|
||||
events = getEvents(0, ctx);
|
||||
events = getEvents(0, Env.getCtx());
|
||||
}
|
||||
|
||||
private void updateDateLabel() {
|
||||
|
@ -473,8 +469,8 @@ public class DPCalendar extends DashboardPanel implements EventListener<Event>,
|
|||
String userId = (String) event.getProperty(I_R_Request.COLUMNNAME_AD_User_ID);
|
||||
String createdBy = (String) event.getProperty(I_R_Request.COLUMNNAME_CreatedBy);
|
||||
|
||||
String AD_Client_ID = Integer.toString(Env.getAD_Client_ID(ctx));
|
||||
String AD_User_ID = Integer.toString(Env.getAD_User_ID(ctx));
|
||||
String AD_Client_ID = Integer.toString(Env.getAD_Client_ID(Env.getCtx()));
|
||||
String AD_User_ID = Integer.toString(Env.getAD_User_ID(Env.getCtx()));
|
||||
if (clientId.equals(AD_Client_ID) && !"0".equals(AD_User_ID)) {
|
||||
if (salesRepId.equals(AD_User_ID) || userId.equals(AD_User_ID) || createdBy.equals(AD_User_ID)) {
|
||||
try {
|
||||
|
|
|
@ -15,7 +15,6 @@ package org.adempiere.webui.dashboard;
|
|||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.adempiere.base.Service;
|
||||
import org.adempiere.base.event.EventManager;
|
||||
|
@ -75,8 +74,6 @@ public class DPRecentItems extends DashboardPanel implements EventListener<Event
|
|||
|
||||
private int AD_User_ID;
|
||||
|
||||
private Properties ctx;
|
||||
|
||||
private WeakReference<Desktop> desktop;
|
||||
|
||||
private DesktopCleanup listener;
|
||||
|
@ -85,9 +82,7 @@ public class DPRecentItems extends DashboardPanel implements EventListener<Event
|
|||
{
|
||||
super();
|
||||
|
||||
ctx = new Properties();
|
||||
ctx.putAll(Env.getCtx());
|
||||
AD_User_ID = Env.getAD_User_ID(ctx);
|
||||
AD_User_ID = Env.getAD_User_ID(Env.getCtx());
|
||||
|
||||
Panel panel = new Panel();
|
||||
this.appendChild(panel);
|
||||
|
@ -109,7 +104,7 @@ public class DPRecentItems extends DashboardPanel implements EventListener<Event
|
|||
btn.setIconSclass("z-icon-Refresh");
|
||||
btn.setSclass("trash-toolbarbutton");
|
||||
recentItemsToolbar.appendChild(btn);
|
||||
btn.setTooltiptext(Util.cleanAmp(Msg.getMsg(ctx, "Refresh")));
|
||||
btn.setTooltiptext(Util.cleanAmp(Msg.getMsg(Env.getCtx(), "Refresh")));
|
||||
btn.addEventListener(Events.ON_CLICK, this);
|
||||
}
|
||||
else
|
||||
|
@ -117,7 +112,7 @@ public class DPRecentItems extends DashboardPanel implements EventListener<Event
|
|||
Image imgr = new Image(ThemeManager.getThemeResource("images/Refresh24.png"));
|
||||
recentItemsToolbar.appendChild(imgr);
|
||||
imgr.setStyle("text-align: right; cursor: pointer; width:24px; height:24px;");
|
||||
imgr.setTooltiptext(Util.cleanAmp(Msg.getMsg(ctx, "Refresh")));
|
||||
imgr.setTooltiptext(Util.cleanAmp(Msg.getMsg(Env.getCtx(), "Refresh")));
|
||||
imgr.addEventListener(Events.ON_CLICK, this);
|
||||
}
|
||||
//
|
||||
|
@ -137,7 +132,7 @@ public class DPRecentItems extends DashboardPanel implements EventListener<Event
|
|||
recentItemsToolbar.appendChild(img);
|
||||
img.setStyle("text-align: right; width:24px; height:24px;");
|
||||
img.setDroppable(DELETE_RECENTITEMS_DROPPABLE);
|
||||
img.setTooltiptext(Util.cleanAmp(Msg.getMsg(ctx, "Delete")));
|
||||
img.setTooltiptext(Util.cleanAmp(Msg.getMsg(Env.getCtx(), "Delete")));
|
||||
img.addEventListener(Events.ON_DROP, this);
|
||||
}
|
||||
//
|
||||
|
@ -179,7 +174,7 @@ public class DPRecentItems extends DashboardPanel implements EventListener<Event
|
|||
*/
|
||||
private void riDBremove(int AD_RecentItem_ID)
|
||||
{
|
||||
MRecentItem ri = MRecentItem.get(ctx, AD_RecentItem_ID);
|
||||
MRecentItem ri = MRecentItem.get(Env.getCtx(), AD_RecentItem_ID);
|
||||
ri.deleteEx(true);
|
||||
}
|
||||
|
||||
|
@ -222,8 +217,8 @@ public class DPRecentItems extends DashboardPanel implements EventListener<Event
|
|||
}
|
||||
|
||||
if (AD_RecentItem_ID > 0) {
|
||||
MRecentItem ri = MRecentItem.get(ctx, AD_RecentItem_ID);
|
||||
String TableName = MTable.getTableName(ctx, ri.getAD_Table_ID());
|
||||
MRecentItem ri = MRecentItem.get(Env.getCtx(), AD_RecentItem_ID);
|
||||
String TableName = MTable.getTableName(Env.getCtx(), ri.getAD_Table_ID());
|
||||
MQuery query = MQuery.getEqualQuery(TableName + "_ID", ri.getRecord_ID());
|
||||
|
||||
SessionManager.getAppDesktop().openWindow(ri.getAD_Window_ID(), query, null);
|
||||
|
@ -248,11 +243,11 @@ public class DPRecentItems extends DashboardPanel implements EventListener<Event
|
|||
bxRecentItems.removeChild(comp);
|
||||
}
|
||||
|
||||
int maxri = MSysConfig.getIntValue(MSysConfig.RecentItems_MaxShown, 10, Env.getAD_Client_ID(ctx));
|
||||
int maxri = MSysConfig.getIntValue(MSysConfig.RecentItems_MaxShown, 10, Env.getAD_Client_ID(Env.getCtx()));
|
||||
if (maxri <= 0)
|
||||
return;
|
||||
|
||||
List<MRecentItem> ris = MRecentItem.getFromUser(ctx, AD_User_ID);
|
||||
List<MRecentItem> ris = MRecentItem.getFromUser(Env.getCtx(), AD_User_ID);
|
||||
int riShown = 0;
|
||||
for (MRecentItem ri : ris) {
|
||||
if (ri.getAD_Window_ID() > 0 && MRole.getDefault().getWindowAccess(ri.getAD_Window_ID()) == null)
|
||||
|
|
|
@ -16,7 +16,6 @@ package org.adempiere.webui.dashboard;
|
|||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.adempiere.base.Service;
|
||||
import org.adempiere.base.event.EventManager;
|
||||
|
@ -65,8 +64,6 @@ public class DPRunningJobs extends DashboardPanel implements EventListener<Event
|
|||
|
||||
private int AD_User_ID;
|
||||
|
||||
private Properties ctx;
|
||||
|
||||
private WeakReference<Desktop> desktop;
|
||||
|
||||
private DesktopCleanup listener;
|
||||
|
@ -75,9 +72,7 @@ public class DPRunningJobs extends DashboardPanel implements EventListener<Event
|
|||
{
|
||||
super();
|
||||
|
||||
ctx = new Properties();
|
||||
ctx.putAll(Env.getCtx());
|
||||
AD_User_ID = Env.getAD_User_ID(ctx);
|
||||
AD_User_ID = Env.getAD_User_ID(Env.getCtx());
|
||||
|
||||
Panel panel = new Panel();
|
||||
this.appendChild(panel);
|
||||
|
@ -99,7 +94,7 @@ public class DPRunningJobs extends DashboardPanel implements EventListener<Event
|
|||
btn.setIconSclass("z-icon-Refresh");
|
||||
btn.setSclass("trash-toolbarbutton");
|
||||
jobsToolbar.appendChild(btn);
|
||||
btn.setTooltiptext(Util.cleanAmp(Msg.getMsg(ctx, "Refresh")));
|
||||
btn.setTooltiptext(Util.cleanAmp(Msg.getMsg(Env.getCtx(), "Refresh")));
|
||||
btn.addEventListener(Events.ON_CLICK, this);
|
||||
}
|
||||
else
|
||||
|
@ -107,7 +102,7 @@ public class DPRunningJobs extends DashboardPanel implements EventListener<Event
|
|||
Image imgr = new Image(ThemeManager.getThemeResource("images/Refresh24.png"));
|
||||
jobsToolbar.appendChild(imgr);
|
||||
imgr.setStyle("text-align: right; cursor: pointer; width:24px; height:24px;");
|
||||
imgr.setTooltiptext(Util.cleanAmp(Msg.getMsg(ctx, "Refresh")));
|
||||
imgr.setTooltiptext(Util.cleanAmp(Msg.getMsg(Env.getCtx(), "Refresh")));
|
||||
imgr.addEventListener(Events.ON_CLICK, this);
|
||||
}
|
||||
|
||||
|
@ -191,7 +186,7 @@ public class DPRunningJobs extends DashboardPanel implements EventListener<Event
|
|||
bxJobs.removeChild(comp);
|
||||
}
|
||||
|
||||
List<MPInstance> pis = getRunningJobForUser(ctx, AD_User_ID);
|
||||
List<MPInstance> pis = getRunningJobForUser(AD_User_ID);
|
||||
for (MPInstance pi : pis) {
|
||||
MProcess process = new MProcess(pi.getCtx(), pi.getAD_Process_ID(), pi.get_TrxName());
|
||||
String label = process.getName() + " [" + Msg.getElement(pi.getCtx(), "Created") + " = " + pi.getCreated() + "]";
|
||||
|
@ -206,9 +201,9 @@ public class DPRunningJobs extends DashboardPanel implements EventListener<Event
|
|||
}
|
||||
}
|
||||
|
||||
public static List<MPInstance> getRunningJobForUser(Properties ctx, int AD_User_ID)
|
||||
public static List<MPInstance> getRunningJobForUser(int AD_User_ID)
|
||||
{
|
||||
List<MPInstance> pis = new Query(ctx, MPInstance.Table_Name, "Coalesce(AD_User_ID,0)=? AND IsProcessing='Y' AND IsRunAsJob='Y'", null)
|
||||
List<MPInstance> pis = new Query(Env.getCtx(), MPInstance.Table_Name, "Coalesce(AD_User_ID,0)=? AND IsProcessing='Y' AND IsRunAsJob='Y'", null)
|
||||
.setOnlyActiveRecords(true)
|
||||
.setClient_ID()
|
||||
.setParameters(AD_User_ID)
|
||||
|
|
Loading…
Reference in New Issue