diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/AdempiereIdGenerator.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/AdempiereIdGenerator.java index eeb8112bbe..5b599cb1c5 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/AdempiereIdGenerator.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/AdempiereIdGenerator.java @@ -26,6 +26,10 @@ public class AdempiereIdGenerator implements IdGenerator { private static final String DEFAULT_ZK_COMP_PREFIX = "zk_comp_"; private static final String DESKTOP_ID_ATTRIBUTE = "org.adempiere.comp.id"; + + /* use this to add a component prefix to identify zk component + * if the prefix starts with unq then it will be used as is - if it doesn't then a sequence suffix will be added to guarantee uniqueness + */ public static final String ZK_COMPONENT_PREFIX_ATTRIBUTE = "zk_component_prefix"; @Override @@ -43,6 +47,15 @@ public class AdempiereIdGenerator implements IdGenerator { matcher.appendTail(sb); prefix = sb.toString(); } + if (prefix.startsWith("unq")) { // prefix already guaranteed unique + if (desktop.getComponentByUuidIfAny(prefix) == null) { // but don't trust and look to avoid dups + return prefix; + } else { + prefix = "not" + prefix; // set notunq as the prefix to let dev know something is wrong + } + } + + /* add sequence suffix to guarantee uniqueness */ int i = 0; try { String number = null; diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/component/ADButtonTabList.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/component/ADButtonTabList.java index d894023ee6..286ad3bc5c 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/component/ADButtonTabList.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/component/ADButtonTabList.java @@ -74,7 +74,7 @@ public class ADButtonTabList extends Panel implements IADTabList, EventListener ADTabLabel tabLabel = (ADTabLabel) items[i]; Button button = new Button(); button.setDynamicProperty("Title", tabLabel.description); - button.setAttribute(AdempiereIdGenerator.ZK_COMPONENT_PREFIX_ATTRIBUTE, "ADButtonTab" + i); + button.setAttribute(AdempiereIdGenerator.ZK_COMPONENT_PREFIX_ATTRIBUTE, "unqADButtonTab_" + tabLabel.windowNo + "_" + i); Text text = new Text(tabLabel.label); text.setAttribute("ad_tab_id", tabLabel.AD_Tab_ID); button.appendChild(text); diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/component/CWindowToolbar.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/component/CWindowToolbar.java index c837d373a7..d8c3fc280f 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/component/CWindowToolbar.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/component/CWindowToolbar.java @@ -51,10 +51,10 @@ import org.zkoss.zul.Space; */ public class CWindowToolbar extends FToolbar implements EventListener { - /** - * + /** + * */ - private static final long serialVersionUID = -8259762910508209764L; + private static final long serialVersionUID = -762537218475834634L; private static final String TOOLBAR_BUTTON_STYLE = "background-color: transparent; display:inline-block; margin-left: 1px; margin-right: 1px; width: 26px; height: 24px;"; @@ -124,7 +124,13 @@ public class CWindowToolbar extends FToolbar implements EventListener init(); } - private void init() + public CWindowToolbar(boolean embedded, int windowNo) { + this.embedded = embedded; + setWindowNo(windowNo); + init(); + } + + private void init() { LayoutUtils.addSclass("adwindow-toolbar", this); @@ -203,8 +209,11 @@ public class CWindowToolbar extends FToolbar implements EventListener private ToolBarButton createButton(String name, String image, String tooltip) { ToolBarButton btn = new ToolBarButton(""); - btn.setName("btn"+name); - btn.setAttribute(AdempiereIdGenerator.ZK_COMPONENT_PREFIX_ATTRIBUTE, btn.getName()); + btn.setName("Btn"+name); + if (windowNo > 0) + btn.setAttribute(AdempiereIdGenerator.ZK_COMPONENT_PREFIX_ATTRIBUTE, "unq" + btn.getName() + "_" + windowNo + (embedded ? "E" : "")); + else + btn.setAttribute(AdempiereIdGenerator.ZK_COMPONENT_PREFIX_ATTRIBUTE, btn.getName()); btn.setImage("/images/"+image + (embedded ? "16.png" : "24.png")); btn.setTooltiptext(Msg.getMsg(Env.getCtx(),tooltip)); if (embedded) diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/component/GridTabRowRenderer.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/component/GridTabRowRenderer.java index ca71d7402b..e78db77337 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/component/GridTabRowRenderer.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/component/GridTabRowRenderer.java @@ -225,7 +225,7 @@ public class GridTabRowRenderer implements RowRenderer, RowRendererExt, Renderer component = createReadonlyCheckbox(value); } else if (gridField.getDisplayType() == DisplayType.Button) { GridRowCtx gridRowCtx = new GridRowCtx(Env.getCtx(), gridTab, rowIndex); - WButtonEditor editor = new WButtonEditor(gridField); + WButtonEditor editor = new WButtonEditor(gridField, rowIndex); editor.setValue(gridTab.getValue(rowIndex, gridField.getColumnName())); editor.setReadWrite(gridField.isEditable(gridRowCtx, true)); editor.getComponent().setAttribute("grid.row.index", rowIndex); diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WButtonEditor.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WButtonEditor.java index 4578c32979..0ca3e7ea3f 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WButtonEditor.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WButtonEditor.java @@ -74,14 +74,18 @@ public class WButtonEditor extends WEditor public WButtonEditor(GridField gridField) { - super(new Button(), gridField); + this(gridField, -1); + } + + public WButtonEditor(GridField gridField, int rowIndex) { + super(new Button(), gridField, rowIndex); m_text = gridField.getHeader(); AD_Process_ID = gridField.getAD_Process_ID(); gridfield = gridField; init(); - } + } - /** + /** * Get AD_Process_ID * @return AD_Process_ID or 0 */ diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WEditor.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WEditor.java index bf45cdf401..c2cebab599 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WEditor.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WEditor.java @@ -82,12 +82,16 @@ public abstract class WEditor implements EventListener, PropertyChangeListener protected WEditorPopupMenu popupMenu; + public WEditor(Component comp, GridField gridField) { + this(comp, gridField, -1); + } + /** * * @param comp * @param gridField */ - public WEditor(Component comp, GridField gridField) + public WEditor(Component comp, GridField gridField, int rowIndex) { if (comp == null) { @@ -100,12 +104,13 @@ public abstract class WEditor implements EventListener, PropertyChangeListener } this.setComponent(comp); - String gridTabName = gridField.getGridTab() != null - ? "_" + gridField.getGridTab().getName() : ""; - if (gridField.getGridTab() != null) - { - comp.setAttribute(AdempiereIdGenerator.ZK_COMPONENT_PREFIX_ATTRIBUTE, "Field_" + gridField.getColumnName() + gridTabName); - } + String gridTabName = gridField.getGridTab() != null ? gridField.getGridTab().getTabNo() + "_" + gridField.getGridTab().getTableName() : ""; + comp.setAttribute(AdempiereIdGenerator.ZK_COMPONENT_PREFIX_ATTRIBUTE, + "unqField_" + + gridField.getWindowNo() + + "_" + gridTabName + + "_" + gridField.getColumnName() + + (rowIndex >= 0 ? "_" + rowIndex : "")); this.gridField = gridField; this.setMandatory(gridField.isMandatory(false)); this.readOnly = gridField.isReadOnly(); diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/AbstractADWindowPanel.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/AbstractADWindowPanel.java index a04397d9d3..74936e613e 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/AbstractADWindowPanel.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/AbstractADWindowPanel.java @@ -237,7 +237,7 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To private void initComponents() { /** Initalise toolbar */ - toolbar = new CWindowToolbar(isEmbedded()); + toolbar = new CWindowToolbar(isEmbedded(), getWindowNo()); toolbar.addListener(this); statusBar = new StatusBarPanel(isEmbedded()); diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/LoginPanel.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/LoginPanel.java index 6e64a84ffe..c588439082 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/LoginPanel.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/LoginPanel.java @@ -263,7 +263,7 @@ public class LoginPanel extends Window implements EventListener txtUserId = new Textbox(); txtUserId.setId("txtUserId"); - txtUserId.setAttribute(AdempiereIdGenerator.ZK_COMPONENT_PREFIX_ATTRIBUTE, txtUserId.getId()); + txtUserId.setAttribute(AdempiereIdGenerator.ZK_COMPONENT_PREFIX_ATTRIBUTE, "unq" + txtUserId.getId()); txtUserId.setCols(25); txtUserId.setMaxlength(40); txtUserId.setWidth("220px"); @@ -272,7 +272,7 @@ public class LoginPanel extends Window implements EventListener txtPassword = new Textbox(); txtPassword.setId("txtPassword"); txtPassword.setType("password"); - txtPassword.setAttribute(AdempiereIdGenerator.ZK_COMPONENT_PREFIX_ATTRIBUTE, txtPassword.getId()); + txtPassword.setAttribute(AdempiereIdGenerator.ZK_COMPONENT_PREFIX_ATTRIBUTE, "unq" + txtPassword.getId()); txtPassword.setCols(25); // txtPassword.setMaxlength(40); @@ -282,7 +282,7 @@ public class LoginPanel extends Window implements EventListener lstLanguage.setAutocomplete(true); lstLanguage.setAutodrop(true); lstLanguage.setId("lstLanguage"); - lstLanguage.setAttribute(AdempiereIdGenerator.ZK_COMPONENT_PREFIX_ATTRIBUTE, lstLanguage.getId()); + lstLanguage.setAttribute(AdempiereIdGenerator.ZK_COMPONENT_PREFIX_ATTRIBUTE, "unq" + lstLanguage.getId()); lstLanguage.addEventListener(Events.ON_SELECT, this); lstLanguage.setWidth("220px"); diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/RolePanel.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/RolePanel.java index bcac74123b..a49aac9ea2 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/RolePanel.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/RolePanel.java @@ -243,7 +243,7 @@ public class RolePanel extends Window implements EventListener, Deferrable lstRole.setAutocomplete(true); lstRole.setAutodrop(true); lstRole.setId("lstRole"); - lstRole.setAttribute(AdempiereIdGenerator.ZK_COMPONENT_PREFIX_ATTRIBUTE, lstRole.getId()); + lstRole.setAttribute(AdempiereIdGenerator.ZK_COMPONENT_PREFIX_ATTRIBUTE, "unq" + lstRole.getId()); lstRole.addEventListener(Events.ON_SELECT, this); lstRole.setWidth("220px"); @@ -252,7 +252,7 @@ public class RolePanel extends Window implements EventListener, Deferrable lstClient.setAutocomplete(true); lstClient.setAutodrop(true); lstClient.setId("lstClient"); - lstClient.setAttribute(AdempiereIdGenerator.ZK_COMPONENT_PREFIX_ATTRIBUTE, lstClient.getId()); + lstClient.setAttribute(AdempiereIdGenerator.ZK_COMPONENT_PREFIX_ATTRIBUTE, "unq" + lstClient.getId()); lstClient.addEventListener(Events.ON_SELECT, this); lstClient.setWidth("220px"); @@ -261,7 +261,7 @@ public class RolePanel extends Window implements EventListener, Deferrable lstOrganisation.setAutocomplete(true); lstOrganisation.setAutodrop(true); lstOrganisation.setId("lstOrganisation"); - lstOrganisation.setAttribute(AdempiereIdGenerator.ZK_COMPONENT_PREFIX_ATTRIBUTE, lstOrganisation.getId()); + lstOrganisation.setAttribute(AdempiereIdGenerator.ZK_COMPONENT_PREFIX_ATTRIBUTE, "unq" + lstOrganisation.getId()); lstOrganisation.addEventListener(Events.ON_SELECT, this); lstOrganisation.setWidth("220px"); @@ -270,7 +270,7 @@ public class RolePanel extends Window implements EventListener, Deferrable lstWarehouse.setAutocomplete(true); lstWarehouse.setAutodrop(true); lstWarehouse.setId("lstWarehouse"); - lstWarehouse.setAttribute(AdempiereIdGenerator.ZK_COMPONENT_PREFIX_ATTRIBUTE, lstWarehouse.getId()); + lstWarehouse.setAttribute(AdempiereIdGenerator.ZK_COMPONENT_PREFIX_ATTRIBUTE, "unq" + lstWarehouse.getId()); lstWarehouse.addEventListener(Events.ON_SELECT, this); lstWarehouse.setWidth("220px");