summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTapio Aali <tapio@vaadin.com>2014-10-07 10:22:24 +0300
committerVaadin Code Review <review@vaadin.com>2014-10-15 09:06:07 +0000
commita4a992efcf95b3615402047456fcb2995a1736f4 (patch)
tree58f1d41c2f9154dd4df18a5f0f51c22babcb4271
parentad742c4ed476615d612cc95509351039da7d3707 (diff)
downloadvaadin-framework-a4a992efcf95b3615402047456fcb2995a1736f4.tar.gz
vaadin-framework-a4a992efcf95b3615402047456fcb2995a1736f4.zip
Fixed FontIcons on VWindow (#14481).
Change-Id: I1b7cb280088379a6512e23a663dbf2a31f8123cd
-rw-r--r--client/src/com/vaadin/client/ui/VWindow.java66
-rw-r--r--uitest/src/com/vaadin/tests/components/window/WindowWithIcon.java27
-rw-r--r--uitest/src/com/vaadin/tests/components/window/WindowWithIconTest.java16
3 files changed, 76 insertions, 33 deletions
diff --git a/client/src/com/vaadin/client/ui/VWindow.java b/client/src/com/vaadin/client/ui/VWindow.java
index 58e7a83012..5c9a2ab47d 100644
--- a/client/src/com/vaadin/client/ui/VWindow.java
+++ b/client/src/com/vaadin/client/ui/VWindow.java
@@ -75,7 +75,7 @@ import com.vaadin.shared.ui.window.WindowRole;
/**
* "Sub window" component.
- *
+ *
* @author Vaadin Ltd
*/
public class VWindow extends VOverlay implements ShortcutActionHandlerOwner,
@@ -233,7 +233,7 @@ public class VWindow extends VOverlay implements ShortcutActionHandlerOwner,
/*
* Stores the element that has focus in the application UI when the
* window is opened, so it can be restored when the window closes.
- *
+ *
* This is currently implemented for the case when one non-modal window
* can be open at the same time, and the focus is not changed while the
* window is open.
@@ -267,7 +267,7 @@ public class VWindow extends VOverlay implements ShortcutActionHandlerOwner,
/*
* Restores the previously stored focused element.
- *
+ *
* When the focus was changed outside the window while the window was
* open, the originally stored element is restored.
*/
@@ -309,7 +309,7 @@ public class VWindow extends VOverlay implements ShortcutActionHandlerOwner,
/**
* Returns true if this window is the topmost VWindow
- *
+ *
* @return
*/
private boolean isActive() {
@@ -460,7 +460,7 @@ public class VWindow extends VOverlay implements ShortcutActionHandlerOwner,
* is prevented.
* <p>
* This message is not visible on the screen.
- *
+ *
* @param topMessage
* String provided when the user navigates with Shift-Tab keys to
* the top of the window
@@ -475,7 +475,7 @@ public class VWindow extends VOverlay implements ShortcutActionHandlerOwner,
* key is prevented.
* <p>
* This message is not visible on the screen.
- *
+ *
* @param bottomMessage
* String provided when the user navigates with the Tab key to
* the bottom of the window
@@ -488,7 +488,7 @@ public class VWindow extends VOverlay implements ShortcutActionHandlerOwner,
* Gets the message that is provided to users of assistive devices when the
* user reaches the top of the window when leaving a window with the tab key
* is prevented.
- *
+ *
* @return the top message
*/
public String getTabStopTopAssistiveText() {
@@ -499,7 +499,7 @@ public class VWindow extends VOverlay implements ShortcutActionHandlerOwner,
* Gets the message that is provided to users of assistive devices when the
* user reaches the bottom of the window when leaving a window with the tab
* key is prevented.
- *
+ *
* @return the bottom message
*/
public String getTabStopBottomAssistiveText() {
@@ -609,7 +609,7 @@ public class VWindow extends VOverlay implements ShortcutActionHandlerOwner,
/**
* Sets the closable state of the window. Additionally hides/shows the close
* button according to the new state.
- *
+ *
* @param closable
* true if the window can be closed by the user
*/
@@ -631,7 +631,7 @@ public class VWindow extends VOverlay implements ShortcutActionHandlerOwner,
* Returns the closable state of the sub window. If the sub window is
* closable a decoration (typically an X) is shown to the user. By clicking
* on the X the user can close the window.
- *
+ *
* @return true if the sub window is closable
*/
protected boolean isClosable() {
@@ -663,7 +663,7 @@ public class VWindow extends VOverlay implements ShortcutActionHandlerOwner,
* correctly if clicking on the "close" button in the window header but
* closing the window from a button for example in the window will fail.
* Symptom described in #10776
- *
+ *
* The problematic part is that for the focus to be returned correctly
* an input element needs to be focused in the root panel. Focusing some
* other element apparently won't work.
@@ -871,13 +871,8 @@ public class VWindow extends VOverlay implements ShortcutActionHandlerOwner,
setCaption(c, null);
}
- public void setCaption(String c, String icon) {
+ public void setCaption(String c, String iconURL) {
String html = Util.escapeHTML(c);
- if (icon != null) {
- icon = client.translateVaadinUri(icon);
- html = "<img src=\"" + Util.escapeAttribute(icon)
- + "\" class=\"v-icon\" alt=\"\" />" + html;
- }
// Provide information to assistive device users that a sub window was
// opened
@@ -889,13 +884,18 @@ public class VWindow extends VOverlay implements ShortcutActionHandlerOwner,
+ assistivePostfix + "</span>";
html = prefix + html + postfix;
- DOM.setInnerHTML(headerText, html);
+ headerText.setInnerHTML(html);
+
+ if (iconURL != null) {
+ Icon icon = client.getIcon(iconURL);
+ DOM.insertChild(headerText, icon.getElement(), 0);
+ }
}
/**
* Setter for the text for assistive devices the window caption is prefixed
* with.
- *
+ *
* @param assistivePrefix
* the assistivePrefix to set
*/
@@ -906,7 +906,7 @@ public class VWindow extends VOverlay implements ShortcutActionHandlerOwner,
/**
* Getter for the text for assistive devices the window caption is prefixed
* with.
- *
+ *
* @return the assistivePrefix
*/
public String getAssistivePrefix() {
@@ -916,7 +916,7 @@ public class VWindow extends VOverlay implements ShortcutActionHandlerOwner,
/**
* Setter for the text for assistive devices the window caption is postfixed
* with.
- *
+ *
* @param assistivePostfix
* the assistivePostfix to set
*/
@@ -927,7 +927,7 @@ public class VWindow extends VOverlay implements ShortcutActionHandlerOwner,
/**
* Getter for the text for assistive devices the window caption is postfixed
* with.
- *
+ *
* @return the assistivePostfix
*/
public String getAssistivePostfix() {
@@ -1079,14 +1079,14 @@ public class VWindow extends VOverlay implements ShortcutActionHandlerOwner,
/**
* TODO check if we need to support this with touch based devices.
- *
+ *
* Checks if the cursor was inside the browser content area when the event
* happened.
- *
+ *
* @param event
* The event to be checked
* @return true, if the cursor is inside the browser content area
- *
+ *
* false, otherwise
*/
private boolean cursorInsideBrowserContentArea(Event event) {
@@ -1372,7 +1372,7 @@ public class VWindow extends VOverlay implements ShortcutActionHandlerOwner,
* assistive devices when it is opened.
* <p>
* When the provided array is empty, an existing description is removed.
- *
+ *
* @param connectors
* with the connectors of the widgets to use as description
*/
@@ -1410,7 +1410,7 @@ public class VWindow extends VOverlay implements ShortcutActionHandlerOwner,
* Gets the connectors that are used as assistive description. Text
* contained in these connectors will be read by assistive devices when the
* window is opened.
- *
+ *
* @return list of previously set connectors
*/
public List<Connector> getAssistiveDescription() {
@@ -1419,14 +1419,14 @@ public class VWindow extends VOverlay implements ShortcutActionHandlerOwner,
/**
* Sets the WAI-ARIA role the window.
- *
+ *
* This role defines how an assistive device handles a window. Available
* roles are alertdialog and dialog (@see <a
* href="http://www.w3.org/TR/2011/CR-wai-aria-20110118/roles">Roles
* Model</a>).
- *
+ *
* The default role is dialog.
- *
+ *
* @param role
* WAI-ARIA role to set for the window
*/
@@ -1445,7 +1445,7 @@ public class VWindow extends VOverlay implements ShortcutActionHandlerOwner,
* The value of the parameter doTabStop is stored and used for non-modal
* windows. For modal windows, the handlers are always registered, while
* preserving the stored value.
- *
+ *
* @param doTabStop
* true to prevent leaving the window, false to allow leaving the
* window for non modal windows
@@ -1462,9 +1462,9 @@ public class VWindow extends VOverlay implements ShortcutActionHandlerOwner,
/**
* Adds a Handler for when user moves the window.
- *
+ *
* @since 7.1.9
- *
+ *
* @return {@link HandlerRegistration} used to remove the handler
*/
public HandlerRegistration addMoveHandler(WindowMoveHandler handler) {
diff --git a/uitest/src/com/vaadin/tests/components/window/WindowWithIcon.java b/uitest/src/com/vaadin/tests/components/window/WindowWithIcon.java
new file mode 100644
index 0000000000..15ceb569b4
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/window/WindowWithIcon.java
@@ -0,0 +1,27 @@
+package com.vaadin.tests.components.window;
+
+import com.vaadin.server.FontAwesome;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.ui.Window;
+
+public class WindowWithIcon extends AbstractTestUI {
+
+ @Override
+ protected void setup(VaadinRequest request) {
+ Window window = new Window("Window Caption");
+ window.setIcon(FontAwesome.ROCKET);
+ addWindow(window);
+ }
+
+ @Override
+ protected String getTestDescription() {
+ return "Window should work properly with font icons.";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 14481;
+ }
+
+}
diff --git a/uitest/src/com/vaadin/tests/components/window/WindowWithIconTest.java b/uitest/src/com/vaadin/tests/components/window/WindowWithIconTest.java
new file mode 100644
index 0000000000..25c7f57238
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/window/WindowWithIconTest.java
@@ -0,0 +1,16 @@
+package com.vaadin.tests.components.window;
+
+import org.junit.Test;
+
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+public class WindowWithIconTest extends MultiBrowserTest {
+
+ @Test
+ public void testWindowWithIcon() throws Exception {
+ openTestURL();
+
+ compareScreen("icon-rendered-properly");
+ }
+
+}