From fb4248119d77a6865a42ffdf0d80f10d683769a5 Mon Sep 17 00:00:00 2001
From: Pekka Hyvönen
+ * 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.
+ *
+ * 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.
+ *
+ * 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.
- *
+ *
*
*
* Form
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.
* Form
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}.
*
* Override this method to control how the fields are added to the layout. *
- * + * * @param propertyId * @param field */ @@ -577,13 +577,13 @@ public class Form extends AbstractField* 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. *
- * + * * @see com.vaadin.data.Item#getItemProperty(Object) */ @Override @@ -604,7 +604,7 @@ public class Form extends AbstractFieldtrue
.
*/
@@ -685,12 +685,12 @@ public class Form extends AbstractField* Setting item datasource clears any fields, the form might contain and * adds all the properties as fields to the form. *
- * + * * @see com.vaadin.data.Item.Viewer#setItemDataSource(Item) */ @Override @@ -702,13 +702,13 @@ public class Form extends AbstractField* 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. *
- * + * * @see com.vaadin.data.Item.Viewer#setItemDataSource(Item) */ public void setItemDataSource(Item newDataSource, @@ -759,7 +759,7 @@ public class Form extends AbstractField
* By default form uses OrderedLayout
with form
* -style.
*
* If set to null then Form uses a FormLayout by default. *
- * + * * @param layout * the layout of the form. */ @@ -839,16 +839,16 @@ public class Form extends AbstractField* 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. *
- * + * * 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
* A Form is empty if all of its fields are empty.
- *
+ *
*/
@Override
public boolean isEmpty() {
@@ -1222,7 +1222,7 @@ public class Form extends AbstractField