diff --git a/build.gradle b/build.gradle index ee90ad2126..dfc9c20ffd 100644 --- a/build.gradle +++ b/build.gradle @@ -60,7 +60,7 @@ def webToolkitLegacyModule = project(':cuba-web6-toolkit') def webModuleThemes = project(':cuba-web-themes') def webLegacyModuleThemes = project(':cuba-web6-themes') -def vaadinVersion = '7.1.9.cuba.4' +def vaadinVersion = '7.1.9.cuba.5' def vaadinLegacyVersion = '6.6.1.144' def springVersion = '3.1.3.RELEASE' diff --git a/modules/web-toolkit/src/com/haulmont/cuba/web/toolkit/ui/client/menubar/CubaMenuBarConnector.java b/modules/web-toolkit/src/com/haulmont/cuba/web/toolkit/ui/client/menubar/CubaMenuBarConnector.java index a2f961070d..0971bd95bf 100644 --- a/modules/web-toolkit/src/com/haulmont/cuba/web/toolkit/ui/client/menubar/CubaMenuBarConnector.java +++ b/modules/web-toolkit/src/com/haulmont/cuba/web/toolkit/ui/client/menubar/CubaMenuBarConnector.java @@ -10,6 +10,7 @@ import com.google.gwt.user.client.ui.Widget; import com.haulmont.cuba.web.toolkit.ui.CubaMenuBar; import com.vaadin.client.ApplicationConnection; import com.vaadin.client.UIDL; +import com.vaadin.client.ui.VMenuBar; import com.vaadin.client.ui.menubar.MenuBarConnector; import com.vaadin.shared.ui.Connect; @@ -58,10 +59,17 @@ public class CubaMenuBarConnector extends MenuBarConnector { @Override protected String getItemId(UIDL uidl) { - if (uidl.hasAttribute("testId")) { - return uidl.getStringAttribute("testId"); + if (uidl.hasAttribute("tid")) { + return uidl.getStringAttribute("tid"); } return null; } + + @Override + protected void assignAdditionalAttributes(VMenuBar.CustomMenuItem currentItem, UIDL item) { + if (item.hasAttribute("cid")) { + currentItem.getElement().setAttribute("cuba-id", item.getStringAttribute("cid")); + } + } } \ No newline at end of file diff --git a/modules/web/src/com/haulmont/cuba/web/sys/MenuBuilder.java b/modules/web/src/com/haulmont/cuba/web/sys/MenuBuilder.java index ddc478b829..03f2e50f72 100644 --- a/modules/web/src/com/haulmont/cuba/web/sys/MenuBuilder.java +++ b/modules/web/src/com/haulmont/cuba/web/sys/MenuBuilder.java @@ -173,9 +173,11 @@ public class MenuBuilder { TestIdManager testIdManager = appWindow.getAppUI().getTestIdManager(); String id = testIdManager.normalize(conf.getId()); - testIdManager.reserveId(id); + String testId = menuBar.getId() + "_" + id; + testIdManager.reserveId(testId); - menuBar.setTestId(menuItem, menuBar.getId() + "_" + id); + menuBar.setTestId(menuItem, testId); + menuBar.setCubaId(menuItem, id); } } } \ No newline at end of file diff --git a/modules/web/src/com/haulmont/cuba/web/toolkit/ui/CubaMenuBar.java b/modules/web/src/com/haulmont/cuba/web/toolkit/ui/CubaMenuBar.java index 7955f88b78..a88604017d 100644 --- a/modules/web/src/com/haulmont/cuba/web/toolkit/ui/CubaMenuBar.java +++ b/modules/web/src/com/haulmont/cuba/web/toolkit/ui/CubaMenuBar.java @@ -19,8 +19,9 @@ import java.util.Map; */ public class CubaMenuBar extends com.vaadin.ui.MenuBar { - protected final Map shortcuts = new HashMap<>(); - protected final Map testIds = new HashMap<>(); + protected Map shortcuts = null; + protected Map testIds = null; + protected Map cubaIds = null; @Override protected CubaMenuBarState getState() { @@ -47,6 +48,10 @@ public class CubaMenuBar extends com.vaadin.ui.MenuBar { } public void setShortcut(MenuItem item, String str) { + if (shortcuts == null) { + shortcuts = new HashMap<>(); + } + if (shortcuts.containsKey(item)) { shortcuts.remove(item); } @@ -54,23 +59,38 @@ public class CubaMenuBar extends com.vaadin.ui.MenuBar { } public void clearShortcut(MenuItem item) { - shortcuts.remove(item); + if (shortcuts != null) { + shortcuts.remove(item); + } } public void setTestId(MenuItem item, String id) { + if (testIds == null) { + testIds = new HashMap<>(); + } testIds.put(item, id); } + public void setCubaId(MenuItem item, String id) { + if (cubaIds == null) { + cubaIds = new HashMap<>(); + } + cubaIds.put(item, id); + } + @Override protected void paintAdditionalItemParams(PaintTarget target, MenuItem item) throws PaintException { - if (shortcuts.containsKey(item)) { + if (shortcuts != null && shortcuts.containsKey(item)) { String shortcut = shortcuts.get(item); if (shortcut != null) { target.addAttribute("shortcut", shortcut); } } - if (testIds.containsKey(item)) { - target.addAttribute("testId", testIds.get(item)); + if (testIds != null && testIds.containsKey(item)) { + target.addAttribute("tid", testIds.get(item)); + } + if (cubaIds != null && cubaIds.containsKey(item)) { + target.addAttribute("cid", cubaIds.get(item)); } } } \ No newline at end of file diff --git a/modules/web6-toolkit/src/com/vaadin/terminal/gwt/client/ui/VMenuBar.java b/modules/web6-toolkit/src/com/vaadin/terminal/gwt/client/ui/VMenuBar.java index 34907dd9e8..9324d84ad6 100644 --- a/modules/web6-toolkit/src/com/vaadin/terminal/gwt/client/ui/VMenuBar.java +++ b/modules/web6-toolkit/src/com/vaadin/terminal/gwt/client/ui/VMenuBar.java @@ -249,7 +249,7 @@ public class VMenuBar extends SimpleFocusablePanel implements Paintable, while (itr.hasNext()) { UIDL item = (UIDL) itr.next(); - CustomMenuItem currentItem = null; + CustomMenuItem currentItem; String itemText = item.getStringAttribute("text"); final int itemId = item.getIntAttribute("id"); @@ -1109,6 +1109,13 @@ public class VMenuBar extends SimpleFocusablePanel implements Paintable, VMenuBar root = findRootMenu(); client.registerTooltip(root, this, info); } + + if (uidl.hasAttribute("debugId")) { + getElement().setId(uidl.getStringAttribute("debugId")); + } + if (uidl.hasAttribute("cid")) { + getElement().setAttribute("cuba-id", uidl.getStringAttribute("cid")); + } } @Override diff --git a/modules/web6/src/com/haulmont/cuba/web/sys/MenuBuilder.java b/modules/web6/src/com/haulmont/cuba/web/sys/MenuBuilder.java index 0264e2db55..31b77e285c 100644 --- a/modules/web6/src/com/haulmont/cuba/web/sys/MenuBuilder.java +++ b/modules/web6/src/com/haulmont/cuba/web/sys/MenuBuilder.java @@ -11,6 +11,7 @@ import com.haulmont.cuba.gui.NoSuchScreenException; import com.haulmont.cuba.gui.TestIdManager; import com.haulmont.cuba.gui.config.*; import com.haulmont.cuba.security.global.UserSession; +import com.haulmont.cuba.web.App; import com.haulmont.cuba.web.AppWindow; import com.haulmont.cuba.web.toolkit.MenuShortcutAction; import com.vaadin.ui.MenuBar; @@ -169,5 +170,8 @@ public class MenuBuilder { if (menuBar.getDebugId() != null && !conf.isSeparator()) { menuBar.setDebugId(menuItem, testIdManager.normalize(menuBar.getDebugId() + "_" + conf.getId())); } + if (App.getInstance().isTestMode() && !conf.isSeparator()) { + menuBar.setCubaId(menuItem, conf.getId()); + } } } \ No newline at end of file diff --git a/modules/web6/src/com/haulmont/cuba/web/toolkit/ui/MenuBar.java b/modules/web6/src/com/haulmont/cuba/web/toolkit/ui/MenuBar.java index 1bd5cc7348..9694c06707 100644 --- a/modules/web6/src/com/haulmont/cuba/web/toolkit/ui/MenuBar.java +++ b/modules/web6/src/com/haulmont/cuba/web/toolkit/ui/MenuBar.java @@ -20,13 +20,13 @@ import java.util.Map; */ public class MenuBar extends com.vaadin.ui.MenuBar { - protected Map shortcuts; protected boolean vertical; + protected Map shortcuts; protected BiMap debugIds; + protected Map cubaIds; public MenuBar() { - shortcuts = new HashMap<>(); } public void setShortcut(MenuItem item, KeyCombination shortcut) { @@ -34,6 +34,10 @@ public class MenuBar extends com.vaadin.ui.MenuBar { } public void setShortcut(MenuItem item, String str) { + if (shortcuts == null) { + shortcuts = new HashMap<>(); + } + if (shortcuts.containsKey(item)) { shortcuts.remove(item); } @@ -41,7 +45,9 @@ public class MenuBar extends com.vaadin.ui.MenuBar { } public void clearShortcut(MenuItem item) { - shortcuts.remove(item); + if (shortcuts != null) { + shortcuts.remove(item); + } } public void setDebugId(MenuItem item, String id) { @@ -51,6 +57,13 @@ public class MenuBar extends com.vaadin.ui.MenuBar { debugIds.put(item, id); } + public void setCubaId(MenuItem item, String id) { + if (cubaIds == null) { + cubaIds = new HashMap<>(); + } + cubaIds.put(item, id); + } + public String getDebugId(MenuItem item) { if (debugIds != null) { return debugIds.get(item); @@ -60,7 +73,6 @@ public class MenuBar extends com.vaadin.ui.MenuBar { @Override public void changeVariables(Object source, Map variables) { - if (variables.containsKey("clickedDebugId")) { MenuItem clickedItem = debugIds.inverse().get(variables.get("clickedDebugId")); if (clickedItem != null && clickedItem.isEnabled()) { @@ -140,7 +152,7 @@ public class MenuBar extends com.vaadin.ui.MenuBar { } //*************************** - if (shortcuts.containsKey(item)) { + if (shortcuts != null && shortcuts.containsKey(item)) { String shortcut = shortcuts.get(item); if (shortcut != null) { target.addAttribute("shortcut", shortcut); @@ -152,12 +164,15 @@ public class MenuBar extends com.vaadin.ui.MenuBar { target.addAttribute("debugId", debugIds.get(item)); } + if (cubaIds != null && cubaIds.containsKey(item)) { + target.addAttribute("cid", cubaIds.get(item)); + } + if (item.hasChildren()) { for (com.vaadin.ui.MenuBar.MenuItem child : item.getChildren()) { paintItem(target, child); } } - } target.endTag("item");