IDEMPIERE-1232 Zoom condition fixes. 1) Fixed WFEditor.zoom not using zoom condition. 2) Added null check for the query parameter in AEnv.zoom methods 3) Fixed AEnv.zoom(AD_Window_ID, query) not using zoom condition. Added AEnv.showZoomWindow(AD_Window_ID, query) to replace the direct opening of zoom window usage.
This commit is contained in:
parent
6de2833897
commit
288c967594
|
@ -75,6 +75,9 @@ public class MZoomCondition extends X_AD_ZoomCondition
|
||||||
|
|
||||||
private static int findZoomWindowByTableId(int AD_Table_ID, MQuery query)
|
private static int findZoomWindowByTableId(int AD_Table_ID, MQuery query)
|
||||||
{
|
{
|
||||||
|
if (query == null)
|
||||||
|
return 0;
|
||||||
|
|
||||||
MZoomCondition[] conditions = MZoomCondition.getConditions(AD_Table_ID);
|
MZoomCondition[] conditions = MZoomCondition.getConditions(AD_Table_ID);
|
||||||
if (conditions.length > 0)
|
if (conditions.length > 0)
|
||||||
{
|
{
|
||||||
|
@ -111,6 +114,9 @@ public class MZoomCondition extends X_AD_ZoomCondition
|
||||||
*/
|
*/
|
||||||
public static int findZoomWindowByWindowId(int AD_Window_ID, MQuery query)
|
public static int findZoomWindowByWindowId(int AD_Window_ID, MQuery query)
|
||||||
{
|
{
|
||||||
|
if (query == null)
|
||||||
|
return 0;
|
||||||
|
|
||||||
int tableID = DB.getSQLValueEx(null,
|
int tableID = DB.getSQLValueEx(null,
|
||||||
"SELECT t.AD_Table_ID " +
|
"SELECT t.AD_Table_ID " +
|
||||||
"FROM AD_Tab tab JOIN AD_Table t ON t.AD_Table_ID=tab.AD_Table_ID " +
|
"FROM AD_Tab tab JOIN AD_Table t ON t.AD_Table_ID=tab.AD_Table_ID " +
|
||||||
|
@ -125,45 +131,49 @@ public class MZoomCondition extends X_AD_ZoomCondition
|
||||||
if (tableName != null && tableName.equals(query.getZoomTableName())) {
|
if (tableName != null && tableName.equals(query.getZoomTableName())) {
|
||||||
return findZoomWindowByTableId(tableID, query);
|
return findZoomWindowByTableId(tableID, query);
|
||||||
} else {
|
} else {
|
||||||
GridWindow window = GridWindow.get(Env.getCtx(), -1, AD_Window_ID);
|
try {
|
||||||
if (window == null || window.getTabCount() == 0)
|
GridWindow window = GridWindow.get(Env.getCtx(), -1, AD_Window_ID);
|
||||||
return 0;
|
if (window == null || window.getTabCount() == 0)
|
||||||
//resolve zoom to detail
|
return 0;
|
||||||
int size = window.getTabCount();
|
//resolve zoom to detail
|
||||||
GridTab gTab = null;
|
int size = window.getTabCount();
|
||||||
for(int i = 0; i < size; i++)
|
GridTab gTab = null;
|
||||||
{
|
for(int i = 0; i < size; i++)
|
||||||
if (window.getTab(i).getTableName().equals(query.getZoomTableName()))
|
|
||||||
{
|
{
|
||||||
gTab = window.getTab(i);
|
if (window.getTab(i).getTableName().equals(query.getZoomTableName()))
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (gTab != null)
|
|
||||||
{
|
|
||||||
window.initTab(gTab.getTabNo());
|
|
||||||
GridTab parentTab = gTab.getParentTab();
|
|
||||||
int parentId = DB.getSQLValue(null, "SELECT " + gTab.getLinkColumnName() + " FROM " + gTab.getTableName() + " WHERE " + query.getWhereClause());
|
|
||||||
if (parentId <= 0)return 0;
|
|
||||||
|
|
||||||
while (parentTab != null)
|
|
||||||
{
|
|
||||||
window.initTab(parentTab.getTabNo());
|
|
||||||
if (parentTab.getParentTab() != null)
|
|
||||||
{
|
{
|
||||||
parentId = DB.getSQLValue(null, "SELECT " + parentTab.getLinkColumnName() + " FROM " + parentTab.getTableName() + " WHERE "
|
gTab = window.getTab(i);
|
||||||
+ parentTab.getTableName()+"_ID="+parentId);
|
break;
|
||||||
if (parentId <= 0) return 0;
|
|
||||||
parentTab = parentTab.getParentTab();
|
|
||||||
}
|
}
|
||||||
else
|
}
|
||||||
{
|
if (gTab != null)
|
||||||
if (parentTab == window.getTab(0))
|
{
|
||||||
|
window.initTab(gTab.getTabNo());
|
||||||
|
GridTab parentTab = gTab.getParentTab();
|
||||||
|
int parentId = DB.getSQLValue(null, "SELECT " + gTab.getLinkColumnName() + " FROM " + gTab.getTableName() + " WHERE " + query.getWhereClause());
|
||||||
|
if (parentId <= 0)return 0;
|
||||||
|
|
||||||
|
while (parentTab != null)
|
||||||
|
{
|
||||||
|
window.initTab(parentTab.getTabNo());
|
||||||
|
if (parentTab.getParentTab() != null)
|
||||||
{
|
{
|
||||||
return findZoomWindowByTableId(parentTab.getAD_Table_ID(), parentId);
|
parentId = DB.getSQLValue(null, "SELECT " + parentTab.getLinkColumnName() + " FROM " + parentTab.getTableName() + " WHERE "
|
||||||
|
+ parentTab.getTableName()+"_ID="+parentId);
|
||||||
|
if (parentId <= 0) return 0;
|
||||||
|
parentTab = parentTab.getParentTab();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (parentTab == window.getTab(0))
|
||||||
|
{
|
||||||
|
return findZoomWindowByTableId(parentTab.getAD_Table_ID(), parentId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} finally {
|
||||||
|
Env.clearWinContext(-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -387,10 +387,19 @@ public final class AEnv
|
||||||
zoomQuery.setRecordCount(1); // guess
|
zoomQuery.setRecordCount(1); // guess
|
||||||
}
|
}
|
||||||
int windowId = lookup.getZoom(zoomQuery);
|
int windowId = lookup.getZoom(zoomQuery);
|
||||||
int zoomId = MZoomCondition.findZoomWindowByWindowId(windowId, zoomQuery);
|
zoom(windowId, zoomQuery);
|
||||||
zoom(zoomId > 0 ? zoomId : windowId, zoomQuery);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* open zoom window with query
|
||||||
|
* @param AD_Window_ID
|
||||||
|
* @param query
|
||||||
|
*/
|
||||||
|
public static void showZoomWindow(int AD_Window_ID, MQuery query)
|
||||||
|
{
|
||||||
|
SessionManager.getAppDesktop().showZoomWindow(AD_Window_ID, query);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Zoom to a window with the provided window id and filters according to the
|
* Zoom to a window with the provided window id and filters according to the
|
||||||
* query
|
* query
|
||||||
|
@ -399,7 +408,8 @@ public final class AEnv
|
||||||
*/
|
*/
|
||||||
public static void zoom(int AD_Window_ID, MQuery query)
|
public static void zoom(int AD_Window_ID, MQuery query)
|
||||||
{
|
{
|
||||||
SessionManager.getAppDesktop().showZoomWindow(AD_Window_ID, query);
|
int zoomId = MZoomCondition.findZoomWindowByWindowId(AD_Window_ID, query);
|
||||||
|
showZoomWindow(zoomId > 0 ? zoomId : AD_Window_ID, query);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void showWindow(Window win)
|
public static void showWindow(Window win)
|
||||||
|
@ -421,7 +431,7 @@ public final class AEnv
|
||||||
if (AD_Window_ID == 0)
|
if (AD_Window_ID == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
zoom(AD_Window_ID, query);
|
showZoomWindow(AD_Window_ID, query);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -19,7 +19,6 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
import org.adempiere.exceptions.AdempiereException;
|
|
||||||
import org.adempiere.webui.apps.AEnv;
|
import org.adempiere.webui.apps.AEnv;
|
||||||
import org.adempiere.webui.component.ConfirmPanel;
|
import org.adempiere.webui.component.ConfirmPanel;
|
||||||
import org.adempiere.webui.component.ListItem;
|
import org.adempiere.webui.component.ListItem;
|
||||||
|
@ -33,9 +32,7 @@ import org.adempiere.webui.panel.ADForm;
|
||||||
import org.adempiere.webui.theme.ThemeManager;
|
import org.adempiere.webui.theme.ThemeManager;
|
||||||
import org.compiere.apps.wf.WFGraphLayout;
|
import org.compiere.apps.wf.WFGraphLayout;
|
||||||
import org.compiere.apps.wf.WFNodeWidget;
|
import org.compiere.apps.wf.WFNodeWidget;
|
||||||
import org.compiere.model.MQuery;
|
|
||||||
import org.compiere.model.MRole;
|
import org.compiere.model.MRole;
|
||||||
import org.compiere.model.MTable;
|
|
||||||
import org.compiere.util.DB;
|
import org.compiere.util.DB;
|
||||||
import org.compiere.util.Env;
|
import org.compiere.util.Env;
|
||||||
import org.compiere.util.KeyNamePair;
|
import org.compiere.util.KeyNamePair;
|
||||||
|
@ -445,15 +442,7 @@ public class WFEditor extends ADForm {
|
||||||
private void zoom()
|
private void zoom()
|
||||||
{
|
{
|
||||||
if (m_workflowId > 0) {
|
if (m_workflowId > 0) {
|
||||||
int AD_Window_ID = MTable.get(Env.getCtx(), MWorkflow.Table_ID).getAD_Window_ID();
|
AEnv.zoom(MWorkflow.Table_ID, m_workflowId);
|
||||||
|
|
||||||
if (AD_Window_ID <= 0) {
|
|
||||||
throw new AdempiereException("@NotFound@ @AD_Window_ID@");
|
|
||||||
}
|
|
||||||
|
|
||||||
MQuery query = null;
|
|
||||||
query = MQuery.getEqualQuery("AD_Workflow_ID", m_workflowId);
|
|
||||||
AEnv.zoom(AD_Window_ID, query);
|
|
||||||
}
|
}
|
||||||
} // zoom
|
} // zoom
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue