From cc995bbe0fd7d3f2c992ff20786f969f4505975b Mon Sep 17 00:00:00 2001
From: Leif Åstrand
Date: Tue, 7 May 2013 09:21:10 +0300
Subject: Update merge specification for the master branch.
Change-Id: Ia8ad2d2e44e2d29bfa9e2271e4e4cad0a672ec22
---
scripts/automerge7.sh | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/scripts/automerge7.sh b/scripts/automerge7.sh
index 524b0ff912..8d2cfb5cb8 100755
--- a/scripts/automerge7.sh
+++ b/scripts/automerge7.sh
@@ -1,7 +1,7 @@
#!/bin/bash
-FROM=7.0
-TO=7.1
+FROM=7.1
+TO=master
FROM_HEAD=origin/$FROM
PUSH="origin HEAD:refs/for/$TO"
--
cgit v1.2.3
From 3af82a92984805f4bef45f621e5f3654dcb7bcc9 Mon Sep 17 00:00:00 2001
From: Teemu Pöntelin
Date: Wed, 8 May 2013 16:29:17 +0300
Subject: Fixed a typo in UI class Javadoc. #11804
Change-Id: I609489bd9022285565e227e63b11a73e91831503
---
server/src/com/vaadin/ui/UI.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/server/src/com/vaadin/ui/UI.java b/server/src/com/vaadin/ui/UI.java
index 6433bebbe4..3574c5527d 100644
--- a/server/src/com/vaadin/ui/UI.java
+++ b/server/src/com/vaadin/ui/UI.java
@@ -63,7 +63,7 @@ import com.vaadin.util.CurrentInstance;
* When a new UI instance is needed, typically because the user opens a URL in a
* browser window which points to e.g. {@link VaadinServlet}, all
* {@link UIProvider}s registered to the current {@link VaadinSession} are
- * queried for the UI class that should be used. The selection is by defaylt
+ * queried for the UI class that should be used. The selection is by default
* based on the {@value VaadinSession#UI_PARAMETER} parameter from web.xml.
*
*
--
cgit v1.2.3
From b58e849e240b512067c05e75358fe3feb6fb321c Mon Sep 17 00:00:00 2001
From: Teemu Pöntelin
Date: Wed, 8 May 2013 16:35:18 +0300
Subject: Fixed a typo in @Widgetset annotation Javadoc. #11803
Change-Id: Iba58755f7a70d92d0a48395abc271f7bc5dcfd73
---
server/src/com/vaadin/annotations/Widgetset.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/server/src/com/vaadin/annotations/Widgetset.java b/server/src/com/vaadin/annotations/Widgetset.java
index 40276c18a2..006bf59acf 100644
--- a/server/src/com/vaadin/annotations/Widgetset.java
+++ b/server/src/com/vaadin/annotations/Widgetset.java
@@ -24,7 +24,7 @@ import java.lang.annotation.Target;
import com.vaadin.ui.UI;
/**
- * Defines a specific theme for a {@link UI}.
+ * Defines a specific widgetset for a {@link UI}.
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
--
cgit v1.2.3
From ab210b2a8d08c26ab449ce73dec9ae6e2cd3e2c2 Mon Sep 17 00:00:00 2001
From: Leif Åstrand
Date: Mon, 13 May 2013 13:07:20 +0000
Subject: Revert "Assert that connector needing layout is attached (#11698)"
This reverts commit cb7b02d4e50e91b9377410e79c3578587a900d94
The assert is not a good idea because it is triggered when a connector registers a dependency in its init method.
Change-Id: I3709c4749927e0333b7557cf553080b770639e50
---
client/src/com/vaadin/client/LayoutManager.java | 13 -------------
1 file changed, 13 deletions(-)
diff --git a/client/src/com/vaadin/client/LayoutManager.java b/client/src/com/vaadin/client/LayoutManager.java
index 381aff5afa..14b155c92f 100644
--- a/client/src/com/vaadin/client/LayoutManager.java
+++ b/client/src/com/vaadin/client/LayoutManager.java
@@ -827,7 +827,6 @@ public class LayoutManager {
* the managed layout that should be layouted
*/
public final void setNeedsHorizontalLayout(ManagedLayout layout) {
- assert isAttached(layout);
needsHorizontalLayout.add(layout.getConnectorId());
}
@@ -843,21 +842,9 @@ public class LayoutManager {
* the managed layout that should be layouted
*/
public final void setNeedsVerticalLayout(ManagedLayout layout) {
- assert isAttached(layout);
needsVerticalLayout.add(layout.getConnectorId());
}
- private boolean isAttached(ServerConnector connector) {
- while (connector != null) {
- connector = connector.getParent();
- if (connector == connection.getUIConnector()) {
- return true;
- }
- }
- // Reaching null parent before reaching UI connector -> not attached
- return false;
- }
-
/**
* Gets the outer height (including margins, paddings and borders) of the
* given element, provided that it has been measured. These elements are
--
cgit v1.2.3
From f7ee755e7dd94612c84e0b99735cc602fdbe7634 Mon Sep 17 00:00:00 2001
From: Artur Signell
Date: Wed, 15 May 2013 07:31:59 +0300
Subject: Show loading indicator immediately in init as before (#11850)
Change-Id: Ibe91db13b301aaf0a2b5e6e5fb08f566bf5cadab
---
client/src/com/vaadin/client/ApplicationConnection.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/client/src/com/vaadin/client/ApplicationConnection.java b/client/src/com/vaadin/client/ApplicationConnection.java
index d77a98a83b..1faf39394d 100644
--- a/client/src/com/vaadin/client/ApplicationConnection.java
+++ b/client/src/com/vaadin/client/ApplicationConnection.java
@@ -438,7 +438,7 @@ public class ApplicationConnection {
tooltip.setOwner(uIConnector.getWidget());
- getLoadingIndicator().trigger();
+ getLoadingIndicator().show();
scheduleHeartbeat();
--
cgit v1.2.3
From 8d1ccd76bef6ead837ddb93de307ceee97d6b97b Mon Sep 17 00:00:00 2001
From: Leif Åstrand
Date: Fri, 7 Jun 2013 12:13:43 +0300
Subject: Ignore changes merged from the previous maintenance branch
Change-Id: I16a203db76fd6dc7e091a2b2708f80b9d4cef079
---
scripts/automerge7.sh | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/scripts/automerge7.sh b/scripts/automerge7.sh
index 7b8c37a5aa..935604fb5d 100755
--- a/scripts/automerge7.sh
+++ b/scripts/automerge7.sh
@@ -1,8 +1,10 @@
#!/bin/bash
+IGNORE=7.0
FROM=7.1
TO=master
+IGNORE_HEAD=origin/$IGNORE
FROM_HEAD=origin/$FROM
PUSH="origin HEAD:refs/for/$TO"
@@ -86,7 +88,7 @@ fi
git checkout $TO
git fetch
-pending=`git log $TO..$FROM_HEAD --reverse|grep "^commit "|sed "s/commit //"`
+pending=`git log $TO..$FROM_HEAD ^$IGNORE_HEAD --reverse|grep "^commit "|sed "s/commit //"`
pendingCommit=
pendingCommitMessage=
--
cgit v1.2.3
From fe8d330c3c9f2ae2c0ace28fa5c34e5b2b131112 Mon Sep 17 00:00:00 2001
From: Leif Åstrand
Date: Fri, 7 Jun 2013 14:03:50 +0300
Subject: Escape \ in commit messages
Change-Id: I1c5773dd593d7877833a5b1798f3e812b53a1b1e
---
scripts/automerge7.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/scripts/automerge7.sh b/scripts/automerge7.sh
index 935604fb5d..2b98530902 100755
--- a/scripts/automerge7.sh
+++ b/scripts/automerge7.sh
@@ -96,7 +96,7 @@ for commit in $pending
do
echo "Checking $commit..."
mergeDirective=`git log -n 1 --format=%B $commit|grep "^Merge:"|sed "s/Merge: //"`
- commitMsg=`git log -n 1 --format=oneline --abbrev-commit $commit`
+ commitMsg=`git log -n 1 --format=oneline --abbrev-commit $commit | sed 's/\\\\/\\\\\\\\/g'` #Multiple levels of unescaping, sed just changes \ to \\
if [ "$mergeDirective" == "" ]
then
if can_merge $commit
--
cgit v1.2.3
From cdb8d682af602cc8731e7a63827b499c2da5144e Mon Sep 17 00:00:00 2001
From: tapio
Date: Mon, 17 Jun 2013 14:41:18 +0300
Subject: Add support for setId to TabSheet.Tab (#12064)
Change-Id: Ia88b9d03a26b9670ab4026f8083a0b932dafa1c0
---
client/src/com/vaadin/client/ui/VTabsheet.java | 15 ++++-
server/src/com/vaadin/ui/Component.java | 6 +-
server/src/com/vaadin/ui/TabSheet.java | 39 ++++++++++-
.../components/tabsheet/TabSheetWithTabIds.html | 76 +++++++++++++++++++++
.../components/tabsheet/TabSheetWithTabIds.java | 77 ++++++++++++++++++++++
5 files changed, 206 insertions(+), 7 deletions(-)
create mode 100644 uitest/src/com/vaadin/tests/components/tabsheet/TabSheetWithTabIds.html
create mode 100644 uitest/src/com/vaadin/tests/components/tabsheet/TabSheetWithTabIds.java
diff --git a/client/src/com/vaadin/client/ui/VTabsheet.java b/client/src/com/vaadin/client/ui/VTabsheet.java
index fe29e2ebc0..dc20c27837 100644
--- a/client/src/com/vaadin/client/ui/VTabsheet.java
+++ b/client/src/com/vaadin/client/ui/VTabsheet.java
@@ -112,6 +112,8 @@ public class VTabsheet extends VTabsheetBase implements Focusable,
private String styleName;
+ private String id;
+
private Tab(TabBar tabBar) {
super(DOM.createTD());
this.tabBar = tabBar;
@@ -204,10 +206,10 @@ public class VTabsheet extends VTabsheetBase implements Focusable,
String newStyleName = tabUidl
.getStringAttribute(TabsheetConstants.TAB_STYLE_NAME);
// Find the nth td element
- if (newStyleName != null && newStyleName.length() != 0) {
+ if (newStyleName != null && !newStyleName.isEmpty()) {
if (!newStyleName.equals(styleName)) {
// If we have a new style name
- if (styleName != null && styleName.length() != 0) {
+ if (styleName != null && !styleName.isEmpty()) {
// Remove old style name if present
td.removeClassName(TD_CLASSNAME + "-" + styleName);
}
@@ -221,6 +223,15 @@ public class VTabsheet extends VTabsheetBase implements Focusable,
td.removeClassName(TD_CLASSNAME + "-" + styleName);
styleName = null;
}
+
+ String newId = tabUidl.getStringAttribute("id");
+ if (newId != null && !newId.isEmpty()) {
+ td.setId(newId);
+ id = newId;
+ } else if (id != null) {
+ td.removeAttribute("id");
+ id = null;
+ }
}
public void recalculateCaptionWidth() {
diff --git a/server/src/com/vaadin/ui/Component.java b/server/src/com/vaadin/ui/Component.java
index 485327bb54..c385805675 100644
--- a/server/src/com/vaadin/ui/Component.java
+++ b/server/src/com/vaadin/ui/Component.java
@@ -651,7 +651,7 @@ public interface Component extends ClientConnector, Sizeable, Serializable {
public Locale getLocale();
/**
- * Adds an unique id for component that get's transferred to terminal for
+ * Adds an unique id for component that is used in the client-side for
* testing purposes. Keeping identifiers unique is the responsibility of the
* programmer.
*
@@ -661,7 +661,7 @@ public interface Component extends ClientConnector, Sizeable, Serializable {
public void setId(String id);
/**
- * Get's currently set debug identifier
+ * Gets currently set debug identifier
*
* @return current id, null if not set
*/
@@ -669,7 +669,7 @@ public interface Component extends ClientConnector, Sizeable, Serializable {
/**
*
- * Gets the component's description, used in tooltips and can be displayed
+ * Gets the components description, used in tooltips and can be displayed
* directly in certain other components such as forms. The description can
* be used to briefly describe the state of the component to the user. The
* description string may contain certain XML tags:
diff --git a/server/src/com/vaadin/ui/TabSheet.java b/server/src/com/vaadin/ui/TabSheet.java
index 36022adb74..2c85b279cd 100644
--- a/server/src/com/vaadin/ui/TabSheet.java
+++ b/server/src/com/vaadin/ui/TabSheet.java
@@ -431,7 +431,7 @@ public class TabSheet extends AbstractComponentContainer implements Focusable,
icon);
}
final String caption = tab.getCaption();
- if (caption != null && caption.length() > 0) {
+ if (caption != null && !caption.isEmpty()) {
target.addAttribute(
TabsheetBaseConstants.ATTRIBUTE_TAB_CAPTION, caption);
}
@@ -449,10 +449,15 @@ public class TabSheet extends AbstractComponentContainer implements Focusable,
}
final String styleName = tab.getStyleName();
- if (styleName != null && styleName.length() != 0) {
+ if (styleName != null && !styleName.isEmpty()) {
target.addAttribute(TabsheetConstants.TAB_STYLE_NAME, styleName);
}
+ final String id = tab.getId();
+ if (id != null && !id.isEmpty()) {
+ target.addAttribute("id", id);
+ }
+
target.addAttribute("key", keyMapper.key(component));
if (component.equals(selected)) {
target.addAttribute("selected", true);
@@ -1015,6 +1020,23 @@ public class TabSheet extends AbstractComponentContainer implements Focusable,
* @see #setStyleName(String)
*/
public String getStyleName();
+
+ /**
+ * Adds an unique id for component that is used in the client-side for
+ * testing purposes. Keeping identifiers unique is the responsibility of
+ * the programmer.
+ *
+ * @param id
+ * An alphanumeric id
+ */
+ public void setId(String id);
+
+ /**
+ * Gets currently set debug identifier
+ *
+ * @return current id, null if not set
+ */
+ public String getId();
}
/**
@@ -1030,6 +1052,7 @@ public class TabSheet extends AbstractComponentContainer implements Focusable,
private String description = null;
private ErrorMessage componentError = null;
private String styleName;
+ private String id;
public TabSheetTabImpl(String caption, Resource icon) {
if (caption == null) {
@@ -1150,6 +1173,18 @@ public class TabSheet extends AbstractComponentContainer implements Focusable,
public String getStyleName() {
return styleName;
}
+
+ @Override
+ public void setId(String id) {
+ this.id = id;
+ markAsDirty();
+
+ }
+
+ @Override
+ public String getId() {
+ return id;
+ }
}
/**
diff --git a/uitest/src/com/vaadin/tests/components/tabsheet/TabSheetWithTabIds.html b/uitest/src/com/vaadin/tests/components/tabsheet/TabSheetWithTabIds.html
new file mode 100644
index 0000000000..64e85f55e3
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/tabsheet/TabSheetWithTabIds.html
@@ -0,0 +1,76 @@
+
+
+
+
+
+
diff --git a/uitest/src/com/vaadin/tests/components/tabsheet/TabSheetWithTabIds.java b/uitest/src/com/vaadin/tests/components/tabsheet/TabSheetWithTabIds.java
new file mode 100644
index 0000000000..ae5adea45e
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/tabsheet/TabSheetWithTabIds.java
@@ -0,0 +1,77 @@
+/*
+ * Copyright 2000-2013 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+/**
+ *
+ */
+package com.vaadin.tests.components.tabsheet;
+
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.TabSheet;
+import com.vaadin.ui.TabSheet.Tab;
+
+public class TabSheetWithTabIds extends AbstractTestUI {
+
+ @Override
+ protected void setup(VaadinRequest request) {
+ TabSheet tabSheet = new TabSheet();
+
+ final Tab tab1 = tabSheet.addTab(new Label("Label 1"), "Tab 1", null);
+
+ final Tab tab2 = tabSheet.addTab(new Label("Label 2"), "Tab 2", null);
+
+ final Tab tab3 = tabSheet.addTab(new Label("Label 3"), "Tab 3", null);
+
+ addComponent(tabSheet);
+
+ Button b = new Button("Set ids", new Button.ClickListener() {
+
+ @Override
+ public void buttonClick(ClickEvent event) {
+ tab1.setId("tab1");
+ tab2.setId("tab2");
+ tab3.setId("tab3");
+ }
+ });
+ addComponent(b);
+
+ Button b2 = new Button("Clear ids", new Button.ClickListener() {
+
+ @Override
+ public void buttonClick(ClickEvent event) {
+ tab1.setId(null);
+ tab2.setId(null);
+ tab3.setId(null);
+ }
+ });
+ addComponent(b2);
+ }
+
+ @Override
+ protected String getTestDescription() {
+ return "Add support for setId to TabSheet.Tab";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 12064;
+ }
+
+}
--
cgit v1.2.3
From 6a97757139e6c544cf9d62328546eb96856e8df0 Mon Sep 17 00:00:00 2001
From: Artur Signell
Date: Tue, 18 Jun 2013 22:00:14 +0300
Subject: Removed StringToNumberConverter (#12092)
Change-Id: Iada5bb27eefef788143625c4d63a121f6c2589ea
---
.../util/converter/DefaultConverterFactory.java | 2 -
.../util/converter/StringToNumberConverter.java | 65 ----------------------
.../converter/TestStringToNumberConverter.java | 24 --------
3 files changed, 91 deletions(-)
delete mode 100644 server/src/com/vaadin/data/util/converter/StringToNumberConverter.java
delete mode 100644 server/tests/src/com/vaadin/tests/data/converter/TestStringToNumberConverter.java
diff --git a/server/src/com/vaadin/data/util/converter/DefaultConverterFactory.java b/server/src/com/vaadin/data/util/converter/DefaultConverterFactory.java
index bbd3945a37..3c365ecdff 100644
--- a/server/src/com/vaadin/data/util/converter/DefaultConverterFactory.java
+++ b/server/src/com/vaadin/data/util/converter/DefaultConverterFactory.java
@@ -103,8 +103,6 @@ public class DefaultConverterFactory implements ConverterFactory {
return new StringToIntegerConverter();
} else if (Boolean.class.isAssignableFrom(sourceType)) {
return new StringToBooleanConverter();
- } else if (Number.class.isAssignableFrom(sourceType)) {
- return new StringToNumberConverter();
} else if (Date.class.isAssignableFrom(sourceType)) {
return new StringToDateConverter();
} else {
diff --git a/server/src/com/vaadin/data/util/converter/StringToNumberConverter.java b/server/src/com/vaadin/data/util/converter/StringToNumberConverter.java
deleted file mode 100644
index 22df42403f..0000000000
--- a/server/src/com/vaadin/data/util/converter/StringToNumberConverter.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright 2000-2013 Vaadin Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-package com.vaadin.data.util.converter;
-
-import java.text.NumberFormat;
-import java.util.Locale;
-
-/**
- * A converter that converts from {@link Number} to {@link String} and back.
- * Uses the given locale and {@link NumberFormat} for formatting and parsing.
- *
- * Override and overwrite {@link #getFormat(Locale)} to use a different format.
- *
- *
- * @author Vaadin Ltd
- * @since 7.0
- */
-public class StringToNumberConverter extends
- AbstractStringToNumberConverter {
-
- /*
- * (non-Javadoc)
- *
- * @see
- * com.vaadin.data.util.converter.Converter#convertToModel(java.lang.Object,
- * java.lang.Class, java.util.Locale)
- */
- @Override
- public Number convertToModel(String value,
- Class extends Number> targetType, Locale locale)
- throws ConversionException {
- if (targetType != getModelType()) {
- throw new ConversionException("Converter only supports "
- + getModelType().getName() + " (targetType was "
- + targetType.getName() + ")");
- }
-
- return convertToNumber(value, targetType, locale);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.vaadin.data.util.converter.Converter#getModelType()
- */
- @Override
- public Class getModelType() {
- return Number.class;
- }
-
-}
diff --git a/server/tests/src/com/vaadin/tests/data/converter/TestStringToNumberConverter.java b/server/tests/src/com/vaadin/tests/data/converter/TestStringToNumberConverter.java
deleted file mode 100644
index 66fc4f6532..0000000000
--- a/server/tests/src/com/vaadin/tests/data/converter/TestStringToNumberConverter.java
+++ /dev/null
@@ -1,24 +0,0 @@
-package com.vaadin.tests.data.converter;
-
-import junit.framework.TestCase;
-
-import com.vaadin.data.util.converter.StringToNumberConverter;
-
-public class TestStringToNumberConverter extends TestCase {
-
- StringToNumberConverter converter = new StringToNumberConverter();
-
- public void testNullConversion() {
- assertEquals(null, converter.convertToModel(null, Number.class, null));
- }
-
- public void testEmptyStringConversion() {
- assertEquals(null, converter.convertToModel("", Number.class, null));
- }
-
- public void testValueConversion() {
- assertEquals(Long.valueOf(10),
- converter.convertToModel("10", Number.class, null));
- assertEquals(10.5, converter.convertToModel("10.5", Number.class, null));
- }
-}
--
cgit v1.2.3
From b84d2feabf34a972b42c82ead780768883591378 Mon Sep 17 00:00:00 2001
From: Artur Signell
Date: Tue, 18 Jun 2013 22:15:54 +0300
Subject: Adds String <-> BigDecimal converter (#9997)
* BigDecimal properties connected to String based fields (TextField/TextArea/...) are now supported without custom converters
Change-Id: I2dab67875b3cfdb46b17e9d4cc35ffb94c114478
---
.../util/converter/DefaultConverterFactory.java | 3 +
.../converter/StringToBigDecimalConverter.java | 60 ++++++++++
.../converter/TestStringToBigDecimalConverter.java | 53 +++++++++
.../components/textfield/BigDecimalTextField.html | 123 +++++++++++++++++++++
.../components/textfield/BigDecimalTextField.java | 123 +++++++++++++++++++++
5 files changed, 362 insertions(+)
create mode 100644 server/src/com/vaadin/data/util/converter/StringToBigDecimalConverter.java
create mode 100644 server/tests/src/com/vaadin/tests/data/converter/TestStringToBigDecimalConverter.java
create mode 100644 uitest/src/com/vaadin/tests/components/textfield/BigDecimalTextField.html
create mode 100644 uitest/src/com/vaadin/tests/components/textfield/BigDecimalTextField.java
diff --git a/server/src/com/vaadin/data/util/converter/DefaultConverterFactory.java b/server/src/com/vaadin/data/util/converter/DefaultConverterFactory.java
index 3c365ecdff..0b3cfcd1b0 100644
--- a/server/src/com/vaadin/data/util/converter/DefaultConverterFactory.java
+++ b/server/src/com/vaadin/data/util/converter/DefaultConverterFactory.java
@@ -16,6 +16,7 @@
package com.vaadin.data.util.converter;
+import java.math.BigDecimal;
import java.util.Date;
import java.util.logging.Logger;
@@ -101,6 +102,8 @@ public class DefaultConverterFactory implements ConverterFactory {
return new StringToFloatConverter();
} else if (Integer.class.isAssignableFrom(sourceType)) {
return new StringToIntegerConverter();
+ } else if (BigDecimal.class.isAssignableFrom(sourceType)) {
+ return new StringToBigDecimalConverter();
} else if (Boolean.class.isAssignableFrom(sourceType)) {
return new StringToBooleanConverter();
} else if (Date.class.isAssignableFrom(sourceType)) {
diff --git a/server/src/com/vaadin/data/util/converter/StringToBigDecimalConverter.java b/server/src/com/vaadin/data/util/converter/StringToBigDecimalConverter.java
new file mode 100644
index 0000000000..75d4cedd23
--- /dev/null
+++ b/server/src/com/vaadin/data/util/converter/StringToBigDecimalConverter.java
@@ -0,0 +1,60 @@
+/*
+ * Copyright 2000-2013 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.vaadin.data.util.converter;
+
+import java.math.BigDecimal;
+import java.text.DecimalFormat;
+import java.text.NumberFormat;
+import java.util.Locale;
+
+/**
+ * A converter that converts from {@link String} to {@link BigDecimal} and back.
+ * Uses the given locale and a {@link NumberFormat} instance for formatting and
+ * parsing.
+ *
+ * Leading and trailing white spaces are ignored when converting from a String.
+ *
+ *
+ * Override and overwrite {@link #getFormat(Locale)} to use a different format.
+ *
+ *
+ * @author Vaadin Ltd
+ * @since 7.2
+ */
+public class StringToBigDecimalConverter extends
+ AbstractStringToNumberConverter {
+ @Override
+ protected NumberFormat getFormat(Locale locale) {
+ NumberFormat numberFormat = super.getFormat(locale);
+ if (numberFormat instanceof DecimalFormat) {
+ ((DecimalFormat) numberFormat).setParseBigDecimal(true);
+ }
+
+ return numberFormat;
+ }
+
+ @Override
+ public BigDecimal convertToModel(String value,
+ Class extends BigDecimal> targetType, Locale locale)
+ throws com.vaadin.data.util.converter.Converter.ConversionException {
+ return (BigDecimal) convertToNumber(value, BigDecimal.class, locale);
+ }
+
+ @Override
+ public Class getModelType() {
+ return BigDecimal.class;
+ }
+}
diff --git a/server/tests/src/com/vaadin/tests/data/converter/TestStringToBigDecimalConverter.java b/server/tests/src/com/vaadin/tests/data/converter/TestStringToBigDecimalConverter.java
new file mode 100644
index 0000000000..5db33691b6
--- /dev/null
+++ b/server/tests/src/com/vaadin/tests/data/converter/TestStringToBigDecimalConverter.java
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2000-2013 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.vaadin.tests.data.converter;
+
+import java.math.BigDecimal;
+import java.util.Locale;
+
+import junit.framework.TestCase;
+
+import com.vaadin.data.util.converter.StringToBigDecimalConverter;
+
+public class TestStringToBigDecimalConverter extends TestCase {
+
+ StringToBigDecimalConverter converter = new StringToBigDecimalConverter();
+
+ public void testNullConversion() {
+ assertEquals(null,
+ converter.convertToModel(null, BigDecimal.class, null));
+ }
+
+ public void testEmptyStringConversion() {
+ assertEquals(null, converter.convertToModel("", BigDecimal.class, null));
+ }
+
+ public void testValueParsing() {
+ BigDecimal converted = converter.convertToModel("10", BigDecimal.class,
+ null);
+ BigDecimal expected = new BigDecimal(10);
+ assertEquals(expected, converted);
+ }
+
+ public void testValueFormatting() {
+ BigDecimal bd = new BigDecimal(12.5);
+ String expected = "12,5";
+
+ String converted = converter.convertToPresentation(bd, String.class,
+ Locale.GERMAN);
+ assertEquals(expected, converted);
+ }
+}
diff --git a/uitest/src/com/vaadin/tests/components/textfield/BigDecimalTextField.html b/uitest/src/com/vaadin/tests/components/textfield/BigDecimalTextField.html
new file mode 100644
index 0000000000..2428e8b4bb
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/textfield/BigDecimalTextField.html
@@ -0,0 +1,123 @@
+
+
+
+
+
+
+New Test
+
+
+
+
+
diff --git a/uitest/src/com/vaadin/tests/components/textfield/BigDecimalTextField.java b/uitest/src/com/vaadin/tests/components/textfield/BigDecimalTextField.java
new file mode 100644
index 0000000000..18d8679c2f
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/textfield/BigDecimalTextField.java
@@ -0,0 +1,123 @@
+/*
+ * Copyright 2000-2013 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.vaadin.tests.components.textfield;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.util.Locale;
+
+import com.vaadin.data.fieldgroup.FieldGroup;
+import com.vaadin.data.util.BeanItem;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUIWithLog;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+import com.vaadin.ui.FormLayout;
+import com.vaadin.ui.TextField;
+import com.vaadin.ui.VerticalLayout;
+
+/**
+ * @since 7.2
+ * @author Vaadin Ltd
+ */
+public class BigDecimalTextField extends AbstractTestUIWithLog {
+
+ @Override
+ protected void setup(VaadinRequest request) {
+ final VerticalLayout layout = new VerticalLayout();
+ layout.setMargin(true);
+ setLocale(new Locale("fi", "FI"));
+
+ BeanBigDecimal beanBigDecimal = new BeanBigDecimal();
+ BeanItem beanItem = new BeanItem(
+ beanBigDecimal);
+
+ FormLayout formLayout = new FormLayout();
+ TextField textField = new TextField("BigDecimal field");
+ textField.setImmediate(true);
+ textField.setValue("12");
+ formLayout.addComponent(textField);
+
+ final FieldGroup fieldGroup = new FieldGroup(beanItem);
+ fieldGroup.bind(textField, "decimal");
+
+ Button setValue = new Button("Set value to 15,2", new ClickListener() {
+ @Override
+ public void buttonClick(ClickEvent event) {
+ ((TextField) fieldGroup.getField("decimal")).setValue("15,2");
+ }
+ });
+
+ Button button = new Button("Commit");
+ button.addClickListener(new Button.ClickListener() {
+ @Override
+ public void buttonClick(Button.ClickEvent event) {
+ try {
+ fieldGroup.commit();
+ log("Commit ok. Property value: "
+ + fieldGroup.getItemDataSource()
+ .getItemProperty("decimal").getValue());
+ } catch (FieldGroup.CommitException e) {
+ log("Commit failed: " + e.getMessage());
+ }
+ }
+ });
+
+ layout.addComponent(formLayout);
+ layout.addComponent(setValue);
+ layout.addComponent(button);
+
+ setContent(layout);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.vaadin.tests.components.AbstractTestUI#getTestDescription()
+ */
+ @Override
+ protected String getTestDescription() {
+ return "Tests that BigDecimals work correctly with TextFields";
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.vaadin.tests.components.AbstractTestUI#getTicketNumber()
+ */
+ @Override
+ protected Integer getTicketNumber() {
+ return 9997;
+ }
+
+ public static class BeanBigDecimal implements Serializable {
+ BigDecimal decimal;
+
+ public BeanBigDecimal() {
+
+ }
+
+ public BigDecimal getDecimal() {
+ return decimal;
+ }
+
+ public void setDecimal(BigDecimal decimal) {
+ this.decimal = decimal;
+ }
+ }
+
+}
--
cgit v1.2.3
From 24b0386b4f0d3033766562573a6a322f656bf0ed Mon Sep 17 00:00:00 2001
From: Henri Sara
Date: Tue, 2 Jul 2013 09:22:25 +0300
Subject: Fix two tests broken by removal of StringToNumberConverter (#12092)
Change-Id: Ic1520ddf670d83ce804acf240067c85d493196ca
---
uitest/src/com/vaadin/tests/components/table/DoublesInTable.java | 4 ++--
.../src/com/vaadin/tests/minitutorials/v7a1/FormatTableValue.java | 6 +++---
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/uitest/src/com/vaadin/tests/components/table/DoublesInTable.java b/uitest/src/com/vaadin/tests/components/table/DoublesInTable.java
index 355cd43d37..4cf2506eeb 100644
--- a/uitest/src/com/vaadin/tests/components/table/DoublesInTable.java
+++ b/uitest/src/com/vaadin/tests/components/table/DoublesInTable.java
@@ -9,7 +9,7 @@ import com.vaadin.data.Property.ValueChangeEvent;
import com.vaadin.data.Property.ValueChangeListener;
import com.vaadin.data.util.BeanItemContainer;
import com.vaadin.data.util.converter.Converter;
-import com.vaadin.data.util.converter.StringToNumberConverter;
+import com.vaadin.data.util.converter.StringToDoubleConverter;
import com.vaadin.tests.components.TestBase;
import com.vaadin.tests.data.bean.Address;
import com.vaadin.tests.data.bean.Country;
@@ -276,7 +276,7 @@ public class DoublesInTable extends TestBase {
});
- t.setConverter("rent", new StringToNumberConverter() {
+ t.setConverter("rent", new StringToDoubleConverter() {
@Override
protected NumberFormat getFormat(Locale locale) {
return NumberFormat.getCurrencyInstance(locale);
diff --git a/uitest/src/com/vaadin/tests/minitutorials/v7a1/FormatTableValue.java b/uitest/src/com/vaadin/tests/minitutorials/v7a1/FormatTableValue.java
index be2768a5f7..8485bba499 100644
--- a/uitest/src/com/vaadin/tests/minitutorials/v7a1/FormatTableValue.java
+++ b/uitest/src/com/vaadin/tests/minitutorials/v7a1/FormatTableValue.java
@@ -3,7 +3,7 @@ package com.vaadin.tests.minitutorials.v7a1;
import java.text.NumberFormat;
import java.util.Locale;
-import com.vaadin.data.util.converter.StringToNumberConverter;
+import com.vaadin.data.util.converter.StringToDoubleConverter;
import com.vaadin.server.VaadinRequest;
import com.vaadin.tests.components.AbstractTestUI;
import com.vaadin.ui.Table;
@@ -30,14 +30,14 @@ public class FormatTableValue extends AbstractTestUI {
table.getItem(itemId).getItemProperty(DEFAULT_PROPERTY)
.setValue(3.1415);
- table.setConverter(PERCENT_PROPERTY, new StringToNumberConverter() {
+ table.setConverter(PERCENT_PROPERTY, new StringToDoubleConverter() {
@Override
protected NumberFormat getFormat(Locale locale) {
return NumberFormat.getPercentInstance(locale);
}
});
- table.setConverter(CURRENCY_PROPERTY, new StringToNumberConverter() {
+ table.setConverter(CURRENCY_PROPERTY, new StringToDoubleConverter() {
@Override
protected NumberFormat getFormat(Locale locale) {
return NumberFormat.getCurrencyInstance(locale);
--
cgit v1.2.3
From d23c06a6145ca4c4f03377fc324e08693926873b Mon Sep 17 00:00:00 2001
From: michaelvogt
Date: Fri, 10 May 2013 17:45:21 +0300
Subject: Accessibility for Notification (#11820)
Change-Id: Ic9c1a417fa791927897b6fcdf35a1fb4444dfd70
---
client/src/com/vaadin/client/ui/VNotification.java | 67 ++++-
client/src/com/vaadin/client/ui/VOverlay.java | 2 +-
server/src/com/vaadin/server/SystemMessages.java | 12 +-
server/src/com/vaadin/ui/Notification.java | 136 ++++++++++-
.../com/vaadin/ui/NotificationConfiguration.java | 269 +++++++++++++++++++++
server/src/com/vaadin/ui/UI.java | 12 +
.../ui/ui/NotificationConfigurationBean.java | 137 +++++++++++
shared/src/com/vaadin/shared/ui/ui/UIState.java | 18 ++
.../notification/NotificationsWaiAria.html | 117 +++++++++
.../notification/NotificationsWaiAria.java | 113 +++++++++
10 files changed, 872 insertions(+), 11 deletions(-)
create mode 100644 server/src/com/vaadin/ui/NotificationConfiguration.java
create mode 100644 shared/src/com/vaadin/shared/ui/ui/NotificationConfigurationBean.java
create mode 100644 uitest/src/com/vaadin/tests/components/notification/NotificationsWaiAria.html
create mode 100644 uitest/src/com/vaadin/tests/components/notification/NotificationsWaiAria.java
diff --git a/client/src/com/vaadin/client/ui/VNotification.java b/client/src/com/vaadin/client/ui/VNotification.java
index 7019394e3b..0ddc8bf7c5 100644
--- a/client/src/com/vaadin/client/ui/VNotification.java
+++ b/client/src/com/vaadin/client/ui/VNotification.java
@@ -21,19 +21,25 @@ import java.util.Date;
import java.util.EventObject;
import java.util.Iterator;
+import com.google.gwt.aria.client.Roles;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.KeyCodes;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.Element;
import com.google.gwt.user.client.Event;
import com.google.gwt.user.client.Timer;
+import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.HTML;
+import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.Widget;
import com.vaadin.client.ApplicationConnection;
import com.vaadin.client.BrowserInfo;
import com.vaadin.client.UIDL;
import com.vaadin.client.Util;
+import com.vaadin.client.ui.aria.AriaHelper;
import com.vaadin.shared.Position;
+import com.vaadin.shared.ui.ui.NotificationConfigurationBean;
+import com.vaadin.shared.ui.ui.NotificationConfigurationBean.Role;
import com.vaadin.shared.ui.ui.UIConstants;
public class VNotification extends VOverlay {
@@ -149,15 +155,67 @@ public class VNotification extends VOverlay {
}
public void show(Widget widget, Position position, String style) {
- setWidget(widget);
+ NotificationConfigurationBean styleSetup = getUiState(style);
+ setWaiAriaRole(styleSetup);
+
+ FlowPanel panel = new FlowPanel();
+ if (styleSetup.hasAssistivePrefix()) {
+ panel.add(new Label(styleSetup.getAssistivePrefix()));
+ AriaHelper.setVisibleForAssistiveDevicesOnly(panel.getElement(),
+ true);
+ }
+
+ panel.add(widget);
+
+ if (styleSetup.hasAssistivePostfix()) {
+ panel.add(new Label(styleSetup.getAssistivePostfix()));
+ AriaHelper.setVisibleForAssistiveDevicesOnly(panel.getElement(),
+ true);
+ }
+ setWidget(panel);
show(position, style);
}
public void show(String html, Position position, String style) {
- setWidget(new HTML(html));
+ NotificationConfigurationBean styleSetup = getUiState(style);
+ String assistiveDeviceOnlyStyle = AriaHelper.ASSISTIVE_DEVICE_ONLY_STYLE;
+
+ setWaiAriaRole(styleSetup);
+
+ String type = "";
+ String usage = "";
+
+ if (styleSetup != null && styleSetup.hasAssistivePrefix()) {
+ type = ""
+ + styleSetup.getAssistivePrefix() + "";
+ }
+
+ if (styleSetup != null && styleSetup.hasAssistivePostfix()) {
+ usage = ""
+ + styleSetup.getAssistivePostfix() + "";
+ }
+
+ setWidget(new HTML(type + html + usage));
show(position, style);
}
+ private NotificationConfigurationBean getUiState(String style) {
+ NotificationConfigurationBean styleSetup = getApplicationConnection()
+ .getUIConnector().getState().notificationConfiguration.setup
+ .get(style);
+ return styleSetup;
+ }
+
+ private void setWaiAriaRole(NotificationConfigurationBean styleSetup) {
+ Roles.getAlertRole().set(getElement());
+
+ if (styleSetup != null && styleSetup.getAssistiveRole() != null) {
+ if (Role.STATUS == styleSetup.getAssistiveRole()) {
+ Roles.getStatusRole().set(getElement());
+ }
+ }
+ }
+
public void show(Position position, String style) {
setOpacity(getElement(), startOpacity);
if (style != null) {
@@ -377,7 +435,8 @@ public class VNotification extends VOverlay {
final String parsedUri = client
.translateVaadinUri(notification
.getStringAttribute(UIConstants.ATTRIBUTE_NOTIFICATION_ICON));
- html += "";
+ html += "";
}
if (notification
.hasAttribute(UIConstants.ATTRIBUTE_NOTIFICATION_CAPTION)) {
@@ -417,6 +476,8 @@ public class VNotification extends VOverlay {
public static VNotification createNotification(int delayMsec, Widget owner) {
final VNotification notification = GWT.create(VNotification.class);
+ notification.setWaiAriaRole(null);
+
notification.delayMsec = delayMsec;
if (BrowserInfo.get().isTouchDevice()) {
new Timer() {
diff --git a/client/src/com/vaadin/client/ui/VOverlay.java b/client/src/com/vaadin/client/ui/VOverlay.java
index ced476f9dd..206e26b960 100644
--- a/client/src/com/vaadin/client/ui/VOverlay.java
+++ b/client/src/com/vaadin/client/ui/VOverlay.java
@@ -172,7 +172,7 @@ public class VOverlay extends PopupPanel implements CloseHandler {
*
* See default theme 'shadow.css' for implementation example.
*/
- private static final String SHADOW_HTML = "";
+ private static final String SHADOW_HTML = "";
/**
* Matches {@link PopupPanel}.ANIMATION_DURATION
diff --git a/server/src/com/vaadin/server/SystemMessages.java b/server/src/com/vaadin/server/SystemMessages.java
index 5e0fde1d4a..299c725207 100644
--- a/server/src/com/vaadin/server/SystemMessages.java
+++ b/server/src/com/vaadin/server/SystemMessages.java
@@ -63,32 +63,32 @@ public class SystemMessages implements Serializable {
protected String sessionExpiredURL = null;
protected boolean sessionExpiredNotificationEnabled = true;
protected String sessionExpiredCaption = "Session Expired";
- protected String sessionExpiredMessage = "Take note of any unsaved data, and click here to continue.";
+ protected String sessionExpiredMessage = "Take note of any unsaved data, and click here or press ESC key to continue.";
protected String communicationErrorURL = null;
protected boolean communicationErrorNotificationEnabled = true;
protected String communicationErrorCaption = "Communication problem";
- protected String communicationErrorMessage = "Take note of any unsaved data, and click here to continue.";
+ protected String communicationErrorMessage = "Take note of any unsaved data, and click here or press ESC to continue.";
protected String authenticationErrorURL = null;
protected boolean authenticationErrorNotificationEnabled = true;
protected String authenticationErrorCaption = "Authentication problem";
- protected String authenticationErrorMessage = "Take note of any unsaved data, and click here to continue.";
+ protected String authenticationErrorMessage = "Take note of any unsaved data, and click here or press ESC to continue.";
protected String internalErrorURL = null;
protected boolean internalErrorNotificationEnabled = true;
protected String internalErrorCaption = "Internal error";
- protected String internalErrorMessage = "Please notify the administrator. Take note of any unsaved data, and click here to continue.";
+ protected String internalErrorMessage = "Please notify the administrator. Take note of any unsaved data, and click here or press ESC to continue.";
protected String outOfSyncURL = null;
protected boolean outOfSyncNotificationEnabled = true;
protected String outOfSyncCaption = "Out of sync";
- protected String outOfSyncMessage = "Something has caused us to be out of sync with the server. Take note of any unsaved data, and click here to re-sync.";
+ protected String outOfSyncMessage = "Something has caused us to be out of sync with the server. Take note of any unsaved data, and click here or press ESC to re-sync.";
protected String cookiesDisabledURL = null;
protected boolean cookiesDisabledNotificationEnabled = true;
protected String cookiesDisabledCaption = "Cookies disabled";
- protected String cookiesDisabledMessage = "This application requires cookies to function. Please enable cookies in your browser and click here to try again.";
+ protected String cookiesDisabledMessage = "This application requires cookies to function. Please enable cookies in your browser and click here or press ESC to try again.";
/**
* Use {@link CustomizedSystemMessages} to customize
diff --git a/server/src/com/vaadin/ui/Notification.java b/server/src/com/vaadin/ui/Notification.java
index cf1d03ab5c..f9bb1521e7 100644
--- a/server/src/com/vaadin/ui/Notification.java
+++ b/server/src/com/vaadin/ui/Notification.java
@@ -21,6 +21,7 @@ import java.io.Serializable;
import com.vaadin.server.Page;
import com.vaadin.server.Resource;
import com.vaadin.shared.Position;
+import com.vaadin.shared.ui.ui.NotificationConfigurationBean.Role;
/**
* A notification message, used to display temporary messages to the user - for
@@ -190,21 +191,32 @@ public class Notification implements Serializable {
case WARNING_MESSAGE:
delayMsec = 1500;
styleName = "warning";
+ setNavigationConfiguration("Warning: ", "", Role.ALERT);
break;
case ERROR_MESSAGE:
delayMsec = -1;
styleName = "error";
+ setNavigationConfiguration("Error: ", " - close with ESC",
+ Role.ALERT);
break;
case TRAY_NOTIFICATION:
delayMsec = 3000;
position = Position.BOTTOM_RIGHT;
styleName = "tray";
-
+ setNavigationConfiguration("Info: ", "", Role.STATUS);
+ break;
case HUMANIZED_MESSAGE:
default:
+ styleName = "humanized";
+ setNavigationConfiguration("Info: ", "", Role.ALERT);
break;
}
+ }
+ private void setNavigationConfiguration(String prefix, String postfix,
+ Role ariaRole) {
+ UI.getCurrent().getNotificationConfiguration()
+ .setStyleConfiguration(styleName, prefix, postfix, ariaRole);
}
/**
@@ -321,6 +333,128 @@ public class Notification implements Serializable {
return styleName;
}
+ /**
+ * Sets the accessibility prefix for a notification type.
+ *
+ * This prefix is read to assistive device users before the content of the
+ * notification, but not visible on the page.
+ *
+ * @param type
+ * Type of the notification
+ * @param prefix
+ * String that is placed before the notification content
+ */
+ public void setAssistivePrefixForType(Type type, String prefix) {
+ UI.getCurrent().getNotificationConfiguration()
+ .setAssistivePrefixForStyle(getStyle(type), prefix);
+ }
+
+ /**
+ * Gets the accessibility prefix for a notification type.
+ *
+ * This prefix is read to assistive device users before the content of the
+ * notification, but not visible on the page.
+ *
+ * @param type
+ * Type of the notification
+ * @return The accessibility prefix for the provided notification type
+ */
+ public String getAssistivePrefixForType(Type type) {
+ return UI.getCurrent().getNotificationConfiguration()
+ .getAssistivePrefixForStyle(getStyle(type));
+ }
+
+ /**
+ * Sets the accessibility postfix for a notification type.
+ *
+ * This postfix is read to assistive device users after the content of the
+ * notification, but not visible on the page.
+ *
+ * @param type
+ * Type of the notification
+ * @param postfix
+ * String that is placed after the notification content
+ */
+ public void setAssistivePostfixForType(Type type, String postfix) {
+ UI.getCurrent().getNotificationConfiguration()
+ .setAssistivePostfixForStyle(getStyle(type), postfix);
+ }
+
+ /**
+ * Gets the accessibility postfix for a notification type.
+ *
+ * This postfix is read to assistive device users after the content of the
+ * notification, but not visible on the page.
+ *
+ * @param type
+ * Type of the notification
+ * @return The accessibility postfix for the provided notification type
+ */
+ public String getAssistivePostfixForType(Type type) {
+ return UI.getCurrent().getNotificationConfiguration()
+ .getAssistivePostfixForStyle(getStyle(type));
+ }
+
+ /**
+ * Sets the WAI-ARIA role for a notification type.
+ *
+ * This role defines how an assistive device handles a notification.
+ * Available roles are alert and status (@see Roles
+ * Model).
+ *
+ * The default role is alert.
+ *
+ * @param type
+ * Type of the notification
+ * @param role
+ * Role to set for the notification type
+ */
+ public void setAssistiveRoleForType(Type type, Role role) {
+ UI.getCurrent().getNotificationConfiguration()
+ .setAssistiveRoleForStyle(getStyle(type), role);
+ }
+
+ /**
+ * Gets the WAI-ARIA role for a notification type.
+ *
+ * This role defines how an assistive device handles a notification.
+ * Available roles are alert and status (@see Roles
+ * Model)
+ *
+ * The default role is alert.
+ *
+ * @param type
+ * Type of the notification
+ * @return Role to set for the notification type
+ */
+ public Role getAssistiveRoleForType(Type type) {
+ return UI.getCurrent().getNotificationConfiguration()
+ .getAssistiveRoleForStyle(getStyle(type));
+ }
+
+ private String getStyle(Type type) {
+ String style = "";
+
+ switch (type) {
+ case WARNING_MESSAGE:
+ style = "warning";
+ break;
+ case ERROR_MESSAGE:
+ style = "error";
+ break;
+ case TRAY_NOTIFICATION:
+ style = "tray";
+ case HUMANIZED_MESSAGE:
+ default:
+ style = "humanized";
+ break;
+ }
+
+ return style;
+ }
+
/**
* Sets whether html is allowed in the caption and description. If set to
* true, the texts are passed to the browser as html and the developer is
diff --git a/server/src/com/vaadin/ui/NotificationConfiguration.java b/server/src/com/vaadin/ui/NotificationConfiguration.java
new file mode 100644
index 0000000000..52d3e76d63
--- /dev/null
+++ b/server/src/com/vaadin/ui/NotificationConfiguration.java
@@ -0,0 +1,269 @@
+/*
+ * Copyright 2000-2013 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+/**
+ *
+ */
+package com.vaadin.ui;
+
+import java.io.Serializable;
+
+import com.vaadin.shared.ui.ui.NotificationConfigurationBean;
+import com.vaadin.shared.ui.ui.NotificationConfigurationBean.Role;
+import com.vaadin.shared.ui.ui.UIState.NotificationConfigurationState;
+
+/**
+ * Provides methods for configuring the notification.
+ *
+ * @author Vaadin Ltd
+ * @since 7.1
+ */
+public interface NotificationConfiguration extends Serializable {
+ public void setStyleConfiguration(String style, String prefix,
+ String postfix, Role ariaRole);
+
+ /**
+ * Returns the complete configuration object for the given notification
+ * style.
+ *
+ * @param style
+ * String of the notification style to return
+ * @return The notification configuration object
+ */
+ public NotificationConfigurationBean getStyleConfiguration(String style);
+
+ /**
+ * Sets the accessibility prefix for the given notification style.
+ *
+ * This prefix is read to assistive device users in front of the content of
+ * the notification, but not visible on the page.
+ *
+ * @param style
+ * String of the notification style
+ * @param prefix
+ * String that is placed before the notification content
+ */
+ public void setAssistivePrefixForStyle(String style, String prefix);
+
+ /**
+ * Returns the accessibility prefix for the given notification style.
+ *
+ * This prefix is read to assistive device users in front of the content of
+ * the notification, but not visible on the page.
+ *
+ * @param style
+ * String of the notification style
+ * @return The prefix of the provided notification style
+ */
+ public String getAssistivePrefixForStyle(String style);
+
+ /**
+ * Sets the accessibility postfix for the given notification style.
+ *
+ * This postfix is read to assistive device users after the content of the
+ * notification, but not visible on the page.
+ *
+ * @param style
+ * String of the notification style
+ * @param postfix
+ * String that is placed after the notification content
+ */
+ public void setAssistivePostfixForStyle(String style, String postfix);
+
+ /**
+ * Returns the accessibility postfix for the given notification style.
+ *
+ * This postfix is read to assistive device users after the content of the
+ * notification, but not visible on the page.
+ *
+ * @param style
+ * String of the notification style
+ * @return The postfix of the provided notification style
+ */
+ public String getAssistivePostfixForStyle(String style);
+
+ /**
+ * Sets the WAI-ARIA role for a notification style.
+ *
+ * This role defines how an assistive device handles a notification.
+ * Available roles are alert, alertdialog and status (@see Roles
+ * Model)
+ *
+ * The default role is alert.
+ *
+ * @param style
+ * String of the notification style
+ * @param role
+ * Role to set for the notification type
+ */
+ public void setAssistiveRoleForStyle(String style, Role role);
+
+ /**
+ * Returns the WAI-ARIA role for a notification style.
+ *
+ * This role defines how an assistive device handles a notification.
+ * Available roles are alert, alertdialog and status (@see Roles
+ * Model )
+ *
+ * The default role is alert.
+ *
+ * @param style
+ * String of the notification style
+ * @return The current Role for the notification type
+ */
+ public Role getAssistiveRoleForStyle(String style);
+}
+
+class NotificationConfigurationImpl implements NotificationConfiguration {
+
+ private UI ui;
+
+ public NotificationConfigurationImpl(UI ui) {
+ this.ui = ui;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * com.vaadin.ui.NotificationConfiguration#setStyleConfiguration(java.lang
+ * .String, java.lang.String, java.lang.String,
+ * com.vaadin.ui.NotificationConfiguration.Role)
+ */
+ @Override
+ public void setStyleConfiguration(String style, String prefix,
+ String postfix, Role ariaRole) {
+ getState().setup.put(style, new NotificationConfigurationBean(prefix,
+ postfix, ariaRole));
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * com.vaadin.ui.NotificationConfiguration#getStyleConfiguration(java.lang
+ * .String)
+ */
+ @Override
+ public NotificationConfigurationBean getStyleConfiguration(String style) {
+ return getState(false).setup.get(style);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * com.vaadin.ui.NotificationConfiguration#setStylePrefix(java.lang.String,
+ * java.lang.String)
+ */
+ @Override
+ public void setAssistivePrefixForStyle(String style, String prefix) {
+ getConfigurationBean(style).setAssistivePrefix(prefix);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * com.vaadin.ui.NotificationConfiguration#getStylePrefix(java.lang.String)
+ */
+ @Override
+ public String getAssistivePrefixForStyle(String style) {
+ NotificationConfigurationBean styleSetup = getState().setup.get(style);
+ if (styleSetup != null) {
+ return styleSetup.getAssistivePrefix();
+ }
+
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * com.vaadin.ui.NotificationConfiguration#setStylePostfix(com.vaadin.ui
+ * .Notification.Type, java.lang.String)
+ */
+ @Override
+ public void setAssistivePostfixForStyle(String style, String postfix) {
+ getConfigurationBean(style).setAssistivePostfix(postfix);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * com.vaadin.ui.NotificationConfiguration#getStylePostfix(com.vaadin.ui
+ * .Notification.Type)
+ */
+ @Override
+ public String getAssistivePostfixForStyle(String style) {
+ NotificationConfigurationBean styleSetup = getState().setup.get(style);
+ if (styleSetup != null) {
+ return styleSetup.getAssistivePostfix();
+ }
+
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.vaadin.ui.NotificationConfiguration#setStyleRole(com.vaadin.ui.
+ * Notification.Type, com.vaadin.ui.NotificationConfiguration.Role)
+ */
+ @Override
+ public void setAssistiveRoleForStyle(String style, Role role) {
+ getConfigurationBean(style).setAssistiveRole(role);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.vaadin.ui.NotificationConfiguration#getStyleRole(com.vaadin.ui.
+ * Notification.Type)
+ */
+ @Override
+ public Role getAssistiveRoleForStyle(String style) {
+ NotificationConfigurationBean styleSetup = getState().setup.get(style);
+ if (styleSetup != null) {
+ return styleSetup.getAssistiveRole();
+ }
+
+ return null;
+ }
+
+ private NotificationConfigurationBean getConfigurationBean(String style) {
+ NotificationConfigurationBean styleSetup = getState().setup.get(style);
+ if (styleSetup == null) {
+ styleSetup = new NotificationConfigurationBean();
+ getState().setup.put(style, styleSetup);
+ }
+
+ return styleSetup;
+ }
+
+ private NotificationConfigurationState getState() {
+ return ui.getState().notificationConfiguration;
+ }
+
+ private NotificationConfigurationState getState(boolean markAsDirty) {
+ return ui.getState(markAsDirty).notificationConfiguration;
+ }
+
+}
diff --git a/server/src/com/vaadin/ui/UI.java b/server/src/com/vaadin/ui/UI.java
index e0811e51f7..2138edd6ac 100644
--- a/server/src/com/vaadin/ui/UI.java
+++ b/server/src/com/vaadin/ui/UI.java
@@ -218,6 +218,9 @@ public abstract class UI extends AbstractSingleComponentContainer implements
private PushConfiguration pushConfiguration = new PushConfigurationImpl(
this);
+ private NotificationConfiguration notificationConfiguration = new NotificationConfigurationImpl(
+ this);
+
/**
* Creates a new empty UI without a caption. The content of the UI must be
* set by calling {@link #setContent(Component)} before using the UI.
@@ -1281,6 +1284,15 @@ public abstract class UI extends AbstractSingleComponentContainer implements
return tooltipConfiguration;
}
+ /**
+ * Retrieves the object used for configuring notifications.
+ *
+ * @return The instance used for notification configuration
+ */
+ public NotificationConfiguration getNotificationConfiguration() {
+ return notificationConfiguration;
+ }
+
/**
* Retrieves the object used for configuring the loading indicator.
*
diff --git a/shared/src/com/vaadin/shared/ui/ui/NotificationConfigurationBean.java b/shared/src/com/vaadin/shared/ui/ui/NotificationConfigurationBean.java
new file mode 100644
index 0000000000..05a1706763
--- /dev/null
+++ b/shared/src/com/vaadin/shared/ui/ui/NotificationConfigurationBean.java
@@ -0,0 +1,137 @@
+/*
+ * Copyright 2000-2013 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+/**
+ *
+ */
+package com.vaadin.shared.ui.ui;
+
+import java.io.Serializable;
+
+/**
+ * Holds configuration information for a notification type.
+ *
+ * @author Vaadin Ltd
+ */
+public class NotificationConfigurationBean implements Serializable {
+ /**
+ * Available WAI-ARIA roles for a notification.
+ */
+ public enum Role {
+ ALERT, STATUS
+ };
+
+ private String prefix;
+ private String postfix;
+ private Role role = Role.ALERT;
+
+ public NotificationConfigurationBean() {
+ }
+
+ public NotificationConfigurationBean(String prefix, String postfix,
+ Role role) {
+ this.prefix = prefix;
+ this.postfix = postfix;
+ this.role = role;
+ }
+
+ /**
+ * Returns the accessibility prefix, which is placed before the notification
+ * content.
+ *
+ * @return the prefix
+ */
+ public String getAssistivePrefix() {
+ return prefix;
+ }
+
+ /**
+ * Sets the accessibility prefix, which is placed before the notification
+ * content.
+ *
+ * @param pefix
+ * the prefix to set
+ */
+ public void setAssistivePrefix(String prefix) {
+ this.prefix = prefix;
+ }
+
+ /**
+ * Checks if an accessibility prefix is set.
+ *
+ * @return true when assistivePrefix is not null and has a length > 0, false
+ * otherwise
+ */
+ public boolean hasAssistivePrefix() {
+ return prefix != null && !prefix.isEmpty();
+ }
+
+ /**
+ * Returns the accessibility postfix, which is placed after the notification
+ * content.
+ *
+ * @return the postfix
+ */
+ public String getAssistivePostfix() {
+ return postfix;
+ }
+
+ /**
+ * Sets the accessibility postfix, which is placed after the notification
+ * content.
+ *
+ * @param postfix
+ * the postfix to set
+ */
+ public void setAssistivePostfix(String postfix) {
+ this.postfix = postfix;
+ }
+
+ /**
+ * Checks if an accessibility postfix is set.
+ *
+ * @return true when postfix is not null and has a length > 0, false
+ * otherwise
+ */
+ public boolean hasAssistivePostfix() {
+ return postfix != null && !postfix.isEmpty();
+ }
+
+ /**
+ * Returns the WAI-ARIA role that defines how an assistive device will
+ * inform the user about a notification.
+ *
+ * @return the role
+ */
+ public Role getAssistiveRole() {
+ return role;
+ }
+
+ /**
+ * Sets the WAI-ARIA role that defines how an assistive device will inform
+ * the user about a notification.
+ *
+ * Available roles are alert, alertdialog and status (@see Roles
+ * Model).
+ *
+ * @param role
+ * the role to set
+ */
+ public void setAssistiveRole(Role role) {
+ this.role = role;
+ }
+}
diff --git a/shared/src/com/vaadin/shared/ui/ui/UIState.java b/shared/src/com/vaadin/shared/ui/ui/UIState.java
index 8d042a835f..4cde452a2b 100644
--- a/shared/src/com/vaadin/shared/ui/ui/UIState.java
+++ b/shared/src/com/vaadin/shared/ui/ui/UIState.java
@@ -23,10 +23,12 @@ import java.util.Map;
import com.vaadin.shared.communication.PushMode;
import com.vaadin.shared.ui.TabIndexState;
+import com.vaadin.shared.ui.ui.NotificationConfigurationBean.Role;
public class UIState extends TabIndexState {
public TooltipConfigurationState tooltipConfiguration = new TooltipConfigurationState();
public LoadingIndicatorConfigurationState loadingIndicatorConfiguration = new LoadingIndicatorConfigurationState();
+ public NotificationConfigurationState notificationConfiguration = new NotificationConfigurationState();
public int pollInterval = -1;
// Informing users of assistive devices, that the content of this container
@@ -48,6 +50,22 @@ public class UIState extends TabIndexState {
public int maxWidth = 500;
}
+ public static class NotificationConfigurationState implements Serializable {
+ public Map setup = new HashMap();
+ {
+ setup.put("error", new NotificationConfigurationBean("Error: ",
+ " - close with ESC-key", Role.ALERT));
+ setup.put("warning", new NotificationConfigurationBean("Warning: ",
+ null, Role.ALERT));
+ setup.put("humanized", new NotificationConfigurationBean("Info: ",
+ null, Role.ALERT));
+ setup.put("tray", new NotificationConfigurationBean("Status: ",
+ null, Role.STATUS));
+ setup.put("assistive", new NotificationConfigurationBean("Note: ",
+ null, Role.STATUS));
+ };
+ }
+
public static class PushConfigurationState implements Serializable {
public static final String TRANSPORT_PARAM = "transport";
public static final String FALLBACK_TRANSPORT_PARAM = "fallbackTransport";
diff --git a/uitest/src/com/vaadin/tests/components/notification/NotificationsWaiAria.html b/uitest/src/com/vaadin/tests/components/notification/NotificationsWaiAria.html
new file mode 100644
index 0000000000..aa13b9e637
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/notification/NotificationsWaiAria.html
@@ -0,0 +1,117 @@
+
+
+
+
+
+
+NotificationsWaiAria
+
+
+