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