Seed for [2848787] Automated tests for zkwebui - component name fixed

Initial seed creating customized ID for fields in windows - needed to extend the work for toolbar buttons, tabs, etc
Link to SF Tracker: http://sourceforge.net/support/tracker.php?aid=2848787
This commit is contained in:
Carlos Ruiz 2010-04-28 09:41:59 +00:00
parent a07eec6d46
commit 1ef7773018
3 changed files with 57 additions and 0 deletions

View File

@ -0,0 +1,52 @@
/******************************************************************************
* Copyright (C) 2010 Carlos Ruiz *
* Copyright (C) 2009 Quality Systems & Solutions - globalqss *
* This program is free software; you can redistribute it and/or modify it *
* under the terms version 2 of the GNU General Public License as published *
* by the Free Software Foundation. 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., *
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
*****************************************************************************/
package org.adempiere.webui;
import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.Desktop;
import org.zkoss.zk.ui.Page;
import org.zkoss.zk.ui.sys.IdGenerator;
public class AdempiereIdGenerator implements IdGenerator {
@Override
public String nextComponentUuid(Desktop desktop, Component comp) {
String id = (String) comp.getAttribute("zk_component_ID");
if (id != null && id.length() > 0)
return id;
String prefix = (String) comp.getAttribute("zk_component_prefix");
if (prefix == null || prefix.length() == 0)
prefix = "zk_comp_";
int i = Integer.parseInt(desktop.getAttribute("Id_Num").toString());
i++;// Start from 1
desktop.setAttribute("Id_Num", String.valueOf(i));
return prefix + i;
}
@Override
public String nextDesktopId(Desktop desktop) {
if (desktop.getAttribute("Id_Num") == null) {
String number = "0";
desktop.setAttribute("Id_Num", number);
}
return null;
}
@Override
public String nextPageUuid(Page page) {
return null;
}
}

View File

@ -92,6 +92,7 @@ public abstract class WEditor implements EventListener, PropertyChangeListener
} }
this.setComponent(comp); this.setComponent(comp);
comp.setAttribute("zk_component_prefix", "Field_" + gridField.getColumnName() + "_" + gridField.getAD_Tab_ID() + "_" + gridField.getWindowNo() + "_");
this.gridField = gridField; this.gridField = gridField;
this.setMandatory(gridField.isMandatory(false)); this.setMandatory(gridField.isMandatory(false));
this.readOnly = gridField.isReadOnly(); this.readOnly = gridField.isReadOnly();

View File

@ -40,6 +40,10 @@
</system-config> </system-config>
--> -->
<system-config>
<id-generator-class>org.adempiere.webui.AdempiereIdGenerator</id-generator-class>
</system-config>
<!-- <!--
polling - org.zkoss.zkex.ui.impl.PollingServerPush polling - org.zkoss.zkex.ui.impl.PollingServerPush
comet - org.zkoss.zkmax.ui.comet.CometServerPush ( enterprise edition only ) comet - org.zkoss.zkmax.ui.comet.CometServerPush ( enterprise edition only )