summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--client/src/com/vaadin/client/ApplicationConnection.java3
-rw-r--r--client/src/com/vaadin/client/ui/ui/UIConnector.java53
-rw-r--r--uitest/src/com/vaadin/tests/themes/LegacyComponentThemeChange.java6
-rw-r--r--uitest/src/com/vaadin/tests/themes/LegacyComponentThemeChangeTest.java16
4 files changed, 26 insertions, 52 deletions
diff --git a/client/src/com/vaadin/client/ApplicationConnection.java b/client/src/com/vaadin/client/ApplicationConnection.java
index d9e705426b..cb780e7273 100644
--- a/client/src/com/vaadin/client/ApplicationConnection.java
+++ b/client/src/com/vaadin/client/ApplicationConnection.java
@@ -63,7 +63,6 @@ import com.google.gwt.user.client.Window.ClosingHandler;
import com.google.gwt.user.client.ui.HasWidgets;
import com.google.gwt.user.client.ui.Widget;
import com.vaadin.client.ApplicationConfiguration.ErrorMessage;
-import com.vaadin.client.ApplicationConnection.ApplicationStoppedEvent;
import com.vaadin.client.ResourceLoader.ResourceLoadEvent;
import com.vaadin.client.ResourceLoader.ResourceLoadListener;
import com.vaadin.client.communication.HasJavaScriptConnectorHelper;
@@ -804,7 +803,7 @@ public class ApplicationConnection implements HasHandlers {
return parameters;
}
- protected void repaintAll() {
+ public void repaintAll() {
makeUidlRequest(Json.createArray(), getRepaintAllParameters());
}
diff --git a/client/src/com/vaadin/client/ui/ui/UIConnector.java b/client/src/com/vaadin/client/ui/ui/UIConnector.java
index bcd90437a4..e0a4608505 100644
--- a/client/src/com/vaadin/client/ui/ui/UIConnector.java
+++ b/client/src/com/vaadin/client/ui/ui/UIConnector.java
@@ -1040,59 +1040,16 @@ public class UIConnector extends AbstractSingleComponentContainerConnector
}
- forceStateChangeRecursively(UIConnector.this);
- // UIDL has no stored URL which we can repaint so we do some find and
- // replace magic...
- String newThemeBase = getConnection().translateVaadinUri("theme://");
- replaceThemeAttribute(oldThemeBase, newThemeBase);
+ // Request a full resynchronization from the server to deal with legacy
+ // components
+ getConnection().repaintAll();
+ // Immediately update state and do layout while waiting for the resync
+ forceStateChangeRecursively(UIConnector.this);
getLayoutManager().forceLayout();
}
/**
- * Finds all attributes where theme:// urls have possibly been used and
- * replaces any old theme url with a new one
- *
- * @param oldPrefix
- * The start of the old theme URL
- * @param newPrefix
- * The start of the new theme URL
- */
- private void replaceThemeAttribute(String oldPrefix, String newPrefix) {
- // Images
- replaceThemeAttribute("src", oldPrefix, newPrefix);
- // Embedded flash
- replaceThemeAttribute("value", oldPrefix, newPrefix);
- replaceThemeAttribute("movie", oldPrefix, newPrefix);
- }
-
- /**
- * Finds any attribute of the given type where theme:// urls have possibly
- * been used and replaces any old theme url with a new one
- *
- * @param attributeName
- * The name of the attribute, e.g. "src"
- * @param oldPrefix
- * The start of the old theme URL
- * @param newPrefix
- * The start of the new theme URL
- */
- private void replaceThemeAttribute(String attributeName, String oldPrefix,
- String newPrefix) {
- // Find all "attributeName=" which start with "oldPrefix" using e.g.
- // [^src='http://oldpath']
- NodeList<Element> elements = querySelectorAll("[" + attributeName
- + "^='" + oldPrefix + "']");
- for (int i = 0; i < elements.getLength(); i++) {
- Element element = elements.getItem(i);
- element.setAttribute(
- attributeName,
- element.getAttribute(attributeName).replace(oldPrefix,
- newPrefix));
- }
- }
-
- /**
* Force a full recursive recheck of every connector's state variables.
*
* @see #forceStateChange()
diff --git a/uitest/src/com/vaadin/tests/themes/LegacyComponentThemeChange.java b/uitest/src/com/vaadin/tests/themes/LegacyComponentThemeChange.java
index 4582123f5f..0a57b77aa3 100644
--- a/uitest/src/com/vaadin/tests/themes/LegacyComponentThemeChange.java
+++ b/uitest/src/com/vaadin/tests/themes/LegacyComponentThemeChange.java
@@ -29,6 +29,7 @@ import com.vaadin.ui.ComboBox;
import com.vaadin.ui.Embedded;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.MenuBar;
+import com.vaadin.ui.MenuBar.MenuItem;
import com.vaadin.ui.Table;
import com.vaadin.ui.VerticalLayout;
@@ -60,7 +61,10 @@ public class LegacyComponentThemeChange extends AbstractTestUIWithLog {
ThemeResource varyingIcon = new ThemeResource("menubar-theme-icon.png");
MenuBar bar = new MenuBar();
bar.addItem("runo", alwaysTheSameIconImage, null);
- bar.addItem("seletedtheme", varyingIcon, null);
+ bar.addItem("selectedtheme", varyingIcon, null);
+ MenuItem sub = bar.addItem("sub menu", null);
+ sub.addItem("runo", alwaysTheSameIconImage, null);
+ sub.addItem("selectedtheme", varyingIcon, null);
vl.addComponent(bar);
diff --git a/uitest/src/com/vaadin/tests/themes/LegacyComponentThemeChangeTest.java b/uitest/src/com/vaadin/tests/themes/LegacyComponentThemeChangeTest.java
index c6593104da..3c992f3af5 100644
--- a/uitest/src/com/vaadin/tests/themes/LegacyComponentThemeChangeTest.java
+++ b/uitest/src/com/vaadin/tests/themes/LegacyComponentThemeChangeTest.java
@@ -122,8 +122,22 @@ public class LegacyComponentThemeChangeTest extends MultiBrowserTest {
// The other image should change with the theme
WebElement themeImage = $(MenuBarElement.class).first().findElement(
- By.xpath(".//span[text()='seletedtheme']/img"));
+ By.xpath(".//span[text()='selectedtheme']/img"));
assertAttributePrefix(themeImage, "src", theme);
+
+ WebElement subMenuItem = $(MenuBarElement.class).first().findElement(
+ By.xpath(".//span[text()='sub menu']"));
+ subMenuItem.click();
+
+ WebElement subMenu = findElement(By.className("v-menubar-popup"));
+ WebElement subMenuRuno = subMenu.findElement(By
+ .xpath(".//span[text()='runo']/img"));
+ String subMenuRunoImageSrc = subMenuRuno.getAttribute("src");
+ Assert.assertEquals(getThemeURL("runo") + "icons/16/ok.png",
+ subMenuRunoImageSrc);
+ WebElement subMenuThemeImage = subMenu.findElement(By
+ .xpath(".//span[text()='selectedtheme']/img"));
+ assertAttributePrefix(subMenuThemeImage, "src", theme);
}
private void assertAttributePrefix(WebElement element, String attribute,