summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTapio Aali <tapio@vaadin.com>2014-10-07 10:22:24 +0300
committerSauli Tähkäpää <sauli@vaadin.com>2014-10-29 09:01:37 +0200
commit995fe9c6ab00d14d46e4ba76a7cc5c24bec63c32 (patch)
treee6da20223a97dd01995fe86e9fd2321b43a23eca
parentdc9838d1f7c8e50db40086b0d716de605783462c (diff)
downloadvaadin-framework-995fe9c6ab00d14d46e4ba76a7cc5c24bec63c32.tar.gz
vaadin-framework-995fe9c6ab00d14d46e4ba76a7cc5c24bec63c32.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 7223e4ac83..65e837bca7 100644
--- a/client/src/com/vaadin/client/ui/VWindow.java
+++ b/client/src/com/vaadin/client/ui/VWindow.java
@@ -73,7 +73,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() {
@@ -451,7 +451,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
@@ -466,7 +466,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
@@ -479,7 +479,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() {
@@ -490,7 +490,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() {
@@ -600,7 +600,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
*/
@@ -622,7 +622,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() {
@@ -654,7 +654,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.
@@ -862,13 +862,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
@@ -880,13 +875,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
*/
@@ -897,7 +897,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() {
@@ -907,7 +907,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
*/
@@ -918,7 +918,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() {
@@ -1070,14 +1070,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) {
@@ -1366,7 +1366,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
*/
@@ -1404,7 +1404,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() {
@@ -1413,14 +1413,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
*/
@@ -1439,7 +1439,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
@@ -1456,9 +1456,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");
+ }
+
+}