summaryrefslogtreecommitdiffstats
path: root/compatibility-server
diff options
context:
space:
mode:
authorPekka Hyvönen <pekka@vaadin.com>2016-10-07 16:06:01 +0300
committerVaadin Code Review <review@vaadin.com>2016-10-13 06:41:15 +0000
commitfb4248119d77a6865a42ffdf0d80f10d683769a5 (patch)
tree60692a31b04a85958fefb6959e06e7039a3ea879 /compatibility-server
parentb66631c3dc5d79caa6a78274d2ea4107ccae7973 (diff)
downloadvaadin-framework-fb4248119d77a6865a42ffdf0d80f10d683769a5.tar.gz
vaadin-framework-fb4248119d77a6865a42ffdf0d80f10d683769a5.zip
Remove AbstractComponent.immediate
All components are now in immediate mode by default. V7 compatibility components will use AbstractLegacyComponent that has immediate. V7 ColorPickerPopup will not have setImmediate, since it extends V8 Window, which is not in V7 compatibility packages. Removed OutOfSync and ResynchronizeAfterAsyncRemoval Tests, since those tested UI in not immediate mode, which is invalid now. Removed WindowResizeListener, LazyWindowResize, test UIs, since both used immediate and there were no test run for either. Change-Id: Ie1c8cfa4c48461db944ff9b13efe8473c5a3298f
Diffstat (limited to 'compatibility-server')
-rw-r--r--compatibility-server/src/main/java/com/vaadin/v7/ui/AbstractColorPicker.java6
-rw-r--r--compatibility-server/src/main/java/com/vaadin/v7/ui/AbstractField.java11
-rw-r--r--compatibility-server/src/main/java/com/vaadin/v7/ui/AbstractLegacyComponent.java121
-rw-r--r--compatibility-server/src/main/java/com/vaadin/v7/ui/Calendar.java22
-rw-r--r--compatibility-server/src/main/java/com/vaadin/v7/ui/Form.java160
-rw-r--r--compatibility-server/src/main/java/com/vaadin/v7/ui/Label.java3
-rw-r--r--compatibility-server/src/main/java/com/vaadin/v7/ui/Upload.java3
-rw-r--r--compatibility-server/src/main/java/com/vaadin/v7/ui/components/colorpicker/ColorPickerPopup.java109
-rw-r--r--compatibility-server/src/main/java/com/vaadin/v7/ui/components/colorpicker/ColorPickerPreview.java1
-rw-r--r--compatibility-server/src/test/java/com/vaadin/v7/ui/AbstractLegacyComponentDeclarativeTest.java224
-rw-r--r--compatibility-server/src/test/java/com/vaadin/v7/ui/AbstractLegacyComponentTest.java21
11 files changed, 518 insertions, 163 deletions
diff --git a/compatibility-server/src/main/java/com/vaadin/v7/ui/AbstractColorPicker.java b/compatibility-server/src/main/java/com/vaadin/v7/ui/AbstractColorPicker.java
index d8d491ff31..668ffd568a 100644
--- a/compatibility-server/src/main/java/com/vaadin/v7/ui/AbstractColorPicker.java
+++ b/compatibility-server/src/main/java/com/vaadin/v7/ui/AbstractColorPicker.java
@@ -22,7 +22,6 @@ import java.util.Collection;
import org.jsoup.nodes.Attributes;
import org.jsoup.nodes.Element;
-import com.vaadin.ui.AbstractComponent;
import com.vaadin.ui.UI;
import com.vaadin.ui.Window.CloseEvent;
import com.vaadin.ui.Window.CloseListener;
@@ -43,7 +42,7 @@ import com.vaadin.v7.ui.components.colorpicker.ColorSelector;
* @since 7.0.0
*/
@Deprecated
-public abstract class AbstractColorPicker extends AbstractComponent
+public abstract class AbstractColorPicker extends AbstractLegacyComponent
implements CloseListener, ColorSelector {
private static final Method COLOR_CHANGE_METHOD;
static {
@@ -478,7 +477,6 @@ public abstract class AbstractColorPicker extends AbstractComponent
window.setHistoryVisible(historyVisible);
window.setPreviewVisible(textfieldVisible);
- window.setImmediate(true);
window.addCloseListener(this);
window.addColorChangeListener(new ColorChangeListener() {
@Override
@@ -576,7 +574,7 @@ public abstract class AbstractColorPicker extends AbstractComponent
DesignAttributeHandler.writeAttribute("color", attribute,
color.getCSS(), Color.WHITE.getCSS(), String.class);
DesignAttributeHandler.writeAttribute("popup-style", attribute,
- (popupStyle == PopupStyle.POPUP_NORMAL ? "normal" : "simple"),
+ popupStyle == PopupStyle.POPUP_NORMAL ? "normal" : "simple",
"normal", String.class);
DesignAttributeHandler.writeAttribute("position", attribute,
positionX + "," + positionY, "0,0", String.class);
diff --git a/compatibility-server/src/main/java/com/vaadin/v7/ui/AbstractField.java b/compatibility-server/src/main/java/com/vaadin/v7/ui/AbstractField.java
index 180c1f15b8..8ac94f6592 100644
--- a/compatibility-server/src/main/java/com/vaadin/v7/ui/AbstractField.java
+++ b/compatibility-server/src/main/java/com/vaadin/v7/ui/AbstractField.java
@@ -37,7 +37,6 @@ import com.vaadin.server.AbstractErrorMessage;
import com.vaadin.server.CompositeErrorMessage;
import com.vaadin.server.ErrorMessage;
import com.vaadin.shared.util.SharedUtil;
-import com.vaadin.ui.AbstractComponent;
import com.vaadin.ui.Component;
import com.vaadin.ui.declarative.DesignAttributeHandler;
import com.vaadin.ui.declarative.DesignContext;
@@ -83,7 +82,7 @@ import com.vaadin.v7.shared.AbstractFieldState;
*/
@SuppressWarnings("serial")
@Deprecated
-public abstract class AbstractField<T> extends AbstractComponent
+public abstract class AbstractField<T> extends AbstractLegacyComponent
implements Field<T>, Property.ReadOnlyStatusChangeListener,
Property.ReadOnlyStatusChangeNotifier, Action.ShortcutNotifier {
@@ -211,7 +210,7 @@ public abstract class AbstractField<T> extends AbstractComponent
@Override
public boolean isReadOnly() {
return super.isReadOnly()
- || (dataSource != null && dataSource.isReadOnly());
+ || dataSource != null && dataSource.isReadOnly();
}
/**
@@ -253,7 +252,7 @@ public abstract class AbstractField<T> extends AbstractComponent
public void commit()
throws Buffered.SourceException, InvalidValueException {
if (dataSource != null && !dataSource.isReadOnly()) {
- if ((isInvalidCommitted() || isValid())) {
+ if (isInvalidCommitted() || isValid()) {
try {
// Commits the value to datasource.
@@ -662,7 +661,7 @@ public abstract class AbstractField<T> extends AbstractComponent
// Fires value change if the value has changed
T value = getInternalValue();
- if ((value != oldValue) && ((value != null && !value.equals(oldValue))
+ if (value != oldValue && (value != null && !value.equals(oldValue)
|| value == null)) {
fireValueChange(false);
}
@@ -1521,7 +1520,7 @@ public abstract class AbstractField<T> extends AbstractComponent
@Override
public boolean isEmpty() {
- return (getFieldValue() == null);
+ return getFieldValue() == null;
}
@Override
diff --git a/compatibility-server/src/main/java/com/vaadin/v7/ui/AbstractLegacyComponent.java b/compatibility-server/src/main/java/com/vaadin/v7/ui/AbstractLegacyComponent.java
new file mode 100644
index 0000000000..11ac309089
--- /dev/null
+++ b/compatibility-server/src/main/java/com/vaadin/v7/ui/AbstractLegacyComponent.java
@@ -0,0 +1,121 @@
+/*
+ * Copyright 2000-2016 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.vaadin.v7.ui;
+
+import org.jsoup.nodes.Attributes;
+import org.jsoup.nodes.Element;
+
+import com.vaadin.ui.AbstractComponent;
+import com.vaadin.ui.declarative.DesignAttributeHandler;
+import com.vaadin.ui.declarative.DesignContext;
+import com.vaadin.v7.shared.AbstractLegacyComponentState;
+
+/**
+ * An abstract base class for compatibility components.
+ * <p>
+ * Used since immediate property has been removed in Vaadin 8 from
+ * {@link AbstractComponent}.
+ *
+ * @author Vaadin Ltd
+ * @since 8.0
+ * @deprecated only used for Vaadin 7 compatiblity components
+ */
+@Deprecated
+public class AbstractLegacyComponent extends AbstractComponent {
+
+ private Boolean explicitImmediateValue;
+
+ /**
+ * Returns the explicitly set immediate value.
+ *
+ * @return the explicitly set immediate value or null if
+ * {@link #setImmediate(boolean)} has not been explicitly invoked
+ */
+ protected Boolean getExplicitImmediateValue() {
+ return explicitImmediateValue;
+ }
+
+ /**
+ * Returns the immediate mode of the component.
+ * <p>
+ * Since Vaadin 8, the default mode is immediate.
+ *
+ * @return true if the component is in immediate mode (explicitly or
+ * implicitly set), false if the component if not in immediate mode
+ */
+ public boolean isImmediate() {
+ if (explicitImmediateValue != null) {
+ return explicitImmediateValue;
+ } else {
+ return true;
+ }
+ }
+
+ /**
+ * Sets the component's immediate mode to the specified status.
+ * <p>
+ * Since Vaadin 8, the default mode is immediate.
+ *
+ * @param immediate
+ * the boolean value specifying if the component should be in the
+ * immediate mode after the call.
+ */
+ public void setImmediate(boolean immediate) {
+ explicitImmediateValue = immediate;
+ getState().immediate = immediate;
+ }
+
+ @Override
+ public void readDesign(Element design, DesignContext designContext) {
+ super.readDesign(design, designContext);
+
+ Attributes attr = design.attributes();
+ // handle immediate
+ if (attr.hasKey("immediate")) {
+ setImmediate(DesignAttributeHandler.getFormatter()
+ .parse(attr.get("immediate"), Boolean.class));
+ }
+ }
+
+ @Override
+ public void writeDesign(Element design, DesignContext designContext) {
+ super.writeDesign(design, designContext);
+
+ AbstractLegacyComponent def = designContext.getDefaultInstance(this);
+ Attributes attr = design.attributes();
+ // handle immediate
+ if (explicitImmediateValue != null) {
+ DesignAttributeHandler.writeAttribute("immediate", attr,
+ explicitImmediateValue, def.isImmediate(), Boolean.class);
+ }
+ }
+
+ @Override
+ public void beforeClientResponse(boolean initial) {
+ super.beforeClientResponse(initial);
+ getState().immediate = isImmediate();
+ }
+
+ @Override
+ protected AbstractLegacyComponentState getState() {
+ return (AbstractLegacyComponentState) super.getState();
+ }
+
+ @Override
+ protected AbstractLegacyComponentState getState(boolean markAsDirty) {
+ return (AbstractLegacyComponentState) super.getState(markAsDirty);
+ }
+}
diff --git a/compatibility-server/src/main/java/com/vaadin/v7/ui/Calendar.java b/compatibility-server/src/main/java/com/vaadin/v7/ui/Calendar.java
index d8ffd0b1e8..da6443da29 100644
--- a/compatibility-server/src/main/java/com/vaadin/v7/ui/Calendar.java
+++ b/compatibility-server/src/main/java/com/vaadin/v7/ui/Calendar.java
@@ -49,7 +49,6 @@ import com.vaadin.event.dd.TargetDetails;
import com.vaadin.server.KeyMapper;
import com.vaadin.server.PaintException;
import com.vaadin.server.PaintTarget;
-import com.vaadin.ui.AbstractComponent;
import com.vaadin.ui.LegacyComponent;
import com.vaadin.ui.declarative.DesignAttributeHandler;
import com.vaadin.ui.declarative.DesignContext;
@@ -119,7 +118,7 @@ import com.vaadin.v7.ui.components.calendar.handler.BasicWeekClickHandler;
*/
@SuppressWarnings("serial")
@Deprecated
-public class Calendar extends AbstractComponent
+public class Calendar extends AbstractLegacyComponent
implements CalendarComponentEvents.NavigationNotifier,
CalendarComponentEvents.EventMoveNotifier,
CalendarComponentEvents.RangeSelectNotifier,
@@ -440,7 +439,7 @@ public class Calendar extends AbstractComponent
}
private void setupCalendarEvents() {
- int durationInDays = (int) (((endDate.getTime()) - startDate.getTime())
+ int durationInDays = (int) ((endDate.getTime() - startDate.getTime())
/ DateConstants.DAYINMILLIS);
durationInDays++;
if (durationInDays > 60) {
@@ -503,7 +502,7 @@ public class Calendar extends AbstractComponent
endDate = getEndDate();
}
- int durationInDays = (int) (((endDate.getTime()) - startDate.getTime())
+ int durationInDays = (int) ((endDate.getTime() - startDate.getTime())
/ DateConstants.DAYINMILLIS);
durationInDays++;
if (durationInDays > 60) {
@@ -524,7 +523,7 @@ public class Calendar extends AbstractComponent
df_date.setTimeZone(currentCalendar.getTimeZone());
df_time.setTimeZone(currentCalendar.getTimeZone());
- state.now = (df_date.format(now) + " " + df_time.format(now));
+ state.now = df_date.format(now) + " " + df_time.format(now);
Date firstDateToShow = expandStartDate(startDate, durationInDays > 7);
Date lastDateToShow = expandEndDate(endDate, durationInDays > 7);
@@ -570,7 +569,7 @@ public class Calendar extends AbstractComponent
cal.add(java.util.Calendar.SECOND, -1);
Date end = cal.getTime();
- boolean monthView = (durationInDays > 7);
+ boolean monthView = durationInDays > 7;
/**
* If in day or week view add actions for each half-an-hour.
@@ -903,9 +902,9 @@ public class Calendar extends AbstractComponent
* The date caption pattern.
*/
public void setWeeklyCaptionFormat(String dateFormatPattern) {
- if ((weeklyCaptionFormat == null && dateFormatPattern != null)
- || (weeklyCaptionFormat != null
- && !weeklyCaptionFormat.equals(dateFormatPattern))) {
+ if (weeklyCaptionFormat == null && dateFormatPattern != null
+ || weeklyCaptionFormat != null
+ && !weeklyCaptionFormat.equals(dateFormatPattern)) {
weeklyCaptionFormat = dateFormatPattern;
markAsDirty();
}
@@ -932,7 +931,7 @@ public class Calendar extends AbstractComponent
// monday first
if (calendar.getFirstDayOfWeek() == java.util.Calendar.MONDAY) {
- fow = (fow == java.util.Calendar.SUNDAY) ? 7 : fow - 1;
+ fow = fow == java.util.Calendar.SUNDAY ? 7 : fow - 1;
}
return fow;
@@ -1985,8 +1984,7 @@ public class Calendar extends AbstractComponent
if (currentTimeFormat != null) {
design.attr("time-format",
- (currentTimeFormat == TimeFormat.Format12H ? "12h"
- : "24h"));
+ currentTimeFormat == TimeFormat.Format12H ? "12h" : "24h");
}
if (startDate != null) {
design.attr("start-date", df_date.format(getStartDate()));
diff --git a/compatibility-server/src/main/java/com/vaadin/v7/ui/Form.java b/compatibility-server/src/main/java/com/vaadin/v7/ui/Form.java
index e9bdf8771e..579bc063b8 100644
--- a/compatibility-server/src/main/java/com/vaadin/v7/ui/Form.java
+++ b/compatibility-server/src/main/java/com/vaadin/v7/ui/Form.java
@@ -1,12 +1,12 @@
/*
* Copyright 2000-2016 Vaadin Ltd.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
@@ -55,7 +55,7 @@ import com.vaadin.v7.shared.form.FormState;
/**
* Form component provides easy way of creating and managing sets fields.
- *
+ *
* <p>
* <code>Form</code> is a container for fields implementing {@link Field}
* interface. It provides support for any layouts and provides buffering
@@ -64,7 +64,7 @@ import com.vaadin.v7.shared.form.FormState;
* setting immediateness, etc. Also direct mechanism for replacing existing
* fields with selections is given.
* </p>
- *
+ *
* <p>
* <code>Form</code> provides customizable editor for classes implementing
* {@link com.vaadin.data.Item} interface. Also the form itself implements this
@@ -78,7 +78,7 @@ import com.vaadin.v7.shared.form.FormState;
* properties of any class following bean pattern, can be accessed trough
* {@link com.vaadin.data.util.BeanItem}.
* </p>
- *
+ *
* @author Vaadin Ltd.
* @since 3.0
* @deprecated As of 7.0, use {@link FieldGroup} instead of {@link Form} for
@@ -134,7 +134,7 @@ public class Form extends AbstractField<Object>
/**
* Form needs to repaint itself if child fields value changes due possible
* change in form validity.
- *
+ *
* TODO introduce ValidityChangeEvent (#6239) and start using it instead.
* See e.g. DateField#notifyFormOfValidityChange().
*/
@@ -164,7 +164,7 @@ public class Form extends AbstractField<Object>
/**
* Constructs a new form with default layout.
- *
+ *
* <p>
* By default the form uses {@link FormLayout}.
* </p>
@@ -176,7 +176,7 @@ public class Form extends AbstractField<Object>
/**
* Constructs a new form with given {@link Layout}.
- *
+ *
* @param formLayout
* the layout of the form.
*/
@@ -187,7 +187,7 @@ public class Form extends AbstractField<Object>
/**
* Constructs a new form with given {@link Layout} and
* {@link FormFieldFactory}.
- *
+ *
* @param formLayout
* the layout of the form.
* @param fieldFactory
@@ -231,7 +231,7 @@ public class Form extends AbstractField<Object>
/**
* The error message of a Form is the error of the first field with a
* non-empty error.
- *
+ *
* Empty error messages of the contained fields are skipped, because an
* empty error indicator would be confusing to the user, especially if there
* are errors that have something to display. This is also the reason why
@@ -284,15 +284,15 @@ public class Form extends AbstractField<Object>
/**
* Controls the making validation visible implicitly on commit.
- *
+ *
* Having commit() call setValidationVisible(true) implicitly is the default
* behaviour. You can disable the implicit setting by setting this property
* as false.
- *
+ *
* It is useful, because you usually want to start with the form free of
* errors and only display them after the user clicks Ok. You can disable
* the implicit setting by setting this property as false.
- *
+ *
* @param makeVisible
* If true (default), validation is made visible when commit() is
* called. If false, the visibility is left as it is.
@@ -303,9 +303,9 @@ public class Form extends AbstractField<Object>
/**
* Is validation made automatically visible on commit?
- *
+ *
* See setValidationVisibleOnCommit().
- *
+ *
* @return true if validation is made automatically visible on commit.
*/
public boolean isValidationVisibleOnCommit() {
@@ -339,7 +339,7 @@ public class Form extends AbstractField<Object>
// Try to commit all
for (final Iterator<Object> i = propertyIds.iterator(); i.hasNext();) {
try {
- final Field<?> f = (fields.get(i.next()));
+ final Field<?> f = fields.get(i.next());
// Commit only non-readonly fields.
if (!f.isReadOnly()) {
f.commit();
@@ -387,7 +387,7 @@ public class Form extends AbstractField<Object>
// Try to discard all changes
for (final Iterator<Object> i = propertyIds.iterator(); i.hasNext();) {
try {
- (fields.get(i.next())).discard();
+ fields.get(i.next()).discard();
} catch (final Buffered.SourceException e) {
if (problems == null) {
problems = new LinkedList<>();
@@ -445,14 +445,14 @@ public class Form extends AbstractField<Object>
this.buffered = buffered;
for (final Iterator<Object> i = propertyIds.iterator(); i
.hasNext();) {
- (fields.get(i.next())).setBuffered(buffered);
+ fields.get(i.next()).setBuffered(buffered);
}
}
}
/**
* Adds a new property to form and create corresponding field.
- *
+ *
* @see com.vaadin.data.Item#addItemProperty(Object, Property)
*/
@Override
@@ -488,16 +488,16 @@ public class Form extends AbstractField<Object>
/**
* Registers the field with the form and adds the field to the form layout.
- *
+ *
* <p>
* The property id must not be already used in the form.
* </p>
- *
+ *
* <p>
* This field is added to the layout using the
* {@link #attachField(Object, Field)} method.
* </p>
- *
+ *
* @param propertyId
* the Property id the the field.
* @param field
@@ -512,12 +512,12 @@ public class Form extends AbstractField<Object>
/**
* Register the field with the form. All registered fields are validated
* when the form is validated and also committed when the form is committed.
- *
+ *
* <p>
* The property id must not be already used in the form.
* </p>
- *
- *
+ *
+ *
* @param propertyId
* the Property id of the field.
* @param field
@@ -539,8 +539,8 @@ public class Form extends AbstractField<Object>
// form.
// Should this also include invalidCommitted (#3993)?
field.setBuffered(buffered);
- if (isImmediate() && field instanceof AbstractComponent) {
- ((AbstractComponent) field).setImmediate(true);
+ if (isImmediate() && field instanceof AbstractLegacyComponent) {
+ ((AbstractLegacyComponent) field).setImmediate(true);
}
}
@@ -553,11 +553,11 @@ public class Form extends AbstractField<Object>
* CustomLayout location given by the string representation of the property
* id using {@link CustomLayout#addComponent(Component, String)}.
* </p>
- *
+ *
* <p>
* Override this method to control how the fields are added to the layout.
* </p>
- *
+ *
* @param propertyId
* @param field
*/
@@ -577,13 +577,13 @@ public class Form extends AbstractField<Object>
/**
* The property identified by the property id.
- *
+ *
* <p>
* The property data source of the field specified with property id is
* returned. If there is a (with specified property id) having no data
* source, the field is returned instead of the data source.
* </p>
- *
+ *
* @see com.vaadin.data.Item#getItemProperty(Object)
*/
@Override
@@ -604,7 +604,7 @@ public class Form extends AbstractField<Object>
/**
* Gets the field identified by the propertyid.
- *
+ *
* @param propertyId
* the id of the property.
*/
@@ -620,7 +620,7 @@ public class Form extends AbstractField<Object>
/**
* Removes the property and corresponding field from the form.
- *
+ *
* @see com.vaadin.data.Item#removeItemProperty(Object)
*/
@Override
@@ -647,7 +647,7 @@ public class Form extends AbstractField<Object>
* Override this method to control how the fields are removed from the
* layout.
* </p>
- *
+ *
* @param field
* the field to be detached from the forms layout.
*/
@@ -660,7 +660,7 @@ public class Form extends AbstractField<Object>
/**
* Removes all properties and fields from the form.
- *
+ *
* @return the Success of the operation. Removal of all fields succeeded if
* (and only if) the return value is <code>true</code>.
*/
@@ -685,12 +685,12 @@ public class Form extends AbstractField<Object>
/**
* Sets the item datasource for the form.
- *
+ *
* <p>
* Setting item datasource clears any fields, the form might contain and
* adds all the properties as fields to the form.
* </p>
- *
+ *
* @see com.vaadin.data.Item.Viewer#setItemDataSource(Item)
*/
@Override
@@ -702,13 +702,13 @@ public class Form extends AbstractField<Object>
/**
* Set the item datasource for the form, but limit the form contents to
* specified properties of the item.
- *
+ *
* <p>
* Setting item datasource clears any fields, the form might contain and
* adds the specified the properties as fields to the form, in the specified
* order.
* </p>
- *
+ *
* @see com.vaadin.data.Item.Viewer#setItemDataSource(Item)
*/
public void setItemDataSource(Item newDataSource,
@@ -759,7 +759,7 @@ public class Form extends AbstractField<Object>
* property straight to Field. If Property.Viewer type property (e.g.
* PropertyFormatter) is already set for field, the property is bound to
* that Property.Viewer.
- *
+ *
* @param propertyId
* @param property
* @param field
@@ -771,7 +771,7 @@ public class Form extends AbstractField<Object>
// expect developer has e.g. PropertyFormatter that he wishes to use and
// assign the property to the Viewer instead.
boolean hasFilterProperty = field.getPropertyDataSource() != null
- && (field.getPropertyDataSource() instanceof Property.Viewer);
+ && field.getPropertyDataSource() instanceof Property.Viewer;
if (hasFilterProperty) {
((Property.Viewer) field.getPropertyDataSource())
.setPropertyDataSource(property);
@@ -782,12 +782,12 @@ public class Form extends AbstractField<Object>
/**
* Gets the layout of the form.
- *
+ *
* <p>
* By default form uses <code>OrderedLayout</code> with <code>form</code>
* -style.
* </p>
- *
+ *
* @return the Layout of the form.
*/
public Layout getLayout() {
@@ -796,11 +796,11 @@ public class Form extends AbstractField<Object>
/**
* Sets the layout of the form.
- *
+ *
* <p>
* If set to null then Form uses a FormLayout by default.
* </p>
- *
+ *
* @param layout
* the layout of the form.
*/
@@ -839,16 +839,16 @@ public class Form extends AbstractField<Object>
/**
* Sets the form field to be selectable from static list of changes.
- *
+ *
* <p>
* The list values and descriptions are given as array. The value-array must
* contain the current value of the field and the lengths of the arrays must
* match. Null values are not supported.
* </p>
- *
+ *
* Note: since Vaadin 7.0, returns an {@link AbstractSelect} instead of a
* {@link Select}.
- *
+ *
* @param propertyId
* the id of the property.
* @param values
@@ -883,7 +883,7 @@ public class Form extends AbstractField<Object>
boolean isMultiselect = false;
for (int i = 0; i < values.length && !found; i++) {
if (values[i] == value
- || (value != null && value.equals(values[i]))) {
+ || value != null && value.equals(values[i])) {
found = true;
}
}
@@ -895,7 +895,7 @@ public class Form extends AbstractField<Object>
found = false;
for (int i = 0; i < values.length && !found; i++) {
if (values[i] == val
- || (val != null && val.equals(values[i]))) {
+ || val != null && val.equals(values[i])) {
found = true;
}
}
@@ -958,20 +958,20 @@ public class Form extends AbstractField<Object>
/**
* Checks the validity of the Form and all of its fields.
- *
+ *
* @see com.vaadin.legacy.data.Validatable#validate()
*/
@Override
public void validate() throws Validator.InvalidValueException {
super.validate();
for (final Iterator<Object> i = propertyIds.iterator(); i.hasNext();) {
- (fields.get(i.next())).validate();
+ fields.get(i.next()).validate();
}
}
/**
* Checks the validabtable object accept invalid values.
- *
+ *
* @see com.vaadin.legacy.data.Validatable#isInvalidAllowed()
*/
@Override
@@ -981,7 +981,7 @@ public class Form extends AbstractField<Object>
/**
* Should the validabtable object accept invalid values.
- *
+ *
* @see com.vaadin.legacy.data.Validatable#setInvalidAllowed(boolean)
*/
@Override
@@ -992,24 +992,24 @@ public class Form extends AbstractField<Object>
/**
* Sets the component's to read-only mode to the specified state.
- *
+ *
* @see com.vaadin.ui.Component#setReadOnly(boolean)
*/
@Override
public void setReadOnly(boolean readOnly) {
super.setReadOnly(readOnly);
for (final Iterator<?> i = propertyIds.iterator(); i.hasNext();) {
- (fields.get(i.next())).setReadOnly(readOnly);
+ fields.get(i.next()).setReadOnly(readOnly);
}
}
/**
* Sets the field factory used by this Form to genarate Fields for
* properties.
- *
+ *
* {@link FormFieldFactory} is used to create fields for form properties.
* {@link DefaultFieldFactory} is used by default.
- *
+ *
* @param fieldFactory
* the new factory used to create the fields.
* @see Field
@@ -1021,7 +1021,7 @@ public class Form extends AbstractField<Object>
/**
* Get the field factory of the form.
- *
+ *
* @return the FormFieldFactory Factory used to create the fields.
*/
public FormFieldFactory getFormFieldFactory() {
@@ -1030,7 +1030,7 @@ public class Form extends AbstractField<Object>
/**
* Gets the field type.
- *
+ *
* @see com.vaadin.legacy.ui.AbstractField#getType()
*/
@Override
@@ -1043,9 +1043,9 @@ public class Form extends AbstractField<Object>
/**
* Sets the internal value.
- *
+ *
* This is relevant when the Form is used as Field.
- *
+ *
* @see com.vaadin.legacy.ui.AbstractField#setInternalValue(java.lang.Object)
*/
@Override
@@ -1067,7 +1067,7 @@ public class Form extends AbstractField<Object>
* Gets the first focusable field in form. If there are enabled,
* non-read-only fields, the first one of them is returned. Otherwise, the
* field for the first property (or null if none) is returned.
- *
+ *
* @return the Field.
*/
private Field<?> getFirstFocusableField() {
@@ -1093,9 +1093,9 @@ public class Form extends AbstractField<Object>
/**
* Updates the internal form datasource.
- *
+ *
* Method setFormDataSource.
- *
+ *
* @param data
* @param properties
*/
@@ -1121,7 +1121,7 @@ public class Form extends AbstractField<Object>
/**
* Returns the visibleProperties.
- *
+ *
* @return the Collection of visible Item properites.
*/
public Collection<?> getVisibleItemProperties() {
@@ -1130,7 +1130,7 @@ public class Form extends AbstractField<Object>
/**
* Sets the visibleProperties.
- *
+ *
* @param visibleProperties
* the visibleProperties to set.
*/
@@ -1145,7 +1145,7 @@ public class Form extends AbstractField<Object>
/**
* Sets the visibleProperties.
- *
+ *
* @param visibleProperties
* the visibleProperties to set.
*/
@@ -1159,7 +1159,7 @@ public class Form extends AbstractField<Object>
/**
* Focuses the first field in the form.
- *
+ *
* @see com.vaadin.ui.Component.Focusable#focus()
*/
@Override
@@ -1172,7 +1172,7 @@ public class Form extends AbstractField<Object>
/**
* Sets the Tabulator index of this Focusable component.
- *
+ *
* @see com.vaadin.ui.Component.Focusable#setTabIndex(int)
*/
@Override
@@ -1180,7 +1180,7 @@ public class Form extends AbstractField<Object>
super.setTabIndex(tabIndex);
for (final Iterator<?> i = getItemPropertyIds().iterator(); i
.hasNext();) {
- (getField(i.next())).setTabIndex(tabIndex);
+ getField(i.next()).setTabIndex(tabIndex);
}
}
@@ -1193,8 +1193,8 @@ public class Form extends AbstractField<Object>
super.setImmediate(immediate);
for (Iterator<Field<?>> i = fields.values().iterator(); i.hasNext();) {
Field<?> f = i.next();
- if (f instanceof AbstractComponent) {
- ((AbstractComponent) f).setImmediate(immediate);
+ if (f instanceof AbstractLegacyComponent) {
+ ((AbstractLegacyComponent) f).setImmediate(immediate);
}
}
}
@@ -1203,7 +1203,7 @@ public class Form extends AbstractField<Object>
* {@inheritDoc}
* <p>
* A Form is empty if all of its fields are empty.
- *
+ *
*/
@Override
public boolean isEmpty() {
@@ -1222,7 +1222,7 @@ public class Form extends AbstractField<Object>
/*
* (non-Javadoc)
- *
+ *
* @see com.vaadin.ui.AbstractField#clear()
*/
@Override
@@ -1237,7 +1237,7 @@ public class Form extends AbstractField<Object>
/**
* Adding validators directly to form is not supported.
- *
+ *
* Add the validators to form fields instead.
*/
@Override
@@ -1248,7 +1248,7 @@ public class Form extends AbstractField<Object>
/**
* Returns a layout that is rendered below normal form contents. This area
* can be used for example to include buttons related to form contents.
- *
+ *
* @return layout rendered below normal form contents or null if no footer
* is used
*/
@@ -1259,7 +1259,7 @@ public class Form extends AbstractField<Object>
/**
* Sets the layout that is rendered below normal form contents. No footer is
* rendered if this is set to null, .
- *
+ *
* @param footer
* the new footer layout
*/
@@ -1295,7 +1295,7 @@ public class Form extends AbstractField<Object>
* {@link AbstractField}. The ownActionManager handles Actions attached to
* this Form specifically, while the ActionManager in AbstractField
* delegates to the containing Window (i.e global Actions).
- *
+ *
* @return
*/
protected ActionManager getOwnActionManager() {
diff --git a/compatibility-server/src/main/java/com/vaadin/v7/ui/Label.java b/compatibility-server/src/main/java/com/vaadin/v7/ui/Label.java
index 9836f33d20..559df24875 100644
--- a/compatibility-server/src/main/java/com/vaadin/v7/ui/Label.java
+++ b/compatibility-server/src/main/java/com/vaadin/v7/ui/Label.java
@@ -23,7 +23,6 @@ import java.util.Locale;
import org.jsoup.nodes.Element;
import com.vaadin.shared.util.SharedUtil;
-import com.vaadin.ui.AbstractComponent;
import com.vaadin.ui.Component;
import com.vaadin.ui.declarative.DesignContext;
import com.vaadin.ui.declarative.DesignFormatter;
@@ -57,7 +56,7 @@ import com.vaadin.v7.shared.ui.label.LabelState;
*/
@SuppressWarnings("serial")
@Deprecated
-public class Label extends AbstractComponent implements Property<String>,
+public class Label extends AbstractLegacyComponent implements Property<String>,
Property.Viewer, Property.ValueChangeListener,
Property.ValueChangeNotifier, Comparable<Label> {
diff --git a/compatibility-server/src/main/java/com/vaadin/v7/ui/Upload.java b/compatibility-server/src/main/java/com/vaadin/v7/ui/Upload.java
index d3bc4b1473..9483ac3eca 100644
--- a/compatibility-server/src/main/java/com/vaadin/v7/ui/Upload.java
+++ b/compatibility-server/src/main/java/com/vaadin/v7/ui/Upload.java
@@ -31,7 +31,6 @@ import com.vaadin.server.PaintTarget;
import com.vaadin.server.StreamVariable.StreamingProgressEvent;
import com.vaadin.shared.EventId;
import com.vaadin.shared.Registration;
-import com.vaadin.ui.AbstractComponent;
import com.vaadin.ui.Component;
import com.vaadin.ui.LegacyComponent;
import com.vaadin.util.ReflectTools;
@@ -79,7 +78,7 @@ import com.vaadin.v7.shared.ui.upload.UploadState;
*/
@SuppressWarnings("serial")
@Deprecated
-public class Upload extends AbstractComponent
+public class Upload extends AbstractLegacyComponent
implements Component.Focusable, LegacyComponent {
/**
diff --git a/compatibility-server/src/main/java/com/vaadin/v7/ui/components/colorpicker/ColorPickerPopup.java b/compatibility-server/src/main/java/com/vaadin/v7/ui/components/colorpicker/ColorPickerPopup.java
index 03f920c92b..a6f35fa6f9 100644
--- a/compatibility-server/src/main/java/com/vaadin/v7/ui/components/colorpicker/ColorPickerPopup.java
+++ b/compatibility-server/src/main/java/com/vaadin/v7/ui/components/colorpicker/ColorPickerPopup.java
@@ -1,12 +1,12 @@
/*
* Copyright 2000-2016 Vaadin Ltd.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
@@ -45,12 +45,12 @@ import com.vaadin.v7.ui.Slider.ValueOutOfBoundsException;
/**
* A component that represents color selection popup within a color picker.
- *
+ *
* @since 7.0.0
*/
@Deprecated
-public class ColorPickerPopup extends Window implements ClickListener,
- ColorChangeListener, ColorSelector {
+public class ColorPickerPopup extends Window
+ implements ClickListener, ColorChangeListener, ColorSelector {
private static final String STYLENAME = "v-colorpicker-popup";
@@ -155,7 +155,6 @@ public class ColorPickerPopup extends Window implements ClickListener,
setContent(layout);
setStyleName(STYLENAME);
setResizable(false);
- setImmediate(true);
// Create the history
history = new ColorPickerHistory();
history.addColorChangeListener(this);
@@ -257,7 +256,7 @@ public class ColorPickerPopup extends Window implements ClickListener,
/**
* Creates the RGB tab.
- *
+ *
* @return the component
*/
private Component createRGBTab(Color color) {
@@ -287,8 +286,8 @@ public class ColorPickerPopup extends Window implements ClickListener,
public void valueChange(ValueChangeEvent event) {
double red = (Double) event.getProperty().getValue();
if (!updatingColors) {
- Color newColor = new Color((int) red, selectedColor
- .getGreen(), selectedColor.getBlue());
+ Color newColor = new Color((int) red,
+ selectedColor.getGreen(), selectedColor.getBlue());
setColor(newColor);
}
}
@@ -338,7 +337,7 @@ public class ColorPickerPopup extends Window implements ClickListener,
/**
* Creates the hsv tab.
- *
+ *
* @return the component
*/
private Component createHSVTab(Color color) {
@@ -372,16 +371,16 @@ public class ColorPickerPopup extends Window implements ClickListener,
@Override
public void valueChange(ValueChangeEvent event) {
if (!updatingColors) {
- float hue = (Float.parseFloat(event.getProperty()
- .getValue().toString())) / 360f;
- float saturation = (Float.parseFloat(saturationSlider
- .getValue().toString())) / 100f;
- float value = (Float.parseFloat(valueSlider.getValue()
- .toString())) / 100f;
+ float hue = Float.parseFloat(
+ event.getProperty().getValue().toString()) / 360f;
+ float saturation = Float.parseFloat(
+ saturationSlider.getValue().toString()) / 100f;
+ float value = Float.parseFloat(
+ valueSlider.getValue().toString()) / 100f;
// Set the color
- Color color = new Color(Color.HSVtoRGB(hue, saturation,
- value));
+ Color color = new Color(
+ Color.HSVtoRGB(hue, saturation, value));
setColor(color);
/*
@@ -403,14 +402,14 @@ public class ColorPickerPopup extends Window implements ClickListener,
@Override
public void valueChange(ValueChangeEvent event) {
if (!updatingColors) {
- float hue = (Float.parseFloat(hueSlider.getValue()
- .toString())) / 360f;
- float saturation = (Float.parseFloat(event.getProperty()
- .getValue().toString())) / 100f;
- float value = (Float.parseFloat(valueSlider.getValue()
- .toString())) / 100f;
- Color color = new Color(Color.HSVtoRGB(hue, saturation,
- value));
+ float hue = Float
+ .parseFloat(hueSlider.getValue().toString()) / 360f;
+ float saturation = Float.parseFloat(
+ event.getProperty().getValue().toString()) / 100f;
+ float value = Float.parseFloat(
+ valueSlider.getValue().toString()) / 100f;
+ Color color = new Color(
+ Color.HSVtoRGB(hue, saturation, value));
setColor(color);
}
}
@@ -424,15 +423,15 @@ public class ColorPickerPopup extends Window implements ClickListener,
@Override
public void valueChange(ValueChangeEvent event) {
if (!updatingColors) {
- float hue = (Float.parseFloat(hueSlider.getValue()
- .toString())) / 360f;
- float saturation = (Float.parseFloat(saturationSlider
- .getValue().toString())) / 100f;
- float value = (Float.parseFloat(event.getProperty()
- .getValue().toString())) / 100f;
-
- Color color = new Color(Color.HSVtoRGB(hue, saturation,
- value));
+ float hue = Float
+ .parseFloat(hueSlider.getValue().toString()) / 360f;
+ float saturation = Float.parseFloat(
+ saturationSlider.getValue().toString()) / 100f;
+ float value = Float.parseFloat(
+ event.getProperty().getValue().toString()) / 100f;
+
+ Color color = new Color(
+ Color.HSVtoRGB(hue, saturation, value));
setColor(color);
}
}
@@ -446,7 +445,7 @@ public class ColorPickerPopup extends Window implements ClickListener,
/**
* Creates the select tab.
- *
+ *
* @return the component
*/
private Component createSelectTab() {
@@ -505,7 +504,7 @@ public class ColorPickerPopup extends Window implements ClickListener,
/**
* Gets the history.
- *
+ *
* @return the history
*/
public ColorPickerHistory getHistory() {
@@ -536,7 +535,7 @@ public class ColorPickerPopup extends Window implements ClickListener,
/**
* Gets the color history.
- *
+ *
* @return the color history
*/
public List<Color> getColorHistory() {
@@ -569,10 +568,10 @@ public class ColorPickerPopup extends Window implements ClickListener,
blueSlider.setValue(((Integer) color.getBlue()).doubleValue());
greenSlider.setValue(((Integer) color.getGreen()).doubleValue());
} catch (ValueOutOfBoundsException e) {
- getLogger().log(
- Level.WARNING,
+ getLogger().log(Level.WARNING,
"Unable to set RGB color value to " + color.getRed() + ","
- + color.getGreen() + "," + color.getBlue(), e);
+ + color.getGreen() + "," + color.getBlue(),
+ e);
}
}
@@ -582,10 +581,8 @@ public class ColorPickerPopup extends Window implements ClickListener,
saturationSlider.setValue(((Float) (hsv[1] * 100f)).doubleValue());
valueSlider.setValue(((Float) (hsv[2] * 100f)).doubleValue());
} catch (ValueOutOfBoundsException e) {
- getLogger().log(
- Level.WARNING,
- "Unable to set HSV color value to " + hsv[0] + "," + hsv[1]
- + "," + hsv[2], e);
+ getLogger().log(Level.WARNING, "Unable to set HSV color value to "
+ + hsv[0] + "," + hsv[1] + "," + hsv[2], e);
}
}
@@ -601,7 +598,7 @@ public class ColorPickerPopup extends Window implements ClickListener,
/**
* Checks the visibility of the given tab
- *
+ *
* @param tab
* The tab to check
* @return true if tab is visible, false otherwise
@@ -618,7 +615,7 @@ public class ColorPickerPopup extends Window implements ClickListener,
/**
* How many tabs are visible
- *
+ *
* @return The number of tabs visible
*/
private int tabsNumVisible() {
@@ -640,7 +637,7 @@ public class ColorPickerPopup extends Window implements ClickListener,
/**
* Set RGB tab visibility
- *
+ *
* @param visible
* The visibility of the RGB tab
*/
@@ -656,7 +653,7 @@ public class ColorPickerPopup extends Window implements ClickListener,
/**
* Set HSV tab visibility
- *
+ *
* @param visible
* The visibility of the HSV tab
*/
@@ -672,7 +669,7 @@ public class ColorPickerPopup extends Window implements ClickListener,
/**
* Set Swatches tab visibility
- *
+ *
* @param visible
* The visibility of the Swatches tab
*/
@@ -688,7 +685,7 @@ public class ColorPickerPopup extends Window implements ClickListener,
/**
* Set the History visibility
- *
+ *
* @param visible
*/
public void setHistoryVisible(boolean visible) {
@@ -698,7 +695,7 @@ public class ColorPickerPopup extends Window implements ClickListener,
/**
* Set the preview visibility
- *
+ *
* @param visible
*/
public void setPreviewVisible(boolean visible) {
@@ -712,7 +709,7 @@ public class ColorPickerPopup extends Window implements ClickListener,
@Override
public Color calculate(int x, int y) {
- float h = (x / 220f);
+ float h = x / 220f;
float s = 1f;
float v = 1f;
@@ -764,8 +761,8 @@ public class ColorPickerPopup extends Window implements ClickListener,
@Override
public Color calculate(int x, int y) {
- float saturation = 1f - (y / 220.0f);
- float value = (x / 220.0f);
+ float saturation = 1f - y / 220.0f;
+ float value = x / 220.0f;
float hue = Float.parseFloat(hueSlider.getValue().toString())
/ 360f;
diff --git a/compatibility-server/src/main/java/com/vaadin/v7/ui/components/colorpicker/ColorPickerPreview.java b/compatibility-server/src/main/java/com/vaadin/v7/ui/components/colorpicker/ColorPickerPreview.java
index 2b627efbe7..9a6e3598e8 100644
--- a/compatibility-server/src/main/java/com/vaadin/v7/ui/components/colorpicker/ColorPickerPreview.java
+++ b/compatibility-server/src/main/java/com/vaadin/v7/ui/components/colorpicker/ColorPickerPreview.java
@@ -59,7 +59,6 @@ public class ColorPickerPreview extends CssLayout implements ColorSelector,
private ColorPickerPreview() {
setStyleName("v-colorpicker-preview");
- setImmediate(true);
field = new TextField();
field.setImmediate(true);
field.setSizeFull();
diff --git a/compatibility-server/src/test/java/com/vaadin/v7/ui/AbstractLegacyComponentDeclarativeTest.java b/compatibility-server/src/test/java/com/vaadin/v7/ui/AbstractLegacyComponentDeclarativeTest.java
new file mode 100644
index 0000000000..0577a5743e
--- /dev/null
+++ b/compatibility-server/src/test/java/com/vaadin/v7/ui/AbstractLegacyComponentDeclarativeTest.java
@@ -0,0 +1,224 @@
+/*
+ * Copyright 2000-2016 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.vaadin.v7.ui;
+
+import static org.junit.Assert.assertTrue;
+
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.lang.reflect.Field;
+import java.nio.charset.Charset;
+import java.util.Locale;
+
+import org.jsoup.nodes.Attributes;
+import org.jsoup.nodes.Element;
+import org.jsoup.parser.Tag;
+import org.junit.Before;
+import org.junit.Test;
+
+import com.vaadin.server.ErrorMessage.ErrorLevel;
+import com.vaadin.server.ExternalResource;
+import com.vaadin.server.FileResource;
+import com.vaadin.server.Responsive;
+import com.vaadin.server.ThemeResource;
+import com.vaadin.server.UserError;
+import com.vaadin.tests.design.DeclarativeTestBase;
+import com.vaadin.ui.AbstractComponent;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.declarative.Design;
+import com.vaadin.ui.declarative.DesignContext;
+
+/**
+ * Test cases for reading and writing the properties of AbstractComponent.
+ *
+ * @since
+ * @author Vaadin Ltd
+ */
+public class AbstractLegacyComponentDeclarativeTest
+ extends DeclarativeTestBase<AbstractLegacyComponent> {
+
+ private AbstractLegacyComponent component;
+
+ @Before
+ public void setUp() {
+ NativeSelect ns = new NativeSelect();
+ component = ns;
+ }
+
+ @Test
+ public void testEmptyDesign() {
+ String design = "<vaadin7-native-select>";
+ testRead(design, component);
+ testWrite(design, component);
+ }
+
+ @Test
+ public void testProperties() {
+ String design = "<vaadin7-native-select id=\"testId\" primary-style-name=\"test-style\" "
+ + "caption=\"test-caption\" locale=\"fi_FI\" description=\"test-description\" "
+ + "error=\"<div>test-error</div>\" />";
+ component.setId("testId");
+ component.setPrimaryStyleName("test-style");
+ component.setCaption("test-caption");
+ component.setLocale(new Locale("fi", "FI"));
+ component.setDescription("test-description");
+ component.setComponentError(new UserError("<div>test-error</div>",
+ com.vaadin.server.AbstractErrorMessage.ContentMode.HTML,
+ ErrorLevel.ERROR));
+ component.setImmediate(true);
+ testRead(design, component);
+ testWrite(design, component);
+ }
+
+ @Test
+ public void testReadImmediate() {
+ // Additional tests for the immediate property, including
+ // explicit immediate values
+ String[] design = { "<vaadin7-native-select/>",
+ "<vaadin7-native-select immediate=\"false\"/>",
+ "<vaadin7-native-select immediate=\"true\"/>",
+ "<vaadin7-native-select immediate />" };
+ Boolean[] explicitImmediate = { null, Boolean.FALSE, Boolean.TRUE,
+ Boolean.TRUE };
+ boolean[] immediate = { true, false, true, true };
+ for (int i = 0; i < design.length; i++) {
+ component = (AbstractLegacyComponent) Design
+ .read(new ByteArrayInputStream(
+ design[i].getBytes(Charset.forName("UTF-8"))));
+ assertEquals(immediate[i], component.isImmediate());
+ assertEquals(explicitImmediate[i], getExplicitImmediate(component));
+ }
+ }
+
+ @Test
+ public void testExternalIcon() {
+ String design = "<vaadin7-native-select icon=\"http://example.com/example.gif\"/>";
+ component.setIcon(
+ new ExternalResource("http://example.com/example.gif"));
+ testRead(design, component);
+ testWrite(design, component);
+ }
+
+ @Test
+ public void testThemeIcon() {
+ String design = "<vaadin7-native-select icon=\"theme://example.gif\"/>";
+ component.setIcon(new ThemeResource("example.gif"));
+ testRead(design, component);
+ testWrite(design, component);
+ }
+
+ @Test
+ public void testFileResourceIcon() {
+ String design = "<vaadin7-native-select icon=\"img/example.gif\"/>";
+ component.setIcon(new FileResource(new File("img/example.gif")));
+ testRead(design, component);
+ testWrite(design, component);
+ }
+
+ @Test
+ public void testWidthAndHeight() {
+ String design = "<vaadin7-native-select width=\"70%\" height=\"12px\"/>";
+ component.setWidth("70%");
+ component.setHeight("12px");
+ testRead(design, component);
+ testWrite(design, component);
+ }
+
+ @Test
+ public void testSizeFull() {
+ String design = "<vaadin7-native-select size-full />";
+ component.setSizeFull();
+ testRead(design, component);
+ testWrite(design, component);
+ }
+
+ @Test
+ public void testHeightFull() {
+ String design = "<vaadin7-native-select height-full width=\"20px\"/>";
+ component.setHeight("100%");
+ component.setWidth("20px");
+ testRead(design, component);
+ testWrite(design, component);
+ }
+
+ @Test
+ public void testWidthFull() {
+ String design = "<vaadin7-native-select caption=\"Foo\" caption-as-html width-full height=\"20px\"></vaadin7-native-select>";
+ AbstractLegacyComponent component = new NativeSelect();
+ component.setCaptionAsHtml(true);
+ component.setCaption("Foo");
+ component.setHeight("20px");
+ component.setWidth("100%");
+ testRead(design, component);
+ testWrite(design, component);
+ }
+
+ @Test
+ public void testResponsive() {
+ String design = "<vaadin7-native-select responsive />";
+ Responsive.makeResponsive(component);
+ testRead(design, component);
+ testWrite(design, component);
+ }
+
+ @Test
+ public void testResponsiveFalse() {
+ String design = "<vaadin7-native-select responsive =\"false\"/>";
+ // Only test read as the attribute responsive=false would not be written
+ testRead(design, component);
+ }
+
+ @Test
+ public void testReadAlreadyResponsive() {
+ AbstractComponent component = new Label();
+ Responsive.makeResponsive(component);
+ Element design = createDesign(true);
+ component.readDesign(design, new DesignContext());
+ assertEquals("Component should have only one extension", 1,
+ component.getExtensions().size());
+ }
+
+ @Test
+ public void testUnknownProperties() {
+ String design = "<vaadin7-native-select foo=\"bar\"/>";
+
+ DesignContext context = readAndReturnContext(design);
+ NativeSelect ns = (NativeSelect) context.getRootComponent();
+ assertTrue("Custom attribute was preserved in custom attributes",
+ context.getCustomAttributes(ns).containsKey("foo"));
+
+ testWrite(ns, design, context);
+ }
+
+ private Element createDesign(boolean responsive) {
+ Attributes attributes = new Attributes();
+ attributes.put("responsive", responsive);
+ Element node = new Element(Tag.valueOf("vaadin-label"), "", attributes);
+ return node;
+ }
+
+ private Boolean getExplicitImmediate(AbstractLegacyComponent component) {
+ try {
+ Field immediate = AbstractLegacyComponent.class
+ .getDeclaredField("explicitImmediateValue");
+ immediate.setAccessible(true);
+ return (Boolean) immediate.get(component);
+ } catch (Exception e) {
+ throw new RuntimeException(
+ "Getting the field explicitImmediateValue failed.");
+ }
+ }
+}
diff --git a/compatibility-server/src/test/java/com/vaadin/v7/ui/AbstractLegacyComponentTest.java b/compatibility-server/src/test/java/com/vaadin/v7/ui/AbstractLegacyComponentTest.java
new file mode 100644
index 0000000000..1a683ad373
--- /dev/null
+++ b/compatibility-server/src/test/java/com/vaadin/v7/ui/AbstractLegacyComponentTest.java
@@ -0,0 +1,21 @@
+package com.vaadin.v7.ui;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+
+public class AbstractLegacyComponentTest {
+ AbstractLegacyComponent component = new AbstractLegacyComponent() {
+ };
+
+ @Test
+ public void testImmediate() {
+ assertTrue("Component should be immediate by default",
+ component.isImmediate());
+ component.setImmediate(false);
+ assertFalse(
+ "Explicitly non-immediate component should not be immediate",
+ component.isImmediate());
+ }
+}