Quellcode durchsuchen

Remove deprecated Property.toString() mode

The Property.toString() alternatives combined with the legacyPropertyToString
servlet init parameter was introduced in Vaadin 7.0 to ease migration of
applications written in earlier versions. This is no longer relevant.

Change-Id: I6b20e96408738a2a0d60f230c329ce0b329465a8
tags/8.0.0.alpha1
Artur Signell vor 7 Jahren
Ursprung
Commit
a8563a10bb

+ 16
- 28
server/src/main/java/com/vaadin/annotations/VaadinServletConfiguration.java Datei anzeigen

@@ -1,12 +1,12 @@
/*
* Copyright 2000-2014 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,7 +26,6 @@ import java.lang.annotation.Target;
import com.vaadin.server.Constants;
import com.vaadin.server.DefaultDeploymentConfiguration;
import com.vaadin.server.DeploymentConfiguration;
import com.vaadin.server.DeploymentConfiguration.LegacyProperyToStringMode;
import com.vaadin.server.VaadinServlet;
import com.vaadin.server.VaadinSession;
import com.vaadin.ui.UI;
@@ -39,7 +38,7 @@ import com.vaadin.ui.UI;
* as well as from specific methods in {@link DeploymentConfiguration}. Init
* params defined in <code>web.xml</code> or the <code>@WebServlet</code>
* annotation take precedence over values defined in this annotation.
*
*
* @since 7.1
* @author Vaadin Ltd
*/
@@ -50,7 +49,7 @@ public @interface VaadinServletConfiguration {
/**
* Defines the init parameter name for methods in
* {@link VaadinServletConfiguration}.
*
*
* @since 7.1
* @author Vaadin Ltd
*/
@@ -60,7 +59,7 @@ public @interface VaadinServletConfiguration {
public @interface InitParameterName {
/**
* The name of the init parameter that the annotated method controls.
*
*
* @return the parameter name
*/
public String value();
@@ -68,9 +67,9 @@ public @interface VaadinServletConfiguration {

/**
* Whether Vaadin is in production mode.
*
*
* @return true if in production mode, false otherwise.
*
*
* @see DeploymentConfiguration#isProductionMode()
*/
@InitParameterName(Constants.SERVLET_PARAMETER_PRODUCTION_MODE)
@@ -78,7 +77,7 @@ public @interface VaadinServletConfiguration {

/**
* Gets the default UI class to use for the servlet.
*
*
* @return the default UI class
*/
@InitParameterName(VaadinSession.UI_PARAMETER)
@@ -87,9 +86,9 @@ public @interface VaadinServletConfiguration {
/**
* The time resources can be cached in the browser, in seconds. The default
* value is 3600 seconds, i.e. one hour.
*
*
* @return the resource cache time
*
*
* @see DeploymentConfiguration#getResourceCacheTime()
*/
@InitParameterName(Constants.SERVLET_PARAMETER_RESOURCE_CACHE_TIME)
@@ -99,9 +98,9 @@ public @interface VaadinServletConfiguration {
* The number of seconds between heartbeat requests of a UI, or a
* non-positive number if heartbeat is disabled. The default value is 300
* seconds, i.e. 5 minutes.
*
*
* @return the time between heartbeats
*
*
* @see DeploymentConfiguration#getHeartbeatInterval()
*/
@InitParameterName(Constants.SERVLET_PARAMETER_HEARTBEAT_INTERVAL)
@@ -111,11 +110,11 @@ public @interface VaadinServletConfiguration {
* Whether a session should be closed when all its open UIs have been idle
* for longer than its configured maximum inactivity time. The default value
* is <code>false</code>.
*
*
* @return true if UIs and sessions receiving only heartbeat requests are
* eventually closed; false if heartbeat requests extend UI and
* session lifetime indefinitely
*
*
* @see DeploymentConfiguration#isCloseIdleSessions()
*/
@InitParameterName(Constants.SERVLET_PARAMETER_CLOSE_IDLE_SESSIONS)
@@ -124,21 +123,10 @@ public @interface VaadinServletConfiguration {
/**
* The default widgetset to use for the servlet. The default value is
* <code>com.vaadin.DefaultWidgetSet</code>.
*
*
* @return the default widgetset name
*/
@InitParameterName(VaadinServlet.PARAMETER_WIDGETSET)
public String widgetset() default VaadinServlet.DEFAULT_WIDGETSET;

/**
* The legacy Property.toString() mode used. The default value is
* {@link LegacyProperyToStringMode#DISABLED}
*
* @return The Property.toString() mode in use.
*
* @deprecated as of 7.1, should only be used to ease migration
*/
@Deprecated
@InitParameterName(Constants.SERVLET_PARAMETER_LEGACY_PROPERTY_TOSTRING)
public LegacyProperyToStringMode legacyPropertyToStringMode() default LegacyProperyToStringMode.DISABLED;
}

+ 15
- 44
server/src/main/java/com/vaadin/data/util/AbstractProperty.java Datei anzeigen

@@ -1,12 +1,12 @@
/*
* Copyright 2000-2014 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,10 +24,10 @@ import com.vaadin.data.Property;

/**
* Abstract base class for {@link Property} implementations.
*
*
* Handles listener management for {@link ValueChangeListener}s and
* {@link ReadOnlyStatusChangeListener}s.
*
*
* @since 6.6
*/
public abstract class AbstractProperty<T> implements Property<T>,
@@ -51,7 +51,7 @@ public abstract class AbstractProperty<T> implements Property<T>,

/**
* {@inheritDoc}
*
*
* Override for additional restrictions on what is considered a read-only
* property.
*/
@@ -69,48 +69,19 @@ public abstract class AbstractProperty<T> implements Property<T>,
}
}

/**
* Returns a string representation of this object. The returned string
* representation depends on if the legacy Property toString mode is enabled
* or disabled.
* <p>
* If legacy Property toString mode is enabled, returns the value of the
* <code>Property</code> converted to a String.
* </p>
* <p>
* If legacy Property toString mode is disabled, the string representation
* has no special meaning
* </p>
*
* @see LegacyPropertyHelper#isLegacyToStringEnabled()
*
* @return A string representation of the value value stored in the Property
* or a string representation of the Property object.
* @deprecated As of 7.0. To get the property value, use {@link #getValue()}
* instead (and possibly toString on that)
*/
@Deprecated
@Override
public String toString() {
if (!LegacyPropertyHelper.isLegacyToStringEnabled()) {
return super.toString();
} else {
return LegacyPropertyHelper.legacyPropertyToString(this);
}
}

/* Events */

/**
* An <code>Event</code> object specifying the Property whose read-only
* status has been changed.
*/
protected static class ReadOnlyStatusChangeEvent extends
java.util.EventObject implements Property.ReadOnlyStatusChangeEvent {
protected static class ReadOnlyStatusChangeEvent
extends java.util.EventObject
implements Property.ReadOnlyStatusChangeEvent {

/**
* Constructs a new read-only status change event for this object.
*
*
* @param source
* source object of the event.
*/
@@ -120,7 +91,7 @@ public abstract class AbstractProperty<T> implements Property<T>,

/**
* Gets the Property whose read-only state has changed.
*
*
* @return source Property of the event.
*/
@Override
@@ -132,7 +103,7 @@ public abstract class AbstractProperty<T> implements Property<T>,

/**
* Registers a new read-only status change listener for this Property.
*
*
* @param listener
* the new Listener to be registered.
*/
@@ -157,7 +128,7 @@ public abstract class AbstractProperty<T> implements Property<T>,

/**
* Removes a previously registered read-only status change listener.
*
*
* @param listener
* the listener to be removed.
*/
@@ -203,7 +174,7 @@ public abstract class AbstractProperty<T> implements Property<T>,

/**
* Constructs a new value change event for this object.
*
*
* @param source
* source object of the event.
*/
@@ -213,7 +184,7 @@ public abstract class AbstractProperty<T> implements Property<T>,

/**
* Gets the Property whose value has changed.
*
*
* @return source Property of the event.
*/
@Override

+ 117
- 135
server/src/main/java/com/vaadin/data/util/IndexedContainer.java Datei anzeigen

@@ -1,12 +1,12 @@
/*
* Copyright 2000-2014 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
@@ -28,7 +28,6 @@ import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.logging.Logger;

import com.vaadin.data.Container;
import com.vaadin.data.Item;
@@ -38,20 +37,21 @@ import com.vaadin.data.util.filter.UnsupportedFilterException;

/**
* An implementation of the <code>{@link Container.Indexed}</code> interface
* with all important features.</p>
*
* with all important features.
* </p>
*
* Features:
* <ul>
* <li> {@link Container.Indexed}
* <li> {@link Container.Ordered}
* <li> {@link Container.Sortable}
* <li> {@link Container.Filterable}
* <li> {@link Cloneable} (deprecated, might be removed in the future)
* <li>{@link Container.Indexed}
* <li>{@link Container.Ordered}
* <li>{@link Container.Sortable}
* <li>{@link Container.Filterable}
* <li>{@link Cloneable} (deprecated, might be removed in the future)
* <li>Sends all needed events on content changes.
* </ul>
*
*
* @see com.vaadin.data.Container
*
*
* @author Vaadin Ltd.
* @since 3.0
*/
@@ -59,11 +59,11 @@ import com.vaadin.data.util.filter.UnsupportedFilterException;
@SuppressWarnings("serial")
// item type is really IndexedContainerItem, but using Item not to show it in
// public API
public class IndexedContainer extends
AbstractInMemoryContainer<Object, Object, Item> implements
Container.PropertySetChangeNotifier, Property.ValueChangeNotifier,
Container.Sortable, Cloneable, Container.Filterable,
Container.SimpleFilterable {
public class IndexedContainer
extends AbstractInMemoryContainer<Object, Object, Item>
implements Container.PropertySetChangeNotifier,
Property.ValueChangeNotifier, Container.Sortable, Cloneable,
Container.Filterable, Container.SimpleFilterable {

/* Internal structure */

@@ -136,7 +136,7 @@ public class IndexedContainer extends

/*
* (non-Javadoc)
*
*
* @see com.vaadin.data.Container#getContainerPropertyIds()
*/
@Override
@@ -146,7 +146,7 @@ public class IndexedContainer extends

/**
* Gets the type of a Property stored in the list.
*
*
* @param id
* the ID of the Property.
* @return Type of the requested Property
@@ -158,7 +158,7 @@ public class IndexedContainer extends

/*
* (non-Javadoc)
*
*
* @see com.vaadin.data.Container#getContainerProperty(java.lang.Object,
* java.lang.Object)
*/
@@ -176,7 +176,7 @@ public class IndexedContainer extends

/*
* (non-Javadoc)
*
*
* @see com.vaadin.data.Container#addContainerProperty(java.lang.Object,
* java.lang.Class, java.lang.Object)
*/
@@ -201,9 +201,10 @@ public class IndexedContainer extends
// If default value is given, set it
if (defaultValue != null) {
// for existing rows
for (final Iterator<?> i = getAllItemIds().iterator(); i.hasNext();) {
getItem(i.next()).getItemProperty(propertyId).setValue(
defaultValue);
for (final Iterator<?> i = getAllItemIds().iterator(); i
.hasNext();) {
getItem(i.next()).getItemProperty(propertyId)
.setValue(defaultValue);
}
// store for next rows
if (defaultPropertyValues == null) {
@@ -220,7 +221,7 @@ public class IndexedContainer extends

/*
* (non-Javadoc)
*
*
* @see com.vaadin.data.Container#removeAllItems()
*/
@Override
@@ -262,13 +263,13 @@ public class IndexedContainer extends

/*
* (non-Javadoc)
*
*
* @see com.vaadin.data.Container#addItem(java.lang.Object)
*/
@Override
public Item addItem(Object itemId) {
Item item = internalAddItemAtEnd(itemId, new IndexedContainerItem(
itemId), false);
Item item = internalAddItemAtEnd(itemId,
new IndexedContainerItem(itemId), false);
if (item == null) {
return null;
} else if (!isFiltered()) {
@@ -284,7 +285,7 @@ public class IndexedContainer extends

/**
* Helper method to add default values for items if available
*
*
* @param t
* data table of added item
*/
@@ -298,7 +299,7 @@ public class IndexedContainer extends

/*
* (non-Javadoc)
*
*
* @see com.vaadin.data.Container#removeItem(java.lang.Object)
*/
@Override
@@ -323,7 +324,7 @@ public class IndexedContainer extends

/*
* (non-Javadoc)
*
*
* @see com.vaadin.data.Container#removeContainerProperty(java.lang.Object )
*/
@Override
@@ -342,7 +343,8 @@ public class IndexedContainer extends
}

// If remove the Property from all Items
for (final Iterator<Object> i = getAllItemIds().iterator(); i.hasNext();) {
for (final Iterator<Object> i = getAllItemIds().iterator(); i
.hasNext();) {
items.get(i.next()).remove(propertyId);
}

@@ -356,7 +358,7 @@ public class IndexedContainer extends

/*
* (non-Javadoc)
*
*
* @see com.vaadin.data.Container.Ordered#addItemAfter(java.lang.Object,
* java.lang.Object)
*/
@@ -387,13 +389,13 @@ public class IndexedContainer extends

/*
* (non-Javadoc)
*
*
* @see com.vaadin.data.Container.Indexed#addItemAt(int, java.lang.Object)
*/
@Override
public Item addItemAt(int index, Object newItemId) {
return internalAddItemAt(index, newItemId, new IndexedContainerItem(
newItemId), true);
return internalAddItemAt(index, newItemId,
new IndexedContainerItem(newItemId), true);
}

/**
@@ -417,7 +419,7 @@ public class IndexedContainer extends
/**
* Generates an unique identifier for use as an item id. Guarantees that the
* generated id is not currently used as an id.
*
*
* @return
*/
private Serializable generateId() {
@@ -441,7 +443,7 @@ public class IndexedContainer extends
/**
* An <code>event</code> object specifying the list whose Item set has
* changed.
*
*
* @author Vaadin Ltd.
* @since 3.0
*/
@@ -449,14 +451,15 @@ public class IndexedContainer extends

private final int addedItemIndex;

private ItemSetChangeEvent(IndexedContainer source, int addedItemIndex) {
private ItemSetChangeEvent(IndexedContainer source,
int addedItemIndex) {
super(source);
this.addedItemIndex = addedItemIndex;
}

/**
* Iff one item is added, gives its index.
*
*
* @return -1 if either multiple items are changed or some other change
* than add is done.
*/
@@ -469,12 +472,12 @@ public class IndexedContainer extends
/**
* An <code>event</code> object specifying the Property in a list whose
* value has changed.
*
*
* @author Vaadin Ltd.
* @since 3.0
*/
private static class PropertyValueChangeEvent extends EventObject implements
Property.ValueChangeEvent, Serializable {
private static class PropertyValueChangeEvent extends EventObject
implements Property.ValueChangeEvent, Serializable {

private PropertyValueChangeEvent(Property source) {
super(source);
@@ -482,7 +485,7 @@ public class IndexedContainer extends

/*
* (non-Javadoc)
*
*
* @see com.vaadin.data.Property.ValueChangeEvent#getProperty()
*/
@Override
@@ -526,7 +529,7 @@ public class IndexedContainer extends

/*
* (non-Javadoc)
*
*
* @see com.vaadin.data.Property.ValueChangeNotifier#addListener(com.
* vaadin.data.Property.ValueChangeListener)
*/
@@ -550,12 +553,13 @@ public class IndexedContainer extends

/*
* (non-Javadoc)
*
*
* @see com.vaadin.data.Property.ValueChangeNotifier#removeListener(com
* .vaadin.data.Property.ValueChangeListener)
*/
@Override
public void removeValueChangeListener(Property.ValueChangeListener listener) {
public void removeValueChangeListener(
Property.ValueChangeListener listener) {
if (propertyValueChangeListeners != null) {
propertyValueChangeListeners.remove(listener);
}
@@ -573,7 +577,7 @@ public class IndexedContainer extends

/**
* Sends a Property value change event to all interested listeners.
*
*
* @param source
* the IndexedContainerProperty object.
*/
@@ -637,7 +641,7 @@ public class IndexedContainer extends

/**
* Adds new single Property change listener.
*
*
* @param propertyId
* the ID of the Property to add.
* @param itemId
@@ -670,7 +674,7 @@ public class IndexedContainer extends

/**
* Removes a previously registered single Property change listener.
*
*
* @param propertyId
* the ID of the Property to remove.
* @param itemId
@@ -707,10 +711,10 @@ public class IndexedContainer extends
/*
* A class implementing the com.vaadin.data.Item interface to be contained
* in the list.
*
*
* @author Vaadin Ltd.
*
*
*
*
* @since 3.0
*/
class IndexedContainerItem implements Item {
@@ -723,7 +727,7 @@ public class IndexedContainer extends
/**
* Constructs a new ListItem instance and connects it to a host
* container.
*
*
* @param itemId
* the Item ID of the new Item.
*/
@@ -733,7 +737,7 @@ public class IndexedContainer extends

/*
* (non-Javadoc)
*
*
* @see com.vaadin.data.Item#getItemProperty(java.lang.Object)
*/
@Override
@@ -755,7 +759,7 @@ public class IndexedContainer extends
* Item. The format of the string is a space separated catenation of the
* <code>String</code> representations of the values of the Properties
* contained by the Item.
*
*
* @return <code>String</code> representation of the Item contents
*/
@Override
@@ -778,7 +782,7 @@ public class IndexedContainer extends
* list. Two Items inside the same list have always different
* hash-codes, though Items in different lists may have identical
* hash-codes.
*
*
* @return A locally unique hash-code as integer
*/
@Override
@@ -789,7 +793,7 @@ public class IndexedContainer extends
/**
* Tests if the given object is the same as the this object. Two Items
* got from a list container with the same ID are equal.
*
*
* @param obj
* an object to compare with this object
* @return <code>true</code> if the given object is the same as this
@@ -813,7 +817,7 @@ public class IndexedContainer extends
* IndexedContainerItem does not support adding new properties. Add
* properties at container level. See
* {@link IndexedContainer#addContainerProperty(Object, Class, Object)}
*
*
* @see com.vaadin.data.Item#addProperty(Object, Property)
*/
@Override
@@ -827,7 +831,7 @@ public class IndexedContainer extends
* Indexed container does not support removing properties. Remove
* properties at container level. See
* {@link IndexedContainer#removeContainerProperty(Object)}
*
*
* @see com.vaadin.data.Item#removeProperty(Object)
*/
@Override
@@ -843,13 +847,13 @@ public class IndexedContainer extends
* A class implementing the {@link Property} interface to be contained in
* the {@link IndexedContainerItem} contained in the
* {@link IndexedContainer}.
*
*
* @author Vaadin Ltd.
*
*
* @since 3.0
*/
private class IndexedContainerProperty<T> implements Property<T>,
Property.ValueChangeNotifier {
private class IndexedContainerProperty<T>
implements Property<T>, Property.ValueChangeNotifier {

/**
* ID of the Item, where this property resides.
@@ -863,7 +867,7 @@ public class IndexedContainer extends

/**
* Constructs a new {@link IndexedContainerProperty} object.
*
*
* @param itemId
* the ID of the Item to connect the new Property to.
* @param propertyId
@@ -884,7 +888,7 @@ public class IndexedContainer extends

/*
* (non-Javadoc)
*
*
* @see com.vaadin.data.Property#getType()
*/
@Override
@@ -894,7 +898,7 @@ public class IndexedContainer extends

/*
* (non-Javadoc)
*
*
* @see com.vaadin.data.Property#getValue()
*/
@Override
@@ -904,7 +908,7 @@ public class IndexedContainer extends

/*
* (non-Javadoc)
*
*
* @see com.vaadin.data.Property#isReadOnly()
*/
@Override
@@ -914,7 +918,7 @@ public class IndexedContainer extends

/*
* (non-Javadoc)
*
*
* @see com.vaadin.data.Property#setReadOnly(boolean)
*/
@Override
@@ -928,11 +932,12 @@ public class IndexedContainer extends

/*
* (non-Javadoc)
*
*
* @see com.vaadin.data.Property#setValue(java.lang.Object)
*/
@Override
public void setValue(Object newValue) throws Property.ReadOnlyException {
public void setValue(Object newValue)
throws Property.ReadOnlyException {
// Gets the Property set
final Map<Object, Object> propertySet = items.get(itemId);

@@ -956,46 +961,13 @@ public class IndexedContainer extends
firePropertyValueChange(this);
}

/**
* Returns a string representation of this object. The returned string
* representation depends on if the legacy Property toString mode is
* enabled or disabled.
* <p>
* If legacy Property toString mode is enabled, returns the value of the
* <code>Property</code> converted to a String.
* </p>
* <p>
* If legacy Property toString mode is disabled, the string
* representation has no special meaning
* </p>
*
* @return A string representation of the value value stored in the
* Property or a string representation of the Property object.
* @deprecated As of 7.0. To get the property value, use
* {@link #getValue()} instead (and possibly toString on
* that)
*/
@Deprecated
@Override
public String toString() {
if (!LegacyPropertyHelper.isLegacyToStringEnabled()) {
return super.toString();
} else {
return LegacyPropertyHelper.legacyPropertyToString(this);
}
}

private Logger getLogger() {
return Logger.getLogger(IndexedContainerProperty.class.getName());
}

/**
* Calculates a integer hash-code for the Property that's unique inside
* the Item containing the Property. Two different Properties inside the
* same Item contained in the same list always have different
* hash-codes, though Properties in different Items may have identical
* hash-codes.
*
*
* @return A locally unique hash-code as integer
*/
@Override
@@ -1006,7 +978,7 @@ public class IndexedContainer extends
/**
* Tests if the given object is the same as the this object. Two
* Properties got from an Item with the same ID are equal.
*
*
* @param obj
* an object to compare with this object
* @return <code>true</code> if the given object is the same as this
@@ -1019,19 +991,19 @@ public class IndexedContainer extends
return false;
}
final IndexedContainerProperty lp = (IndexedContainerProperty) obj;
return lp.getHost() == getHost()
&& lp.propertyId.equals(propertyId)
return lp.getHost() == getHost() && lp.propertyId.equals(propertyId)
&& lp.itemId.equals(itemId);
}

/*
* (non-Javadoc)
*
*
* @see com.vaadin.data.Property.ValueChangeNotifier#addListener(
* com.vaadin.data.Property.ValueChangeListener)
*/
@Override
public void addValueChangeListener(Property.ValueChangeListener listener) {
public void addValueChangeListener(
Property.ValueChangeListener listener) {
addSinglePropertyChangeListener(propertyId, itemId, listener);
}

@@ -1047,7 +1019,7 @@ public class IndexedContainer extends

/*
* (non-Javadoc)
*
*
* @see com.vaadin.data.Property.ValueChangeNotifier#removeListener
* (com.vaadin.data.Property.ValueChangeListener)
*/
@@ -1075,7 +1047,7 @@ public class IndexedContainer extends

/*
* (non-Javadoc)
*
*
* @see com.vaadin.data.Container.Sortable#sort(java.lang.Object[],
* boolean[])
*/
@@ -1086,7 +1058,7 @@ public class IndexedContainer extends

/*
* (non-Javadoc)
*
*
* @see com.vaadin.data.Container.Sortable#getSortableContainerPropertyIds
* ()
*/
@@ -1107,10 +1079,10 @@ public class IndexedContainer extends

/**
* Supports cloning of the IndexedContainer cleanly.
*
*
* @throws CloneNotSupportedException
* if an object cannot be cloned. .
*
*
* @deprecated As of 6.6. Cloning support might be removed from
* IndexedContainer in the future
*/
@@ -1122,26 +1094,35 @@ public class IndexedContainer extends
final IndexedContainer nc = new IndexedContainer();

// Clone the shallow properties
nc.setAllItemIds(getAllItemIds() != null ? (ListSet<Object>) ((ListSet<Object>) getAllItemIds())
.clone() : null);
nc.setItemSetChangeListeners(getItemSetChangeListeners() != null ? new LinkedList<Container.ItemSetChangeListener>(
getItemSetChangeListeners()) : null);
nc.propertyIds = propertyIds != null ? (ArrayList<Object>) propertyIds
.clone() : null;
nc.setPropertySetChangeListeners(getPropertySetChangeListeners() != null ? new LinkedList<Container.PropertySetChangeListener>(
getPropertySetChangeListeners()) : null);
nc.propertyValueChangeListeners = propertyValueChangeListeners != null ? (LinkedList<Property.ValueChangeListener>) propertyValueChangeListeners
.clone() : null;
nc.readOnlyProperties = readOnlyProperties != null ? (HashSet<Property<?>>) readOnlyProperties
.clone() : null;
nc.singlePropertyValueChangeListeners = singlePropertyValueChangeListeners != null ? (Hashtable<Object, Map<Object, List<Property.ValueChangeListener>>>) singlePropertyValueChangeListeners
.clone() : null;
nc.setAllItemIds(getAllItemIds() != null
? (ListSet<Object>) ((ListSet<Object>) getAllItemIds()).clone()
: null);
nc.setItemSetChangeListeners(getItemSetChangeListeners() != null
? new LinkedList<Container.ItemSetChangeListener>(
getItemSetChangeListeners())
: null);
nc.propertyIds = propertyIds != null
? (ArrayList<Object>) propertyIds.clone() : null;
nc.setPropertySetChangeListeners(getPropertySetChangeListeners() != null
? new LinkedList<Container.PropertySetChangeListener>(
getPropertySetChangeListeners())
: null);
nc.propertyValueChangeListeners = propertyValueChangeListeners != null
? (LinkedList<Property.ValueChangeListener>) propertyValueChangeListeners
.clone()
: null;
nc.readOnlyProperties = readOnlyProperties != null
? (HashSet<Property<?>>) readOnlyProperties.clone() : null;
nc.singlePropertyValueChangeListeners = singlePropertyValueChangeListeners != null
? (Hashtable<Object, Map<Object, List<Property.ValueChangeListener>>>) singlePropertyValueChangeListeners
.clone()
: null;

nc.types = types != null ? (Hashtable<Object, Class<?>>) types.clone()
: null;

nc.setFilters((HashSet<Filter>) ((HashSet<Filter>) getFilters())
.clone());
nc.setFilters(
(HashSet<Filter>) ((HashSet<Filter>) getFilters()).clone());

nc.setFilteredItemIds(getFilteredItemIds() == null ? null
: (ListSet<Object>) ((ListSet<Object>) getFilteredItemIds())
@@ -1152,7 +1133,8 @@ public class IndexedContainer extends
nc.items = null;
} else {
nc.items = new Hashtable<Object, Map<Object, Object>>();
for (final Iterator<?> i = items.keySet().iterator(); i.hasNext();) {
for (final Iterator<?> i = items.keySet().iterator(); i
.hasNext();) {
final Object id = i.next();
final Hashtable<Object, Object> it = (Hashtable<Object, Object>) items
.get(id);
@@ -1198,7 +1180,7 @@ public class IndexedContainer extends

/*
* (non-Javadoc)
*
*
* @see com.vaadin.data.util.AbstractInMemoryContainer#getContainerFilters()
*/
@Override
@@ -1208,7 +1190,7 @@ public class IndexedContainer extends

/*
* (non-Javadoc)
*
*
* @see com.vaadin.data.util.AbstractInMemoryContainer#getContainerFilters()
*/
@Override

+ 0
- 108
server/src/main/java/com/vaadin/data/util/LegacyPropertyHelper.java Datei anzeigen

@@ -1,108 +0,0 @@
/*
* Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.data.util;

import java.io.Serializable;
import java.util.logging.Level;
import java.util.logging.Logger;

import com.vaadin.data.Property;
import com.vaadin.server.Constants;
import com.vaadin.server.DeploymentConfiguration.LegacyProperyToStringMode;
import com.vaadin.server.VaadinService;

/**
* Helper class which provides methods for handling Property.toString in a
* Vaadin 6 compatible way
*
* @author Vaadin Ltd
* @since 7.1
* @deprecated This is only used internally for backwards compatibility
*/
@Deprecated
public class LegacyPropertyHelper implements Serializable {

/**
* Returns the property value converted to a String.
*
* @param p
* The property
* @return A string representation of the property value, compatible with
* how Property implementations in Vaadin 6 do it
*/
public static String legacyPropertyToString(Property p) {
maybeLogLegacyPropertyToStringWarning(p);
Object value = p.getValue();
if (value == null) {
return null;
}
return value.toString();
}

public static void maybeLogLegacyPropertyToStringWarning(Property p) {
if (!logLegacyToStringWarning()) {
return;
}

getLogger().log(Level.WARNING,
Constants.WARNING_LEGACY_PROPERTY_TOSTRING,
p.getClass().getName());
if (getLogger().isLoggable(Level.FINE)) {
getLogger().log(Level.FINE,
"Strack trace for legacy toString to ease debugging",
new Throwable());
}
}

/**
* Checks if legacy Property.toString() implementation is enabled. The
* legacy Property.toString() will return the value of the property somehow
* converted to a String. If the legacy mode is disabled, toString() will
* return super.toString().
* <p>
* The legacy toString mode can be toggled using the
* "legacyPropertyToString" init parameter
* </p>
*
* @return true if legacy Property.toString() mode is enabled, false
* otherwise
*/
public static boolean isLegacyToStringEnabled() {
if (VaadinService.getCurrent() == null) {
// This will happen at least in JUnit tests. We do not what the real
// value should be but it seems more safe to use the legacy mode.
return true;
}
return VaadinService.getCurrent().getDeploymentConfiguration()
.getLegacyPropertyToStringMode().useLegacyMode();
}

private static boolean logLegacyToStringWarning() {
if (VaadinService.getCurrent() == null) {
// This will happen at least in JUnit tests. We do not want to spam
// the log with these messages in this case.
return false;
}
return VaadinService.getCurrent().getDeploymentConfiguration()
.getLegacyPropertyToStringMode() == LegacyProperyToStringMode.WARNING;

}

private static Logger getLogger() {
return Logger.getLogger(LegacyPropertyHelper.class.getName());
}

}

+ 16
- 47
server/src/main/java/com/vaadin/data/util/sqlcontainer/ColumnProperty.java Datei anzeigen

@@ -1,12 +1,12 @@
/*
* Copyright 2000-2014 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
@@ -21,14 +21,13 @@ import java.sql.Timestamp;
import java.util.logging.Logger;

import com.vaadin.data.Property;
import com.vaadin.data.util.LegacyPropertyHelper;
import com.vaadin.legacy.data.util.converter.LegacyConverter.ConversionException;

/**
* ColumnProperty represents the value of one column in a RowItem. In addition
* to the value, ColumnProperty also contains some basic column attributes such
* as nullability status, read-only status and data type.
*
*
* Note that depending on the QueryDelegate in use this does not necessarily map
* into an actual column in a database table.
*/
@@ -63,14 +62,14 @@ final public class ColumnProperty implements Property {
* Deprecated constructor for ColumnProperty. If this is used the primary
* keys are not identified correctly in some cases for some databases (i.e.
* Oracle). See http://dev.vaadin.com/ticket/9145.
*
*
* @param propertyId
* @param readOnly
* @param allowReadOnlyChange
* @param nullable
* @param value
* @param type
*
*
* @deprecated As of 7.0. Use
* {@link #ColumnProperty(String, boolean, boolean, boolean, boolean, Object, Class)
* instead
@@ -85,7 +84,7 @@ final public class ColumnProperty implements Property {

/**
* Creates a new ColumnProperty instance.
*
*
* @param propertyId
* The ID of this property.
* @param readOnly
@@ -124,7 +123,7 @@ final public class ColumnProperty implements Property {
/**
* Returns the current value for this property. To get the previous value
* (if one exists) for a modified property use {@link #getOldValue()}.
*
*
* @return
*/
@Override
@@ -138,7 +137,7 @@ final public class ColumnProperty implements Property {
/**
* Returns the original non-modified value of this property if it has been
* modified.
*
*
* @return The original value if <code>isModified()</code> is true,
* <code>getValue()</code> otherwise.
*/
@@ -147,8 +146,8 @@ final public class ColumnProperty implements Property {
}

@Override
public void setValue(Object newValue) throws ReadOnlyException,
ConversionException {
public void setValue(Object newValue)
throws ReadOnlyException, ConversionException {
if (newValue == null && !nullable) {
throw new NotNullableException(
"Null values are not allowed for this property.");
@@ -232,7 +231,7 @@ final public class ColumnProperty implements Property {
* to be written by the underlying database. Also used for values like
* VERSION and AUTO_INCREMENT fields that might be set to read-only by the
* container but the database still allows writes.
*
*
* @return true if the read-only status can be changed, false otherwise.
*/
public boolean isReadOnlyChangeAllowed() {
@@ -254,36 +253,6 @@ final public class ColumnProperty implements Property {
return propertyId;
}

/**
* Returns a string representation of this object. The returned string
* representation depends on if the legacy Property toString mode is enabled
* or disabled.
* <p>
* If legacy Property toString mode is enabled, returns the value of this
* <code>Property</code> converted to a String.
* </p>
* <p>
* If legacy Property toString mode is disabled, the string representation
* has no special meaning
* </p>
*
* @see LegacyPropertyHelper#isLegacyToStringEnabled()
*
* @return A string representation of the value value stored in the Property
* or a string representation of the Property object.
* @deprecated As of 7.0. To get the property value, use {@link #getValue()}
* instead (and possibly toString on that)
*/
@Deprecated
@Override
public String toString() {
if (!LegacyPropertyHelper.isLegacyToStringEnabled()) {
return super.toString();
} else {
return LegacyPropertyHelper.legacyPropertyToString(this);
}
}

private static Logger getLogger() {
return Logger.getLogger(ColumnProperty.class.getName());
}
@@ -318,7 +287,7 @@ final public class ColumnProperty implements Property {
/**
* Return whether the value of this property should be persisted to the
* database.
*
*
* @return true if the value should be written to the database, false
* otherwise.
*/
@@ -334,7 +303,7 @@ final public class ColumnProperty implements Property {

/**
* Returns whether or not this property is used as a row identifier.
*
*
* @return true if the property is a row identifier, false otherwise.
*/
public boolean isRowIdentifier() {
@@ -359,7 +328,7 @@ final public class ColumnProperty implements Property {
/**
* Constructs a new <code>NotNullableException</code> with the specified
* detail message.
*
*
* @param msg
* the detail message
*/
@@ -370,7 +339,7 @@ final public class ColumnProperty implements Property {
/**
* Constructs a new <code>NotNullableException</code> from another
* exception.
*
*
* @param cause
* The cause of the failure
*/

+ 127
- 169
server/src/main/java/com/vaadin/legacy/ui/LegacyAbstractField.java Datei anzeigen

@@ -1,12 +1,12 @@
/*
* Copyright 2000-2014 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
@@ -32,7 +32,6 @@ import org.jsoup.nodes.Element;

import com.vaadin.data.Buffered;
import com.vaadin.data.Property;
import com.vaadin.data.util.LegacyPropertyHelper;
import com.vaadin.event.Action;
import com.vaadin.event.ShortcutAction;
import com.vaadin.event.ShortcutListener;
@@ -40,8 +39,8 @@ import com.vaadin.legacy.data.Validatable;
import com.vaadin.legacy.data.Validator;
import com.vaadin.legacy.data.Validator.InvalidValueException;
import com.vaadin.legacy.data.util.converter.LegacyConverter;
import com.vaadin.legacy.data.util.converter.LegacyConverterUtil;
import com.vaadin.legacy.data.util.converter.LegacyConverter.ConversionException;
import com.vaadin.legacy.data.util.converter.LegacyConverterUtil;
import com.vaadin.server.AbstractErrorMessage;
import com.vaadin.server.CompositeErrorMessage;
import com.vaadin.server.ErrorMessage;
@@ -60,22 +59,22 @@ import com.vaadin.ui.declarative.DesignContext;
* <code>LegacyAbstractField</code> implements that interface itself, too, so
* accessing the Property value represented by it is straightforward.
* </p>
*
*
* <p>
* LegacyAbstractField also provides the {@link com.vaadin.data.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.
* </p>
*
*
* <p>
* The class also supports {@link com.vaadin.legacy.data.Validator validators} to make
* sure the value contained in the field is valid.
* The class also supports {@link com.vaadin.legacy.data.Validator validators}
* to make sure the value contained in the field is valid.
* </p>
*
*
* @author Vaadin Ltd.
* @since 3.0
*
*
* @deprecated This class is, apart from the rename, identical to the Vaadin 7
* {@code com.vaadin.ui.AbstractField}. It is provided for
* compatibility and migration purposes. As of 8.0, new field
@@ -157,7 +156,7 @@ public abstract class LegacyAbstractField<T> extends AbstractComponent
/**
* Whether this field is currently registered as listening to events from
* its data source.
*
*
* @see #setPropertyDataSource(Property)
* @see #addPropertyListeners()
* @see #removePropertyListeners()
@@ -179,11 +178,11 @@ public abstract class LegacyAbstractField<T> extends AbstractComponent
/**
* Returns true if the error indicator be hidden when painting the component
* even when there are errors.
*
*
* This is a mostly internal method, but can be overridden in subclasses
* e.g. if the error indicator should also be shown for empty fields in some
* cases.
*
*
* @return true to hide the error indicator, false to use the normal logic
* to show it when there are errors
*/
@@ -199,7 +198,7 @@ public abstract class LegacyAbstractField<T> extends AbstractComponent
* 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
*/
@Override
@@ -217,7 +216,7 @@ public abstract class LegacyAbstractField<T> extends AbstractComponent

/**
* Changes the readonly state and throw read-only status change events.
*
*
* @see com.vaadin.ui.Component#setReadOnly(boolean)
*/
@Override
@@ -228,7 +227,7 @@ public abstract class LegacyAbstractField<T> extends AbstractComponent

/**
* Tests if the invalid data is committed to datasource.
*
*
* @see com.vaadin.data.BufferedValidatable#isInvalidCommitted()
*/
@Override
@@ -238,7 +237,7 @@ public abstract class LegacyAbstractField<T> extends AbstractComponent

/**
* Sets if the invalid data should be committed to datasource.
*
*
* @see com.vaadin.data.BufferedValidatable#setInvalidCommitted(boolean)
*/
@Override
@@ -251,8 +250,8 @@ public abstract class LegacyAbstractField<T> extends AbstractComponent
* here, we use the default documentation from the implemented interface.
*/
@Override
public void commit() throws Buffered.SourceException,
InvalidValueException {
public void commit()
throws Buffered.SourceException, InvalidValueException {
if (dataSource != null && !dataSource.isReadOnly()) {
if ((isInvalidCommitted() || isValid())) {
try {
@@ -310,7 +309,7 @@ public abstract class LegacyAbstractField<T> extends AbstractComponent
/**
* Gets the value from the data source. This is only here because of clarity
* in the code that handles both the data model value and the field value.
*
*
* @return The value of the property data source
*/
private Object getDataSourceValue() {
@@ -321,7 +320,7 @@ public abstract class LegacyAbstractField<T> extends AbstractComponent
* Returns the field value. This is always identical to {@link #getValue()}
* and only here because of clarity in the code that handles both the data
* model value and the field value.
*
*
* @return The value of the field
*/
private T getFieldValue() {
@@ -358,9 +357,9 @@ public abstract class LegacyAbstractField<T> extends AbstractComponent
* Setting buffered mode from true to false will commit any pending changes.
* </p>
* <p>
*
*
* </p>
*
*
* @since 7.0.0
* @param buffered
* true if buffered mode should be turned on, false otherwise
@@ -378,7 +377,7 @@ public abstract class LegacyAbstractField<T> extends AbstractComponent

/**
* Checks the buffered mode of this LegacyField.
*
*
* @return true if buffered mode is on, false otherwise
*/
@Override
@@ -386,49 +385,16 @@ public abstract class LegacyAbstractField<T> extends AbstractComponent
return buffered;
}

/**
* Returns a string representation of this object. The returned string
* representation depends on if the legacy Property toString mode is enabled
* or disabled.
* <p>
* If legacy Property toString mode is enabled, returns the value of this
* <code>LegacyField</code> converted to a String.
* </p>
* <p>
* If legacy Property toString mode is disabled, the string representation
* has no special meaning
* </p>
*
* @see LegacyPropertyHelper#isLegacyToStringEnabled()
*
* @return A string representation of the value value stored in the Property
* or a string representation of the Property object.
* @deprecated As of 7.0. Use {@link #getValue()} to get the value of the
* field, {@link #getConvertedValue()} to get the field value
* converted to the data model type or
* {@link #getPropertyDataSource()} .getValue() to get the value
* of the data source.
*/
@Deprecated
@Override
public String toString() {
if (!LegacyPropertyHelper.isLegacyToStringEnabled()) {
return super.toString();
} else {
return LegacyPropertyHelper.legacyPropertyToString(this);
}
}

/* Property interface implementation */

/**
* Gets the current value of the field.
*
*
* <p>
* This is the visible, modified and possible invalid value the user have
* entered to the field.
* </p>
*
*
* <p>
* Note that the object returned is compatible with getType(). For example,
* if the type is String, this returns Strings even when the underlying
@@ -437,12 +403,12 @@ public abstract class LegacyAbstractField<T> extends AbstractComponent
* data source, use {@link Property#getValue()} for the property data
* source.
* </p>
*
*
* <p>
* Since Vaadin 7.0, no implicit conversions between other data types and
* String are performed, but a converter is used if set.
* </p>
*
*
* @return the current value of the field.
*/
@Override
@@ -452,7 +418,7 @@ public abstract class LegacyAbstractField<T> extends AbstractComponent

/**
* Sets the value of the field.
*
*
* @param newFieldValue
* the New value of the field.
* @throws Property.ReadOnlyException
@@ -465,7 +431,7 @@ public abstract class LegacyAbstractField<T> extends AbstractComponent

/**
* Sets the value of the field.
*
*
* @param newFieldValue
* the New value of the field.
* @param repaintIsNotNeeded
@@ -480,7 +446,7 @@ public abstract class LegacyAbstractField<T> extends AbstractComponent

/**
* Sets the value of the field.
*
*
* @since 7.5.7
* @param newFieldValue
* the New value of the field.
@@ -503,10 +469,10 @@ public abstract class LegacyAbstractField<T> extends AbstractComponent
throw new Property.ReadOnlyException();
}
try {
T doubleConvertedFieldValue = convertFromModel(convertToModel(
newFieldValue));
if (!SharedUtil
.equals(newFieldValue, doubleConvertedFieldValue)) {
T doubleConvertedFieldValue = convertFromModel(
convertToModel(newFieldValue));
if (!SharedUtil.equals(newFieldValue,
doubleConvertedFieldValue)) {
newFieldValue = doubleConvertedFieldValue;
repaintIsNotNeeded = false;
}
@@ -517,9 +483,8 @@ public abstract class LegacyAbstractField<T> extends AbstractComponent

// Repaint is needed even when the client thinks that it knows the
// new state if validity of the component may change
if (repaintIsNotNeeded
&& (isRequired() || hasValidators()
|| getConverter() != null)) {
if (repaintIsNotNeeded && (isRequired() || hasValidators()
|| getConverter() != null)) {
repaintIsNotNeeded = false;
}

@@ -545,8 +510,8 @@ public abstract class LegacyAbstractField<T> extends AbstractComponent

// Commits the value to datasource
committingValueToDataSource = true;
getPropertyDataSource().setValue(
convertToModel(newFieldValue));
getPropertyDataSource()
.setValue(convertToModel(newFieldValue));

// The buffer is now unmodified
setModified(false);
@@ -593,7 +558,7 @@ public abstract class LegacyAbstractField<T> extends AbstractComponent

/**
* Gets the current data source of the field, if any.
*
*
* @return the current data source as a Property, or <code>null</code> if
* none defined.
*/
@@ -607,7 +572,7 @@ public abstract class LegacyAbstractField<T> extends AbstractComponent
* Sets the specified Property as the data source for the field. All
* uncommitted changes are replaced with a value from the new data source.
* </p>
*
*
* <p>
* If the datasource has any validators, the same validators are added to
* the field. Because the default behavior of the field is to allow invalid
@@ -616,7 +581,7 @@ public abstract class LegacyAbstractField<T> extends AbstractComponent
* is invalid. After the value is valid, the error message is not shown and
* the commit can be done normally.
* </p>
*
*
* <p>
* If the data source implements
* {@link com.vaadin.data.Property.ValueChangeNotifier} and/or
@@ -627,7 +592,7 @@ public abstract class LegacyAbstractField<T> extends AbstractComponent
* {@link LegacyAbstractField#detach() detach} and re-added on
* {@link LegacyAbstractField#attach() attach}.
* </p>
*
*
* <p>
* Note: before 6.5 we actually called discard() method in the beginning of
* the method. This was removed to simplify implementation, avoid excess
@@ -636,7 +601,7 @@ public abstract class LegacyAbstractField<T> extends AbstractComponent
* method is called). Some complex field implementations might now need to
* override this method to do housekeeping similar to discard().
* </p>
*
*
* @param newDataSource
* the new data source Property.
*/
@@ -651,13 +616,13 @@ public abstract class LegacyAbstractField<T> extends AbstractComponent

// Sets the new data source
dataSource = newDataSource;
getState().propertyReadOnly = dataSource == null ? false : dataSource
.isReadOnly();
getState().propertyReadOnly = dataSource == null ? false
: dataSource.isReadOnly();

// Check if the current converter is compatible.
if (newDataSource != null
&& !LegacyConverterUtil.canConverterPossiblyHandle(getConverter(),
getType(), newDataSource.getType())) {
&& !LegacyConverterUtil.canConverterPossiblyHandle(
getConverter(), getType(), newDataSource.getType())) {
// There is no converter set or there is no way the current
// converter can be compatible.
setConverter(newDataSource.getType());
@@ -674,8 +639,8 @@ public abstract class LegacyAbstractField<T> extends AbstractComponent
setCurrentBufferedSourceException(null);
}
} catch (final Throwable e) {
setCurrentBufferedSourceException(new Buffered.SourceException(
this, e));
setCurrentBufferedSourceException(
new Buffered.SourceException(this, e));
setModified(true);
throw getCurrentBufferedSourceException();
}
@@ -697,9 +662,8 @@ public abstract class LegacyAbstractField<T> extends AbstractComponent

// Fires value change if the value has changed
T value = getInternalValue();
if ((value != oldValue)
&& ((value != null && !value.equals(oldValue))
|| value == null)) {
if ((value != oldValue) && ((value != null && !value.equals(oldValue))
|| value == null)) {
fireValueChange(false);
}
}
@@ -708,20 +672,20 @@ public abstract class LegacyAbstractField<T> extends AbstractComponent
* Retrieves a converter for the field from the converter factory defined
* for the application. Clears the converter if no application reference is
* available or if the factory returns null.
*
*
* @param datamodelType
* The type of the data model that we want to be able to convert
* from
*/
public void setConverter(Class<?> datamodelType) {
LegacyConverter<T, ?> c = (LegacyConverter<T, ?>) LegacyConverterUtil.getConverter(
getType(), datamodelType, getSession());
LegacyConverter<T, ?> c = (LegacyConverter<T, ?>) LegacyConverterUtil
.getConverter(getType(), datamodelType, getSession());
setConverter(c);
}

/**
* Convert the given value from the data source type to the UI type.
*
*
* @param newValue
* The data source value to convert.
* @return The converted value that is compatible with the UI type or the
@@ -736,7 +700,7 @@ public abstract class LegacyAbstractField<T> extends AbstractComponent

/**
* Convert the given value from the data source type to the UI type.
*
*
* @param newValue
* The data source value to convert.
* @return The converted value that is compatible with the UI type or the
@@ -752,7 +716,7 @@ public abstract class LegacyAbstractField<T> extends AbstractComponent

/**
* Convert the given value from the UI type to the data source type.
*
*
* @param fieldValue
* The value to convert. Typically returned by
* {@link #getFieldValue()}
@@ -768,7 +732,7 @@ public abstract class LegacyAbstractField<T> extends AbstractComponent

/**
* Convert the given value from the UI type to the data source type.
*
*
* @param fieldValue
* The value to convert. Typically returned by
* {@link #getFieldValue()}
@@ -793,7 +757,7 @@ public abstract class LegacyAbstractField<T> extends AbstractComponent
/**
* Retrieves the type of the currently used data model. If the field has no
* data source then the model type of the converter is used.
*
*
* @since 7.1
* @return The type of the currently used data model or null if no data
* source or converter is set.
@@ -811,7 +775,7 @@ public abstract class LegacyAbstractField<T> extends AbstractComponent
/**
* Returns the conversion error with {0} replaced by the data source type
* and {1} replaced by the exception (localized) message.
*
*
* @since 7.1
* @param dataSourceType
* the type of the data source
@@ -845,7 +809,7 @@ public abstract class LegacyAbstractField<T> extends AbstractComponent
* converter has been set. The value is not necessarily the same as the data
* source value e.g. if the field is in buffered mode and has been modified.
* </p>
*
*
* @return The converted value that is compatible with the data source type
*/
public Object getConvertedValue() {
@@ -857,7 +821,7 @@ public abstract class LegacyAbstractField<T> extends AbstractComponent
* value given is converted to the field type and then assigned to the
* field. This will update the property data source in the same way as when
* {@link #setValue(Object)} is called.
*
*
* @param value
* The value to set. Must be the same type as the data source.
*/
@@ -870,7 +834,7 @@ public abstract class LegacyAbstractField<T> extends AbstractComponent
/**
* Adds a new validator for the field's value. All validators added to a
* field are checked each time the its value changes.
*
*
* @param validator
* the new validator to be added.
*/
@@ -885,7 +849,7 @@ public abstract class LegacyAbstractField<T> extends AbstractComponent

/**
* Gets the validators of the field.
*
*
* @return An unmodifiable collection that holds all validators for the
* field.
*/
@@ -904,7 +868,7 @@ public abstract class LegacyAbstractField<T> extends AbstractComponent

/**
* Removes the validator from the field.
*
*
* @param validator
* the validator to remove.
*/
@@ -931,10 +895,10 @@ public abstract class LegacyAbstractField<T> extends AbstractComponent
* Tests the current value against registered validators if the field is not
* empty. If the field is empty it is considered valid if it is not required
* and invalid otherwise. Validators are never checked for empty fields.
*
*
* In most cases, {@link #validate()} should be used instead of
* {@link #isValid()} to also get the error message.
*
*
* @return <code>true</code> if all registered validators claim that the
* current value is valid or if the field is empty and not required,
* <code>false</code> otherwise.
@@ -952,16 +916,16 @@ public abstract class LegacyAbstractField<T> extends AbstractComponent

/**
* Checks the validity of the LegacyField.
*
*
* A field is invalid if it is set as required (using
* {@link #setRequired(boolean)} and is empty, if one or several of the
* validators added to the field indicate it is invalid or if the value
* cannot be converted provided a converter has been set.
*
*
* The "required" validation is a built-in validation feature. If the field
* is required and empty this method throws an EmptyValueException with the
* error message set using {@link #setRequiredError(String)}.
*
*
* @see com.vaadin.legacy.data.Validatable#validate()
*/
@Override
@@ -977,7 +941,7 @@ public abstract class LegacyAbstractField<T> extends AbstractComponent
* Validates that the given value pass the validators for the field.
* <p>
* This method does not check the requiredness of the field.
*
*
* @param fieldValue
* The value to check
* @throws Validator.InvalidValueException
@@ -995,8 +959,8 @@ public abstract class LegacyAbstractField<T> extends AbstractComponent
valueToValidate = getConverter().convertToModel(fieldValue,
getModelType(), getLocale());
} catch (ConversionException e) {
throw new InvalidValueException(getConversionError(
getConverter().getModelType(), e));
throw new InvalidValueException(
getConversionError(getConverter().getModelType(), e));
}
}

@@ -1022,9 +986,8 @@ public abstract class LegacyAbstractField<T> extends AbstractComponent
throw validationExceptions.get(0);
}

InvalidValueException[] exceptionArray = validationExceptions
.toArray(new InvalidValueException[validationExceptions
.size()]);
InvalidValueException[] exceptionArray = validationExceptions.toArray(
new InvalidValueException[validationExceptions.size()]);

// Create a composite validator and include all exceptions
throw new Validator.InvalidValueException(null, exceptionArray);
@@ -1033,7 +996,7 @@ public abstract class LegacyAbstractField<T> extends AbstractComponent
/**
* Fields allow invalid values by default. In most cases this is wanted,
* because the field otherwise visually forget the user input immediately.
*
*
* @return true iff the invalid values are allowed.
* @see com.vaadin.legacy.data.Validatable#isInvalidAllowed()
*/
@@ -1052,7 +1015,7 @@ public abstract class LegacyAbstractField<T> extends AbstractComponent
* values. The validators are automatically copied to the field when the
* datasource is set.
* </p>
*
*
* @see com.vaadin.legacy.data.Validatable#setInvalidAllowed(boolean)
*/
@Override
@@ -1065,7 +1028,7 @@ public abstract class LegacyAbstractField<T> extends AbstractComponent
* Error messages shown by the fields are composites of the error message
* thrown by the superclasses (that is the component error message),
* validation errors and buffered source errors.
*
*
* @see com.vaadin.ui.AbstractComponent#getErrorMessage()
*/
@Override
@@ -1098,14 +1061,11 @@ public abstract class LegacyAbstractField<T> extends AbstractComponent
}

// Throw combination of the error types
return new CompositeErrorMessage(
new ErrorMessage[] {
superError,
AbstractErrorMessage
.getErrorMessageForException(validationError),
AbstractErrorMessage
.getErrorMessageForException(
getCurrentBufferedSourceException()) });
return new CompositeErrorMessage(new ErrorMessage[] { superError,
AbstractErrorMessage
.getErrorMessageForException(validationError),
AbstractErrorMessage.getErrorMessageForException(
getCurrentBufferedSourceException()) });

}

@@ -1189,10 +1149,8 @@ public abstract class LegacyAbstractField<T> extends AbstractComponent
static {
try {
READ_ONLY_STATUS_CHANGE_METHOD = Property.ReadOnlyStatusChangeListener.class
.getDeclaredMethod(
"readOnlyStatusChange",
new Class[] {
Property.ReadOnlyStatusChangeEvent.class });
.getDeclaredMethod("readOnlyStatusChange", new Class[] {
Property.ReadOnlyStatusChangeEvent.class });
} catch (final java.lang.NoSuchMethodException e) {
// This should never happen
throw new java.lang.RuntimeException(
@@ -1203,7 +1161,7 @@ public abstract class LegacyAbstractField<T> extends AbstractComponent
/**
* React to read only status changes of the property by requesting a
* repaint.
*
*
* @see Property.ReadOnlyStatusChangeListener
*/
@Override
@@ -1223,7 +1181,7 @@ public abstract class LegacyAbstractField<T> extends AbstractComponent
/**
* An <code>Event</code> object specifying the Property whose read-only
* status has changed.
*
*
* @author Vaadin Ltd.
* @since 3.0
*/
@@ -1232,7 +1190,7 @@ public abstract class LegacyAbstractField<T> extends AbstractComponent

/**
* New instance of text change event.
*
*
* @param source
* the Source of the event.
*/
@@ -1242,7 +1200,7 @@ public abstract class LegacyAbstractField<T> extends AbstractComponent

/**
* Property where the event occurred.
*
*
* @return the Source of the event.
*/
@Override
@@ -1306,10 +1264,10 @@ public abstract class LegacyAbstractField<T> extends AbstractComponent
/**
* This method listens to data source value changes and passes the changes
* forwards.
*
*
* Changes are not forwarded to the listeners of the field during internal
* operations of the field to avoid duplicate notifications.
*
*
* @param event
* the value change event telling the data source contents have
* changed.
@@ -1326,7 +1284,7 @@ public abstract class LegacyAbstractField<T> extends AbstractComponent
* reports different value than the one the field has just
* committed to it. In this case we respect the property
* value.
*
*
* Still, we don't fire value change yet, but instead
* postpone it until "commit" is done. See setValue(Object,
* boolean) and commit().
@@ -1355,7 +1313,7 @@ public abstract class LegacyAbstractField<T> extends AbstractComponent

/*
* (non-Javadoc)
*
*
* @see com.vaadin.ui.Component.Focusable#getTabIndex()
*/
@Override
@@ -1365,7 +1323,7 @@ public abstract class LegacyAbstractField<T> extends AbstractComponent

/*
* (non-Javadoc)
*
*
* @see com.vaadin.ui.Component.Focusable#setTabIndex(int)
*/
@Override
@@ -1377,13 +1335,13 @@ public abstract class LegacyAbstractField<T> extends AbstractComponent
* Returns the internal field value, which might not match the data source
* value e.g. if the field has been modified and is not in write-through
* mode.
*
*
* This method can be overridden by subclasses together with
* {@link #setInternalValue(Object)} to compute internal field value at
* runtime. When doing so, typically also {@link #isModified()} needs to be
* overridden and care should be taken in the management of the empty state
* and buffering support.
*
*
* @return internal field value
*/
protected T getInternalValue() {
@@ -1395,9 +1353,9 @@ public abstract class LegacyAbstractField<T> extends AbstractComponent
* 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.
*
*
* Subclasses can also override {@link #getInternalValue()} if necessary.
*
*
* @param newValue
* the new value to be set.
*/
@@ -1411,7 +1369,7 @@ public abstract class LegacyAbstractField<T> extends AbstractComponent

/**
* Notifies the component that it is connected to an application.
*
*
* @see com.vaadin.ui.Component#attach()
*/
@Override
@@ -1441,8 +1399,8 @@ public abstract class LegacyAbstractField<T> extends AbstractComponent
if (dataSource != null && !isModified()) {
// When we have a data source and the internal value is directly
// read from that we want to update the value
T newInternalValue = convertFromModel(getPropertyDataSource()
.getValue());
T newInternalValue = convertFromModel(
getPropertyDataSource().getValue());
if (!SharedUtil.equals(newInternalValue, getInternalValue())) {
setInternalValue(newInternalValue);
fireValueChange(false);
@@ -1477,17 +1435,17 @@ public abstract class LegacyAbstractField<T> extends AbstractComponent

/**
* Is this field required. Required fields must filled by the user.
*
*
* If the field is required, it is visually indicated in the user interface.
* Furthermore, setting field to be required implicitly adds "non-empty"
* validator and thus isValid() == false or any isEmpty() fields. In those
* cases validation errors are not painted as it is obvious that the user
* must fill in the required fields.
*
*
* On the other hand, for the non-required fields isValid() == true if the
* field isEmpty() regardless of any attached validators.
*
*
*
*
* @return <code>true</code> if the field is required, otherwise
* <code>false</code>.
*/
@@ -1498,16 +1456,16 @@ public abstract class LegacyAbstractField<T> extends AbstractComponent

/**
* Sets the field required. Required fields must filled by the user.
*
*
* If the field is required, it is visually indicated in the user interface.
* Furthermore, setting field to be required implicitly adds "non-empty"
* validator and thus isValid() == false or any isEmpty() fields. In those
* cases validation errors are not painted as it is obvious that the user
* must fill in the required fields.
*
*
* On the other hand, for the non-required fields isValid() == true if the
* field isEmpty() regardless of any attached validators.
*
*
* @param required
* Is the field required.
*/
@@ -1521,7 +1479,7 @@ public abstract class LegacyAbstractField<T> extends AbstractComponent
* setting requiredMessage to be "" or null, no error pop-up or exclamation
* mark is shown for a empty required field. This faults to "". Even in
* those cases isValid() returns false for empty required fields.
*
*
* @param requiredMessage
* Message to be shown when this field is required, but empty.
*/
@@ -1539,7 +1497,7 @@ public abstract class LegacyAbstractField<T> extends AbstractComponent
/**
* Gets the error that is shown if the field value cannot be converted to
* the data source type.
*
*
* @return The error that is shown if conversion of the field value fails
*/
public String getConversionError() {
@@ -1551,7 +1509,7 @@ public abstract class LegacyAbstractField<T> extends AbstractComponent
* the data source type. If {0} is present in the message, it will be
* replaced by the simple name of the data source type. If {1} is present in
* the message, it will be replaced by the ConversionException message.
*
*
* @param valueConversionError
* Message to be shown when conversion of the value fails
*/
@@ -1572,13 +1530,13 @@ public abstract class LegacyAbstractField<T> extends AbstractComponent

/**
* Is automatic, visible validation enabled?
*
*
* If automatic validation is enabled, any validators connected to this
* component are evaluated while painting the component and potential error
* messages are sent to client. If the automatic validation is turned off,
* isValid() and validate() methods still work, but one must show the
* validation in their own code.
*
*
* @return True, if automatic validation is enabled.
*/
public boolean isValidationVisible() {
@@ -1587,13 +1545,13 @@ public abstract class LegacyAbstractField<T> extends AbstractComponent

/**
* Enable or disable automatic, visible validation.
*
*
* If automatic validation is enabled, any validators connected to this
* component are evaluated while painting the component and potential error
* messages are sent to client. If the automatic validation is turned off,
* isValid() and validate() methods still work, but one must show the
* validation in their own code.
*
*
* @param validateAutomatically
* True, if automatic validation is enabled.
*/
@@ -1606,7 +1564,7 @@ public abstract class LegacyAbstractField<T> extends AbstractComponent

/**
* Sets the current buffered source exception.
*
*
* @param currentBufferedSourceException
*/
public void setCurrentBufferedSourceException(
@@ -1617,7 +1575,7 @@ public abstract class LegacyAbstractField<T> extends AbstractComponent

/**
* Gets the current buffered source exception.
*
*
* @return The current source exception
*/
protected Buffered.SourceException getCurrentBufferedSourceException() {
@@ -1628,7 +1586,7 @@ public abstract class LegacyAbstractField<T> extends AbstractComponent
* A ready-made {@link ShortcutListener} that focuses the given
* {@link Focusable} (usually a {@link LegacyField}) when the keyboard
* shortcut is invoked.
*
*
*/
public static class FocusShortcut extends ShortcutListener {
protected Focusable focusable;
@@ -1636,7 +1594,7 @@ public abstract class LegacyAbstractField<T> extends AbstractComponent
/**
* Creates a keyboard shortcut for focusing the given {@link Focusable}
* using the shorthand notation defined in {@link ShortcutAction}.
*
*
* @param focusable
* to focused when the shortcut is invoked
* @param shorthandCaption
@@ -1649,7 +1607,7 @@ public abstract class LegacyAbstractField<T> extends AbstractComponent

/**
* Creates a keyboard shortcut for focusing the given {@link Focusable}.
*
*
* @param focusable
* to focused when the shortcut is invoked
* @param keyCode
@@ -1665,7 +1623,7 @@ public abstract class LegacyAbstractField<T> extends AbstractComponent

/**
* Creates a keyboard shortcut for focusing the given {@link Focusable}.
*
*
* @param focusable
* to focused when the shortcut is invoked
* @param keyCode
@@ -1724,7 +1682,7 @@ public abstract class LegacyAbstractField<T> extends AbstractComponent
/**
* Gets the converter used to convert the property data source value to the
* field value.
*
*
* @return The converter or null if none is set.
*/
public LegacyConverter<T, Object> getConverter() {
@@ -1735,7 +1693,7 @@ public abstract class LegacyAbstractField<T> extends AbstractComponent
* Sets the converter used to convert the field value to property data
* source type. The converter must have a presentation type that matches the
* field type.
*
*
* @param converter
* The new converter to use.
*/
@@ -1800,7 +1758,7 @@ public abstract class LegacyAbstractField<T> extends AbstractComponent

/*
* (non-Javadoc)
*
*
* @see com.vaadin.ui.AbstractComponent#readDesign(org.jsoup.nodes .Element,
* com.vaadin.ui.declarative.DesignContext)
*/
@@ -1816,7 +1774,7 @@ public abstract class LegacyAbstractField<T> extends AbstractComponent

/*
* (non-Javadoc)
*
*
* @see com.vaadin.ui.AbstractComponent#getCustomAttributes()
*/
@Override
@@ -1831,7 +1789,7 @@ public abstract class LegacyAbstractField<T> extends AbstractComponent

/*
* (non-Javadoc)
*
*
* @see com.vaadin.ui.AbstractComponent#writeDesign(org.jsoup.nodes.Element
* , com.vaadin.ui.declarative.DesignContext)
*/

+ 11
- 33
server/src/main/java/com/vaadin/server/Constants.java Datei anzeigen

@@ -1,12 +1,12 @@
/*
* Copyright 2000-2014 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
@@ -20,9 +20,9 @@ import com.vaadin.ui.declarative.DesignContext;

/**
* Internal constants used by both the client and the server side framework
*
*
* @since 6.2
*
*
*/
public interface Constants {

@@ -62,8 +62,7 @@ public interface Constants {
+ "The widgetset in use does not seem to be built for the Vaadin\n"
+ "version in use. This might cause strange problems - a\n"
+ "recompile/deploy is strongly recommended.\n"
+ " Vaadin version: %s\n"
+ " Widgetset version: %s\n"
+ " Vaadin version: %s\n" + " Widgetset version: %s\n"
+ "=================================================================";

// Keep the version number in sync with pom.xml
@@ -83,38 +82,18 @@ public interface Constants {
+ "to vaadin-push.\n"
+ "If managing dependencies manually, please make sure Atmosphere\n"
+ REQUIRED_ATMOSPHERE_RUNTIME_VERSION
+ " is included on the classpath.\n"
+ "Will fall back to using "
+ PushMode.class.getSimpleName()
+ "."
+ PushMode.DISABLED.name()
+ " is included on the classpath.\n" + "Will fall back to using "
+ PushMode.class.getSimpleName() + "." + PushMode.DISABLED.name()
+ ".\n"
+ "=================================================================";

static final String PUSH_NOT_SUPPORTED_ERROR = "\n"
+ "=================================================================\n"
+ "Push is not supported for {0}\n"
+ "Will fall back to using "
+ PushMode.class.getSimpleName()
+ "."
+ PushMode.DISABLED.name()
+ "Push is not supported for {0}\n" + "Will fall back to using "
+ PushMode.class.getSimpleName() + "." + PushMode.DISABLED.name()
+ ".\n"
+ "=================================================================";

public static final String WARNING_LEGACY_PROPERTY_TOSTRING = "You are using toString() instead of getValue() to get the value for a Property of type {0}"
+ ". This is strongly discouraged and only provided for backwards compatibility with Vaadin 6. "
+ "To disable this warning message and retain the behavior, set the init parameter \""
+ Constants.SERVLET_PARAMETER_LEGACY_PROPERTY_TOSTRING
+ "\" to \"true\". To disable the legacy functionality, set \""
+ Constants.SERVLET_PARAMETER_LEGACY_PROPERTY_TOSTRING
+ "\" to false."
+ " (Note that your debugger might call toString() and trigger this message)."
+ " To find out who is calling toString(), enable FINE level logging.";

static final String WARNING_UNKNOWN_LEGACY_PROPERTY_TOSTRING_VALUE = "Unknown value '{0}' for parameter "
+ Constants.SERVLET_PARAMETER_LEGACY_PROPERTY_TOSTRING
+ ". Supported values are 'false','warning','true'";

static final String CANNOT_ACQUIRE_CLASSLOADER_SEVERE = "\n"
+ "=================================================================\n"
+ "Vaadin was unable to acquire class loader from servlet container\n"
@@ -134,7 +113,6 @@ public interface Constants {
static final String SERVLET_PARAMETER_CLOSE_IDLE_SESSIONS = "closeIdleSessions";
static final String SERVLET_PARAMETER_PUSH_MODE = "pushMode";
static final String SERVLET_PARAMETER_UI_PROVIDER = "UIProvider";
static final String SERVLET_PARAMETER_LEGACY_PROPERTY_TOSTRING = "legacyPropertyToString";
static final String SERVLET_PARAMETER_SYNC_ID_CHECK = "syncIdCheck";
static final String SERVLET_PARAMETER_SENDURLSASPARAMETERS = "sendUrlsAsParameters";
static final String SERVLET_PARAMETER_PUSH_SUSPEND_TIMEOUT_LONGPOLLING = "pushLongPollingSuspendTimeout";
@@ -142,7 +120,7 @@ public interface Constants {
* Name of system or context property to write declarative syntax with the
* old "v-" prefix or with the new "vaadin-" prefix. The default value
* depends on the Vaadin branch used.
*
*
* @see DesignContext
* @since 7.5.7
*/

+ 24
- 62
server/src/main/java/com/vaadin/server/DefaultDeploymentConfiguration.java Datei anzeigen

@@ -1,12 +1,12 @@
/*
* Copyright 2000-2014 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
@@ -17,7 +17,6 @@
package com.vaadin.server;

import java.util.Properties;
import java.util.logging.Level;
import java.util.logging.Logger;

import com.vaadin.shared.communication.PushMode;
@@ -25,12 +24,12 @@ import com.vaadin.shared.communication.PushMode;
/**
* The default implementation of {@link DeploymentConfiguration} based on a base
* class for resolving system properties and a set of init parameters.
*
*
* @author Vaadin Ltd
* @since 7.0.0
*/
public class DefaultDeploymentConfiguration extends
AbstractDeploymentConfiguration {
public class DefaultDeploymentConfiguration
extends AbstractDeploymentConfiguration {
/**
* Default value for {@link #getResourceCacheTime()} = {@value} .
*/
@@ -46,15 +45,9 @@ public class DefaultDeploymentConfiguration extends
*/
public static final boolean DEFAULT_CLOSE_IDLE_SESSIONS = false;

/**
* Default value for {@link #getLegacyPropertyToStringMode()} =
* {@link LegacyProperyToStringMode#WARNING}.
*/
public static final LegacyProperyToStringMode DEFAULT_LEGACY_PROPERTY_TO_STRING = LegacyProperyToStringMode.WARNING;

/**
* Default value for {@link #isSyncIdCheckEnabled()} = {@value} .
*
*
* @since 7.3
*/
public static final boolean DEFAULT_SYNC_ID_CHECK = true;
@@ -69,13 +62,12 @@ public class DefaultDeploymentConfiguration extends
private boolean closeIdleSessions;
private PushMode pushMode;
private final Class<?> systemPropertyBaseClass;
private LegacyProperyToStringMode legacyPropertyToStringMode;
private boolean syncIdCheck;
private boolean sendUrlsAsParameters;

/**
* Create a new deployment configuration instance.
*
*
* @param systemPropertyBaseClass
* the class that should be used as a basis when reading system
* properties
@@ -94,32 +86,10 @@ public class DefaultDeploymentConfiguration extends
checkHeartbeatInterval();
checkCloseIdleSessions();
checkPushMode();
checkLegacyPropertyToString();
checkSyncIdCheck();
checkSendUrlsAsParameters();
}

private void checkLegacyPropertyToString() {
String param = getApplicationOrSystemProperty(
Constants.SERVLET_PARAMETER_LEGACY_PROPERTY_TOSTRING,
DEFAULT_LEGACY_PROPERTY_TO_STRING.getPropertyString());

for (LegacyProperyToStringMode mode : LegacyProperyToStringMode
.values()) {
if (mode.getPropertyString().equals(param)) {
legacyPropertyToStringMode = mode;
return;
}
}

getLogger()
.log(Level.WARNING,
Constants.WARNING_UNKNOWN_LEGACY_PROPERTY_TOSTRING_VALUE,
param);

legacyPropertyToStringMode = DEFAULT_LEGACY_PROPERTY_TO_STRING;
}

@Override
public String getApplicationOrSystemProperty(String propertyName,
String defaultValue) {
@@ -142,7 +112,7 @@ public class DefaultDeploymentConfiguration extends

/**
* Gets an system property value.
*
*
* @param parameterName
* the Name or the parameter.
* @return String value or null if not found
@@ -186,7 +156,7 @@ public class DefaultDeploymentConfiguration extends

/**
* Gets an application property value.
*
*
* @param parameterName
* the Name or the parameter.
* @return String value or null if not found
@@ -207,7 +177,7 @@ public class DefaultDeploymentConfiguration extends

/**
* {@inheritDoc}
*
*
* The default is false.
*/
@Override
@@ -295,8 +265,8 @@ public class DefaultDeploymentConfiguration extends
*/
private void checkProductionMode() {
productionMode = getApplicationOrSystemProperty(
Constants.SERVLET_PARAMETER_PRODUCTION_MODE, "false").equals(
"true");
Constants.SERVLET_PARAMETER_PRODUCTION_MODE, "false")
.equals("true");
if (!productionMode) {
getLogger().warning(Constants.NOT_PRODUCTION_MODE_INFO);
}
@@ -308,7 +278,7 @@ public class DefaultDeploymentConfiguration extends
private void checkXsrfProtection() {
xsrfProtectionEnabled = !getApplicationOrSystemProperty(
Constants.SERVLET_PARAMETER_DISABLE_XSRF_PROTECTION, "false")
.equals("true");
.equals("true");
if (!xsrfProtectionEnabled) {
getLogger().warning(Constants.WARNING_XSRF_PROTECTION_DISABLED);
}
@@ -319,10 +289,9 @@ public class DefaultDeploymentConfiguration extends
*/
private void checkResourceCacheTime() {
try {
resourceCacheTime = Integer
.parseInt(getApplicationOrSystemProperty(
Constants.SERVLET_PARAMETER_RESOURCE_CACHE_TIME,
Integer.toString(DEFAULT_RESOURCE_CACHE_TIME)));
resourceCacheTime = Integer.parseInt(getApplicationOrSystemProperty(
Constants.SERVLET_PARAMETER_RESOURCE_CACHE_TIME,
Integer.toString(DEFAULT_RESOURCE_CACHE_TIME)));
} catch (NumberFormatException e) {
getLogger().warning(
Constants.WARNING_RESOURCE_CACHING_TIME_NOT_NUMERIC);
@@ -332,13 +301,12 @@ public class DefaultDeploymentConfiguration extends

private void checkHeartbeatInterval() {
try {
heartbeatInterval = Integer
.parseInt(getApplicationOrSystemProperty(
Constants.SERVLET_PARAMETER_HEARTBEAT_INTERVAL,
Integer.toString(DEFAULT_HEARTBEAT_INTERVAL)));
heartbeatInterval = Integer.parseInt(getApplicationOrSystemProperty(
Constants.SERVLET_PARAMETER_HEARTBEAT_INTERVAL,
Integer.toString(DEFAULT_HEARTBEAT_INTERVAL)));
} catch (NumberFormatException e) {
getLogger().warning(
Constants.WARNING_HEARTBEAT_INTERVAL_NOT_NUMERIC);
getLogger()
.warning(Constants.WARNING_HEARTBEAT_INTERVAL_NOT_NUMERIC);
heartbeatInterval = DEFAULT_HEARTBEAT_INTERVAL;
}
}
@@ -370,18 +338,12 @@ public class DefaultDeploymentConfiguration extends
private void checkSendUrlsAsParameters() {
sendUrlsAsParameters = getApplicationOrSystemProperty(
Constants.SERVLET_PARAMETER_SENDURLSASPARAMETERS,
Boolean.toString(DEFAULT_SEND_URLS_AS_PARAMETERS)).equals(
"true");
Boolean.toString(DEFAULT_SEND_URLS_AS_PARAMETERS))
.equals("true");
}

private Logger getLogger() {
return Logger.getLogger(getClass().getName());
}

@Override
@Deprecated
public LegacyProperyToStringMode getLegacyPropertyToStringMode() {
return legacyPropertyToStringMode;
}

}

+ 24
- 72
server/src/main/java/com/vaadin/server/DeploymentConfiguration.java Datei anzeigen

@@ -1,12 +1,12 @@
/*
* Copyright 2000-2014 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
@@ -19,67 +19,28 @@ package com.vaadin.server;
import java.io.Serializable;
import java.util.Properties;

import com.vaadin.data.util.AbstractProperty;
import com.vaadin.shared.communication.PushMode;

/**
* A collection of properties configured at deploy time as well as a way of
* accessing third party properties not explicitly supported by this class.
*
*
* @author Vaadin Ltd
* @version @VERSION@
* @since 7.0.0
*/
public interface DeploymentConfiguration extends Serializable {

/**
* Determines the mode of the "legacyPropertyToString" parameter.
*
* @author Vaadin Ltd
* @since 7.1
*/
@Deprecated
public enum LegacyProperyToStringMode {
DISABLED("false"), WARNING("warning"), ENABLED("true");

private final String propertyString;

private LegacyProperyToStringMode(String propertyString) {
this.propertyString = propertyString;
}

/**
* Gets the string that should be used in e.g. web.xml for selecting
* this mode.
*
* @return the property value
*/
public String getPropertyString() {
return propertyString;
}

@Override
public String toString() {
// Used by VaadinServlet.readConfigurationAnnotation()
return getPropertyString();
}

public boolean useLegacyMode() {
return this == WARNING || this == ENABLED;
}

}

/**
* Returns whether Vaadin is in production mode.
*
*
* @return true if in production mode, false otherwise.
*/
public boolean isProductionMode();

/**
* Returns whether cross-site request forgery protection is enabled.
*
*
* @return true if XSRF protection is enabled, false otherwise.
*/
public boolean isXsrfProtectionEnabled();
@@ -88,7 +49,7 @@ public interface DeploymentConfiguration extends Serializable {
* Returns whether sync id checking is enabled. The sync id is used to
* gracefully handle situations when the client sends a message to a
* connector that has recently been removed on the server.
*
*
* @since 7.3
* @return <code>true</code> if sync id checking is enabled;
* <code>false</code> otherwise
@@ -97,7 +58,7 @@ public interface DeploymentConfiguration extends Serializable {

/**
* Returns the time resources can be cached in the browsers, in seconds.
*
*
* @return The resource cache time.
*/
public int getResourceCacheTime();
@@ -105,7 +66,7 @@ public interface DeploymentConfiguration extends Serializable {
/**
* Returns the number of seconds between heartbeat requests of a UI, or a
* non-positive number if heartbeat is disabled.
*
*
* @return The time between heartbeats.
*/
public int getHeartbeatInterval();
@@ -114,7 +75,7 @@ public interface DeploymentConfiguration extends Serializable {
* Returns whether the sending of URL's as GET and POST parameters in
* requests with content-type <code>application/x-www-form-urlencoded</code>
* is enabled or not.
*
*
* @return <code>false</code> if set to false or <code>true</code> otherwise
*/
public boolean isSendUrlsAsParameters();
@@ -128,11 +89,11 @@ public interface DeploymentConfiguration extends Serializable {
* heartbeat requests cause the session to stay open for as long as there
* are open UIs on the client side. If it is {@code true}, the session is
* eventually closed if the open UIs do not have any user interaction.
*
*
* @see WrappedSession#getMaxInactiveInterval()
*
*
* @since 7.0.0
*
*
* @return True if UIs and sessions receiving only heartbeat requests are
* eventually closed; false if heartbeat requests extend UI and
* session lifetime indefinitely.
@@ -142,7 +103,7 @@ public interface DeploymentConfiguration extends Serializable {
/**
* Returns the mode of bidirectional ("push") client-server communication
* that should be used.
*
*
* @return The push mode in use.
*/
public PushMode getPushMode();
@@ -150,7 +111,7 @@ public interface DeploymentConfiguration extends Serializable {
/**
* Gets the properties configured for the deployment, e.g. as init
* parameters to the servlet or portlet.
*
*
* @return properties for the application.
*/
public Properties getInitParameters();
@@ -158,7 +119,7 @@ public interface DeploymentConfiguration extends Serializable {
/**
* Gets a configured property. The properties are typically read from e.g.
* web.xml or from system properties of the JVM.
*
*
* @param propertyName
* The simple of the property, in some contexts, lookup might be
* performed using variations of the provided name.
@@ -173,18 +134,18 @@ public interface DeploymentConfiguration extends Serializable {

/**
* Gets UI class configuration option value.
*
*
* @return UI class name
*
*
* @since 7.4
*/
public String getUIClassName();

/**
* Gets UI provider class configuration option value.
*
*
* @since 7.4
*
*
* @return UI class name
*/
public String getUIProviderClassName();
@@ -192,34 +153,25 @@ public interface DeploymentConfiguration extends Serializable {
/**
* Gets Widgetset configuration option value. {@code defaultValue} is
* returned if widgetset parameter is not configured.
*
*
* @since 7.4
*
*
* @return UI class name
*/
public String getWidgetset(String defaultValue);

/**
* Gets resources path configuration option value.
*
*
* @since 7.4
*/
public String getResourcesPath();

/**
* Gets class loader configuration option value.
*
*
* @since 7.4
*/
public String getClassLoaderName();

/**
* Returns to legacy Property.toString() mode used. See
* {@link AbstractProperty#isLegacyToStringEnabled()} for more information.
*
* @return The Property.toString() mode in use.
*/
@Deprecated
public LegacyProperyToStringMode getLegacyPropertyToStringMode();

}

+ 52
- 85
server/src/main/java/com/vaadin/ui/Label.java Datei anzeigen

@@ -1,12 +1,12 @@
/*
* Copyright 2000-2014 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
@@ -23,8 +23,6 @@ import java.util.Locale;
import org.jsoup.nodes.Element;

import com.vaadin.data.Property;
import com.vaadin.data.util.AbstractProperty;
import com.vaadin.data.util.LegacyPropertyHelper;
import com.vaadin.legacy.data.util.converter.LegacyConverter;
import com.vaadin.legacy.data.util.converter.LegacyConverterUtil;
import com.vaadin.shared.ui.label.ContentMode;
@@ -35,9 +33,9 @@ import com.vaadin.ui.declarative.DesignFormatter;

/**
* Label component for showing non-editable short texts.
*
*
* The label content can be set to the modes specified by {@link ContentMode}
*
*
* <p>
* The contents of the label may contain simple formatting:
* <ul>
@@ -51,7 +49,7 @@ import com.vaadin.ui.declarative.DesignFormatter;
* The <b>b</b>,<b>i</b>,<b>u</b> and <b>li</b> tags can contain all the tags in
* the list recursively.
* </p>
*
*
* @author Vaadin Ltd.
* @since 3.0
*/
@@ -113,7 +111,7 @@ public class Label extends AbstractComponent implements Property<String>,

/**
* Creates a new instance of Label with text-contents.
*
*
* @param content
*/
public Label(String content) {
@@ -123,7 +121,7 @@ public class Label extends AbstractComponent implements Property<String>,
/**
* Creates a new instance of Label with text-contents read from given
* datasource.
*
*
* @param contentSource
*/
public Label(Property contentSource) {
@@ -132,7 +130,7 @@ public class Label extends AbstractComponent implements Property<String>,

/**
* Creates a new instance of Label with text-contents.
*
*
* @param content
* @param contentMode
*/
@@ -145,7 +143,7 @@ public class Label extends AbstractComponent implements Property<String>,
/**
* Creates a new instance of Label with text-contents read from given
* datasource.
*
*
* @param contentSource
* @param contentMode
*/
@@ -171,7 +169,7 @@ public class Label extends AbstractComponent implements Property<String>,
* The value of the label is the text that is shown to the end user.
* Depending on the {@link ContentMode} it is plain text or markup.
* </p>
*
*
* @return the value of the label.
*/
@Override
@@ -186,19 +184,20 @@ public class Label extends AbstractComponent implements Property<String>,
/**
* Returns the current value of the data source converted using the current
* locale.
*
*
* @return
*/
private String getDataSourceValue() {
return LegacyConverterUtil.convertFromModel(getPropertyDataSource()
.getValue(), String.class, getConverter(), getLocale());
return LegacyConverterUtil.convertFromModel(
getPropertyDataSource().getValue(), String.class,
getConverter(), getLocale());
}

/**
* Set the value of the label. Value of the label is the XML contents of the
* label. Since Vaadin 7.2, changing the value of Label instance with that
* method will fire ValueChangeEvent.
*
*
* @param newStringValue
* the New value of the label.
*/
@@ -220,7 +219,7 @@ public class Label extends AbstractComponent implements Property<String>,

/**
* Gets the type of the Property.
*
*
* @see com.vaadin.data.Property#getType()
*/
@Override
@@ -230,7 +229,7 @@ public class Label extends AbstractComponent implements Property<String>,

/**
* Gets the viewing data-source property.
*
*
* @return the data source property.
* @see com.vaadin.data.Property.Viewer#getPropertyDataSource()
*/
@@ -242,7 +241,7 @@ public class Label extends AbstractComponent implements Property<String>,
/**
* Sets the property as data-source for viewing. Since Vaadin 7.2 a
* ValueChangeEvent is fired if the new value is different from previous.
*
*
* @param newDataSource
* the new data source Property
* @see com.vaadin.data.Property.Viewer#setPropertyDataSource(com.vaadin.data.Property)
@@ -250,20 +249,19 @@ public class Label extends AbstractComponent implements Property<String>,
@Override
public void setPropertyDataSource(Property newDataSource) {
// Stops listening the old data source changes
if (dataSource != null
&& Property.ValueChangeNotifier.class
.isAssignableFrom(dataSource.getClass())) {
if (dataSource != null && Property.ValueChangeNotifier.class
.isAssignableFrom(dataSource.getClass())) {
((Property.ValueChangeNotifier) dataSource).removeListener(this);
}

// Check if the current converter is compatible.
if (newDataSource != null
&& !LegacyConverterUtil.canConverterPossiblyHandle(getConverter(),
getType(), newDataSource.getType())) {
&& !LegacyConverterUtil.canConverterPossiblyHandle(
getConverter(), getType(), newDataSource.getType())) {
// There is no converter set or there is no way the current
// converter can be compatible.
LegacyConverter<String, ?> c = LegacyConverterUtil.getConverter(String.class,
newDataSource.getType(), getSession());
LegacyConverter<String, ?> c = LegacyConverterUtil.getConverter(
String.class, newDataSource.getType(), getSession());
setConverter(c);
}

@@ -275,9 +273,8 @@ public class Label extends AbstractComponent implements Property<String>,
}

// Listens the new data source if possible
if (dataSource != null
&& Property.ValueChangeNotifier.class
.isAssignableFrom(dataSource.getClass())) {
if (dataSource != null && Property.ValueChangeNotifier.class
.isAssignableFrom(dataSource.getClass())) {
((Property.ValueChangeNotifier) dataSource).addListener(this);
}
markAsDirty();
@@ -285,9 +282,9 @@ public class Label extends AbstractComponent implements Property<String>,

/**
* Gets the content mode of the Label.
*
*
* @return the Content mode of the label.
*
*
* @see ContentMode
*/
public ContentMode getContentMode() {
@@ -296,10 +293,10 @@ public class Label extends AbstractComponent implements Property<String>,

/**
* Sets the content mode of the Label.
*
*
* @param contentMode
* the New content mode of the label.
*
*
* @see ContentMode
*/
public void setContentMode(ContentMode contentMode) {
@@ -328,16 +325,16 @@ public class Label extends AbstractComponent implements Property<String>,

/**
* Value change event
*
*
* @author Vaadin Ltd.
* @since 3.0
*/
public static class ValueChangeEvent extends Component.Event implements
Property.ValueChangeEvent {
public static class ValueChangeEvent extends Component.Event
implements Property.ValueChangeEvent {

/**
* New instance of text change event
*
*
* @param source
* the Source of the event.
*/
@@ -347,7 +344,7 @@ public class Label extends AbstractComponent implements Property<String>,

/**
* Gets the Property that has been modified.
*
*
* @see com.vaadin.data.Property.ValueChangeEvent#getProperty()
*/
@Override
@@ -358,14 +355,15 @@ public class Label extends AbstractComponent implements Property<String>,

/**
* Adds the value change listener.
*
*
* @param listener
* the Listener to be added.
* @see com.vaadin.data.Property.ValueChangeNotifier#addListener(com.vaadin.data.Property.ValueChangeListener)
*/
@Override
public void addValueChangeListener(Property.ValueChangeListener listener) {
addListener(Label.ValueChangeEvent.class, listener, VALUE_CHANGE_METHOD);
addListener(Label.ValueChangeEvent.class, listener,
VALUE_CHANGE_METHOD);
}

/**
@@ -380,13 +378,14 @@ public class Label extends AbstractComponent implements Property<String>,

/**
* Removes the value change listener.
*
*
* @param listener
* the Listener to be removed.
* @see com.vaadin.data.Property.ValueChangeNotifier#removeListener(com.vaadin.data.Property.ValueChangeListener)
*/
@Override
public void removeValueChangeListener(Property.ValueChangeListener listener) {
public void removeValueChangeListener(
Property.ValueChangeListener listener) {
removeListener(Label.ValueChangeEvent.class, listener,
VALUE_CHANGE_METHOD);
}
@@ -411,7 +410,7 @@ public class Label extends AbstractComponent implements Property<String>,

/**
* Listens the value change events from data source.
*
*
* @see com.vaadin.data.Property.ValueChangeListener#valueChange(Property.ValueChangeEvent)
*/
@Override
@@ -463,19 +462,19 @@ public class Label extends AbstractComponent implements Property<String>,

/**
* Compares the Label to other objects.
*
*
* <p>
* Labels can be compared to other labels for sorting label contents. This
* is especially handy for sorting table columns.
* </p>
*
*
* <p>
* In RAW, PREFORMATTED and TEXT modes, the label contents are compared as
* is. In XML, UIDL and HTML modes, only CDATA is compared and tags ignored.
* If the other object is not a Label, its toString() return value is used
* in comparison.
* </p>
*
*
* @param other
* the Other object to compare to.
* @return a negative integer, zero, or a positive integer as this object is
@@ -493,7 +492,7 @@ public class Label extends AbstractComponent implements Property<String>,

/**
* Strips the tags from the XML.
*
*
* @param xml
* the String containing a XML snippet.
* @return the original XML without tags.
@@ -525,7 +524,7 @@ public class Label extends AbstractComponent implements Property<String>,
/**
* Gets the converter used to convert the property data source value to the
* label value.
*
*
* @return The converter or null if none is set.
*/
public LegacyConverter<String, Object> getConverter() {
@@ -535,7 +534,7 @@ public class Label extends AbstractComponent implements Property<String>,
/**
* Sets the converter used to convert the label value to the property data
* source type. The converter must have a presentation type of String.
*
*
* @param converter
* The new converter to use.
*/
@@ -544,41 +543,9 @@ public class Label extends AbstractComponent implements Property<String>,
markAsDirty();
}

/**
* Returns a string representation of this object. The returned string
* representation depends on if the legacy Property toString mode is enabled
* or disabled.
* <p>
* If legacy Property toString mode is enabled, returns the value displayed
* by this label.
* </p>
* <p>
* If legacy Property toString mode is disabled, the string representation
* has no special meaning
* </p>
*
* @see AbstractProperty#isLegacyToStringEnabled()
*
* @return The value displayed by this label or a string representation of
* this Label object.
*
* @deprecated As of 7.0, use {@link #getValue()} to get the value of the
* label or {@link #getPropertyDataSource()}.getValue() to get
* the value of the data source.
*/
@Deprecated
@Override
public String toString() {
if (!LegacyPropertyHelper.isLegacyToStringEnabled()) {
return super.toString();
} else {
return LegacyPropertyHelper.legacyPropertyToString(this);
}
}

/*
* (non-Javadoc)
*
*
* @see com.vaadin.ui.AbstractComponent#readDesign(org.jsoup.nodes .Element,
* com.vaadin.ui.declarative.DesignContext)
*/
@@ -602,7 +569,7 @@ public class Label extends AbstractComponent implements Property<String>,

/*
* (non-Javadoc)
*
*
* @see com.vaadin.ui.AbstractComponent#getCustomAttributes()
*/
@Override
@@ -616,7 +583,7 @@ public class Label extends AbstractComponent implements Property<String>,

/*
* (non-Javadoc)
*
*
* @see com.vaadin.ui.AbstractComponent#writeDesign(org.jsoup.nodes.Element
* , com.vaadin.ui.declarative.DesignContext)
*/

+ 97
- 107
server/src/test/java/com/vaadin/data/util/sqlcontainer/SQLContainerTableQueryTest.java Datei anzeigen

@@ -187,7 +187,7 @@ public class SQLContainerTableQueryTest {
container.commit();

Item item = getItem(container.lastItemId());
assertThat(item.getItemProperty(NAME).getValue().toString(), is("foo"));
assertThat(item.getItemProperty(NAME).getValue(), is("foo"));
}

@Test
@@ -196,7 +196,7 @@ public class SQLContainerTableQueryTest {

container.refresh();

assertThat(getItem(existingItemId).getItemProperty(NAME).toString(),
assertThat(getItem(existingItemId).getItemProperty(NAME).getValue(),
is("foo"));
}

@@ -241,8 +241,8 @@ public class SQLContainerTableQueryTest {
if (SQLTestsConstants.db == DB.MSSQL) {
statement.executeUpdate("insert into people values('Bengt', 30)");
} else {
statement
.executeUpdate("insert into people values(default, 'Bengt', 30)");
statement.executeUpdate(
"insert into people values(default, 'Bengt', 30)");
}
statement.close();
conn.commit();
@@ -255,11 +255,11 @@ public class SQLContainerTableQueryTest {
public void indexOfId_tableWithParameterThree_returnsThree()
throws SQLException {
if (SQLTestsConstants.db == DB.ORACLE) {
assertEquals(3, container.indexOfId(new RowId(
new Object[] { new BigDecimal(3 + offset) })));
assertEquals(3, container.indexOfId(
new RowId(new Object[] { new BigDecimal(3 + offset) })));
} else {
assertEquals(3,
container.indexOfId(new RowId(new Object[] { 3 + offset })));
assertEquals(3, container
.indexOfId(new RowId(new Object[] { 3 + offset })));
}
}

@@ -269,14 +269,14 @@ public class SQLContainerTableQueryTest {
DataGenerator.addFiveThousandPeople(connectionPool);

if (SQLTestsConstants.db == DB.ORACLE) {
container.getItem(new RowId(new Object[] { new BigDecimal(
1337 + offset) }));
assertEquals(1337, container.indexOfId(new RowId(
new Object[] { new BigDecimal(1337 + offset) })));
container.getItem(
new RowId(new Object[] { new BigDecimal(1337 + offset) }));
assertEquals(1337, container.indexOfId(
new RowId(new Object[] { new BigDecimal(1337 + offset) })));
} else {
container.getItem(new RowId(new Object[] { 1337 + offset }));
assertEquals(1337, container.indexOfId(new RowId(
new Object[] { 1337 + offset })));
assertEquals(1337, container
.indexOfId(new RowId(new Object[] { 1337 + offset })));
}
}

@@ -365,44 +365,44 @@ public class SQLContainerTableQueryTest {
@Test
public void isFirstId_tableActualFirstId_returnsTrue() throws SQLException {
if (SQLTestsConstants.db == DB.ORACLE) {
assertTrue(container.isFirstId(new RowId(
new Object[] { new BigDecimal(0 + offset) })));
assertTrue(container.isFirstId(
new RowId(new Object[] { new BigDecimal(0 + offset) })));
} else {
assertTrue(container.isFirstId(new RowId(
new Object[] { 0 + offset })));
assertTrue(container
.isFirstId(new RowId(new Object[] { 0 + offset })));
}
}

@Test
public void isFirstId_tableSecondId_returnsFalse() throws SQLException {
if (SQLTestsConstants.db == DB.ORACLE) {
Assert.assertFalse(container.isFirstId(new RowId(
new Object[] { new BigDecimal(1 + offset) })));
Assert.assertFalse(container.isFirstId(
new RowId(new Object[] { new BigDecimal(1 + offset) })));
} else {
Assert.assertFalse(container.isFirstId(new RowId(
new Object[] { 1 + offset })));
Assert.assertFalse(container
.isFirstId(new RowId(new Object[] { 1 + offset })));
}
}

@Test
public void isLastId_tableSecondId_returnsFalse() throws SQLException {
if (SQLTestsConstants.db == DB.ORACLE) {
Assert.assertFalse(container.isLastId(new RowId(
new Object[] { new BigDecimal(1 + offset) })));
Assert.assertFalse(container.isLastId(
new RowId(new Object[] { new BigDecimal(1 + offset) })));
} else {
Assert.assertFalse(container.isLastId(new RowId(
new Object[] { 1 + offset })));
Assert.assertFalse(
container.isLastId(new RowId(new Object[] { 1 + offset })));
}
}

@Test
public void isLastId_tableLastId_returnsTrue() throws SQLException {
if (SQLTestsConstants.db == DB.ORACLE) {
assertTrue(container.isLastId(new RowId(
new Object[] { new BigDecimal(3 + offset) })));
assertTrue(container.isLastId(
new RowId(new Object[] { new BigDecimal(3 + offset) })));
} else {
assertTrue(container
.isLastId(new RowId(new Object[] { 3 + offset })));
assertTrue(
container.isLastId(new RowId(new Object[] { 3 + offset })));
}
}

@@ -410,11 +410,11 @@ public class SQLContainerTableQueryTest {
public void isLastId_table5000RowsLastId_returnsTrue() throws SQLException {
DataGenerator.addFiveThousandPeople(connectionPool);
if (SQLTestsConstants.db == DB.ORACLE) {
assertTrue(container.isLastId(new RowId(
new Object[] { new BigDecimal(4999 + offset) })));
assertTrue(container.isLastId(
new RowId(new Object[] { new BigDecimal(4999 + offset) })));
} else {
assertTrue(container.isLastId(new RowId(
new Object[] { 4999 + offset })));
assertTrue(container
.isLastId(new RowId(new Object[] { 4999 + offset })));
}
}

@@ -481,7 +481,8 @@ public class SQLContainerTableQueryTest {
}

@Test(expected = UnsupportedOperationException.class)
public void addContainerProperty_normal_isUnsupported() throws SQLException {
public void addContainerProperty_normal_isUnsupported()
throws SQLException {
container.addContainerProperty("asdf", String.class, "");
}

@@ -579,7 +580,8 @@ public class SQLContainerTableQueryTest {
}

@Test
public void indexOfId_tableNewlyAddedItem_returnsFour() throws SQLException {
public void indexOfId_tableNewlyAddedItem_returnsFour()
throws SQLException {
Object id = container.addItem();
assertEquals(4, container.indexOfId(id));
}
@@ -604,8 +606,8 @@ public class SQLContainerTableQueryTest {
Object id = container.addItem();
Item item = container.getItem(id);
item.getItemProperty(NAME).setValue("asdf");
assertEquals("asdf", container.getContainerProperty(id, NAME)
.getValue());
assertEquals("asdf",
container.getContainerProperty(id, NAME).getValue());
}

@Test
@@ -710,7 +712,8 @@ public class SQLContainerTableQueryTest {
}

@Test
public void getItem_tableAddedItemRemoved_returnsNull() throws SQLException {
public void getItem_tableAddedItemRemoved_returnsNull()
throws SQLException {
Object id = container.addItem();

Assert.assertNotNull(container.getItem(id));
@@ -958,7 +961,8 @@ public class SQLContainerTableQueryTest {
}

@Test
public void commit_tableAddedItem_shouldBeWrittenToDB() throws SQLException {
public void commit_tableAddedItem_shouldBeWrittenToDB()
throws SQLException {
Object id = container.addItem();
container.getContainerProperty(id, NAME).setValue("New Name");

@@ -966,9 +970,8 @@ public class SQLContainerTableQueryTest {
Assert.assertSame(id, container.lastItemId());
container.commit();
Assert.assertFalse(container.lastItemId() instanceof TemporaryRowId);
assertEquals("New Name",
container.getContainerProperty(container.lastItemId(), NAME)
.getValue());
assertEquals("New Name", container
.getContainerProperty(container.lastItemId(), NAME).getValue());
}

@Test
@@ -984,12 +987,11 @@ public class SQLContainerTableQueryTest {
Object nextToLast = container.getIdByIndex(container.size() - 2);

Assert.assertFalse(nextToLast instanceof TemporaryRowId);
assertEquals("Herbert", container
.getContainerProperty(nextToLast, NAME).getValue());
assertEquals("Herbert",
container.getContainerProperty(nextToLast, NAME).getValue());
Assert.assertFalse(container.lastItemId() instanceof TemporaryRowId);
assertEquals("Larry",
container.getContainerProperty(container.lastItemId(), NAME)
.getValue());
assertEquals("Larry", container
.getContainerProperty(container.lastItemId(), NAME).getValue());
}

@Test
@@ -1009,9 +1011,8 @@ public class SQLContainerTableQueryTest {
container.getContainerProperty(last, NAME).setValue("Donald");
container.commit();

assertEquals("Donald",
container.getContainerProperty(container.lastItemId(), NAME)
.getValue());
assertEquals("Donald", container
.getContainerProperty(container.lastItemId(), NAME).getValue());
}

@Test
@@ -1027,15 +1028,17 @@ public class SQLContainerTableQueryTest {
}

@Test
public void rollback_tableItemAdded_discardsAddedItem() throws SQLException {
public void rollback_tableItemAdded_discardsAddedItem()
throws SQLException {
int size = container.size();
Object id = container.addItem();
container.getContainerProperty(id, NAME).setValue("foo");
assertEquals(size + 1, container.size());
container.rollback();
assertEquals(size, container.size());
Assert.assertFalse("foo".equals(container.getContainerProperty(
container.lastItemId(), NAME).getValue()));
Assert.assertFalse("foo".equals(
container.getContainerProperty(container.lastItemId(), NAME)
.getValue()));
}

@Test
@@ -1051,12 +1054,14 @@ public class SQLContainerTableQueryTest {
}

@Test
public void rollback_tableItemChanged_discardsChanges() throws SQLException {
public void rollback_tableItemChanged_discardsChanges()
throws SQLException {
Object last = container.lastItemId();
container.getContainerProperty(last, NAME).setValue("foo");
container.rollback();
Assert.assertFalse("foo".equals(container.getContainerProperty(
container.lastItemId(), NAME).getValue()));
Assert.assertFalse("foo".equals(
container.getContainerProperty(container.lastItemId(), NAME)
.getValue()));
}

@Test
@@ -1126,8 +1131,8 @@ public class SQLContainerTableQueryTest {
@Test
public void isModified_tableChangedItem_returnsTrue() throws SQLException {
Assert.assertFalse(container.isModified());
container.getContainerProperty(container.lastItemId(), NAME).setValue(
"foo");
container.getContainerProperty(container.lastItemId(), NAME)
.setValue("foo");
assertTrue(container.isModified());
}

@@ -1151,18 +1156,16 @@ public class SQLContainerTableQueryTest {
assertEquals("Ville",
container.getContainerProperty(container.firstItemId(), NAME)
.getValue());
assertEquals("Börje",
container.getContainerProperty(container.lastItemId(), NAME)
.getValue());
assertEquals("Börje", container
.getContainerProperty(container.lastItemId(), NAME).getValue());

container.addOrderBy(new OrderBy(NAME, true));
// Börje, Kalle, Pelle, Ville
assertEquals("Börje",
container.getContainerProperty(container.firstItemId(), NAME)
.getValue());
assertEquals("Ville",
container.getContainerProperty(container.lastItemId(), NAME)
.getValue());
assertEquals("Ville", container
.getContainerProperty(container.lastItemId(), NAME).getValue());
}

@Test(expected = IllegalArgumentException.class)
@@ -1176,9 +1179,8 @@ public class SQLContainerTableQueryTest {
assertEquals("Ville",
container.getContainerProperty(container.firstItemId(), NAME)
.getValue());
assertEquals("Börje",
container.getContainerProperty(container.lastItemId(), NAME)
.getValue());
assertEquals("Börje", container
.getContainerProperty(container.lastItemId(), NAME).getValue());

container.sort(new Object[] { NAME }, new boolean[] { true });

@@ -1186,25 +1188,22 @@ public class SQLContainerTableQueryTest {
assertEquals("Börje",
container.getContainerProperty(container.firstItemId(), NAME)
.getValue());
assertEquals("Ville",
container.getContainerProperty(container.lastItemId(), NAME)
.getValue());
assertEquals("Ville", container
.getContainerProperty(container.lastItemId(), NAME).getValue());
}

@Test
public void addFilter_table_filtersResults() throws SQLException {
// Ville, Kalle, Pelle, Börje
assertEquals(4, container.size());
assertEquals("Börje",
container.getContainerProperty(container.lastItemId(), NAME)
.getValue());
assertEquals("Börje", container
.getContainerProperty(container.lastItemId(), NAME).getValue());

container.addContainerFilter(new Like(NAME, "%lle"));
// Ville, Kalle, Pelle
assertEquals(3, container.size());
assertEquals("Pelle",
container.getContainerProperty(container.lastItemId(), NAME)
.getValue());
assertEquals("Pelle", container
.getContainerProperty(container.lastItemId(), NAME).getValue());
}

@Test
@@ -1216,9 +1215,8 @@ public class SQLContainerTableQueryTest {

// Ville
assertEquals(1, container.size());
assertEquals("Ville",
container.getContainerProperty(container.lastItemId(), NAME)
.getValue());
assertEquals("Ville", container
.getContainerProperty(container.lastItemId(), NAME).getValue());
}

@Test
@@ -1231,9 +1229,8 @@ public class SQLContainerTableQueryTest {

// Ville
assertEquals(1, container.size());
assertEquals("Ville",
container.getContainerProperty(container.lastItemId(), NAME)
.getValue());
assertEquals("Ville", container
.getContainerProperty(container.lastItemId(), NAME).getValue());
}

@Test
@@ -1246,16 +1243,14 @@ public class SQLContainerTableQueryTest {

// Ville
assertEquals(1, container.size());
assertEquals("Ville",
container.getContainerProperty(container.lastItemId(), NAME)
.getValue());
assertEquals("Ville", container
.getContainerProperty(container.lastItemId(), NAME).getValue());

container.removeAllContainerFilters();

assertEquals(4, container.size());
assertEquals("Börje",
container.getContainerProperty(container.lastItemId(), NAME)
.getValue());
assertEquals("Börje", container
.getContainerProperty(container.lastItemId(), NAME).getValue());
}

@Test
@@ -1267,16 +1262,14 @@ public class SQLContainerTableQueryTest {

// Ville
assertEquals(1, container.size());
assertEquals("Ville",
container.getContainerProperty(container.lastItemId(), NAME)
.getValue());
assertEquals("Ville", container
.getContainerProperty(container.lastItemId(), NAME).getValue());

container.removeContainerFilters(NAME);

assertEquals(4, container.size());
assertEquals("Börje",
container.getContainerProperty(container.lastItemId(), NAME)
.getValue());
assertEquals("Börje", container
.getContainerProperty(container.lastItemId(), NAME).getValue());
}

@Test
@@ -1284,9 +1277,8 @@ public class SQLContainerTableQueryTest {
throws SQLException {
// Ville, Kalle, Pelle, Börje
assertEquals(4, container.size());
assertEquals("Börje",
container.getContainerProperty(container.lastItemId(), NAME)
.getValue());
assertEquals("Börje", container
.getContainerProperty(container.lastItemId(), NAME).getValue());

Object id1 = container.addItem();
container.getContainerProperty(id1, NAME).setValue("Palle");
@@ -1312,7 +1304,8 @@ public class SQLContainerTableQueryTest {

try {
container.getIdByIndex(4);
Assert.fail("SQLContainer.getIdByIndex() returned a value for an index beyond the end of the container");
Assert.fail(
"SQLContainer.getIdByIndex() returned a value for an index beyond the end of the container");
} catch (IndexOutOfBoundsException e) {
// should throw exception - item is filtered out
}
@@ -1335,9 +1328,8 @@ public class SQLContainerTableQueryTest {
assertEquals("Ville",
container.getContainerProperty(container.firstItemId(), NAME)
.getValue());
assertEquals("Börje",
container.getContainerProperty(container.lastItemId(), NAME)
.getValue());
assertEquals("Börje", container
.getContainerProperty(container.lastItemId(), NAME).getValue());

Object id1 = container.addItem();
container.getContainerProperty(id1, NAME).setValue("Wilbert");
@@ -1350,14 +1342,12 @@ public class SQLContainerTableQueryTest {
assertEquals("Börje",
container.getContainerProperty(container.firstItemId(), NAME)
.getValue());
assertEquals(
"Wilbert",
assertEquals("Wilbert",
container.getContainerProperty(
container.getIdByIndex(container.size() - 2), NAME)
.getValue());
assertEquals("Albert",
container.getContainerProperty(container.lastItemId(), NAME)
.getValue());
assertEquals("Albert", container
.getContainerProperty(container.lastItemId(), NAME).getValue());
}

}

+ 7
- 13
server/src/test/java/com/vaadin/server/AbstractDeploymentConfigurationTest.java Datei anzeigen

@@ -1,12 +1,12 @@
/*
* Copyright 2000-2014 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
@@ -25,7 +25,7 @@ import com.vaadin.shared.communication.PushMode;

/**
* Test for {@link AbstractDeploymentConfiguration}
*
*
* @author Vaadin Ltd
*/
public class AbstractDeploymentConfigurationTest {
@@ -80,8 +80,7 @@ public class AbstractDeploymentConfigurationTest {
public void getClassLoader_returnsClassloaderPropertyValue() {
String classLoader = UUID.randomUUID().toString();
DeploymentConfiguration config = getConfig("ClassLoader", classLoader);
Assert.assertEquals(
"Unexpected classLoader configuration option value",
Assert.assertEquals("Unexpected classLoader configuration option value",
classLoader, config.getClassLoaderName());
}

@@ -93,8 +92,8 @@ public class AbstractDeploymentConfigurationTest {
return new DeploymentConfigImpl(props);
}

private static class DeploymentConfigImpl extends
AbstractDeploymentConfiguration {
private static class DeploymentConfigImpl
extends AbstractDeploymentConfiguration {

private Properties properties;

@@ -148,11 +147,6 @@ public class AbstractDeploymentConfigurationTest {
return properties.getProperty(propertyName, defaultValue);
}

@Override
public LegacyProperyToStringMode getLegacyPropertyToStringMode() {
return null;
}

@Override
public boolean isSendUrlsAsParameters() {
return DefaultDeploymentConfiguration.DEFAULT_SEND_URLS_AS_PARAMETERS;

+ 10
- 47
server/src/test/java/com/vaadin/server/VaadinServletConfigurationTest.java Datei anzeigen

@@ -1,12 +1,12 @@
/*
* Copyright 2000-2014 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
@@ -15,7 +15,7 @@
*/

/**
*
*
*/
package com.vaadin.server;

@@ -29,7 +29,6 @@ import org.junit.Assert;
import org.junit.Test;

import com.vaadin.annotations.VaadinServletConfiguration;
import com.vaadin.server.DeploymentConfiguration.LegacyProperyToStringMode;
import com.vaadin.server.MockUIContainingServlet.ServletInUI;
import com.vaadin.ui.UI;

@@ -42,8 +41,8 @@ public class VaadinServletConfigurationTest {

Class<? extends UI> uiClass = new DefaultUIProvider()
.getUIClass(new UIClassSelectionEvent(new VaadinServletRequest(
EasyMock.createMock(HttpServletRequest.class), servlet
.getService())));
EasyMock.createMock(HttpServletRequest.class),
servlet.getService())));
Assert.assertEquals(MockUIContainingServlet.class, uiClass);
}

@@ -55,41 +54,17 @@ public class VaadinServletConfigurationTest {
.getDeploymentConfiguration();

Assert.assertEquals(true, configuration.isProductionMode());
Assert.assertEquals(LegacyProperyToStringMode.DISABLED,
configuration.getLegacyPropertyToStringMode());
Assert.assertEquals(true, configuration.isCloseIdleSessions());
Assert.assertEquals(1234, configuration.getHeartbeatInterval());
Assert.assertEquals(4321, configuration.getResourceCacheTime());

Class<? extends UI> uiClass = new DefaultUIProvider()
.getUIClass(new UIClassSelectionEvent(new VaadinServletRequest(
EasyMock.createMock(HttpServletRequest.class), servlet
.getService())));
EasyMock.createMock(HttpServletRequest.class),
servlet.getService())));
Assert.assertEquals(MockUIContainingServlet.class, uiClass);
}

@Test
public void testLegacyEnabledAnnotation() throws ServletException {
VaadinServlet servlet = new LegacyPropertyEnabledTestServlet();
servlet.init(new MockServletConfig());
DeploymentConfiguration configuration = servlet.getService()
.getDeploymentConfiguration();

Assert.assertEquals(LegacyProperyToStringMode.ENABLED,
configuration.getLegacyPropertyToStringMode());
}

@Test
public void testLegacyWarningAnnotation() throws ServletException {
VaadinServlet servlet = new LegacyPropertyWarningTestServlet();
servlet.init(new MockServletConfig());
DeploymentConfiguration configuration = servlet.getService()
.getDeploymentConfiguration();

Assert.assertEquals(LegacyProperyToStringMode.WARNING,
configuration.getLegacyPropertyToStringMode());
}

@Test
public void testValuesOverriddenForServlet() throws ServletException {
Properties servletInitParams = new Properties();
@@ -106,15 +81,13 @@ public class VaadinServletConfigurationTest {
Assert.assertEquals(false, configuration.isProductionMode());

// Other params are as defined in the annotation
Assert.assertEquals(LegacyProperyToStringMode.DISABLED,
configuration.getLegacyPropertyToStringMode());
Assert.assertEquals(true, configuration.isCloseIdleSessions());
Assert.assertEquals(4321, configuration.getResourceCacheTime());

Class<? extends UI> uiClass = new DefaultUIProvider()
.getUIClass(new UIClassSelectionEvent(new VaadinServletRequest(
EasyMock.createMock(HttpServletRequest.class), servlet
.getService())));
EasyMock.createMock(HttpServletRequest.class),
servlet.getService())));
Assert.assertEquals(MockUIContainingServlet.class, uiClass);
}
}
@@ -123,13 +96,3 @@ public class VaadinServletConfigurationTest {
class TestServlet extends VaadinServlet {

}

@VaadinServletConfiguration(productionMode = true, ui = MockUIContainingServlet.class, legacyPropertyToStringMode = LegacyProperyToStringMode.WARNING)
class LegacyPropertyWarningTestServlet extends VaadinServlet {

}

@VaadinServletConfiguration(productionMode = true, ui = MockUIContainingServlet.class, legacyPropertyToStringMode = LegacyProperyToStringMode.ENABLED)
class LegacyPropertyEnabledTestServlet extends VaadinServlet {

}

+ 2
- 14
server/src/test/java/com/vaadin/tests/util/MockDeploymentConfiguration.java Datei anzeigen

@@ -7,8 +7,8 @@ import java.util.Properties;
import com.vaadin.server.AbstractDeploymentConfiguration;
import com.vaadin.shared.communication.PushMode;

public class MockDeploymentConfiguration extends
AbstractDeploymentConfiguration {
public class MockDeploymentConfiguration
extends AbstractDeploymentConfiguration {

private boolean productionMode = false;
private boolean xsrfProtectionEnabled = true;
@@ -19,7 +19,6 @@ public class MockDeploymentConfiguration extends
private PushMode pushMode = PushMode.DISABLED;
private Properties initParameters = new Properties();
private Map<String, String> applicationOrSystemProperty = new HashMap<String, String>();
private LegacyProperyToStringMode legacyPropertyToStringMode = LegacyProperyToStringMode.DISABLED;
private boolean syncIdCheckEnabled = true;
private boolean sendUrlsAsParameters = true;

@@ -109,17 +108,6 @@ public class MockDeploymentConfiguration extends
}
}

@Override
@Deprecated
public LegacyProperyToStringMode getLegacyPropertyToStringMode() {
return legacyPropertyToStringMode;
}

public void setLegacyPropertyToStringMode(
LegacyProperyToStringMode legacyPropertyToStringMode) {
this.legacyPropertyToStringMode = legacyPropertyToStringMode;
}

@Override
public boolean isSendUrlsAsParameters() {
return sendUrlsAsParameters;

Laden…
Abbrechen
Speichern