diff options
author | Teemu Suo-Anttila <teemusa@vaadin.com> | 2017-03-01 14:27:49 +0200 |
---|---|---|
committer | Henri Sara <henri.sara@gmail.com> | 2017-03-07 12:36:54 +0200 |
commit | f5c15b9b2bcc4eeef210a5977449c76f3b952209 (patch) | |
tree | 6358ed330e0d2baa68d8cdbc5bc5f3893406f236 /compatibility-server | |
parent | 0cfb20938f2b15767ebbd367ad8312642b947c8c (diff) | |
download | vaadin-framework-f5c15b9b2bcc4eeef210a5977449c76f3b952209.tar.gz vaadin-framework-f5c15b9b2bcc4eeef210a5977449c76f3b952209.zip |
Synchronize code between V7 and compatibility package
Diffstat (limited to 'compatibility-server')
56 files changed, 440 insertions, 342 deletions
diff --git a/compatibility-server/src/main/java/com/vaadin/server/GAEVaadinServlet.java b/compatibility-server/src/main/java/com/vaadin/server/GAEVaadinServlet.java index 6cc933e670..5b25a48ba9 100644 --- a/compatibility-server/src/main/java/com/vaadin/server/GAEVaadinServlet.java +++ b/compatibility-server/src/main/java/com/vaadin/server/GAEVaadinServlet.java @@ -344,7 +344,13 @@ public class GAEVaadinServlet extends VaadinServlet { VaadinSession vaadinSession = (VaadinSession) ois.readObject(); getService().storeSession(vaadinSession, new WrappedHttpSession(session)); - } catch (IOException | ClassNotFoundException e) { + } catch (IOException e) { + getLogger().log(Level.WARNING, + "Could not de-serialize ApplicationContext for " + + session.getId() + + " A new one will be created. ", + e); + } catch (ClassNotFoundException e) { getLogger().log(Level.WARNING, "Could not de-serialize ApplicationContext for " + session.getId() diff --git a/compatibility-server/src/main/java/com/vaadin/v7/data/Buffered.java b/compatibility-server/src/main/java/com/vaadin/v7/data/Buffered.java index 2bd55555b3..438376923e 100644 --- a/compatibility-server/src/main/java/com/vaadin/v7/data/Buffered.java +++ b/compatibility-server/src/main/java/com/vaadin/v7/data/Buffered.java @@ -180,6 +180,7 @@ public interface Buffered extends Serializable { return source; } + // Intentional change in compatibility package @Override public ErrorMessage getErrorMessage() { // no message, only the causes to be painted diff --git a/compatibility-server/src/main/java/com/vaadin/v7/data/Validator.java b/compatibility-server/src/main/java/com/vaadin/v7/data/Validator.java index 200ed93779..9167dd2c67 100644 --- a/compatibility-server/src/main/java/com/vaadin/v7/data/Validator.java +++ b/compatibility-server/src/main/java/com/vaadin/v7/data/Validator.java @@ -167,6 +167,7 @@ public interface Validator extends Serializable { return causes; } + // Intentional change in compatibility package @Override public ErrorMessage getErrorMessage() { UserError error = new UserError(getHtmlMessage(), ContentMode.HTML, diff --git a/compatibility-server/src/main/java/com/vaadin/v7/data/fieldgroup/DefaultFieldGroupFieldFactory.java b/compatibility-server/src/main/java/com/vaadin/v7/data/fieldgroup/DefaultFieldGroupFieldFactory.java index 0fd03c21ad..3a2d5cd526 100644 --- a/compatibility-server/src/main/java/com/vaadin/v7/data/fieldgroup/DefaultFieldGroupFieldFactory.java +++ b/compatibility-server/src/main/java/com/vaadin/v7/data/fieldgroup/DefaultFieldGroupFieldFactory.java @@ -160,7 +160,7 @@ public class DefaultFieldGroupFieldFactory implements FieldGroupFieldFactory { * @since 7.4 * @param fieldType * the type of the field - * @return true if any LegacyAbstractField can be assigned to the field + * @return true if any AbstractField can be assigned to the field */ protected boolean anyField(Class<?> fieldType) { return fieldType == Field.class || fieldType == AbstractField.class; diff --git a/compatibility-server/src/main/java/com/vaadin/v7/data/fieldgroup/FieldGroup.java b/compatibility-server/src/main/java/com/vaadin/v7/data/fieldgroup/FieldGroup.java index a56703090f..40802512cb 100644 --- a/compatibility-server/src/main/java/com/vaadin/v7/data/fieldgroup/FieldGroup.java +++ b/compatibility-server/src/main/java/com/vaadin/v7/data/fieldgroup/FieldGroup.java @@ -39,8 +39,10 @@ import com.vaadin.v7.ui.Field; * FieldGroup provides an easy way of binding fields to data and handling * commits of these fields. * <p> - * The typical use case is to create a layout outside the FieldGroup and then - * use FieldGroup to bind the fields to a data source. + * The functionality of FieldGroup is similar to {@link Form} but + * {@link FieldGroup} does not handle layouts in any way. The typical use case + * is to create a layout outside the FieldGroup and then use FieldGroup to bind + * the fields to a data source. * </p> * <p> * {@link FieldGroup} is not a UI component so it cannot be added to a layout. @@ -991,7 +993,7 @@ public class FieldGroup implements Serializable { .createCaptionByPropertyId(propertyId); } - // Create the component (LegacyField) + // Create the component (Field) field = build(caption, propertyType, fieldType); // Store it in the field @@ -1217,7 +1219,7 @@ public class FieldGroup implements Serializable { * <p> * The data type is the type that we want to edit using the field. The field * type is the type of field we want to create, can be {@link Field} if any - * LegacyField is good. + * Field is good. * </p> * * @param caption @@ -1226,7 +1228,7 @@ public class FieldGroup implements Serializable { * The data model type that we want to edit using the field * @param fieldType * The type of field that we want to create - * @return A LegacyField capable of editing the given type + * @return A Field capable of editing the given type * @throws BindException * If the field could not be created */ @@ -1244,9 +1246,9 @@ public class FieldGroup implements Serializable { } /** - * Returns an array containing LegacyField objects reflecting all the fields - * of the class or interface represented by this Class object. The elements - * in the array returned are sorted in declare order from sub class to super + * Returns an array containing Field objects reflecting all the fields of + * the class or interface represented by this Class object. The elements in + * the array returned are sorted in declare order from sub class to super * class. * * @param searchClass diff --git a/compatibility-server/src/main/java/com/vaadin/v7/data/fieldgroup/FieldGroupFieldFactory.java b/compatibility-server/src/main/java/com/vaadin/v7/data/fieldgroup/FieldGroupFieldFactory.java index cf9c4d8fcc..4a62a19aaa 100644 --- a/compatibility-server/src/main/java/com/vaadin/v7/data/fieldgroup/FieldGroupFieldFactory.java +++ b/compatibility-server/src/main/java/com/vaadin/v7/data/fieldgroup/FieldGroupFieldFactory.java @@ -20,8 +20,8 @@ import java.io.Serializable; import com.vaadin.v7.ui.Field; /** - * Factory interface for creating new LegacyField-instances based on the data - * type that should be edited. + * Factory interface for creating new Field-instances based on the data type + * that should be edited. * * @author Vaadin Ltd. * @since 7.0 diff --git a/compatibility-server/src/main/java/com/vaadin/v7/data/util/AbstractBeanContainer.java b/compatibility-server/src/main/java/com/vaadin/v7/data/util/AbstractBeanContainer.java index 70ce642456..1ec6bad129 100644 --- a/compatibility-server/src/main/java/com/vaadin/v7/data/util/AbstractBeanContainer.java +++ b/compatibility-server/src/main/java/com/vaadin/v7/data/util/AbstractBeanContainer.java @@ -174,11 +174,6 @@ public abstract class AbstractBeanContainer<IDTYPE, BEANTYPE> model = BeanItem.getPropertyDescriptors((Class<BEANTYPE>) type); } - /* - * (non-Javadoc) - * - * @see com.vaadin.data.Container#getType(java.lang.Object) - */ @Override public Class<?> getType(Object propertyId) { VaadinPropertyDescriptor<BEANTYPE> descriptor = model.get(propertyId); @@ -211,21 +206,11 @@ public abstract class AbstractBeanContainer<IDTYPE, BEANTYPE> return type; } - /* - * (non-Javadoc) - * - * @see com.vaadin.data.Container#getContainerPropertyIds() - */ @Override public Collection<String> getContainerPropertyIds() { return model.keySet(); } - /* - * (non-Javadoc) - * - * @see com.vaadin.data.Container#removeAllItems() - */ @Override public boolean removeAllItems() { int origSize = size(); @@ -248,11 +233,6 @@ public abstract class AbstractBeanContainer<IDTYPE, BEANTYPE> return true; } - /* - * (non-Javadoc) - * - * @see com.vaadin.data.Container#getItem(java.lang.Object) - */ @Override public BeanItem<BEANTYPE> getItem(Object itemId) { // TODO return only if visible? @@ -264,23 +244,12 @@ public abstract class AbstractBeanContainer<IDTYPE, BEANTYPE> return itemIdToItem.get(itemId); } - /* - * (non-Javadoc) - * - * @see com.vaadin.data.Container#getItemIds() - */ @Override @SuppressWarnings("unchecked") public List<IDTYPE> getItemIds() { return (List<IDTYPE>) super.getItemIds(); } - /* - * (non-Javadoc) - * - * @see com.vaadin.data.Container#getContainerProperty(java.lang.Object, - * java.lang.Object) - */ @Override public Property getContainerProperty(Object itemId, Object propertyId) { Item item = getItem(itemId); @@ -290,11 +259,6 @@ public abstract class AbstractBeanContainer<IDTYPE, BEANTYPE> return item.getItemProperty(propertyId); } - /* - * (non-Javadoc) - * - * @see com.vaadin.data.Container#removeItem(java.lang.Object) - */ @Override public boolean removeItem(Object itemId) { // TODO should also remove items that are filtered out @@ -330,13 +294,6 @@ public abstract class AbstractBeanContainer<IDTYPE, BEANTYPE> filterAll(); } - /* - * (non-Javadoc) - * - * @see - * com.vaadin.data.Container.Filterable#addContainerFilter(java.lang.Object, - * java.lang.String, boolean, boolean) - */ @Override public void addContainerFilter(Object propertyId, String filterString, boolean ignoreCase, boolean onlyMatchPrefix) { @@ -349,11 +306,6 @@ public abstract class AbstractBeanContainer<IDTYPE, BEANTYPE> } } - /* - * (non-Javadoc) - * - * @see com.vaadin.data.Container.Filterable#removeAllContainerFilters() - */ @Override public void removeAllContainerFilters() { if (!getFilters().isEmpty()) { @@ -364,13 +316,6 @@ public abstract class AbstractBeanContainer<IDTYPE, BEANTYPE> } } - /* - * (non-Javadoc) - * - * @see - * com.vaadin.data.Container.Filterable#removeContainerFilters(java.lang - * .Object) - */ @Override public void removeContainerFilters(Object propertyId) { Collection<Filter> removedFilters = super.removeFilters(propertyId); @@ -393,21 +338,11 @@ public abstract class AbstractBeanContainer<IDTYPE, BEANTYPE> removeFilter(filter); } - /* - * (non-Javadoc) - * - * @see com.vaadin.data.util.AbstractInMemoryContainer#hasContainerFilters() - */ @Override public boolean hasContainerFilters() { return super.hasContainerFilters(); } - /* - * (non-Javadoc) - * - * @see com.vaadin.data.util.AbstractInMemoryContainer#getContainerFilters() - */ @Override public Collection<Filter> getContainerFilters() { return super.getContainerFilters(); @@ -461,22 +396,11 @@ public abstract class AbstractBeanContainer<IDTYPE, BEANTYPE> } } - /* - * (non-Javadoc) - * - * @see com.vaadin.data.Container.Sortable#getSortableContainerPropertyIds() - */ @Override public Collection<?> getSortableContainerPropertyIds() { return getSortablePropertyIds(); } - /* - * (non-Javadoc) - * - * @see com.vaadin.data.Container.Sortable#sort(java.lang.Object[], - * boolean[]) - */ @Override public void sort(Object[] propertyId, boolean[] ascending) { sortContainer(propertyId, ascending); diff --git a/compatibility-server/src/main/java/com/vaadin/v7/data/util/AbstractInMemoryContainer.java b/compatibility-server/src/main/java/com/vaadin/v7/data/util/AbstractInMemoryContainer.java index 2f7346d2db..ea7b1ca570 100644 --- a/compatibility-server/src/main/java/com/vaadin/v7/data/util/AbstractInMemoryContainer.java +++ b/compatibility-server/src/main/java/com/vaadin/v7/data/util/AbstractInMemoryContainer.java @@ -595,11 +595,6 @@ public abstract class AbstractInMemoryContainer<ITEMIDTYPE, PROPERTYIDCLASS, ITE return !getContainerFilters().isEmpty(); } - /* - * (non-Javadoc) - * - * @see com.vaadin.data.Container.Filterable#getContainerFilters() - */ protected Collection<Filter> getContainerFilters() { return Collections.unmodifiableCollection(filters); } diff --git a/compatibility-server/src/main/java/com/vaadin/v7/data/util/AbstractProperty.java b/compatibility-server/src/main/java/com/vaadin/v7/data/util/AbstractProperty.java index 86d6b85bc8..9c084f4bbb 100644 --- a/compatibility-server/src/main/java/com/vaadin/v7/data/util/AbstractProperty.java +++ b/compatibility-server/src/main/java/com/vaadin/v7/data/util/AbstractProperty.java @@ -70,6 +70,8 @@ public abstract class AbstractProperty<T> implements Property<T>, } } + // LegacyPropertyHelper has been removed in Vaadin 8 + /* Events */ /** diff --git a/compatibility-server/src/main/java/com/vaadin/v7/data/util/BeanItem.java b/compatibility-server/src/main/java/com/vaadin/v7/data/util/BeanItem.java index 28213d77dc..3a175ac9ee 100644 --- a/compatibility-server/src/main/java/com/vaadin/v7/data/util/BeanItem.java +++ b/compatibility-server/src/main/java/com/vaadin/v7/data/util/BeanItem.java @@ -253,7 +253,7 @@ public class BeanItem<BT> extends PropertysetItem { */ public void addNestedProperty(String nestedPropertyId) { addItemProperty(nestedPropertyId, - new NestedMethodProperty<BT>(getBean(), nestedPropertyId)); + new NestedMethodProperty<Object>(getBean(), nestedPropertyId)); } /** @@ -278,6 +278,7 @@ public class BeanItem<BT> extends PropertysetItem { * * @param bean * The new bean to use for this item, not <code>null</code> + * @since 7.7.7 */ public void setBean(BT bean) { if (bean == null) { diff --git a/compatibility-server/src/main/java/com/vaadin/v7/data/util/HierarchicalContainer.java b/compatibility-server/src/main/java/com/vaadin/v7/data/util/HierarchicalContainer.java index e0b95bfe14..8e33aee66e 100644 --- a/compatibility-server/src/main/java/com/vaadin/v7/data/util/HierarchicalContainer.java +++ b/compatibility-server/src/main/java/com/vaadin/v7/data/util/HierarchicalContainer.java @@ -402,11 +402,6 @@ public class HierarchicalContainer extends IndexedContainer } - /* - * (non-Javadoc) - * - * @see com.vaadin.data.util.IndexedContainer#addItem() - */ @Override public Object addItem() { disableContentsChangeEvents(); @@ -463,11 +458,6 @@ public class HierarchicalContainer extends IndexedContainer } } - /* - * (non-Javadoc) - * - * @see com.vaadin.data.util.IndexedContainer#addItem(java.lang.Object) - */ @Override public Item addItem(Object itemId) { disableContentsChangeEvents(); @@ -490,11 +480,6 @@ public class HierarchicalContainer extends IndexedContainer } } - /* - * (non-Javadoc) - * - * @see com.vaadin.data.util.IndexedContainer#removeAllItems() - */ @Override public boolean removeAllItems() { disableContentsChangeEvents(); @@ -522,11 +507,6 @@ public class HierarchicalContainer extends IndexedContainer } } - /* - * (non-Javadoc) - * - * @see com.vaadin.data.util.IndexedContainer#removeItem(java.lang.Object ) - */ @Override public boolean removeItem(Object itemId) { disableContentsChangeEvents(); @@ -647,11 +627,6 @@ public class HierarchicalContainer extends IndexedContainer } - /* - * (non-Javadoc) - * - * @see com.vaadin.data.util.IndexedContainer#doSort() - */ @Override protected void doSort() { super.doSort(); @@ -693,13 +668,6 @@ public class HierarchicalContainer extends IndexedContainer } } - /* - * Overridden to provide filtering for root & children items. - * - * (non-Javadoc) - * - * @see com.vaadin.data.util.IndexedContainer#updateContainerFiltering() - */ @Override protected boolean doFilterContainer(boolean hasFilters) { if (!hasFilters) { @@ -839,12 +807,6 @@ public class HierarchicalContainer extends IndexedContainer private Set<Object> filterOverride = null; - /* - * (non-Javadoc) - * - * @see - * com.vaadin.data.util.IndexedContainer#passesFilters(java.lang.Object) - */ @Override protected boolean passesFilters(Object itemId) { if (filterOverride != null) { diff --git a/compatibility-server/src/main/java/com/vaadin/v7/data/util/IndexedContainer.java b/compatibility-server/src/main/java/com/vaadin/v7/data/util/IndexedContainer.java index 1e755f1a54..3fada79577 100644 --- a/compatibility-server/src/main/java/com/vaadin/v7/data/util/IndexedContainer.java +++ b/compatibility-server/src/main/java/com/vaadin/v7/data/util/IndexedContainer.java @@ -869,6 +869,8 @@ public class IndexedContainer firePropertyValueChange(this); } + // LegacyPropertyHelper has been removed in Vaadin 8 + /** * Calculates a integer hash-code for the Property that's unique inside * the Item containing the Property. Two different Properties inside the @@ -982,13 +984,13 @@ public class IndexedContainer ? (ListSet<Object>) ((ListSet<Object>) getAllItemIds()).clone() : null); nc.setItemSetChangeListeners(getItemSetChangeListeners() != null - ? new LinkedList<ItemSetChangeListener>( + ? new LinkedList<Container.ItemSetChangeListener>( getItemSetChangeListeners()) : null); nc.propertyIds = propertyIds != null ? (ArrayList<Object>) propertyIds.clone() : null; nc.setPropertySetChangeListeners(getPropertySetChangeListeners() != null - ? new LinkedList<PropertySetChangeListener>( + ? new LinkedList<Container.PropertySetChangeListener>( getPropertySetChangeListeners()) : null); nc.propertyValueChangeListeners = propertyValueChangeListeners != null diff --git a/compatibility-server/src/main/java/com/vaadin/v7/data/util/MethodProperty.java b/compatibility-server/src/main/java/com/vaadin/v7/data/util/MethodProperty.java index e3651d0272..87d56bb4c9 100644 --- a/compatibility-server/src/main/java/com/vaadin/v7/data/util/MethodProperty.java +++ b/compatibility-server/src/main/java/com/vaadin/v7/data/util/MethodProperty.java @@ -773,6 +773,7 @@ public class MethodProperty<T> extends AbstractProperty<T> { * The instance used by this property * * @return the instance used for fetching the property value + * @since 7.7.7 */ public Object getInstance() { return instance; @@ -788,6 +789,7 @@ public class MethodProperty<T> extends AbstractProperty<T> { * * @param instance * the instance to use + * @since 7.7.7 */ public void setInstance(Object instance) { if (this.instance.getClass() != instance.getClass()) { diff --git a/compatibility-server/src/main/java/com/vaadin/v7/data/util/NestedMethodProperty.java b/compatibility-server/src/main/java/com/vaadin/v7/data/util/NestedMethodProperty.java index de1561034c..3657a70266 100644 --- a/compatibility-server/src/main/java/com/vaadin/v7/data/util/NestedMethodProperty.java +++ b/compatibility-server/src/main/java/com/vaadin/v7/data/util/NestedMethodProperty.java @@ -272,6 +272,7 @@ public class NestedMethodProperty<T> extends AbstractProperty<T> { * The instance used by this property * * @return the instance used for fetching the property value + * @since 7.7.7 */ public Object getInstance() { return instance; @@ -287,6 +288,7 @@ public class NestedMethodProperty<T> extends AbstractProperty<T> { * * @param instance * the instance to use + * @since 7.7.7 */ public void setInstance(Object instance) { if (this.instance.getClass() != instance.getClass()) { diff --git a/compatibility-server/src/main/java/com/vaadin/v7/data/util/NestedPropertyDescriptor.java b/compatibility-server/src/main/java/com/vaadin/v7/data/util/NestedPropertyDescriptor.java index a0cfae040c..cd41d887ed 100644 --- a/compatibility-server/src/main/java/com/vaadin/v7/data/util/NestedPropertyDescriptor.java +++ b/compatibility-server/src/main/java/com/vaadin/v7/data/util/NestedPropertyDescriptor.java @@ -50,7 +50,7 @@ public class NestedPropertyDescriptor<BT> public NestedPropertyDescriptor(String name, Class<BT> beanType) throws IllegalArgumentException { this.name = name; - NestedMethodProperty<?> property = new NestedMethodProperty<BT>( + NestedMethodProperty<?> property = new NestedMethodProperty<Object>( beanType, name); this.propertyType = property.getType(); } @@ -67,7 +67,7 @@ public class NestedPropertyDescriptor<BT> @Override public Property<?> createProperty(BT bean) { - return new NestedMethodProperty<BT>(bean, name); + return new NestedMethodProperty<Object>(bean, name); } } diff --git a/compatibility-server/src/main/java/com/vaadin/v7/data/util/PropertysetItem.java b/compatibility-server/src/main/java/com/vaadin/v7/data/util/PropertysetItem.java index 05a2b55ea7..b60b0ed98b 100644 --- a/compatibility-server/src/main/java/com/vaadin/v7/data/util/PropertysetItem.java +++ b/compatibility-server/src/main/java/com/vaadin/v7/data/util/PropertysetItem.java @@ -205,7 +205,7 @@ public class PropertysetItem public void addPropertySetChangeListener( Item.PropertySetChangeListener listener) { if (propertySetChangeListeners == null) { - propertySetChangeListeners = new LinkedList<Item.PropertySetChangeListener>(); + propertySetChangeListeners = new LinkedList<PropertySetChangeListener>(); } propertySetChangeListeners.add(listener); } diff --git a/compatibility-server/src/main/java/com/vaadin/v7/data/util/converter/ConverterUtil.java b/compatibility-server/src/main/java/com/vaadin/v7/data/util/converter/ConverterUtil.java index a93489a0b4..9d1580af9e 100644 --- a/compatibility-server/src/main/java/com/vaadin/v7/data/util/converter/ConverterUtil.java +++ b/compatibility-server/src/main/java/com/vaadin/v7/data/util/converter/ConverterUtil.java @@ -52,6 +52,7 @@ public class ConverterUtil implements Serializable { } if (session != null) { + // Intentional change in compatibility package ConverterFactory factory = (ConverterFactory) session .getConverterFactory(); if (factory == null) { diff --git a/compatibility-server/src/main/java/com/vaadin/v7/data/util/sqlcontainer/ColumnProperty.java b/compatibility-server/src/main/java/com/vaadin/v7/data/util/sqlcontainer/ColumnProperty.java index 3440179e6a..4013915aa7 100644 --- a/compatibility-server/src/main/java/com/vaadin/v7/data/util/sqlcontainer/ColumnProperty.java +++ b/compatibility-server/src/main/java/com/vaadin/v7/data/util/sqlcontainer/ColumnProperty.java @@ -254,6 +254,8 @@ final public class ColumnProperty implements Property { return propertyId; } + // LegacyPropertyHelper has been removed in Vaadin 8 + private static Logger getLogger() { return Logger.getLogger(ColumnProperty.class.getName()); } diff --git a/compatibility-server/src/main/java/com/vaadin/v7/data/util/sqlcontainer/SQLContainer.java b/compatibility-server/src/main/java/com/vaadin/v7/data/util/sqlcontainer/SQLContainer.java index f18940da8b..38542272ee 100644 --- a/compatibility-server/src/main/java/com/vaadin/v7/data/util/sqlcontainer/SQLContainer.java +++ b/compatibility-server/src/main/java/com/vaadin/v7/data/util/sqlcontainer/SQLContainer.java @@ -1419,7 +1419,7 @@ public class SQLContainer implements Container, Container.Filterable, public void addItemSetChangeListener( Container.ItemSetChangeListener listener) { if (itemSetChangeListeners == null) { - itemSetChangeListeners = new LinkedList<ItemSetChangeListener>(); + itemSetChangeListeners = new LinkedList<Container.ItemSetChangeListener>(); } itemSetChangeListeners.add(listener); } diff --git a/compatibility-server/src/main/java/com/vaadin/v7/data/validator/DoubleValidator.java b/compatibility-server/src/main/java/com/vaadin/v7/data/validator/DoubleValidator.java index 7354a9aa06..ef8dde86f4 100644 --- a/compatibility-server/src/main/java/com/vaadin/v7/data/validator/DoubleValidator.java +++ b/compatibility-server/src/main/java/com/vaadin/v7/data/validator/DoubleValidator.java @@ -28,8 +28,8 @@ import com.vaadin.v7.data.util.converter.StringToDoubleConverter; * field instead or bind the field to a {@link Property} of type * {@link Double}. */ -@SuppressWarnings("serial") @Deprecated +@SuppressWarnings("serial") public class DoubleValidator extends AbstractStringValidator { /** diff --git a/compatibility-server/src/main/java/com/vaadin/v7/ui/AbstractField.java b/compatibility-server/src/main/java/com/vaadin/v7/ui/AbstractField.java index 59e078e378..3f2b1d5c1f 100644 --- a/compatibility-server/src/main/java/com/vaadin/v7/ui/AbstractField.java +++ b/compatibility-server/src/main/java/com/vaadin/v7/ui/AbstractField.java @@ -55,16 +55,15 @@ import com.vaadin.v7.shared.AbstractFieldState; * <p> * Abstract field component for implementing buffered property editors. The * field may hold an internal value, or it may be connected to any data source - * that implements the {@link Property}interface. - * <code>LegacyAbstractField</code> implements that interface itself, too, so - * accessing the Property value represented by it is straightforward. + * that implements the {@link Property} interface. <code>AbstractField</code> + * implements that interface itself, too, so accessing the Property value + * represented by it is straightforward. * </p> * * <p> - * LegacyAbstractField also provides the {@link Buffered} interface for - * buffering the data source value. By default the LegacyField is in write - * through-mode and {@link #setWriteThrough(boolean)}should be called to enable - * buffering. + * AbstractField also provides the {@link Buffered} interface for buffering the + * data source value. By default the Field is in write through-mode and + * {@link #setWriteThrough(boolean)}should be called to enable buffering. * </p> * * <p> @@ -193,13 +192,13 @@ public abstract class AbstractField<T> extends AbstractLegacyComponent } /** - * Returns the type of the LegacyField. The methods <code>getValue</code> - * and <code>setValue</code> must be compatible with this type: one must be - * able to safely cast the value returned from <code>getValue</code> to the - * given type and pass any variable assignable to this type as an argument - * to <code>setValue</code>. + * Returns the type of the Field. The methods <code>getValue</code> and + * <code>setValue</code> must be compatible with this type: one must be able + * to safely cast the value returned from <code>getValue</code> to the given + * type and pass any variable assignable to this type as an argument to + * <code>setValue</code>. * - * @return the type of the LegacyField + * @return the type of the Field */ @Override public abstract Class<? extends T> getType(); @@ -348,7 +347,7 @@ public abstract class AbstractField<T> extends AbstractLegacyComponent } /** - * Sets the buffered mode of this LegacyField. + * Sets the buffered mode of this Field. * <p> * When the field is in buffered mode, changes will not be committed to the * property data source until {@link #commit()} is called. @@ -376,7 +375,7 @@ public abstract class AbstractField<T> extends AbstractLegacyComponent } /** - * Checks the buffered mode of this LegacyField. + * Checks the buffered mode of this Field. * * @return true if buffered mode is on, false otherwise */ @@ -385,6 +384,8 @@ public abstract class AbstractField<T> extends AbstractLegacyComponent return buffered; } + // LegacyPropertyHelper has been removed in Vaadin 8 + /* Property interface implementation */ /** @@ -913,7 +914,7 @@ public abstract class AbstractField<T> extends AbstractLegacyComponent } /** - * Checks the validity of the LegacyField. + * Checks the validity of the Field. * * A field is invalid if it is set as required (using * {@link #setRequired(boolean)} and is empty, if one or several of the @@ -1079,7 +1080,7 @@ public abstract class AbstractField<T> extends AbstractLegacyComponent } catch (final java.lang.NoSuchMethodException e) { // This should never happen throw new java.lang.RuntimeException( - "Internal error finding methods in LegacyAbstractField"); + "Internal error finding methods in AbstractField"); } } @@ -1152,7 +1153,7 @@ public abstract class AbstractField<T> extends AbstractLegacyComponent } catch (final java.lang.NoSuchMethodException e) { // This should never happen throw new java.lang.RuntimeException( - "Internal error finding methods in LegacyAbstractField"); + "Internal error finding methods in AbstractField"); } } @@ -1348,10 +1349,10 @@ public abstract class AbstractField<T> extends AbstractLegacyComponent } /** - * Sets the internal field value. This is purely used by LegacyAbstractField - * to change the internal LegacyField value. It does not trigger valuechange - * events. It can be overridden by the inheriting classes to update all - * dependent variables. + * Sets the internal field value. This is purely used by AbstractField to + * change the internal Field value. It does not trigger valuechange events. + * It can be overridden by the inheriting classes to update all dependent + * variables. * * Subclasses can also override {@link #getInternalValue()} if necessary. * diff --git a/compatibility-server/src/main/java/com/vaadin/v7/ui/AbstractTextField.java b/compatibility-server/src/main/java/com/vaadin/v7/ui/AbstractTextField.java index 482dd0b2af..5fa82535bc 100644 --- a/compatibility-server/src/main/java/com/vaadin/v7/ui/AbstractTextField.java +++ b/compatibility-server/src/main/java/com/vaadin/v7/ui/AbstractTextField.java @@ -460,8 +460,8 @@ public abstract class AbstractTextField extends AbstractField<String> implements * Make sure w reset lastKnownTextContent field on value change. The * clearing must happen here as well because TextChangeListener can * revert the original value. Client must respect the value in this - * case. LegacyAbstractField optimizes value change if the existing - * value is reset. Also we need to force repaint if the flag is on. + * case. AbstractField optimizes value change if the existing value is + * reset. Also we need to force repaint if the flag is on. */ if (lastKnownTextContent != null) { lastKnownTextContent = null; diff --git a/compatibility-server/src/main/java/com/vaadin/v7/ui/Calendar.java b/compatibility-server/src/main/java/com/vaadin/v7/ui/Calendar.java index 6e5c1df7f8..259de0d0ad 100644 --- a/compatibility-server/src/main/java/com/vaadin/v7/ui/Calendar.java +++ b/compatibility-server/src/main/java/com/vaadin/v7/ui/Calendar.java @@ -942,16 +942,13 @@ public class Calendar extends AbstractLegacyComponent } /** - * <p> * This method restricts the hours that are shown per day. This affects the * weekly view. The general contract is that <b>firstHour < lastHour</b>. - * </p> - * * <p> * Note that this only affects the rendering process. Events are still * requested by the dates set by {@link #setStartDate(Date)} and * {@link #setEndDate(Date)}. - * </p> + * <p> * You can use {@link #autoScaleVisibleHoursOfDay()} for automatic scaling * of the visible hours based on current events. * diff --git a/compatibility-server/src/main/java/com/vaadin/v7/ui/CheckBox.java b/compatibility-server/src/main/java/com/vaadin/v7/ui/CheckBox.java index 9aabd6293e..7366266787 100644 --- a/compatibility-server/src/main/java/com/vaadin/v7/ui/CheckBox.java +++ b/compatibility-server/src/main/java/com/vaadin/v7/ui/CheckBox.java @@ -129,9 +129,9 @@ public class CheckBox extends AbstractField<Boolean> { } /* - * Overridden to keep the shared state in sync with the LegacyAbstractField - * internal value. Should be removed once LegacyAbstractField is refactored - * to use shared state. + * Overridden to keep the shared state in sync with the AbstractField + * internal value. Should be removed once AbstractField is refactored to use + * shared state. * * See tickets #10921 and #11064. */ diff --git a/compatibility-server/src/main/java/com/vaadin/v7/ui/DateField.java b/compatibility-server/src/main/java/com/vaadin/v7/ui/DateField.java index 33ca986fa1..05b6f950ca 100644 --- a/compatibility-server/src/main/java/com/vaadin/v7/ui/DateField.java +++ b/compatibility-server/src/main/java/com/vaadin/v7/ui/DateField.java @@ -56,8 +56,8 @@ import com.vaadin.v7.shared.ui.datefield.TextualDateFieldState; * compatible with <code>java.util.Date</code>. * </p> * <p> - * Since <code>DateField</code> extends <code>LegacyAbstractField</code> it - * implements the {@link Buffered}interface. + * Since <code>DateField</code> extends <code>AbstractField</code> it implements + * the {@link Buffered}interface. * </p> * <p> * A <code>DateField</code> is in write-through mode by default, so @@ -717,6 +717,21 @@ public class DateField extends AbstractField<Date> implements * and flags about invalid input. */ setInternalValue(null); + + /* + * Due to DateField's special implementation of isValid(), + * datefields validity may change although the logical value does + * not change. This is an issue for Form which expects that validity + * of Fields cannot change unless actual value changes. + * + * So we check if this field is inside a form and the form has + * registered this as a field. In this case we repaint the form. + * Without this hacky solution the form might not be able to clean + * validation errors etc. We could avoid this by firing an extra + * value change event, but feels like at least as bad solution as + * this. + */ + notifyFormOfValidityChange(); markAsDirty(); return; } diff --git a/compatibility-server/src/main/java/com/vaadin/v7/ui/DefaultFieldFactory.java b/compatibility-server/src/main/java/com/vaadin/v7/ui/DefaultFieldFactory.java index b8756c3d7f..f42000a119 100644 --- a/compatibility-server/src/main/java/com/vaadin/v7/ui/DefaultFieldFactory.java +++ b/compatibility-server/src/main/java/com/vaadin/v7/ui/DefaultFieldFactory.java @@ -86,13 +86,13 @@ public class DefaultFieldFactory /** * Creates fields based on the property type. * <p> - * The default field type is {@link LegacyTextField}. Other field types - * generated by this method: + * The default field type is {@link TextField}. Other field types generated + * by this method: * <p> * <b>Boolean</b>: {@link CheckBox}.<br/> - * <b>Date</b>: {@link LegacyDateField}(resolution: day).<br/> + * <b>Date</b>: {@link DateField}(resolution: day).<br/> * <b>Item</b>: {@link Form}. <br/> - * <b>default field type</b>: {@link LegacyTextField}. + * <b>default field type</b>: {@link TextField}. * <p> * * @param type diff --git a/compatibility-server/src/main/java/com/vaadin/v7/ui/Field.java b/compatibility-server/src/main/java/com/vaadin/v7/ui/Field.java index 1e3a4fa7a3..6cb08af5f0 100644 --- a/compatibility-server/src/main/java/com/vaadin/v7/ui/Field.java +++ b/compatibility-server/src/main/java/com/vaadin/v7/ui/Field.java @@ -22,14 +22,14 @@ import com.vaadin.v7.data.BufferedValidatable; import com.vaadin.v7.data.Property; /** - * LegacyField interface is implemented by all legacy field components that have - * a value that the user can change through the user interface. + * Field interface is implemented by all classes (field components) that have a + * value that the user can change through the user interface. * - * LegacyField components are built upon the framework defined in the - * LegacyField interface and the {@link AbstractField} base class. + * Field components are built upon the framework defined in the Field interface + * and the {@link AbstractField} base class. * - * The LegacyField interface inherits the {@link Component} superinterface and - * also the {@link Property} interface to have a value for the field. + * The Field interface inherits the {@link Component} superinterface and also + * the {@link Property} interface to have a value for the field. * * @author Vaadin Ltd. * @@ -85,8 +85,8 @@ public interface Field<T> extends Component, BufferedValidatable, Property<T>, public String getRequiredError(); /** - * An <code>Event</code> object specifying the LegacyField whose value has - * been changed. + * An <code>Event</code> object specifying the Field whose value has been + * changed. * * @author Vaadin Ltd. * @since 3.0 diff --git a/compatibility-server/src/main/java/com/vaadin/v7/ui/Form.java b/compatibility-server/src/main/java/com/vaadin/v7/ui/Form.java index c671caea93..4fc9a63789 100644 --- a/compatibility-server/src/main/java/com/vaadin/v7/ui/Form.java +++ b/compatibility-server/src/main/java/com/vaadin/v7/ui/Form.java @@ -49,6 +49,7 @@ import com.vaadin.v7.data.Item; import com.vaadin.v7.data.Property; import com.vaadin.v7.data.Validatable; import com.vaadin.v7.data.Validator; +import com.vaadin.v7.data.Validator.InvalidValueException; import com.vaadin.v7.data.fieldgroup.FieldGroup; import com.vaadin.v7.data.util.BeanItem; import com.vaadin.v7.shared.form.FormState; @@ -190,7 +191,7 @@ public class Form extends AbstractField<Object> * @param formLayout * the layout of the form. * @param fieldFactory - * the TableFieldFactory of the form. + * the FieldFactory of the form. */ public Form(Layout formLayout, FormFieldFactory fieldFactory) { super(); @@ -317,7 +318,7 @@ public class Form extends AbstractField<Object> */ @Override public void commit() - throws Buffered.SourceException, Validator.InvalidValueException { + throws Buffered.SourceException, InvalidValueException { LinkedList<SourceException> problems = null; @@ -961,7 +962,7 @@ public class Form extends AbstractField<Object> * @see Validatable#validate() */ @Override - public void validate() throws Validator.InvalidValueException { + public void validate() throws InvalidValueException { super.validate(); for (final Iterator<Object> i = propertyIds.iterator(); i.hasNext();) { fields.get(i.next()).validate(); diff --git a/compatibility-server/src/main/java/com/vaadin/v7/ui/FormFieldFactory.java b/compatibility-server/src/main/java/com/vaadin/v7/ui/FormFieldFactory.java index a2c963c0a4..390b77eaac 100644 --- a/compatibility-server/src/main/java/com/vaadin/v7/ui/FormFieldFactory.java +++ b/compatibility-server/src/main/java/com/vaadin/v7/ui/FormFieldFactory.java @@ -1,12 +1,12 @@ /* * Copyright 2000-2016 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 @@ -26,9 +26,9 @@ import com.vaadin.v7.data.fieldgroup.FieldGroup; * property id and uiContext (the component responsible for displaying fields). * Currently this interface is used by {@link Form}, but might later be used by * some other components for {@link Field} generation. - * + * * <p> - * + * * @author Vaadin Ltd. * @since 6.0 * @see TableFieldFactory @@ -40,7 +40,7 @@ public interface FormFieldFactory extends Serializable { /** * Creates a field based on the item, property id and the component (most * commonly {@link Form}) where the Field will be presented. - * + * * @param item * the item where the property belongs to. * @param propertyId diff --git a/compatibility-server/src/main/java/com/vaadin/v7/ui/Grid.java b/compatibility-server/src/main/java/com/vaadin/v7/ui/Grid.java index 207132f364..f9a5062ac1 100644 --- a/compatibility-server/src/main/java/com/vaadin/v7/ui/Grid.java +++ b/compatibility-server/src/main/java/com/vaadin/v7/ui/Grid.java @@ -123,6 +123,7 @@ import com.vaadin.v7.shared.ui.grid.selection.MultiSelectionModelServerRpc; import com.vaadin.v7.shared.ui.grid.selection.MultiSelectionModelState; import com.vaadin.v7.shared.ui.grid.selection.SingleSelectionModelServerRpc; import com.vaadin.v7.shared.ui.grid.selection.SingleSelectionModelState; +import com.vaadin.v7.ui.Grid.SelectionModel.HasUserSelectionAllowed; import com.vaadin.v7.ui.renderers.HtmlRenderer; import com.vaadin.v7.ui.renderers.Renderer; import com.vaadin.v7.ui.renderers.TextRenderer; @@ -1141,6 +1142,35 @@ public class Grid extends AbstractComponent */ @Deprecated public interface SelectionModel extends Serializable, Extension { + + /** + * Interface implemented by selection models which support disabling + * client side selection while still allowing programmatic selection on + * the server. + * + * @since 7.7.7 + */ + public interface HasUserSelectionAllowed extends SelectionModel { + + /** + * Checks if the user is allowed to change the selection. + * + * @return <code>true</code> if the user is allowed to change the + * selection, <code>false</code> otherwise + */ + public boolean isUserSelectionAllowed(); + + /** + * Sets whether the user is allowed to change the selection. + * + * @param userSelectionAllowed + * <code>true</code> if the user is allowed to change the + * selection, <code>false</code> otherwise + */ + public void setUserSelectionAllowed(boolean userSelectionAllowed); + + } + /** * Checks whether an item is selected or not. * @@ -1505,7 +1535,7 @@ public class Grid extends AbstractComponent */ @Deprecated public static class SingleSelectionModel extends AbstractSelectionModel - implements SelectionModel.Single { + implements SelectionModel.Single, HasUserSelectionAllowed { @Override protected void extend(AbstractClientConnector target) { @@ -1514,6 +1544,11 @@ public class Grid extends AbstractComponent @Override public void select(String rowKey) { + if (!isUserSelectionAllowed()) { + throw new IllegalStateException( + "Client tried to select '" + rowKey + + "' although user selection is disallowed"); + } SingleSelectionModel.this.select(getItemId(rowKey), false); } }); @@ -1604,6 +1639,21 @@ public class Grid extends AbstractComponent protected SingleSelectionModelState getState() { return (SingleSelectionModelState) super.getState(); } + + @Override + protected SingleSelectionModelState getState(boolean markAsDirty) { + return (SingleSelectionModelState) super.getState(markAsDirty); + } + + @Override + public boolean isUserSelectionAllowed() { + return getState(false).userSelectionAllowed; + } + + @Override + public void setUserSelectionAllowed(boolean userSelectionAllowed) { + getState().userSelectionAllowed = userSelectionAllowed; + } } /** @@ -1639,7 +1689,8 @@ public class Grid extends AbstractComponent */ @Deprecated public static class MultiSelectionModel extends AbstractSelectionModel - implements SelectionModel.Multi { + implements SelectionModel.Multi, + SelectionModel.HasUserSelectionAllowed { /** * The default selection size limit. @@ -1657,6 +1708,12 @@ public class Grid extends AbstractComponent @Override public void select(List<String> rowKeys) { + if (!isUserSelectionAllowed()) { + throw new IllegalStateException( + "Client tried to select '" + rowKeys + + "' although user selection is disallowed"); + } + List<Object> items = new ArrayList<Object>(); for (String rowKey : rowKeys) { items.add(getItemId(rowKey)); @@ -1666,6 +1723,12 @@ public class Grid extends AbstractComponent @Override public void deselect(List<String> rowKeys) { + if (!isUserSelectionAllowed()) { + throw new IllegalStateException( + "Client tried to deselect '" + rowKeys + + "' although user selection is disallowed"); + } + List<Object> items = new ArrayList<Object>(); for (String rowKey : rowKeys) { items.add(getItemId(rowKey)); @@ -1675,11 +1738,21 @@ public class Grid extends AbstractComponent @Override public void selectAll() { + if (!isUserSelectionAllowed()) { + throw new IllegalStateException( + "Client tried to select all although user selection is disallowed"); + } + MultiSelectionModel.this.selectAll(false); } @Override public void deselectAll() { + if (!isUserSelectionAllowed()) { + throw new IllegalStateException( + "Client tried to deselect all although user selection is disallowed"); + } + MultiSelectionModel.this.deselectAll(false); } }); @@ -1963,6 +2036,21 @@ public class Grid extends AbstractComponent protected MultiSelectionModelState getState() { return (MultiSelectionModelState) super.getState(); } + + @Override + protected MultiSelectionModelState getState(boolean markAsDirty) { + return (MultiSelectionModelState) super.getState(markAsDirty); + } + + @Override + public boolean isUserSelectionAllowed() { + return getState(false).userSelectionAllowed; + } + + @Override + public void setUserSelectionAllowed(boolean userSelectionAllowed) { + getState().userSelectionAllowed = userSelectionAllowed; + } } /** @@ -2390,14 +2478,17 @@ public class Grid extends AbstractComponent } /** - * Merges columns cells in a row + * Merges columns cells in a row. * * @param propertyIds * The property ids of columns to merge * @return The remaining visible cell after the merge */ public CELLTYPE join(Object... propertyIds) { - assert propertyIds.length > 1 : "You need to merge at least 2 properties"; + if (propertyIds.length < 2) { + throw new IllegalArgumentException( + "You need to merge at least 2 properties"); + } Set<CELLTYPE> cells = new HashSet<CELLTYPE>(); for (int i = 0; i < propertyIds.length; ++i) { @@ -2408,14 +2499,17 @@ public class Grid extends AbstractComponent } /** - * Merges columns cells in a row + * Merges columns cells in a row. * * @param cells * The cells to merge. Must be from the same row. * @return The remaining visible cell after the merge */ public CELLTYPE join(CELLTYPE... cells) { - assert cells.length > 1 : "You need to merge at least 2 cells"; + if (cells.length < 2) { + throw new IllegalArgumentException( + "You need to merge at least 2 cells"); + } return join(new HashSet<CELLTYPE>(Arrays.asList(cells))); } @@ -4637,7 +4731,7 @@ public class Grid extends AbstractComponent * own Container. * * @see #setContainerDataSource(Indexed) - * @see #LegacyGrid() + * @see #Grid() */ private boolean defaultContainer = true; @@ -5150,7 +5244,7 @@ public class Grid extends AbstractComponent * @return unmodifiable copy of current columns in visual order */ public List<Column> getColumns() { - List<Column> columns = new ArrayList<Column>(); + List<Column> columns = new ArrayList<Grid.Column>(); for (String columnId : getState(false).columnOrder) { columns.add(getColumnByColumnId(columnId)); } @@ -6830,6 +6924,15 @@ public class Grid extends AbstractComponent } } + /** + * Refreshes, i.e. causes the client side to re-render all rows. + * + * @since 7.7.7 + */ + public void refreshAllRows() { + datasourceExtension.refreshCache(); + } + private static Logger getLogger() { return Logger.getLogger(Grid.class.getName()); } diff --git a/compatibility-server/src/main/java/com/vaadin/v7/ui/HorizontalLayout.java b/compatibility-server/src/main/java/com/vaadin/v7/ui/HorizontalLayout.java index de5ae3ab38..f7598637b6 100644 --- a/compatibility-server/src/main/java/com/vaadin/v7/ui/HorizontalLayout.java +++ b/compatibility-server/src/main/java/com/vaadin/v7/ui/HorizontalLayout.java @@ -35,6 +35,7 @@ import com.vaadin.ui.Component; * spacing on by default */ @Deprecated +@SuppressWarnings("serial") public class HorizontalLayout extends com.vaadin.ui.HorizontalLayout { /** * Constructs an empty HorizontalLayout. diff --git a/compatibility-server/src/main/java/com/vaadin/v7/ui/Label.java b/compatibility-server/src/main/java/com/vaadin/v7/ui/Label.java index bb273dab46..a5cb55d54c 100644 --- a/compatibility-server/src/main/java/com/vaadin/v7/ui/Label.java +++ b/compatibility-server/src/main/java/com/vaadin/v7/ui/Label.java @@ -549,6 +549,8 @@ public class Label extends AbstractLegacyComponent implements Property<String>, markAsDirty(); } + // LegacyPropertyHelper has been removed in Vaadin 8 + /* * (non-Javadoc) * diff --git a/compatibility-server/src/main/java/com/vaadin/v7/ui/ListSelect.java b/compatibility-server/src/main/java/com/vaadin/v7/ui/ListSelect.java index b5ae1cd396..16619afdf5 100644 --- a/compatibility-server/src/main/java/com/vaadin/v7/ui/ListSelect.java +++ b/compatibility-server/src/main/java/com/vaadin/v7/ui/ListSelect.java @@ -51,6 +51,8 @@ public class ListSelect extends AbstractSelect { super(caption); } + // Columns are no longer used for width. + public int getRows() { return rows; } @@ -75,6 +77,7 @@ public class ListSelect extends AbstractSelect { @Override public void paintContent(PaintTarget target) throws PaintException { + // Width is no longer based on columns // Adds the number of rows if (rows != 0) { target.addAttribute("rows", rows); diff --git a/compatibility-server/src/main/java/com/vaadin/v7/ui/ProgressBar.java b/compatibility-server/src/main/java/com/vaadin/v7/ui/ProgressBar.java index b23cf99097..99cdf97f04 100644 --- a/compatibility-server/src/main/java/com/vaadin/v7/ui/ProgressBar.java +++ b/compatibility-server/src/main/java/com/vaadin/v7/ui/ProgressBar.java @@ -144,9 +144,9 @@ public class ProgressBar extends AbstractField<Float> } /* - * Overridden to keep the shared state in sync with the LegacyAbstractField - * internal value. Should be removed once LegacyAbstractField is refactored - * to use shared state. + * Overridden to keep the shared state in sync with the AbstractField + * internal value. Should be removed once AbstractField is refactored to use + * shared state. * * See tickets #10921 and #11064. */ diff --git a/compatibility-server/src/main/java/com/vaadin/v7/ui/Table.java b/compatibility-server/src/main/java/com/vaadin/v7/ui/Table.java index 8b6ad8dbfb..e3f122f25d 100644 --- a/compatibility-server/src/main/java/com/vaadin/v7/ui/Table.java +++ b/compatibility-server/src/main/java/com/vaadin/v7/ui/Table.java @@ -4124,7 +4124,7 @@ public class Table extends AbstractSelect implements Action.Container, /** * Binds an item property to a field generated by TableFieldFactory. The - * default behavior is to bind property straight to LegacyField. If + * default behavior is to bind property straight to Field. If * Property.Viewer type property (e.g. PropertyFormatter) is already set for * field, the property is bound to that Property.Viewer. * @@ -4783,7 +4783,7 @@ public class Table extends AbstractSelect implements Action.Container, * * The FieldFactory is only used if the Table is editable. * - * @return TableFieldFactory used to create the LegacyField instances. + * @return TableFieldFactory used to create the Field instances. * @see #isEditable */ public TableFieldFactory getTableFieldFactory() { @@ -4793,8 +4793,8 @@ public class Table extends AbstractSelect implements Action.Container, /** * Is table editable. * - * If table is editable a editor of type LegacyField is created for each - * table cell. The assigned FieldFactory is used to create the instances. + * If table is editable a editor of type Field is created for each table + * cell. The assigned FieldFactory is used to create the instances. * * To provide custom editors for table cells create a class implementing the * FieldFactory interface, and assign it to table, and set the editable @@ -4812,8 +4812,8 @@ public class Table extends AbstractSelect implements Action.Container, /** * Sets the editable property. * - * If table is editable a editor of type LegacyField is created for each - * table cell. The assigned FieldFactory is used to create the instances. + * If table is editable a editor of type Field is created for each table + * cell. The assigned FieldFactory is used to create the instances. * * To provide custom editors for table cells create a class implementing the * FieldFactory interface, and assign it to table, and set the editable diff --git a/compatibility-server/src/main/java/com/vaadin/v7/ui/TableFieldFactory.java b/compatibility-server/src/main/java/com/vaadin/v7/ui/TableFieldFactory.java index 8bdec4ca66..1f3d14c8dd 100644 --- a/compatibility-server/src/main/java/com/vaadin/v7/ui/TableFieldFactory.java +++ b/compatibility-server/src/main/java/com/vaadin/v7/ui/TableFieldFactory.java @@ -21,7 +21,7 @@ import com.vaadin.ui.Component; import com.vaadin.v7.data.Container; /** - * Factory interface for creating new LegacyField-instances based on Container + * Factory interface for creating new Field-instances based on Container * (datasource), item id, property id and uiContext (the component responsible * for displaying fields). Currently this interface is used by {@link Table}, * but might later be used by some other components for {@link Field} diff --git a/compatibility-server/src/main/java/com/vaadin/v7/ui/TextField.java b/compatibility-server/src/main/java/com/vaadin/v7/ui/TextField.java index a78cb3b0d6..3e7be6c7f4 100644 --- a/compatibility-server/src/main/java/com/vaadin/v7/ui/TextField.java +++ b/compatibility-server/src/main/java/com/vaadin/v7/ui/TextField.java @@ -32,11 +32,10 @@ import com.vaadin.v7.data.Property; * </p> * * <p> - * Since <code>TextField</code> extends <code>LegacyAbstractField</code> it - * implements the {@link Buffered} interface. A <code>TextField</code> is in - * write-through mode by default, so - * {@link AbstractField#setWriteThrough(boolean)} must be called to enable - * buffering. + * Since <code>TextField</code> extends <code>AbstractField</code> it implements + * the {@link Buffered} interface. A <code>TextField</code> is in write-through + * mode by default, so {@link AbstractField#setWriteThrough(boolean)} must be + * called to enable buffering. * </p> * * @author Vaadin Ltd. diff --git a/compatibility-server/src/main/java/com/vaadin/v7/ui/Tree.java b/compatibility-server/src/main/java/com/vaadin/v7/ui/Tree.java index 67da52df51..5f114c06cb 100644 --- a/compatibility-server/src/main/java/com/vaadin/v7/ui/Tree.java +++ b/compatibility-server/src/main/java/com/vaadin/v7/ui/Tree.java @@ -1242,7 +1242,7 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, if (actionHandler != null) { if (actionHandlers == null) { - actionHandlers = new LinkedList<Handler>(); + actionHandlers = new LinkedList<Action.Handler>(); actionMapper = new KeyMapper<Action>(); } diff --git a/compatibility-server/src/main/java/com/vaadin/v7/ui/TwinColSelect.java b/compatibility-server/src/main/java/com/vaadin/v7/ui/TwinColSelect.java index d1ddaa4f08..5f585962ff 100644 --- a/compatibility-server/src/main/java/com/vaadin/v7/ui/TwinColSelect.java +++ b/compatibility-server/src/main/java/com/vaadin/v7/ui/TwinColSelect.java @@ -65,6 +65,8 @@ public class TwinColSelect extends AbstractSelect { setMultiSelect(true); } + // Columns are no longer used for width. + public int getRows() { return rows; } @@ -104,7 +106,7 @@ public class TwinColSelect extends AbstractSelect { @Override public void paintContent(PaintTarget target) throws PaintException { - // Adds the number of columns + // Width is no longer based on columns // Adds the number of rows if (rows != 0) { target.addAttribute("rows", rows); diff --git a/compatibility-server/src/main/java/com/vaadin/v7/ui/components/calendar/ContainerEventProvider.java b/compatibility-server/src/main/java/com/vaadin/v7/ui/components/calendar/ContainerEventProvider.java index d00439cbb8..a559b09bac 100644 --- a/compatibility-server/src/main/java/com/vaadin/v7/ui/components/calendar/ContainerEventProvider.java +++ b/compatibility-server/src/main/java/com/vaadin/v7/ui/components/calendar/ContainerEventProvider.java @@ -240,13 +240,6 @@ public class ContainerEventProvider return event; } - /* - * (non-Javadoc) - * - * @see - * com.vaadin.addon.calendar.event.CalendarEventProvider#getEvents(java. - * util.Date, java.util.Date) - */ @Override public List<CalendarEvent> getEvents(Date startDate, Date endDate) { eventCache.clear(); @@ -279,14 +272,6 @@ public class ContainerEventProvider return Collections.unmodifiableList(eventCache); } - /* - * (non-Javadoc) - * - * @see com.vaadin.addon.calendar.event.CalendarEventProvider. - * EventSetChangeNotifier - * #addListener(com.vaadin.addon.calendar.event.CalendarEventProvider. - * EventSetChangeListener) - */ @Override public void addEventSetChangeListener(EventSetChangeListener listener) { if (!eventSetChangeListeners.contains(listener)) { @@ -294,26 +279,11 @@ public class ContainerEventProvider } } - /* - * (non-Javadoc) - * - * @see com.vaadin.addon.calendar.event.CalendarEventProvider. - * EventSetChangeNotifier - * #removeListener(com.vaadin.addon.calendar.event.CalendarEventProvider. - * EventSetChangeListener) - */ @Override public void removeEventSetChangeListener(EventSetChangeListener listener) { eventSetChangeListeners.remove(listener); } - /* - * (non-Javadoc) - * - * @see com.vaadin.addon.calendar.event.CalendarEvent.EventChangeNotifier# - * addListener - * (com.vaadin.addon.calendar.event.CalendarEvent.EventChangeListener) - */ @Override public void addEventChangeListener(EventChangeListener listener) { if (eventChangeListeners.contains(listener)) { @@ -321,13 +291,6 @@ public class ContainerEventProvider } } - /* - * (non-Javadoc) - * - * @see com.vaadin.addon.calendar.event.CalendarEvent.EventChangeNotifier# - * removeListener - * (com.vaadin.addon.calendar.event.CalendarEvent.EventChangeListener) - */ @Override public void removeEventChangeListener(EventChangeListener listener) { eventChangeListeners.remove(listener); @@ -421,13 +384,6 @@ public class ContainerEventProvider return allDayProperty; } - /* - * (non-Javadoc) - * - * @see - * com.vaadin.data.Container.ItemSetChangeListener#containerItemSetChange - * (com.vaadin.data.Container.ItemSetChangeEvent) - */ @Override public void containerItemSetChange(ItemSetChangeEvent event) { if (event.getContainer() == container) { @@ -438,13 +394,6 @@ public class ContainerEventProvider } } - /* - * (non-Javadoc) - * - * @see - * com.vaadin.data.Property.ValueChangeListener#valueChange(com.vaadin.data - * .Property.ValueChangeEvent) - */ @Override public void valueChange(ValueChangeEvent event) { /* @@ -454,14 +403,6 @@ public class ContainerEventProvider */ } - /* - * (non-Javadoc) - * - * @see - * com.vaadin.addon.calendar.ui.CalendarComponentEvents.EventMoveHandler - * #eventMove - * (com.vaadin.addon.calendar.ui.CalendarComponentEvents.MoveEvent) - */ @Override public void eventMove(MoveEvent event) { CalendarEvent ce = event.getCalendarEvent(); @@ -485,14 +426,6 @@ public class ContainerEventProvider } } - /* - * (non-Javadoc) - * - * @see - * com.vaadin.addon.calendar.ui.CalendarComponentEvents.EventResizeHandler - * #eventResize - * (com.vaadin.addon.calendar.ui.CalendarComponentEvents.EventResize) - */ @Override public void eventResize(EventResize event) { CalendarEvent ce = event.getCalendarEvent(); @@ -522,13 +455,6 @@ public class ContainerEventProvider ignoreContainerEvents(); } - /* - * (non-Javadoc) - * - * @see - * com.vaadin.addon.calendar.event.CalendarEditableEventProvider#addEvent - * (com.vaadin.addon.calendar.event.CalendarEvent) - */ @Override public void addEvent(CalendarEvent event) { Item item; @@ -552,13 +478,6 @@ public class ContainerEventProvider } } - /* - * (non-Javadoc) - * - * @see - * com.vaadin.addon.calendar.event.CalendarEditableEventProvider#removeEvent - * (com.vaadin.addon.calendar.event.CalendarEvent) - */ @Override public void removeEvent(CalendarEvent event) { container.removeItem(event); diff --git a/compatibility-server/src/main/java/com/vaadin/v7/ui/components/colorpicker/ColorPickerPreview.java b/compatibility-server/src/main/java/com/vaadin/v7/ui/components/colorpicker/ColorPickerPreview.java index 9a6e3598e8..3b2ec99d97 100644 --- a/compatibility-server/src/main/java/com/vaadin/v7/ui/components/colorpicker/ColorPickerPreview.java +++ b/compatibility-server/src/main/java/com/vaadin/v7/ui/components/colorpicker/ColorPickerPreview.java @@ -1,12 +1,12 @@ /* * Copyright 2000-2016 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 @@ -26,12 +26,12 @@ import com.vaadin.v7.ui.TextField; /** * A component that represents color selection preview within a color picker. - * + * * @since 7.0.0 */ @Deprecated -public class ColorPickerPreview extends CssLayout implements ColorSelector, - ValueChangeListener { +public class ColorPickerPreview extends CssLayout + implements ColorSelector, ValueChangeListener { private static final String STYLE_DARK_COLOR = "v-textfield-dark"; private static final String STYLE_LIGHT_COLOR = "v-textfield-light"; @@ -98,8 +98,8 @@ public class ColorPickerPreview extends CssLayout implements ColorSelector, // Set the text color field.removeStyleName(STYLE_DARK_COLOR); field.removeStyleName(STYLE_LIGHT_COLOR); - if (this.color.getRed() + this.color.getGreen() + this.color - .getBlue() < 3 * 128) { + if (this.color.getRed() + this.color.getGreen() + + this.color.getBlue() < 3 * 128) { field.addStyleName(STYLE_DARK_COLOR); } else { field.addStyleName(STYLE_LIGHT_COLOR); @@ -161,8 +161,8 @@ public class ColorPickerPreview extends CssLayout implements ColorSelector, value.length() - 1).split(","); int hue = Integer.parseInt(colors[0]); - int saturation = Integer.parseInt(colors[1] - .replace("%", "")); + int saturation = Integer + .parseInt(colors[1].replace("%", "")); int lightness = Integer .parseInt(colors[2].replace("%", "")); int rgb = Color.HSLtoRGB(hue, saturation, lightness); diff --git a/compatibility-server/src/main/java/com/vaadin/v7/ui/components/colorpicker/ColorPickerSelect.java b/compatibility-server/src/main/java/com/vaadin/v7/ui/components/colorpicker/ColorPickerSelect.java index 63d46d6cc4..79dfdf3b49 100644 --- a/compatibility-server/src/main/java/com/vaadin/v7/ui/components/colorpicker/ColorPickerSelect.java +++ b/compatibility-server/src/main/java/com/vaadin/v7/ui/components/colorpicker/ColorPickerSelect.java @@ -1,12 +1,12 @@ /* * Copyright 2000-2016 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 @@ -24,12 +24,12 @@ import com.vaadin.v7.ui.ComboBox; /** * A component that represents color selection swatches within a color picker. - * + * * @since 7.0.0 */ @Deprecated -public class ColorPickerSelect extends CustomComponent implements - ColorSelector, ValueChangeListener { +public class ColorPickerSelect extends CustomComponent + implements ColorSelector, ValueChangeListener { /** The range. */ private final ComboBox range; @@ -49,7 +49,7 @@ public class ColorPickerSelect extends CustomComponent implements /** * Instantiates a new color range property id. - * + * * @param caption * the caption */ @@ -65,7 +65,7 @@ public class ColorPickerSelect extends CustomComponent implements /** * Instantiates a new color picker select. - * + * * @param rows * the rows * @param columns @@ -102,12 +102,12 @@ public class ColorPickerSelect extends CustomComponent implements /** * Creates the all colors. - * + * * @param rows * the rows * @param columns * the columns - * + * * @return the color[][] */ private Color[][] createAllColors(int rows, int columns) { @@ -131,8 +131,8 @@ public class ColorPickerSelect extends CustomComponent implements value = 1f - ((row - (rows / 2f)) / (rows / 2f)); } - colors[row][col] = new Color(Color.HSVtoRGB(hue, - saturation, value)); + colors[row][col] = new Color( + Color.HSVtoRGB(hue, saturation, value)); } // The last row should have the black&white gradient @@ -141,8 +141,8 @@ public class ColorPickerSelect extends CustomComponent implements float saturation = 0f; float value = 1f - ((float) col / (float) columns); - colors[row][col] = new Color(Color.HSVtoRGB(hue, - saturation, value)); + colors[row][col] = new Color( + Color.HSVtoRGB(hue, saturation, value)); } } } @@ -152,14 +152,14 @@ public class ColorPickerSelect extends CustomComponent implements /** * Creates the color. - * + * * @param color * the color * @param rows * the rows * @param columns * the columns - * + * * @return the color[][] */ private Color[][] createColors(Color color, int rows, int columns) { @@ -183,12 +183,12 @@ public class ColorPickerSelect extends CustomComponent implements / (((float) rows * (float) columns) / 2f); } else { index -= ((rows * columns) / 2); - value = 1f - index - / (((float) rows * (float) columns) / 2f); + value = 1f + - index / (((float) rows * (float) columns) / 2f); } - colors[row][col] = new Color(Color.HSVtoRGB(hue, saturation, - value)); + colors[row][col] = new Color( + Color.HSVtoRGB(hue, saturation, value)); } } diff --git a/compatibility-server/src/main/java/com/vaadin/v7/ui/renderers/AbstractJavaScriptRenderer.java b/compatibility-server/src/main/java/com/vaadin/v7/ui/renderers/AbstractJavaScriptRenderer.java index 755c3fcc60..b41b6c2620 100644 --- a/compatibility-server/src/main/java/com/vaadin/v7/ui/renderers/AbstractJavaScriptRenderer.java +++ b/compatibility-server/src/main/java/com/vaadin/v7/ui/renderers/AbstractJavaScriptRenderer.java @@ -71,7 +71,7 @@ import elemental.json.JsonValue; * <li><code>init(cell)</code> - Prepares a cell for rendering. Corresponds to * {@link com.vaadin.client.renderers.ComplexRenderer#init(com.vaadin.client.widget.grid.RendererCellReference)} * .</li> - * <li><code>destory(cell)</code> - Allows the renderer to release resources + * <li><code>destroy(cell)</code> - Allows the renderer to release resources * allocate for a cell that will no longer be used. Corresponds to * {@link com.vaadin.client.renderers.ComplexRenderer#destroy(com.vaadin.client.widget.grid.RendererCellReference)} * .</li> diff --git a/compatibility-server/src/test/java/com/vaadin/tests/server/component/AbstractListenerMethodsTestBase.java b/compatibility-server/src/test/java/com/vaadin/tests/server/component/AbstractListenerMethodsTestBase.java index 66e68573d8..7924b36f7e 100644 --- a/compatibility-server/src/test/java/com/vaadin/tests/server/component/AbstractListenerMethodsTestBase.java +++ b/compatibility-server/src/test/java/com/vaadin/tests/server/component/AbstractListenerMethodsTestBase.java @@ -30,6 +30,7 @@ public abstract class AbstractListenerMethodsTestBase { for (Class<?> c : classes) { boolean found = false; for (Method m : c.getDeclaredMethods()) { + // Intentional change in compatibility package String methodName = m.getName(); if (methodName.startsWith("add") && methodName.endsWith("Listener") @@ -154,6 +155,7 @@ public abstract class AbstractListenerMethodsTestBase { private Method getAddListenerMethod(Class<?> cls, Class<?> listenerClass) throws SecurityException, NoSuchMethodException { + // Intentional change in compatibility package return cls.getMethod("add" + listenerClass.getSimpleName(), listenerClass); @@ -161,6 +163,7 @@ public abstract class AbstractListenerMethodsTestBase { private Method getRemoveListenerMethod(Class<?> cls, Class<?> listenerClass) throws SecurityException, NoSuchMethodException { + // Intentional change in compatibility package return cls.getMethod("remove" + listenerClass.getSimpleName(), listenerClass); @@ -178,4 +181,4 @@ public abstract class AbstractListenerMethodsTestBase { registeredListeners.toArray()); } -}
\ No newline at end of file +} diff --git a/compatibility-server/src/test/java/com/vaadin/tests/server/component/slider/SliderTest.java b/compatibility-server/src/test/java/com/vaadin/tests/server/component/slider/SliderTest.java index 8c093fdf72..1f7783dda5 100644 --- a/compatibility-server/src/test/java/com/vaadin/tests/server/component/slider/SliderTest.java +++ b/compatibility-server/src/test/java/com/vaadin/tests/server/component/slider/SliderTest.java @@ -41,8 +41,8 @@ public class SliderTest { slider.setValue(-1.0); } catch (Slider.ValueOutOfBoundsException e) { - assertThat(e.getMessage(), - containsString("Value -1.0 is out of bounds: [0.0, 100.0]")); + assertThat(e.getMessage(), containsString( + "Value -1.0 is out of bounds: [0.0, 100.0]")); } } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/data/util/PerformanceTestIndexedContainerTest.java b/compatibility-server/src/test/java/com/vaadin/v7/data/util/PerformanceTestIndexedContainerTest.java index 3f174eb649..516e4eb63d 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/data/util/PerformanceTestIndexedContainerTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/data/util/PerformanceTestIndexedContainerTest.java @@ -17,6 +17,8 @@ public class PerformanceTestIndexedContainerTest { // TODO should improve performance of these methods private static final long ADD_ITEM_AT_FAIL_THRESHOLD = 5000; private static final long ADD_ITEM_AFTER_FAIL_THRESHOLD = 5000; + // FIXME: Vaadin 7 compatibility version fails this check with original + // value of 5000 private static final long ADD_ITEM_AFTER_LAST_FAIL_THRESHOLD = 6000; private static final long ADD_ITEMS_CONSTRUCTOR_FAIL_THRESHOLD = 200; diff --git a/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/SQLContainerTableQueryTest.java b/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/SQLContainerTableQueryTest.java index fe1e7e1813..d39d604852 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/SQLContainerTableQueryTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/SQLContainerTableQueryTest.java @@ -187,7 +187,7 @@ public class SQLContainerTableQueryTest { container.commit(); Item item = getItem(container.lastItemId()); - assertThat(item.getItemProperty(NAME).getValue(), is("foo")); + assertThat(item.getItemProperty(NAME).getValue().toString(), is("foo")); } @Test @@ -196,8 +196,8 @@ public class SQLContainerTableQueryTest { container.refresh(); - assertThat(getItem(existingItemId).getItemProperty(NAME).getValue(), - is("foo")); + assertThat(getItem(existingItemId).getItemProperty(NAME).getValue() + .toString(), is("foo")); } @Test diff --git a/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/generator/SQLGeneratorsTest.java b/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/generator/SQLGeneratorsTest.java index 7f27d2a2fd..078363af19 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/generator/SQLGeneratorsTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/generator/SQLGeneratorsTest.java @@ -75,7 +75,7 @@ public class SQLGeneratorsTest { @Test public void generateSelectQuery_filtersAndOrderingSet_shouldSucceed() { SQLGenerator sg = new DefaultSQLGenerator(); - List<com.vaadin.v7.data.Container.Filter> f = new ArrayList<Filter>(); + List<Filter> f = new ArrayList<Filter>(); f.add(new Like("name", "%lle")); List<OrderBy> ob = Arrays.asList(new OrderBy("name", true)); StatementHelper sh = sg.generateSelectQuery("TABLE", f, ob, 0, 0, null); diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/design/WriteLegacyDesignTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/design/WriteLegacyDesignTest.java index 046b365601..c6652b77d9 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/design/WriteLegacyDesignTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/design/WriteLegacyDesignTest.java @@ -88,7 +88,7 @@ public class WriteLegacyDesignTest { private void checkNode(Node node) { if (node instanceof Element) { - assertTrue("Expected " + node.nodeName() + " to start with v-", + assertTrue("Wrong design element prefix", node.nodeName().startsWith("v-")); for (Node child : node.childNodes()) { checkNode(child); diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/abstractfield/AbsFieldValidatorsTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/abstractfield/AbsFieldValidatorsTest.java index 09ab8fe65f..5aee75af36 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/abstractfield/AbsFieldValidatorsTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/abstractfield/AbsFieldValidatorsTest.java @@ -69,6 +69,15 @@ public class AbsFieldValidatorsTest { } @Test + public void validatorShouldMakeImmediate() { + assertFalse("field should not be immediate by default", + field.isImmediate()); + field.addValidator(validator); + assertTrue("field should be immediate when it has a validator", + field.isImmediate()); + } + + @Test public void nonImmediateFieldWithValidator() { field.setImmediate(false); field.addValidator(validator); @@ -76,4 +85,30 @@ public class AbsFieldValidatorsTest { field.isImmediate()); } + @Test + public void removeValidatorMakesNonImmediate() { + field.addValidator(validator); + field.removeValidator(validator); + assertFalse("field should be non-immediate after validator was removed", + field.isImmediate()); + } + + @Test + public void requiredMakesImmediate() { + assertFalse("field should not be immediate by default", + field.isImmediate()); + field.setRequired(true); + assertTrue("field should be immediate when it is required", + field.isImmediate()); + } + + @Test + public void removeRequiredMakesNonImmediate() { + assertFalse("field should not be immediate by default", + field.isImmediate()); + field.setRequired(true); + field.setRequired(false); + assertFalse("field should not be immediate even though it was required", + field.isImmediate()); + } } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/abstractfield/AbsFieldValueConversionsTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/abstractfield/AbsFieldValueConversionsTest.java index 6594ed9351..d4bdb4fe53 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/abstractfield/AbsFieldValueConversionsTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/abstractfield/AbsFieldValueConversionsTest.java @@ -1,6 +1,7 @@ package com.vaadin.v7.tests.server.component.abstractfield; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import java.util.Locale; @@ -19,6 +20,7 @@ import com.vaadin.v7.data.util.ObjectProperty; import com.vaadin.v7.data.util.converter.Converter; import com.vaadin.v7.data.util.converter.Converter.ConversionException; import com.vaadin.v7.data.util.converter.StringToIntegerConverter; +import com.vaadin.v7.ui.CheckBox; import com.vaadin.v7.ui.TextField; public class AbsFieldValueConversionsTest { @@ -153,6 +155,65 @@ public class AbsFieldValueConversionsTest { tf.getValue()); } + @Test + public void testBooleanNullConversion() { + CheckBox cb = new CheckBox(); + cb.setConverter(new Converter<Boolean, Boolean>() { + + @Override + public Boolean convertToModel(Boolean value, + Class<? extends Boolean> targetType, Locale locale) { + // value from a CheckBox should never be null as long as it is + // not set to null (handled by conversion below). + assertNotNull(value); + return value; + } + + @Override + public Boolean convertToPresentation(Boolean value, + Class<? extends Boolean> targetType, Locale locale) { + // Datamodel -> field + if (value == null) { + return false; + } + + return value; + } + + @Override + public Class<Boolean> getModelType() { + return Boolean.class; + } + + @Override + public Class<Boolean> getPresentationType() { + return Boolean.class; + } + + }); + MethodProperty<Boolean> property = new MethodProperty<Boolean>( + paulaBean, "deceased"); + cb.setPropertyDataSource(property); + assertEquals(Boolean.FALSE, property.getValue()); + assertEquals(Boolean.FALSE, cb.getValue()); + Boolean newDmValue = cb.getConverter().convertToPresentation( + cb.getValue(), Boolean.class, new Locale("fi", "FI")); + assertEquals(Boolean.FALSE, newDmValue); + + // FIXME: Should be able to set to false here to cause datamodel to be + // set to false but the change will not be propagated to the Property + // (field value is already false) + + cb.setValue(true); + assertEquals(Boolean.TRUE, cb.getValue()); + assertEquals(Boolean.TRUE, property.getValue()); + + cb.setValue(false); + assertEquals(Boolean.FALSE, cb.getValue()); + assertEquals(Boolean.FALSE, property.getValue()); + + } + // Now specific to Integer because StringToNumberConverter has been removed public static class NumberBean { private Integer number; diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/abstractfield/AbstractFieldListenersTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/abstractfield/AbstractFieldListenersTest.java index f284229e28..ece14756cb 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/abstractfield/AbstractFieldListenersTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/abstractfield/AbstractFieldListenersTest.java @@ -7,7 +7,7 @@ import com.vaadin.v7.data.Property.ReadOnlyStatusChangeEvent; import com.vaadin.v7.data.Property.ReadOnlyStatusChangeListener; import com.vaadin.v7.data.Property.ValueChangeEvent; import com.vaadin.v7.data.Property.ValueChangeListener; -import com.vaadin.v7.ui.Table; +import com.vaadin.v7.ui.CheckBox; public class AbstractFieldListenersTest extends AbstractListenerMethodsTestBase { @@ -15,13 +15,14 @@ public class AbstractFieldListenersTest @Test public void testReadOnlyStatusChangeListenerAddGetRemove() throws Exception { - testListenerAddGetRemove(Table.class, ReadOnlyStatusChangeEvent.class, + testListenerAddGetRemove(CheckBox.class, + ReadOnlyStatusChangeEvent.class, ReadOnlyStatusChangeListener.class); } @Test public void testValueChangeListenerAddGetRemove() throws Exception { - testListenerAddGetRemove(Table.class, ValueChangeEvent.class, + testListenerAddGetRemove(CheckBox.class, ValueChangeEvent.class, ValueChangeListener.class); } } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/grid/ItemSetChangeDuringEditorCommit.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/grid/ItemSetChangeDuringEditorCommit.java index 0a97a84999..6e43eb2b85 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/grid/ItemSetChangeDuringEditorCommit.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/grid/ItemSetChangeDuringEditorCommit.java @@ -103,4 +103,4 @@ public class ItemSetChangeDuringEditorCommit { .applyInvocation(invocation); } -}
\ No newline at end of file +} diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/grid/MultiSelectionModelTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/grid/MultiSelectionModelTest.java index 044124bc8a..b4ccb094d0 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/grid/MultiSelectionModelTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/grid/MultiSelectionModelTest.java @@ -24,10 +24,12 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Test; +import com.vaadin.ui.ComponentTest; import com.vaadin.v7.data.Container; import com.vaadin.v7.data.util.IndexedContainer; import com.vaadin.v7.event.SelectionEvent; import com.vaadin.v7.event.SelectionEvent.SelectionListener; +import com.vaadin.v7.shared.ui.grid.selection.MultiSelectionModelServerRpc; import com.vaadin.v7.shared.ui.grid.selection.MultiSelectionModelState; import com.vaadin.v7.ui.Grid; @@ -187,4 +189,40 @@ public class MultiSelectionModelTest { } Assert.fail("Not all items were correctly selected"); } + + @Test(expected = IllegalStateException.class) + public void refuseSelectWhenUserSelectionDisallowed() { + ((HasUserSelectionAllowed) grid.getSelectionModel()) + .setUserSelectionAllowed(false); + MultiSelectionModelServerRpc serverRpc = ComponentTest.getRpcProxy( + grid.getSelectionModel(), MultiSelectionModelServerRpc.class); + serverRpc.select(Collections.singletonList("a")); + } + + @Test(expected = IllegalStateException.class) + public void refuseDeselectWhenUserSelectionDisallowed() { + ((HasUserSelectionAllowed) grid.getSelectionModel()) + .setUserSelectionAllowed(false); + MultiSelectionModelServerRpc serverRpc = ComponentTest.getRpcProxy( + grid.getSelectionModel(), MultiSelectionModelServerRpc.class); + serverRpc.deselect(Collections.singletonList("a")); + } + + @Test(expected = IllegalStateException.class) + public void refuseSelectAllWhenUserSelectionDisallowed() { + ((HasUserSelectionAllowed) grid.getSelectionModel()) + .setUserSelectionAllowed(false); + MultiSelectionModelServerRpc serverRpc = ComponentTest.getRpcProxy( + grid.getSelectionModel(), MultiSelectionModelServerRpc.class); + serverRpc.selectAll(); + } + + @Test(expected = IllegalStateException.class) + public void refuseDeselectAllWhenUserSelectionDisallowed() { + ((HasUserSelectionAllowed) grid.getSelectionModel()) + .setUserSelectionAllowed(false); + MultiSelectionModelServerRpc serverRpc = ComponentTest.getRpcProxy( + grid.getSelectionModel(), MultiSelectionModelServerRpc.class); + serverRpc.deselectAll(); + } } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/grid/SingleSelectionModelTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/grid/SingleSelectionModelTest.java index e18c5bbe8b..ffb07b986b 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/grid/SingleSelectionModelTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/grid/SingleSelectionModelTest.java @@ -20,10 +20,12 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Test; +import com.vaadin.ui.ComponentTest; import com.vaadin.v7.data.Container; import com.vaadin.v7.data.util.IndexedContainer; import com.vaadin.v7.event.SelectionEvent; import com.vaadin.v7.event.SelectionEvent.SelectionListener; +import com.vaadin.v7.shared.ui.grid.selection.SingleSelectionModelServerRpc; import com.vaadin.v7.ui.Grid; import com.vaadin.v7.ui.Grid.SelectionMode; import com.vaadin.v7.ui.Grid.SingleSelectionModel; @@ -150,4 +152,13 @@ public class SingleSelectionModelTest { } }); } + + @Test(expected = IllegalStateException.class) + public void refuseSelectionWhenUserSelectionDisallowed() { + ((HasUserSelectionAllowed) grid.getSelectionModel()) + .setUserSelectionAllowed(false); + SingleSelectionModelServerRpc serverRpc = ComponentTest.getRpcProxy( + grid.getSelectionModel(), SingleSelectionModelServerRpc.class); + serverRpc.select("a"); + } } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/table/TableDeclarativeTestBase.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/table/TableDeclarativeTestBase.java index c8b3e8116b..814160782f 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/table/TableDeclarativeTestBase.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/table/TableDeclarativeTestBase.java @@ -36,6 +36,7 @@ public abstract class TableDeclarativeTestBase } protected String getTag() { + // Compatibility classes have a different prefix return "vaadin7-table"; } |