aboutsummaryrefslogtreecommitdiffstats
path: root/server/src/com/vaadin/ui
diff options
context:
space:
mode:
authorJohn Ahlroos <john@vaadin.com>2014-04-24 13:27:57 +0300
committerLeif Åstrand <leif@vaadin.com>2014-04-25 06:28:11 +0000
commit91fa89a9a384d64a953996efa6d6f42eff1f4c8a (patch)
tree408e8fbee4a554fbd100b4e3ef3923596f04af29 /server/src/com/vaadin/ui
parent387603a6712a68c05fdb154824fe950b2df9c451 (diff)
parent0a5eeeca649676432a4166255a4aee0028a3adcc (diff)
downloadvaadin-framework-91fa89a9a384d64a953996efa6d6f42eff1f4c8a.tar.gz
vaadin-framework-91fa89a9a384d64a953996efa6d6f42eff1f4c8a.zip
Merge remote-tracking branch 'origin/master' into grid
Change-Id: I596407a5d5c28c6ec3fb27d443e6bf143bddee6c
Diffstat (limited to 'server/src/com/vaadin/ui')
-rw-r--r--server/src/com/vaadin/ui/AbstractOrderedLayout.java10
-rw-r--r--server/src/com/vaadin/ui/ComboBox.java14
-rw-r--r--server/src/com/vaadin/ui/Notification.java167
-rw-r--r--server/src/com/vaadin/ui/NotificationConfiguration.java240
-rw-r--r--server/src/com/vaadin/ui/TabSheet.java85
-rw-r--r--server/src/com/vaadin/ui/Table.java60
-rw-r--r--server/src/com/vaadin/ui/UI.java10
-rw-r--r--server/src/com/vaadin/ui/Window.java31
-rw-r--r--server/src/com/vaadin/ui/components/calendar/ContainerEventProvider.java4
9 files changed, 213 insertions, 408 deletions
diff --git a/server/src/com/vaadin/ui/AbstractOrderedLayout.java b/server/src/com/vaadin/ui/AbstractOrderedLayout.java
index c9eb756daa..f5fd4d7bfc 100644
--- a/server/src/com/vaadin/ui/AbstractOrderedLayout.java
+++ b/server/src/com/vaadin/ui/AbstractOrderedLayout.java
@@ -213,8 +213,12 @@ public abstract class AbstractOrderedLayout extends AbstractLayout implements
if (oldLocation == -1) {
addComponent(newComponent);
} else if (newLocation == -1) {
+ Alignment alignment = getComponentAlignment(oldComponent);
+ float expandRatio = getExpandRatio(oldComponent);
+
removeComponent(oldComponent);
addComponent(newComponent, oldLocation);
+ applyLayoutSettings(newComponent, alignment, expandRatio);
} else {
// Both old and new are in the layout
if (oldLocation > newLocation) {
@@ -444,4 +448,10 @@ public abstract class AbstractOrderedLayout extends AbstractLayout implements
defaultComponentAlignment = defaultAlignment;
}
+ private void applyLayoutSettings(Component target, Alignment alignment,
+ float expandRatio) {
+ setComponentAlignment(target, alignment);
+ setExpandRatio(target, expandRatio);
+ }
+
}
diff --git a/server/src/com/vaadin/ui/ComboBox.java b/server/src/com/vaadin/ui/ComboBox.java
index 5fb2f81011..da29618efe 100644
--- a/server/src/com/vaadin/ui/ComboBox.java
+++ b/server/src/com/vaadin/ui/ComboBox.java
@@ -103,22 +103,30 @@ public class ComboBox extends AbstractSelect implements
private boolean textInputAllowed = true;
public ComboBox() {
- setNewItemsAllowed(false);
+ initDefaults();
}
public ComboBox(String caption, Collection<?> options) {
super(caption, options);
- setNewItemsAllowed(false);
+ initDefaults();
}
public ComboBox(String caption, Container dataSource) {
super(caption, dataSource);
- setNewItemsAllowed(false);
+ initDefaults();
}
public ComboBox(String caption) {
super(caption);
+ initDefaults();
+ }
+
+ /**
+ * Initialize the ComboBox with default settings
+ */
+ private void initDefaults() {
setNewItemsAllowed(false);
+ setImmediate(true);
}
/**
diff --git a/server/src/com/vaadin/ui/Notification.java b/server/src/com/vaadin/ui/Notification.java
index 31fa265b02..7064bfcf39 100644
--- a/server/src/com/vaadin/ui/Notification.java
+++ b/server/src/com/vaadin/ui/Notification.java
@@ -21,7 +21,6 @@ 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
@@ -64,7 +63,27 @@ import com.vaadin.shared.ui.ui.NotificationConfigurationBean.Role;
*/
public class Notification implements Serializable {
public enum Type {
- HUMANIZED_MESSAGE, WARNING_MESSAGE, ERROR_MESSAGE, TRAY_NOTIFICATION, ASSISTIVE_NOTIFICATION;
+ HUMANIZED_MESSAGE("humanized"), WARNING_MESSAGE("warning"), ERROR_MESSAGE(
+ "error"), TRAY_NOTIFICATION("tray"),
+ /**
+ * @since 7.2
+ */
+ ASSISTIVE_NOTIFICATION("assistive");
+
+ private String style;
+
+ Type(String style) {
+ this.style = style;
+ }
+
+ /**
+ * @since 7.2
+ *
+ * @return the style name for this notification type.
+ */
+ public String getStyle() {
+ return style;
+ }
}
@Deprecated
@@ -187,44 +206,28 @@ public class Notification implements Serializable {
}
private void setType(Type type) {
+ styleName = type.getStyle();
switch (type) {
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 ASSISTIVE_NOTIFICATION:
delayMsec = 3000;
position = Position.ASSISTIVE;
- styleName = "assistive";
- setNavigationConfiguration("Note: ", "", Role.ALERT);
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);
- }
-
/**
* Gets the caption part of the notification message.
*
@@ -340,132 +343,6 @@ public class Notification implements Serializable {
}
/**
- * 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 <a
- * href="http://www.w3.org/TR/2011/CR-wai-aria-20110118/roles">Roles
- * Model</a>).
- *
- * 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 <a
- * href="http://www.w3.org/TR/2011/CR-wai-aria-20110118/roles">Roles
- * Model</a>)
- *
- * 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";
- break;
- case ASSISTIVE_NOTIFICATION:
- style = "assistive";
- break;
- 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
* responsible for ensuring no harmful html is used. If set to false, the
diff --git a/server/src/com/vaadin/ui/NotificationConfiguration.java b/server/src/com/vaadin/ui/NotificationConfiguration.java
index 52d3e76d63..e6d19f84f7 100644
--- a/server/src/com/vaadin/ui/NotificationConfiguration.java
+++ b/server/src/com/vaadin/ui/NotificationConfiguration.java
@@ -21,112 +21,99 @@ 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;
+import com.vaadin.shared.ui.ui.NotificationRole;
+import com.vaadin.shared.ui.ui.UIState.NotificationTypeConfiguration;
+import com.vaadin.ui.Notification.Type;
/**
* Provides methods for configuring the notification.
- *
+ *
* @author Vaadin Ltd
- * @since 7.1
+ * @since 7.2
*/
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
+ * Sets the accessibility prefix for a notification type.
+ * <p>
+ * 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
+ * string that is placed before the notification content
*/
- public void setAssistivePrefixForStyle(String style, String prefix);
+ public void setAssistivePrefix(Type type, 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
+ * Gets the accessibility prefix for a notification type.
+ * <p>
+ * 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 getAssistivePrefixForStyle(String style);
+ public String getAssistivePrefix(Type type);
/**
- * Sets the accessibility postfix for the given notification style.
- *
+ * Sets the accessibility postfix for a notification type.
+ * <p>
* 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 type
+ * type of the notification
* @param postfix
- * String that is placed after the notification content
+ * string that is placed after the notification content
*/
- public void setAssistivePostfixForStyle(String style, String postfix);
+ public void setAssistivePostfix(Type type, String postfix);
/**
- * Returns the accessibility postfix for the given notification style.
- *
+ * Gets the accessibility postfix for a notification type.
+ * <p>
* 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
+ *
+ * @param type
+ * type of the notification
+ * @return The accessibility postfix for the provided notification type
*/
- public String getAssistivePostfixForStyle(String style);
+ public String getAssistivePostfix(Type type);
/**
- * Sets the WAI-ARIA role for a notification style.
- *
+ * Sets the WAI-ARIA role for a notification type.
+ * <p>
* This role defines how an assistive device handles a notification.
- * Available roles are alert, alertdialog and status (@see <a
+ * Available roles are alert and status (@see <a
* href="http://www.w3.org/TR/2011/CR-wai-aria-20110118/roles">Roles
- * Model</a>)
- *
+ * Model</a>).
+ *
* The default role is alert.
- *
- * @param style
- * String of the notification style
+ *
+ * @param type
+ * type of the notification
* @param role
- * Role to set for the notification type
+ * role to set for the notification type
*/
- public void setAssistiveRoleForStyle(String style, Role role);
+ public void setAssistiveRole(Type type, NotificationRole role);
/**
- * Returns the WAI-ARIA role for a notification style.
- *
+ * Gets the WAI-ARIA role for a notification type.
+ * <p>
* This role defines how an assistive device handles a notification.
- * Available roles are alert, alertdialog and status (@see <a
+ * Available roles are alert and status (@see <a
* href="http://www.w3.org/TR/2011/CR-wai-aria-20110118/roles">Roles
- * Model</a> )
- *
+ * Model</a>)
+ * <p>
* The default role is alert.
- *
- * @param style
- * String of the notification style
- * @return The current Role for the notification type
+ *
+ * @param type
+ * type of the notification
+ * @return role to set for the notification type
*/
- public Role getAssistiveRoleForStyle(String style);
+ public NotificationRole getAssistiveRole(Type type);
}
class NotificationConfigurationImpl implements NotificationConfiguration {
@@ -137,133 +124,62 @@ class NotificationConfigurationImpl implements NotificationConfiguration {
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);
+ public void setAssistivePrefix(Type type, String prefix) {
+ getConfigurationBean(type).prefix = prefix;
}
- /*
- * (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);
+ public String getAssistivePrefix(Type type) {
+ NotificationTypeConfiguration styleSetup = getTypeConf(type);
if (styleSetup != null) {
- return styleSetup.getAssistivePrefix();
+ return styleSetup.prefix;
}
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);
+ public void setAssistivePostfix(Type type, String postfix) {
+ getConfigurationBean(type).postfix = 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);
+ public String getAssistivePostfix(Type type) {
+ NotificationTypeConfiguration styleSetup = getTypeConf(type);
if (styleSetup != null) {
- return styleSetup.getAssistivePostfix();
+ return styleSetup.postfix;
}
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);
+ public void setAssistiveRole(Type type, NotificationRole role) {
+ getConfigurationBean(type).notificationRole = 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);
+ public NotificationRole getAssistiveRole(Type type) {
+ NotificationTypeConfiguration styleSetup = getTypeConf(type);
if (styleSetup != null) {
- return styleSetup.getAssistiveRole();
+ return styleSetup.notificationRole;
}
return null;
}
- private NotificationConfigurationBean getConfigurationBean(String style) {
- NotificationConfigurationBean styleSetup = getState().setup.get(style);
+ private NotificationTypeConfiguration getConfigurationBean(Type type) {
+ NotificationTypeConfiguration styleSetup = getTypeConf(type);
if (styleSetup == null) {
- styleSetup = new NotificationConfigurationBean();
- getState().setup.put(style, styleSetup);
+ styleSetup = new NotificationTypeConfiguration();
+ ui.getState().notificationConfigurations.put(type.getStyle(), styleSetup);
}
return styleSetup;
}
- private NotificationConfigurationState getState() {
- return ui.getState().notificationConfiguration;
+ private NotificationTypeConfiguration getTypeConf(Type type) {
+ return ui.getState().notificationConfigurations.get(type.getStyle());
}
-
- private NotificationConfigurationState getState(boolean markAsDirty) {
- return ui.getState(markAsDirty).notificationConfiguration;
- }
-
}
diff --git a/server/src/com/vaadin/ui/TabSheet.java b/server/src/com/vaadin/ui/TabSheet.java
index 8e2c40fc0f..17ea352d49 100644
--- a/server/src/com/vaadin/ui/TabSheet.java
+++ b/server/src/com/vaadin/ui/TabSheet.java
@@ -292,34 +292,7 @@ public class TabSheet extends AbstractComponentContainer implements Focusable,
* @return the created {@link Tab}
*/
public Tab addTab(Component c, String caption, Resource icon) {
- return addTab(c, caption, icon, "", components.size());
- }
-
- /**
- * Adds a new tab into TabSheet.
- *
- * The first tab added to a tab sheet is automatically selected and a tab
- * selection event is fired.
- *
- * If the component is already present in the tab sheet, changes its caption
- * and icon and icon alternate text and returns the corresponding (old) tab,
- * preserving other tab metadata.
- *
- * @param c
- * the component to be added onto tab - should not be null.
- * @param caption
- * the caption to be set for the component and used rendered in
- * tab bar
- * @param icon
- * the icon to be set for the component and used rendered in tab
- * bar
- * @param iconAltText
- * the alternate text for the icon
- * @return the created {@link Tab}
- */
- public Tab addTab(Component c, String caption, Resource icon,
- String iconAltText) {
- return addTab(c, caption, icon, iconAltText, components.size());
+ return addTab(c, caption, icon, components.size());
}
/**
@@ -344,43 +317,13 @@ public class TabSheet extends AbstractComponentContainer implements Focusable,
* the position at where the the tab should be added.
* @return the created {@link Tab}
*/
- public Tab addTab(Component c, String caption, Resource icon, int position) {
- return addTab(c, caption, icon, "", position);
- }
-
- /**
- * Adds a new tab into TabSheet.
- *
- * The first tab added to a tab sheet is automatically selected and a tab
- * selection event is fired.
- *
- * If the component is already present in the tab sheet, changes its caption
- * and icon and icon alternate text and returns the corresponding (old) tab,
- * preserving other tab metadata like the position.
- *
- * @param tabComponent
- * the component to be added onto tab - should not be null.
- * @param caption
- * the caption to be set for the component and used rendered in
- * tab bar
- * @param icon
- * the icon to be set for the component and used rendered in tab
- * bar
- * @param iconAltText
- * the alternate text for the icon
- * @param position
- * the position at where the the tab should be added.
- * @return the created {@link Tab}
- */
- public Tab addTab(Component tabComponent, String caption, Resource icon,
- String iconAltText, int position) {
-
+ public Tab addTab(Component tabComponent, String caption, Resource icon, int position) {
if (tabComponent == null) {
return null;
} else if (tabs.containsKey(tabComponent)) {
Tab tab = tabs.get(tabComponent);
tab.setCaption(caption);
- tab.setIcon(icon, iconAltText);
+ tab.setIcon(icon);
return tab;
} else {
components.add(position, tabComponent);
@@ -461,11 +404,11 @@ public class TabSheet extends AbstractComponentContainer implements Focusable,
Tab tab = ((TabSheet) source).getTab(c);
caption = tab.getCaption();
icon = tab.getIcon();
- iconAltText = tab.getIconAltText();
+ iconAltText = tab.getIconAlternateText();
}
source.removeComponent(c);
- addTab(c, caption, icon, iconAltText);
-
+ Tab tab = addTab(c, caption, icon);
+ tab.setIconAlternateText(iconAltText);
}
}
@@ -968,16 +911,20 @@ public class TabSheet extends AbstractComponentContainer implements Focusable,
/**
* Gets the icon alt text for the tab.
+ *
+ * @since 7.2
*/
- public String getIconAltText();
+ public String getIconAlternateText();
/**
* Sets the icon alt text for the tab.
- *
+ *
+ * @since 7.2
+ *
* @param iconAltText
* the icon to set
*/
- public void setIconAltText(String iconAltText);
+ public void setIconAlternateText(String iconAltText);
/**
* Gets the description for the tab. The description can be used to
@@ -1135,12 +1082,12 @@ public class TabSheet extends AbstractComponentContainer implements Focusable,
}
@Override
- public String getIconAltText() {
+ public String getIconAlternateText() {
return tabState.iconAltText;
}
@Override
- public void setIconAltText(String iconAltText) {
+ public void setIconAlternateText(String iconAltText) {
tabState.iconAltText = iconAltText;
markAsDirty();
}
@@ -1428,7 +1375,7 @@ public class TabSheet extends AbstractComponentContainer implements Focusable,
*/
private static void copyTabMetadata(Tab from, Tab to) {
to.setCaption(from.getCaption());
- to.setIcon(from.getIcon(), from.getIconAltText());
+ to.setIcon(from.getIcon(), from.getIconAlternateText());
to.setDescription(from.getDescription());
to.setVisible(from.isVisible());
to.setEnabled(from.isEnabled());
diff --git a/server/src/com/vaadin/ui/Table.java b/server/src/com/vaadin/ui/Table.java
index 06e82dedcb..e23a1bf688 100644
--- a/server/src/com/vaadin/ui/Table.java
+++ b/server/src/com/vaadin/ui/Table.java
@@ -2647,6 +2647,10 @@ public class Table extends AbstractSelect implements Action.Container,
* new container contains properties that are not meant to be shown you
* should use {@link Table#setContainerDataSource(Container, Collection)}
* instead, especially if the table is editable.
+ * <p>
+ * Keeps propertyValueConverters if the corresponding id exists in the new
+ * data source and is of a compatible type.
+ * </p>
*
* @param newDataSource
* the new data source.
@@ -2681,9 +2685,14 @@ public class Table extends AbstractSelect implements Action.Container,
/**
* Sets the container data source and the columns that will be visible.
* Columns are shown in the collection's iteration order.
+ * <p>
+ * Keeps propertyValueConverters if the corresponding id exists in the new
+ * data source and is of a compatible type.
+ * </p>
*
* @see Table#setContainerDataSource(Container)
* @see Table#setVisibleColumns(Object[])
+ * @see Table#setConverter(Object, Converter<String, ?>)
*
* @param newDataSource
* the new data source.
@@ -2702,6 +2711,26 @@ public class Table extends AbstractSelect implements Action.Container,
visibleIds = new ArrayList<Object>();
}
+ // Retain propertyValueConverters if their corresponding ids are
+ // properties of the new
+ // data source and are of a compatible type
+ if (propertyValueConverters != null) {
+ Collection<?> newPropertyIds = newDataSource
+ .getContainerPropertyIds();
+ LinkedList<Object> retainableValueConverters = new LinkedList<Object>();
+ for (Object propertyId : newPropertyIds) {
+ Converter<String, ?> converter = getConverter(propertyId);
+ if (converter != null) {
+ if (typeIsCompatible(converter.getModelType(),
+ newDataSource.getType(propertyId))) {
+ retainableValueConverters.add(propertyId);
+ }
+ }
+ }
+ propertyValueConverters.keySet().retainAll(
+ retainableValueConverters);
+ }
+
// Assures that the data source is ordered by making unordered
// containers ordered by wrapping them
if (newDataSource instanceof Container.Ordered) {
@@ -2738,6 +2767,20 @@ public class Table extends AbstractSelect implements Action.Container,
}
/**
+ * Checks if class b can be safely assigned to class a.
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ private boolean typeIsCompatible(Class<?> a, Class<?> b) {
+ // TODO Implement this check properly
+ // Basically we need to do a a.isAssignableFrom(b)
+ // with special considerations for primitive types.
+ return true;
+ }
+
+ /**
* Gets items ids from a range of key values
*
* @param startRowKey
@@ -4229,6 +4272,8 @@ public class Table extends AbstractSelect implements Action.Container,
columnIcons.remove(propertyId);
columnHeaders.remove(propertyId);
columnFooters.remove(propertyId);
+ // If a propertyValueConverter was defined for the property, remove it.
+ propertyValueConverters.remove(propertyId);
return super.removeContainerProperty(propertyId);
}
@@ -5844,16 +5889,13 @@ public class Table extends AbstractSelect implements Action.Container,
throw new IllegalArgumentException("PropertyId " + propertyId
+ " must be in the container");
}
- // FIXME: This check should be here but primitive types like Boolean
- // formatter for boolean property must be handled
- // if (!converter.getSourceType().isAssignableFrom(getType(propertyId)))
- // {
- // throw new IllegalArgumentException("Property type ("
- // + getType(propertyId)
- // + ") must match converter source type ("
- // + converter.getSourceType() + ")");
- // }
+ if (!typeIsCompatible(converter.getModelType(), getType(propertyId))) {
+ throw new IllegalArgumentException("Property type ("
+ + getType(propertyId)
+ + ") must match converter source type ("
+ + converter.getModelType() + ")");
+ }
propertyValueConverters.put(propertyId,
(Converter<String, Object>) converter);
refreshRowCache();
diff --git a/server/src/com/vaadin/ui/UI.java b/server/src/com/vaadin/ui/UI.java
index 275aeb4c79..3ae0aea6f7 100644
--- a/server/src/com/vaadin/ui/UI.java
+++ b/server/src/com/vaadin/ui/UI.java
@@ -669,10 +669,10 @@ public abstract class UI extends AbstractSingleComponentContainer implements
* @param request
* the request that caused this UI to be reloaded
*/
- public void doReinit(VaadinRequest request) {
+ public void doRefresh(VaadinRequest request) {
// This is a horrible hack. We want to have the most recent location and
- // browser window size available in reinit(), but we want to call
- // listeners, if any, only after reinit(). So we momentarily assign the
+ // browser window size available in refresh(), but we want to call
+ // listeners, if any, only after refresh(). So we momentarily assign the
// old values back before setting the new values again to ensure the
// events are properly fired.
@@ -684,7 +684,7 @@ public abstract class UI extends AbstractSingleComponentContainer implements
page.init(request);
- reinit(request);
+ refresh(request);
URI newLocation = page.getLocation();
int newWidth = page.getBrowserWindowWidth();
@@ -710,7 +710,7 @@ public abstract class UI extends AbstractSingleComponentContainer implements
* @param request
* the request that caused this UI to be reloaded
*/
- protected void reinit(VaadinRequest request) {
+ protected void refresh(VaadinRequest request) {
}
/**
diff --git a/server/src/com/vaadin/ui/Window.java b/server/src/com/vaadin/ui/Window.java
index d3afdaacf1..11a6fde853 100644
--- a/server/src/com/vaadin/ui/Window.java
+++ b/server/src/com/vaadin/ui/Window.java
@@ -18,9 +18,6 @@ package com.vaadin.ui;
import java.io.Serializable;
import java.lang.reflect.Method;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
import java.util.Map;
import com.vaadin.event.FieldEvents.BlurEvent;
@@ -41,7 +38,7 @@ import com.vaadin.shared.MouseEventDetails;
import com.vaadin.shared.ui.window.WindowMode;
import com.vaadin.shared.ui.window.WindowServerRpc;
import com.vaadin.shared.ui.window.WindowState;
-import com.vaadin.shared.ui.window.WindowState.WindowRole;
+import com.vaadin.shared.ui.window.WindowRole;
import com.vaadin.util.ReflectTools;
/**
@@ -1017,15 +1014,15 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier,
* window. Text contained in these components will be read by assistive
* devices when it is opened.
*
- * @param connectors
- * with the components to use as description
+ * @param components
+ * the components to use as description
*/
- public void setAssistiveDescription(Connector... connectors) {
- if (connectors == null) {
+ public void setAssistiveDescription(Component... components) {
+ if (components == null) {
throw new IllegalArgumentException(
"Parameter connectors must be non-null");
} else {
- getState().contentDescription = connectors;
+ getState().contentDescription = components;
}
}
@@ -1034,11 +1031,19 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier,
* contained in these components will be read by assistive devices when the
* window is opened.
*
- * @return list of previously set components
+ * @return array of previously set components
*/
- public List<Connector> getAssistiveDescription() {
- return Collections.unmodifiableList(Arrays
- .asList(getState().contentDescription));
+ public Component[] getAssistiveDescription() {
+ Connector[] contentDescription = getState().contentDescription;
+ if (contentDescription == null) {
+ return null;
+ }
+
+ Component[] target = new Component[contentDescription.length];
+ System.arraycopy(contentDescription, 0, target, 0,
+ contentDescription.length);
+
+ return target;
}
/**
diff --git a/server/src/com/vaadin/ui/components/calendar/ContainerEventProvider.java b/server/src/com/vaadin/ui/components/calendar/ContainerEventProvider.java
index 37ea255d27..b025de6f9a 100644
--- a/server/src/com/vaadin/ui/components/calendar/ContainerEventProvider.java
+++ b/server/src/com/vaadin/ui/components/calendar/ContainerEventProvider.java
@@ -224,8 +224,8 @@ public class ContainerEventProvider implements CalendarEditableEventProvider,
}
if (styleNameProperty != null
&& item.getItemPropertyIds().contains(styleNameProperty)) {
- basicEvent.setDescription(String.valueOf(item.getItemProperty(
- descriptionProperty).getValue()));
+ basicEvent.setStyleName(String.valueOf(item.getItemProperty(
+ styleNameProperty).getValue()));
}
event = basicEvent;
}