IDEMPIERE-5750 Error when switching to tab when choosing a language other than English (#1920)
* IDEMPIERE-5750 Error when switching to tab when choosing a language other than English * - avoid usage of AdempiereIdGenerator.escapeId when not ZkUnitTest
This commit is contained in:
parent
7a66540bca
commit
b7b0b16476
|
@ -0,0 +1,46 @@
|
|||
/***********************************************************************
|
||||
* This file is part of iDempiere ERP Open Source *
|
||||
* http://www.idempiere.org *
|
||||
* *
|
||||
* Copyright (C) Contributors *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License *
|
||||
* as published by the Free Software Foundation; either version 2 *
|
||||
* of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the Free Software *
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, *
|
||||
* MA 02110-1301, USA. *
|
||||
* *
|
||||
* Contributors: *
|
||||
* - Carlos Ruiz - globalqss - bxservice *
|
||||
**********************************************************************/
|
||||
|
||||
package org.compiere.model;
|
||||
|
||||
/**
|
||||
* Collection of System properties used in iDempiere
|
||||
*
|
||||
* @author Carlos Ruiz - globalqss - bxservice
|
||||
*/
|
||||
|
||||
public class SystemProperties {
|
||||
|
||||
public static final String ZkUnitTest = "ZkUnitTest";
|
||||
|
||||
/**
|
||||
* ZkUnitTest=true to define if the component ids must be generated using AdempiereIdGenerator.escapeId
|
||||
* @return
|
||||
*/
|
||||
public static boolean isZkUnitTest() {
|
||||
return "true".equals(System.getProperty(ZkUnitTest));
|
||||
}
|
||||
|
||||
}
|
|
@ -53,7 +53,7 @@
|
|||
<stringAttribute key="org.eclipse.jdt.launching.JRE_CONTAINER" value="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-os ${target.os} -ws ${target.ws} -arch ${target.arch} -nl ${target.nl} -consoleLog -console"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.pde.ui.workbenchClasspathProvider"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Dorg.eclipse.swt.graphics.Resource.reportNonDisposed=true --add-modules=java.se --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.nio=ALL-UNNAMED --add-opens=java.base/sun.nio.ch=ALL-UNNAMED --add-opens=java.management/sun.management=ALL-UNNAMED --add-opens=jdk.management/com.sun.management.internal=ALL-UNNAMED --add-exports=java.base/jdk.internal.ref=ALL-UNNAMED --add-exports=java.desktop/sun.awt=ALL-UNNAMED --add-exports=java.sql.rowset/com.sun.rowset=ALL-UNNAMED --add-exports=java.naming/com.sun.jndi.ldap=ALL-UNNAMED -Declipse.product=org.adempiere.server.product -Dosgi.noShutdown=true -Dosgi.framework.activeThreadType=normal -Dorg.osgi.framework.bootdelegation=sun.security.ssl -Dosgi.compatibility.bootdelegation=true -Djetty.home=jettyhome -Djetty.etc.config.urls=etc/jetty.xml,etc/jetty-deployer.xml,etc/jetty-ssl.xml,etc/jetty-ssl-context.xml,etc/jetty-http.xml,etc/jetty-https.xml,etc/jetty-threadpool.xml,etc/jetty-http-forwarded.xml -Dmail.mime.encodefilename=true -Dmail.mime.decodefilename=true -Dmail.mime.encodeparameters=true -Dmail.mime.decodeparameters=true -Dhazelcast.config=hazelcast.xml -Dorg.zkoss.zk.config.path=file://${project_loc:org.adempiere.ui.zk}/WEB-INF/zk-selenium.xml"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Dorg.eclipse.swt.graphics.Resource.reportNonDisposed=true --add-modules=java.se --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.nio=ALL-UNNAMED --add-opens=java.base/sun.nio.ch=ALL-UNNAMED --add-opens=java.management/sun.management=ALL-UNNAMED --add-opens=jdk.management/com.sun.management.internal=ALL-UNNAMED --add-exports=java.base/jdk.internal.ref=ALL-UNNAMED --add-exports=java.desktop/sun.awt=ALL-UNNAMED --add-exports=java.sql.rowset/com.sun.rowset=ALL-UNNAMED --add-exports=java.naming/com.sun.jndi.ldap=ALL-UNNAMED -Declipse.product=org.adempiere.server.product -Dosgi.noShutdown=true -Dosgi.framework.activeThreadType=normal -Dorg.osgi.framework.bootdelegation=sun.security.ssl -Dosgi.compatibility.bootdelegation=true -Djetty.home=jettyhome -Djetty.etc.config.urls=etc/jetty.xml,etc/jetty-deployer.xml,etc/jetty-ssl.xml,etc/jetty-ssl-context.xml,etc/jetty-http.xml,etc/jetty-https.xml,etc/jetty-threadpool.xml,etc/jetty-http-forwarded.xml -Dmail.mime.encodefilename=true -Dmail.mime.decodefilename=true -Dmail.mime.encodeparameters=true -Dmail.mime.decodeparameters=true -Dhazelcast.config=hazelcast.xml -Dorg.zkoss.zk.config.path=file://${project_loc:org.adempiere.ui.zk}/WEB-INF/zk-selenium.xml -DZkUnitTest=true"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.WORKING_DIRECTORY" value="${project_loc:org.adempiere.base}/.."/>
|
||||
<stringAttribute key="pde.version" value="3.3"/>
|
||||
<stringAttribute key="product" value="org.adempiere.server.server_product"/>
|
||||
|
|
|
@ -105,6 +105,14 @@ public class AdempiereIdGenerator implements IdGenerator {
|
|||
return name.toLowerCase();
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate an id with just alphanumeric characters
|
||||
* This is used for ZkUnitTest that requires predictable iDs, f.e. Selenium
|
||||
* WARNING: it doesn't work well with non-alphanumeric languages
|
||||
* f.e. in Russian the translation for bank and account lead to the same id ____
|
||||
* @param prefix
|
||||
* @return
|
||||
*/
|
||||
public static String escapeId(String prefix) {
|
||||
Pattern pattern = Pattern.compile("[^a-zA-Z_0-9]");
|
||||
Matcher matcher = pattern.matcher(prefix);
|
||||
|
|
|
@ -46,6 +46,7 @@ import org.compiere.model.MRole;
|
|||
import org.compiere.model.MSysConfig;
|
||||
import org.compiere.model.MTable;
|
||||
import org.compiere.model.PO;
|
||||
import org.compiere.model.SystemProperties;
|
||||
import org.compiere.util.CLogger;
|
||||
import org.compiere.util.DB;
|
||||
import org.compiere.util.Env;
|
||||
|
@ -303,6 +304,7 @@ public class ADSortTab extends Panel implements IADTabpanel
|
|||
ZKUpdateUtil.setVflex(yesList, true);
|
||||
ZKUpdateUtil.setVflex(noList, true);
|
||||
|
||||
if (SystemProperties.isZkUnitTest())
|
||||
setId(AdempiereIdGenerator.escapeId(gridTab.getName()));
|
||||
|
||||
EventListener<Event> mouseListener = new EventListener<Event>()
|
||||
|
|
|
@ -86,6 +86,7 @@ import org.compiere.model.MTree;
|
|||
import org.compiere.model.MTreeNode;
|
||||
import org.compiere.model.PO;
|
||||
import org.compiere.model.Query;
|
||||
import org.compiere.model.SystemProperties;
|
||||
import org.compiere.model.X_AD_FieldGroup;
|
||||
import org.compiere.model.X_AD_ToolBarButton;
|
||||
import org.compiere.util.CCache;
|
||||
|
@ -448,6 +449,7 @@ DataStatusListener, IADTabpanel, IdSpace, IFieldEditorContainer
|
|||
|
||||
this.getChildren().clear();
|
||||
|
||||
if (SystemProperties.isZkUnitTest())
|
||||
setId(AdempiereIdGenerator.escapeId(gridTab.getName()));
|
||||
|
||||
int AD_Tree_ID = 0;
|
||||
|
|
|
@ -112,6 +112,7 @@ import org.compiere.model.MUserPreference;
|
|||
import org.compiere.model.MWindow;
|
||||
import org.compiere.model.PO;
|
||||
import org.compiere.model.StateChangeEvent;
|
||||
import org.compiere.model.SystemProperties;
|
||||
import org.compiere.model.X_AD_CtxHelp;
|
||||
import org.compiere.process.DocAction;
|
||||
import org.compiere.process.ProcessInfo;
|
||||
|
@ -3699,6 +3700,7 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
|
|||
if(cf.isInitOK())
|
||||
{
|
||||
final WCreateFromWindow window = (WCreateFromWindow) cf.getWindow();
|
||||
if (SystemProperties.isZkUnitTest())
|
||||
window.setWidgetAttribute(AdempiereWebUI.WIDGET_INSTANCE_NAME, AdempiereIdGenerator.escapeId(window.getTitle()));
|
||||
window.addEventListener(DialogEvents.ON_WINDOW_CLOSE, new EventListener<Event>() {
|
||||
@Override
|
||||
|
@ -4133,6 +4135,7 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
|
|||
}
|
||||
infoWindow.setContentStyle("overflow: auto");
|
||||
|
||||
if (SystemProperties.isZkUnitTest())
|
||||
infoWindow.setWidgetAttribute(AdempiereWebUI.WIDGET_INSTANCE_NAME, AdempiereIdGenerator.escapeId(infoWindow.getTitle()));
|
||||
infoWindow.addEventListener(DialogEvents.ON_WINDOW_CLOSE, new EventListener<Event>() {
|
||||
@Override
|
||||
|
|
|
@ -21,6 +21,7 @@ import java.util.List;
|
|||
|
||||
import org.adempiere.webui.AdempiereIdGenerator;
|
||||
import org.adempiere.webui.LayoutUtils;
|
||||
import org.compiere.model.SystemProperties;
|
||||
import org.zkoss.zk.au.out.AuScript;
|
||||
import org.zkoss.zk.ui.IdSpace;
|
||||
import org.zkoss.zk.ui.Page;
|
||||
|
@ -112,9 +113,11 @@ public class Combobox extends org.zkoss.zul.Combobox implements IdSpace
|
|||
public Comboitem appendItem(String label)
|
||||
{
|
||||
ComboItem item = new ComboItem(label);
|
||||
if (SystemProperties.isZkUnitTest()) {
|
||||
String id = AdempiereIdGenerator.escapeId(label);
|
||||
if (getFellowIfAny(id) == null )
|
||||
item.setId(id);
|
||||
}
|
||||
item.setParent(this);
|
||||
return item;
|
||||
}
|
||||
|
@ -143,9 +146,11 @@ public class Combobox extends org.zkoss.zul.Combobox implements IdSpace
|
|||
*/
|
||||
public void appendItem(String name, Object value) {
|
||||
ComboItem item = new ComboItem(name, value);
|
||||
if (SystemProperties.isZkUnitTest()) {
|
||||
String id = AdempiereIdGenerator.escapeId(name);
|
||||
if (getFellowIfAny(id) == null)
|
||||
item.setId(id);
|
||||
}
|
||||
this.appendChild(item);
|
||||
}
|
||||
|
||||
|
|
|
@ -33,6 +33,7 @@ import org.adempiere.webui.factory.ButtonFactory;
|
|||
import org.adempiere.webui.session.SessionManager;
|
||||
import org.adempiere.webui.theme.ThemeManager;
|
||||
import org.adempiere.webui.util.ZKUpdateUtil;
|
||||
import org.compiere.model.SystemProperties;
|
||||
import org.compiere.util.Env;
|
||||
import org.compiere.util.Msg;
|
||||
import org.compiere.util.Util;
|
||||
|
@ -376,6 +377,7 @@ public class Messagebox extends Window implements EventListener<Event>
|
|||
this.setSizable(true);
|
||||
|
||||
this.setVisible(true);
|
||||
if (SystemProperties.isZkUnitTest()) {
|
||||
String id = "MessageBox_"+AdempiereIdGenerator.escapeId(title);
|
||||
//make sure id is unique
|
||||
Page page = AEnv.getDesktop().getFirstPage();
|
||||
|
@ -390,6 +392,7 @@ public class Messagebox extends Window implements EventListener<Event>
|
|||
id = newId;
|
||||
}
|
||||
this.setId(id);
|
||||
}
|
||||
AEnv.showCenterScreen(this);
|
||||
|
||||
return returnValue;
|
||||
|
|
|
@ -37,6 +37,7 @@ import org.compiere.model.MForm;
|
|||
import org.compiere.model.MInfoWindow;
|
||||
import org.compiere.model.MQuery;
|
||||
import org.compiere.model.MTask;
|
||||
import org.compiere.model.SystemProperties;
|
||||
import org.compiere.util.Env;
|
||||
import org.compiere.wf.MWorkflow;
|
||||
import org.zkoss.util.media.AMedia;
|
||||
|
@ -156,9 +157,11 @@ public abstract class TabbedDesktop extends AbstractDesktop {
|
|||
final ADWindow adWindow = new ADWindow(Env.getCtx(), windowId, query);
|
||||
|
||||
final DesktopTabpanel tabPanel = new DesktopTabpanel();
|
||||
String id = AdempiereIdGenerator.escapeId(adWindow.getTitle());
|
||||
int windowNo = adWindow.getADWindowContent().getWindowNo();
|
||||
if (SystemProperties.isZkUnitTest()) {
|
||||
String id = AdempiereIdGenerator.escapeId(adWindow.getTitle());
|
||||
tabPanel.setId(id+"_"+windowNo);
|
||||
}
|
||||
final Tab tab = windowContainer.addWindow(tabPanel, adWindow.getTitle(), true, DecorateInfo.get(adWindow));
|
||||
|
||||
tab.setClosable(false);
|
||||
|
|
|
@ -46,6 +46,7 @@ import org.adempiere.webui.window.LoginWindow;
|
|||
import org.compiere.model.MRole;
|
||||
import org.compiere.model.MSysConfig;
|
||||
import org.compiere.model.MUser;
|
||||
import org.compiere.model.SystemProperties;
|
||||
import org.compiere.util.Env;
|
||||
import org.compiere.util.KeyNamePair;
|
||||
import org.compiere.util.Language;
|
||||
|
@ -368,9 +369,11 @@ public class RolePanel extends Window implements EventListener<Event>, Deferrabl
|
|||
for(int i = 0; i < m_clientKNPairs.length; i++)
|
||||
{
|
||||
ComboItem ci = new ComboItem(m_clientKNPairs[i].getName(), m_clientKNPairs[i].getID());
|
||||
if (SystemProperties.isZkUnitTest()) {
|
||||
String id = AdempiereIdGenerator.escapeId(ci.getLabel());
|
||||
if (lstClient.getFellowIfAny(id) == null)
|
||||
ci.setId(id);
|
||||
}
|
||||
lstClient.appendChild(ci);
|
||||
if (m_clientKNPairs[i].getID().equals(initDefault))
|
||||
lstClient.setSelectedItem(ci);
|
||||
|
@ -425,9 +428,11 @@ public class RolePanel extends Window implements EventListener<Event>, Deferrabl
|
|||
for (int i = 0; i < roleKNPairs.length; i++)
|
||||
{
|
||||
ComboItem ci = new ComboItem(roleKNPairs[i].getName(), roleKNPairs[i].getID());
|
||||
if (SystemProperties.isZkUnitTest()) {
|
||||
String id = AdempiereIdGenerator.escapeId(ci.getLabel());
|
||||
if (lstRole.getFellowIfAny(id) == null)
|
||||
ci.setId(id);
|
||||
}
|
||||
lstRole.appendChild(ci);
|
||||
if (roleKNPairs[i].getID().equals(initDefault))
|
||||
lstRole.setSelectedItem(ci);
|
||||
|
@ -473,9 +478,11 @@ public class RolePanel extends Window implements EventListener<Event>, Deferrabl
|
|||
for(int i = 0; i < orgKNPairs.length; i++)
|
||||
{
|
||||
ComboItem ci = new ComboItem(orgKNPairs[i].getName(), orgKNPairs[i].getID());
|
||||
if (SystemProperties.isZkUnitTest()) {
|
||||
String id = AdempiereIdGenerator.escapeId(ci.getLabel());
|
||||
if (lstOrganisation.getFellowIfAny(id) == null)
|
||||
ci.setId(id);
|
||||
}
|
||||
lstOrganisation.appendChild(ci);
|
||||
if(orgKNPairs[i].getID().equals(initDefault))
|
||||
lstOrganisation.setSelectedItem(ci);
|
||||
|
|
|
@ -55,6 +55,7 @@ import org.compiere.model.MMFARegistration;
|
|||
import org.compiere.model.MSysConfig;
|
||||
import org.compiere.model.MUser;
|
||||
import org.compiere.model.PO;
|
||||
import org.compiere.model.SystemProperties;
|
||||
import org.compiere.util.CLogger;
|
||||
import org.compiere.util.Env;
|
||||
import org.compiere.util.KeyNamePair;
|
||||
|
@ -267,9 +268,11 @@ public class ValidateMFAPanel extends Window implements EventListener<Event> {
|
|||
m_autoCall = true;
|
||||
}
|
||||
ComboItem ci = new ComboItem(reg.getName() + " - " + method.getMethod(), reg.getMFA_Registration_ID());
|
||||
if (SystemProperties.isZkUnitTest()) {
|
||||
String id = AdempiereIdGenerator.escapeId(ci.getLabel());
|
||||
if (lstMFAMechanism.getFellowIfAny(id) == null)
|
||||
ci.setId(id);
|
||||
}
|
||||
lstMFAMechanism.appendChild(ci);
|
||||
}
|
||||
lstMFAMechanism.setSelectedIndex(0);
|
||||
|
|
Loading…
Reference in New Issue