IDEMPIERE-3978 Zoom from QuickInfo to a specific window / peer review and tests

This commit is contained in:
Carlos Ruiz 2019-06-04 10:26:58 +02:00
parent c0b4da403d
commit b600b9878d
5 changed files with 50 additions and 31 deletions

View File

@ -49,7 +49,7 @@ public class MQuery implements Serializable
/**
*
*/
private static final long serialVersionUID = 481623650333512326L;
private static final long serialVersionUID = -1495322773308601375L;
/**
* Get Query from Parameter
@ -386,12 +386,12 @@ public class MQuery implements Serializable
private int m_zoomWindow_ID;
public int getM_zoomWindow_ID() {
public int getZoomWindowID() {
return m_zoomWindow_ID;
}
public void setM_zoomWindow_ID(int m_zoomWindow_ID) {
public void setZoomWindowID(int m_zoomWindow_ID) {
this.m_zoomWindow_ID = m_zoomWindow_ID;
}

View File

@ -20,6 +20,7 @@ import java.awt.Dimension;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Iterator;
import java.util.List;
import java.util.Properties;
import java.util.logging.Level;
@ -41,7 +42,7 @@ public class MWindow extends X_AD_Window
/**
*
*/
private static final long serialVersionUID = 8966733945232755787L;
private static final long serialVersionUID = -6027810254265627308L;
/** Static Logger */
private static CLogger s_log = CLogger.getCLogger (MWindow.class);
@ -69,6 +70,39 @@ public class MWindow extends X_AD_Window
return retValue;
} // get
/**
* get Window ID by UU
* @param ctx context
* @param uu AD_Window_UU
* @return MWindow object
*/
public static synchronized MWindow get(Properties ctx, String uu)
{
if (uu == null)
return null;
MWindow retValue = null;
Iterator<MWindow> it = s_cache.values().iterator();
while (it.hasNext())
{
retValue = it.next();
if (uu.equals(retValue.getAD_Window_UU()) && retValue.getCtx() == ctx)
{
return retValue;
}
}
final String whereClause = MWindow.COLUMNNAME_AD_Window_UU + "=?";
MWindow window = new Query(Env.getCtx(), MWindow.Table_Name, whereClause, null)
.setParameters(uu)
.setOnlyActiveRecords(true)
.first();
if (window != null)
retValue = window;
return retValue;
}
/**
* Standard Constructor
* @param ctx context
@ -241,26 +275,4 @@ public class MWindow extends X_AD_Window
}
//end vpj-cd e-evolution
/**
* get Window ID by UU
* @param uu
* @return
*/
public static int findByUU(String uu)
{
int retValue = 0;
final String whereClause = MWindow.COLUMNNAME_AD_Window_UU + "=?";
MWindow window = new Query(Env.getCtx(), MWindow.Table_Name, whereClause, null)
.setParameters(uu)
.setOnlyActiveRecords(true)
.first();
if (window != null)
retValue = window.get_ID();
return retValue;
}
} // M_Window

View File

@ -462,7 +462,7 @@ public final class AEnv
if (query == null || query.getTableName() == null || query.getTableName().length() == 0)
return;
int AD_Window_ID = query.getM_zoomWindow_ID();
int AD_Window_ID = query.getZoomWindowID();
if (AD_Window_ID <= 0)
AD_Window_ID = Env.getZoomWindowID(query);

View File

@ -18,6 +18,7 @@ import java.util.Map;
import org.adempiere.webui.event.ZoomEvent;
import org.compiere.model.MQuery;
import org.compiere.model.MWindow;
import org.compiere.util.Env;
import org.zkoss.json.JSONArray;
import org.zkoss.lang.Objects;
import org.zkoss.zk.au.AuRequest;
@ -69,10 +70,13 @@ public class ZoomCommand implements AuService {
code = data.get(1);
}
if (data.size() > 3)
if ( data.size() > 3 && data.get(3) != null
&& data.get(2) != null && data.get(2).toString().equalsIgnoreCase("AD_Window_UU"))
{
String windowUU = (String) data.get(3);
windowID = MWindow.findByUU(windowUU);
MWindow window = MWindow.get(Env.getCtx(), windowUU);
if (window != null)
windowID = window.getAD_Window_ID();
}
//
MQuery query = new MQuery(tableName);
@ -81,7 +85,7 @@ public class ZoomCommand implements AuService {
query.setZoomTableName(tableName);
query.setZoomColumnName(columnName);
query.setZoomValue(code);
query.setM_zoomWindow_ID(windowID);
query.setZoomWindowID(windowID);
Events.postEvent(new ZoomEvent(comp, query));

View File

@ -1,5 +1,8 @@
function zoom(cmpid, column, value){
zoomWindow(cmpid, column, value, null)
zAu.cmd0.showBusy(null);
var widget = zk.Widget.$(cmpid);
var event = new zk.Event(widget, 'onZoom', {data: [column, value]}, {toServer: true});
zAu.send(event);
}
function zoomWindow(cmpid, column, value, windowuu){