summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--client/src/main/java/com/vaadin/client/VCaption.java32
-rw-r--r--client/src/main/java/com/vaadin/client/ui/AbstractComponentConnector.java10
-rw-r--r--client/src/main/java/com/vaadin/client/ui/AbstractFieldConnector.java17
-rw-r--r--client/src/main/java/com/vaadin/client/ui/HasErrorIndicator.java (renamed from client/src/main/java/com/vaadin/client/v7/ui/checkbox/LegacyCheckBoxConnector.java)20
-rw-r--r--client/src/main/java/com/vaadin/client/ui/HasRequiredIndicator.java33
-rw-r--r--client/src/main/java/com/vaadin/client/ui/VCustomLayout.java12
-rw-r--r--client/src/main/java/com/vaadin/client/ui/VFormLayout.java4
-rw-r--r--client/src/main/java/com/vaadin/client/ui/absolutelayout/AbsoluteLayoutConnector.java13
-rw-r--r--client/src/main/java/com/vaadin/client/ui/checkbox/CheckBoxConnector.java2
-rw-r--r--client/src/main/java/com/vaadin/client/ui/csslayout/CssLayoutConnector.java2
-rw-r--r--client/src/main/java/com/vaadin/client/ui/formlayout/FormLayoutConnector.java9
-rw-r--r--client/src/main/java/com/vaadin/client/ui/gridlayout/GridLayoutConnector.java2
-rw-r--r--client/src/main/java/com/vaadin/client/ui/orderedlayout/AbstractOrderedLayoutConnector.java17
-rw-r--r--client/src/main/java/com/vaadin/client/ui/panel/PanelConnector.java2
-rw-r--r--client/src/main/java/com/vaadin/client/ui/popupview/PopupViewConnector.java6
-rw-r--r--compatibility-client/src/main/java/com/vaadin/v7/client/ui/AbstractFieldConnector.java74
-rw-r--r--compatibility-client/src/main/java/com/vaadin/v7/client/ui/checkbox/CheckBoxConnector.java155
-rw-r--r--compatibility-client/src/main/java/com/vaadin/v7/client/ui/combobox/ComboBoxConnector.java2
-rw-r--r--compatibility-client/src/main/java/com/vaadin/v7/client/ui/datefield/AbstractDateFieldConnector.java2
-rw-r--r--compatibility-client/src/main/java/com/vaadin/v7/client/ui/optiongroup/OptionGroupBaseConnector.java2
-rw-r--r--compatibility-client/src/main/java/com/vaadin/v7/client/ui/progressindicator/ProgressBarConnector.java2
-rw-r--r--compatibility-client/src/main/java/com/vaadin/v7/client/ui/richtextarea/RichTextAreaConnector.java2
-rw-r--r--compatibility-client/src/main/java/com/vaadin/v7/client/ui/table/TableConnector.java2
-rw-r--r--compatibility-server/src/main/java/com/vaadin/v7/ui/CheckBox.java (renamed from server/src/main/java/com/vaadin/v7/ui/CheckBox.java)0
24 files changed, 353 insertions, 69 deletions
diff --git a/client/src/main/java/com/vaadin/client/VCaption.java b/client/src/main/java/com/vaadin/client/VCaption.java
index 3c07470c27..7e8fd97d25 100644
--- a/client/src/main/java/com/vaadin/client/VCaption.java
+++ b/client/src/main/java/com/vaadin/client/VCaption.java
@@ -26,12 +26,12 @@ import com.google.gwt.user.client.Event;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HasHTML;
import com.vaadin.client.communication.StateChangeEvent;
-import com.vaadin.client.ui.AbstractFieldConnector;
+import com.vaadin.client.ui.HasErrorIndicator;
+import com.vaadin.client.ui.HasRequiredIndicator;
import com.vaadin.client.ui.Icon;
import com.vaadin.client.ui.ImageIcon;
import com.vaadin.client.ui.aria.AriaHelper;
import com.vaadin.shared.AbstractComponentState;
-import com.vaadin.shared.AbstractFieldState;
import com.vaadin.shared.ComponentConstants;
import com.vaadin.shared.ui.ComponentStateUtil;
@@ -158,14 +158,13 @@ public class VCaption extends HTML {
boolean hasIcon = owner.getState().resources
.containsKey(ComponentConstants.ICON_RESOURCE);
boolean showRequired = false;
- boolean showError = owner.getState().errorMessage != null;
- if (owner.getState() instanceof AbstractFieldState) {
- AbstractFieldState abstractFieldState = (AbstractFieldState) owner
- .getState();
- showError = showError && !abstractFieldState.hideErrors;
+ boolean showError = false;
+ if (owner instanceof HasRequiredIndicator) {
+ showRequired = ((HasRequiredIndicator) owner)
+ .isRequiredIndicatorVisible();
}
- if (owner instanceof AbstractFieldConnector) {
- showRequired = ((AbstractFieldConnector) owner).isRequired();
+ if (owner instanceof HasErrorIndicator) {
+ showError = ((HasErrorIndicator) owner).isErrorIndicatorVisible();
}
if (icon != null) {
@@ -454,24 +453,27 @@ public class VCaption extends HTML {
}
}
- public static boolean isNeeded(AbstractComponentState state) {
+ public static boolean isNeeded(ComponentConnector connector) {
+ AbstractComponentState state = connector.getState();
if (state.caption != null) {
return true;
}
if (state.resources.containsKey(ComponentConstants.ICON_RESOURCE)) {
return true;
}
- if (state.errorMessage != null) {
+ if (connector instanceof HasErrorIndicator
+ && ((HasErrorIndicator) connector).isErrorIndicatorVisible()) {
return true;
}
- if (state instanceof AbstractFieldState) {
- if (((AbstractFieldState) state).required) {
- return true;
- }
+ if (connector instanceof HasRequiredIndicator
+ && ((HasRequiredIndicator) connector)
+ .isRequiredIndicatorVisible()) {
+ return true;
}
return false;
+
}
/**
diff --git a/client/src/main/java/com/vaadin/client/ui/AbstractComponentConnector.java b/client/src/main/java/com/vaadin/client/ui/AbstractComponentConnector.java
index f59b7d581d..a6d73be0c8 100644
--- a/client/src/main/java/com/vaadin/client/ui/AbstractComponentConnector.java
+++ b/client/src/main/java/com/vaadin/client/ui/AbstractComponentConnector.java
@@ -62,7 +62,7 @@ import com.vaadin.shared.ui.ComponentStateUtil;
import com.vaadin.shared.ui.TabIndexState;
public abstract class AbstractComponentConnector extends AbstractConnector
- implements ComponentConnector {
+ implements ComponentConnector, HasErrorIndicator {
private HandlerRegistration contextHandler = null;
@@ -616,8 +616,7 @@ public abstract class AbstractComponentConnector extends AbstractConnector
* primary style name of the widget returned by {@link #getWidget()}
* <p>
* This method can be overridden to provide additional style names for the
- * component, for example see
- * {@link AbstractFieldConnector#updateWidgetStyleNames()}
+ * component, for example see {@code AbstractFieldConnector}
* </p>
*/
protected void updateWidgetStyleNames() {
@@ -809,4 +808,9 @@ public abstract class AbstractComponentConnector extends AbstractConnector
public void flush() {
// No generic implementation. Override if needed
}
+
+ @Override
+ public boolean isErrorIndicatorVisible() {
+ return getState().errorMessage != null;
+ }
}
diff --git a/client/src/main/java/com/vaadin/client/ui/AbstractFieldConnector.java b/client/src/main/java/com/vaadin/client/ui/AbstractFieldConnector.java
index 2783083a8d..f714023d39 100644
--- a/client/src/main/java/com/vaadin/client/ui/AbstractFieldConnector.java
+++ b/client/src/main/java/com/vaadin/client/ui/AbstractFieldConnector.java
@@ -18,8 +18,8 @@ package com.vaadin.client.ui;
import com.vaadin.client.StyleConstants;
import com.vaadin.shared.AbstractFieldState;
-public abstract class AbstractFieldConnector
- extends AbstractComponentConnector {
+public abstract class AbstractFieldConnector extends AbstractComponentConnector
+ implements HasRequiredIndicator, HasErrorIndicator {
@Override
public AbstractFieldState getState() {
@@ -43,11 +43,17 @@ public abstract class AbstractFieldConnector
*
* @return true if required indicator should be shown
*/
- public boolean isRequired() {
+ @Override
+ public boolean isRequiredIndicatorVisible() {
return getState().required && !isReadOnly();
}
@Override
+ public boolean isErrorIndicatorVisible() {
+ return super.isErrorIndicatorVisible() && !getState().hideErrors;
+ }
+
+ @Override
protected void updateWidgetStyleNames() {
super.updateWidgetStyleNames();
@@ -56,8 +62,9 @@ public abstract class AbstractFieldConnector
// add / remove error style name to Fields
setWidgetStyleNameWithPrefix(getWidget().getStylePrimaryName(),
- StyleConstants.REQUIRED_EXT, isRequired());
+ StyleConstants.REQUIRED_EXT, isRequiredIndicatorVisible());
- getWidget().setStyleName(StyleConstants.REQUIRED, isRequired());
+ getWidget().setStyleName(StyleConstants.REQUIRED,
+ isRequiredIndicatorVisible());
}
}
diff --git a/client/src/main/java/com/vaadin/client/v7/ui/checkbox/LegacyCheckBoxConnector.java b/client/src/main/java/com/vaadin/client/ui/HasErrorIndicator.java
index f3e46e9b01..806617b8ee 100644
--- a/client/src/main/java/com/vaadin/client/v7/ui/checkbox/LegacyCheckBoxConnector.java
+++ b/client/src/main/java/com/vaadin/client/ui/HasErrorIndicator.java
@@ -13,13 +13,21 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
-package com.vaadin.client.v7.ui.checkbox;
+package com.vaadin.client.ui;
-import com.vaadin.client.ui.checkbox.CheckBoxConnector;
-import com.vaadin.shared.ui.Connect;
-import com.vaadin.v7.ui.CheckBox;
+import com.vaadin.client.ComponentConnector;
-@Connect(CheckBox.class)
-public class LegacyCheckBoxConnector extends CheckBoxConnector {
+/**
+ * Implemented by connectors supporting an error indicator.
+ */
+public interface HasErrorIndicator extends ComponentConnector {
+
+ /**
+ * Checks if an error indicator should be shown for the given connector.
+ *
+ * @return <code>true</code> to show an indicator, <code>false</code>
+ * otherwise
+ */
+ boolean isErrorIndicatorVisible();
}
diff --git a/client/src/main/java/com/vaadin/client/ui/HasRequiredIndicator.java b/client/src/main/java/com/vaadin/client/ui/HasRequiredIndicator.java
new file mode 100644
index 0000000000..5575c3a774
--- /dev/null
+++ b/client/src/main/java/com/vaadin/client/ui/HasRequiredIndicator.java
@@ -0,0 +1,33 @@
+/*
+ * 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.client.ui;
+
+import com.vaadin.client.ComponentConnector;
+
+/**
+ * Implemented by connectors supporting a required flag.
+ */
+public interface HasRequiredIndicator extends ComponentConnector {
+
+ /**
+ * Checks if a required indicator should be shown for the given connector.
+ *
+ * @return <code>true</code> to show an indicator, <code>false</code>
+ * otherwise
+ */
+ boolean isRequiredIndicatorVisible();
+
+}
diff --git a/client/src/main/java/com/vaadin/client/ui/VCustomLayout.java b/client/src/main/java/com/vaadin/client/ui/VCustomLayout.java
index 70e243cc1e..82140a12fe 100644
--- a/client/src/main/java/com/vaadin/client/ui/VCustomLayout.java
+++ b/client/src/main/java/com/vaadin/client/ui/VCustomLayout.java
@@ -300,20 +300,22 @@ public class VCustomLayout extends ComplexPanel {
return res;
}
- /** Update caption for given widget */
- public void updateCaption(ComponentConnector paintable) {
- Widget widget = paintable.getWidget();
+ /**
+ * Update caption for the given child connector.
+ */
+ public void updateCaption(ComponentConnector childConnector) {
+ Widget widget = childConnector.getWidget();
if (widget.getParent() != this) {
// Widget has not been added because the location was not found
return;
}
VCaptionWrapper wrapper = childWidgetToCaptionWrapper.get(widget);
- if (VCaption.isNeeded(paintable.getState())) {
+ if (VCaption.isNeeded(childConnector)) {
if (wrapper == null) {
// Add a wrapper between the layout and the child widget
final String loc = getLocation(widget);
super.remove(widget);
- wrapper = new VCaptionWrapper(paintable, client);
+ wrapper = new VCaptionWrapper(childConnector, client);
super.add(wrapper, locationToElement.get(loc));
childWidgetToCaptionWrapper.put(widget, wrapper);
}
diff --git a/client/src/main/java/com/vaadin/client/ui/VFormLayout.java b/client/src/main/java/com/vaadin/client/ui/VFormLayout.java
index d31479d855..550f20c755 100644
--- a/client/src/main/java/com/vaadin/client/ui/VFormLayout.java
+++ b/client/src/main/java/com/vaadin/client/ui/VFormLayout.java
@@ -302,8 +302,8 @@ public class VFormLayout extends SimplePanel {
removeStyleDependentName("hasdescription");
}
- boolean required = owner instanceof AbstractFieldConnector
- && ((AbstractFieldConnector) owner).isRequired();
+ boolean required = owner instanceof HasRequiredIndicator
+ && ((HasRequiredIndicator) owner).isRequiredIndicatorVisible();
AriaHelper.handleInputRequired(owner.getWidget(), required);
diff --git a/client/src/main/java/com/vaadin/client/ui/absolutelayout/AbsoluteLayoutConnector.java b/client/src/main/java/com/vaadin/client/ui/absolutelayout/AbsoluteLayoutConnector.java
index e38cefb91f..0e82397261 100644
--- a/client/src/main/java/com/vaadin/client/ui/absolutelayout/AbsoluteLayoutConnector.java
+++ b/client/src/main/java/com/vaadin/client/ui/absolutelayout/AbsoluteLayoutConnector.java
@@ -116,20 +116,21 @@ public class AbsoluteLayoutConnector extends AbstractComponentContainerConnector
* .client.ComponentConnector)
*/
@Override
- public void updateCaption(ComponentConnector component) {
+ public void updateCaption(ComponentConnector childConnector) {
VAbsoluteLayout absoluteLayoutWidget = getWidget();
- boolean captionIsNeeded = VCaption.isNeeded(component.getState());
+ boolean captionIsNeeded = VCaption.isNeeded(childConnector);
VCaption caption = absoluteLayoutWidget
- .getWidgetCaption(component.getWidget());
+ .getWidgetCaption(childConnector.getWidget());
if (captionIsNeeded) {
if (caption == null) {
- caption = new VCaption(component, getConnection());
+ caption = new VCaption(childConnector, getConnection());
}
- absoluteLayoutWidget.setWidgetCaption(component.getWidget(),
+ absoluteLayoutWidget.setWidgetCaption(childConnector.getWidget(),
caption);
} else if (caption != null) {
- absoluteLayoutWidget.setWidgetCaption(component.getWidget(), null);
+ absoluteLayoutWidget.setWidgetCaption(childConnector.getWidget(),
+ null);
}
}
diff --git a/client/src/main/java/com/vaadin/client/ui/checkbox/CheckBoxConnector.java b/client/src/main/java/com/vaadin/client/ui/checkbox/CheckBoxConnector.java
index 706ee30cc5..598280cf5c 100644
--- a/client/src/main/java/com/vaadin/client/ui/checkbox/CheckBoxConnector.java
+++ b/client/src/main/java/com/vaadin/client/ui/checkbox/CheckBoxConnector.java
@@ -82,7 +82,7 @@ public class CheckBoxConnector extends AbstractFieldConnector
getWidget().setAriaInvalid(false);
}
- getWidget().setAriaRequired(isRequired());
+ getWidget().setAriaRequired(isRequiredIndicatorVisible());
if (isReadOnly()) {
getWidget().setEnabled(false);
}
diff --git a/client/src/main/java/com/vaadin/client/ui/csslayout/CssLayoutConnector.java b/client/src/main/java/com/vaadin/client/ui/csslayout/CssLayoutConnector.java
index fe5f843098..40e473c8d8 100644
--- a/client/src/main/java/com/vaadin/client/ui/csslayout/CssLayoutConnector.java
+++ b/client/src/main/java/com/vaadin/client/ui/csslayout/CssLayoutConnector.java
@@ -190,7 +190,7 @@ public class CssLayoutConnector extends AbstractLayoutConnector {
String childId = child.getConnectorId();
VCaption caption = childIdToCaption.get(childId);
- if (VCaption.isNeeded(child.getState())) {
+ if (VCaption.isNeeded(child)) {
if (caption == null) {
caption = new VCaption(child, getConnection());
childIdToCaption.put(childId, caption);
diff --git a/client/src/main/java/com/vaadin/client/ui/formlayout/FormLayoutConnector.java b/client/src/main/java/com/vaadin/client/ui/formlayout/FormLayoutConnector.java
index eede83e3e9..eccec23877 100644
--- a/client/src/main/java/com/vaadin/client/ui/formlayout/FormLayoutConnector.java
+++ b/client/src/main/java/com/vaadin/client/ui/formlayout/FormLayoutConnector.java
@@ -27,8 +27,8 @@ import com.vaadin.client.TooltipInfo;
import com.vaadin.client.Util;
import com.vaadin.client.WidgetUtil;
import com.vaadin.client.communication.StateChangeEvent;
-import com.vaadin.client.ui.AbstractFieldConnector;
import com.vaadin.client.ui.AbstractLayoutConnector;
+import com.vaadin.client.ui.HasErrorIndicator;
import com.vaadin.client.ui.LayoutClickEventHandler;
import com.vaadin.client.ui.PostLayoutListener;
import com.vaadin.client.ui.VFormLayout;
@@ -248,10 +248,9 @@ public class FormLayoutConnector extends AbstractLayoutConnector
component.getState(), component.isEnabled());
boolean hideErrors = false;
- // FIXME This incorrectly depends on AbstractFieldConnector
- if (component instanceof AbstractFieldConnector) {
- hideErrors = ((AbstractFieldConnector) component)
- .getState().hideErrors;
+ if (component instanceof HasErrorIndicator) {
+ hideErrors = !((HasErrorIndicator) component)
+ .isErrorIndicatorVisible();
}
getWidget().table.updateError(component.getWidget(),
diff --git a/client/src/main/java/com/vaadin/client/ui/gridlayout/GridLayoutConnector.java b/client/src/main/java/com/vaadin/client/ui/gridlayout/GridLayoutConnector.java
index 976fbb11c5..3113183e3e 100644
--- a/client/src/main/java/com/vaadin/client/ui/gridlayout/GridLayoutConnector.java
+++ b/client/src/main/java/com/vaadin/client/ui/gridlayout/GridLayoutConnector.java
@@ -170,7 +170,7 @@ public class GridLayoutConnector extends AbstractComponentContainerConnector
public void updateCaption(ComponentConnector childConnector) {
VGridLayout layout = getWidget();
Cell cell = layout.widgetToCell.get(childConnector.getWidget());
- if (VCaption.isNeeded(childConnector.getState())) {
+ if (VCaption.isNeeded(childConnector)) {
VLayoutSlot layoutSlot = cell.slot;
VCaption caption = layoutSlot.getCaption();
if (caption == null) {
diff --git a/client/src/main/java/com/vaadin/client/ui/orderedlayout/AbstractOrderedLayoutConnector.java b/client/src/main/java/com/vaadin/client/ui/orderedlayout/AbstractOrderedLayoutConnector.java
index db6203efb3..0e3bf73342 100644
--- a/client/src/main/java/com/vaadin/client/ui/orderedlayout/AbstractOrderedLayoutConnector.java
+++ b/client/src/main/java/com/vaadin/client/ui/orderedlayout/AbstractOrderedLayoutConnector.java
@@ -33,14 +33,14 @@ import com.vaadin.client.Util;
import com.vaadin.client.WidgetUtil;
import com.vaadin.client.communication.StateChangeEvent;
import com.vaadin.client.communication.StateChangeEvent.StateChangeHandler;
-import com.vaadin.client.ui.AbstractFieldConnector;
import com.vaadin.client.ui.AbstractLayoutConnector;
+import com.vaadin.client.ui.HasErrorIndicator;
+import com.vaadin.client.ui.HasRequiredIndicator;
import com.vaadin.client.ui.Icon;
import com.vaadin.client.ui.LayoutClickEventHandler;
import com.vaadin.client.ui.aria.AriaHelper;
import com.vaadin.client.ui.layout.ElementResizeEvent;
import com.vaadin.client.ui.layout.ElementResizeListener;
-import com.vaadin.shared.AbstractFieldState;
import com.vaadin.shared.ComponentConstants;
import com.vaadin.shared.communication.URLReference;
import com.vaadin.shared.ui.AlignmentInfo;
@@ -260,15 +260,14 @@ public abstract class AbstractOrderedLayoutConnector
List<String> styles = child.getState().styles;
String error = child.getState().errorMessage;
- boolean showError = error != null;
- if (child.getState() instanceof AbstractFieldState) {
- AbstractFieldState abstractFieldState = (AbstractFieldState) child
- .getState();
- showError = showError && !abstractFieldState.hideErrors;
+ boolean showError = false;
+ if (child instanceof HasErrorIndicator) {
+ showError = ((HasErrorIndicator) child).isErrorIndicatorVisible();
}
boolean required = false;
- if (child instanceof AbstractFieldConnector) {
- required = ((AbstractFieldConnector) child).isRequired();
+ if (child instanceof HasRequiredIndicator) {
+ required = ((HasRequiredIndicator) child)
+ .isRequiredIndicatorVisible();
}
boolean enabled = child.isEnabled();
diff --git a/client/src/main/java/com/vaadin/client/ui/panel/PanelConnector.java b/client/src/main/java/com/vaadin/client/ui/panel/PanelConnector.java
index ab3acdfec0..2e5237598f 100644
--- a/client/src/main/java/com/vaadin/client/ui/panel/PanelConnector.java
+++ b/client/src/main/java/com/vaadin/client/ui/panel/PanelConnector.java
@@ -143,7 +143,7 @@ public class PanelConnector extends AbstractSingleComponentContainerConnector
getWidget().setIconUri(null, client);
}
- getWidget().setErrorIndicatorVisible(null != getState().errorMessage);
+ getWidget().setErrorIndicatorVisible(isErrorIndicatorVisible());
// We may have actions attached to this panel
if (uidl.getChildCount() > 0) {
diff --git a/client/src/main/java/com/vaadin/client/ui/popupview/PopupViewConnector.java b/client/src/main/java/com/vaadin/client/ui/popupview/PopupViewConnector.java
index 3916b419c1..1ee6e9b9f7 100644
--- a/client/src/main/java/com/vaadin/client/ui/popupview/PopupViewConnector.java
+++ b/client/src/main/java/com/vaadin/client/ui/popupview/PopupViewConnector.java
@@ -63,13 +63,13 @@ public class PopupViewConnector extends AbstractHasComponentsConnector
}
@Override
- public void updateCaption(ComponentConnector component) {
- if (VCaption.isNeeded(component.getState())) {
+ public void updateCaption(ComponentConnector childConnector) {
+ if (VCaption.isNeeded(childConnector)) {
if (getWidget().popup.captionWrapper != null) {
getWidget().popup.captionWrapper.updateCaption();
} else {
getWidget().popup.captionWrapper = new VCaptionWrapper(
- component, getConnection());
+ childConnector, getConnection());
getWidget().popup.setWidget(getWidget().popup.captionWrapper);
getWidget().popup.captionWrapper.updateCaption();
}
diff --git a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/AbstractFieldConnector.java b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/AbstractFieldConnector.java
new file mode 100644
index 0000000000..063852279d
--- /dev/null
+++ b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/AbstractFieldConnector.java
@@ -0,0 +1,74 @@
+/*
+ * 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.client.ui;
+
+import com.vaadin.client.StyleConstants;
+import com.vaadin.client.ui.AbstractComponentConnector;
+import com.vaadin.client.ui.HasErrorIndicator;
+import com.vaadin.client.ui.HasRequiredIndicator;
+import com.vaadin.shared.AbstractFieldState;
+
+@Deprecated
+public abstract class AbstractFieldConnector extends AbstractComponentConnector
+ implements HasRequiredIndicator, HasErrorIndicator {
+
+ @Override
+ public AbstractFieldState getState() {
+ return (AbstractFieldState) super.getState();
+ }
+
+ @Override
+ public boolean isReadOnly() {
+ return super.isReadOnly() || getState().propertyReadOnly;
+ }
+
+ public boolean isModified() {
+ return getState().modified;
+ }
+
+ /**
+ * Checks whether the required indicator should be shown for the field.
+ *
+ * Required indicators are hidden if the field or its data source is
+ * read-only.
+ *
+ * @return true if required indicator should be shown
+ */
+ @Override
+ public boolean isRequiredIndicatorVisible() {
+ return getState().required && !isReadOnly();
+ }
+
+ @Override
+ public boolean isErrorIndicatorVisible() {
+ return super.isErrorIndicatorVisible() && !getState().hideErrors;
+ }
+
+ @Override
+ protected void updateWidgetStyleNames() {
+ super.updateWidgetStyleNames();
+
+ // add / remove modified style name to Fields
+ setWidgetStyleName(StyleConstants.MODIFIED, isModified());
+
+ // add / remove error style name to Fields
+ setWidgetStyleNameWithPrefix(getWidget().getStylePrimaryName(),
+ StyleConstants.REQUIRED_EXT, isRequiredIndicatorVisible());
+
+ getWidget().setStyleName(StyleConstants.REQUIRED,
+ isRequiredIndicatorVisible());
+ }
+}
diff --git a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/checkbox/CheckBoxConnector.java b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/checkbox/CheckBoxConnector.java
new file mode 100644
index 0000000000..67e83a754f
--- /dev/null
+++ b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/checkbox/CheckBoxConnector.java
@@ -0,0 +1,155 @@
+/*
+ * 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.client.ui.checkbox;
+
+import com.google.gwt.dom.client.Style.Display;
+import com.google.gwt.event.dom.client.ClickEvent;
+import com.google.gwt.event.dom.client.ClickHandler;
+import com.google.gwt.user.client.DOM;
+import com.google.gwt.user.client.Event;
+import com.vaadin.client.MouseEventDetailsBuilder;
+import com.vaadin.client.VCaption;
+import com.vaadin.client.VTooltip;
+import com.vaadin.client.annotations.OnStateChange;
+import com.vaadin.client.communication.StateChangeEvent;
+import com.vaadin.client.ui.ConnectorFocusAndBlurHandler;
+import com.vaadin.client.ui.Icon;
+import com.vaadin.client.ui.VCheckBox;
+import com.vaadin.shared.EventId;
+import com.vaadin.shared.MouseEventDetails;
+import com.vaadin.shared.ui.Connect;
+import com.vaadin.shared.ui.checkbox.CheckBoxServerRpc;
+import com.vaadin.shared.ui.checkbox.CheckBoxState;
+import com.vaadin.v7.client.ui.AbstractFieldConnector;
+import com.vaadin.v7.ui.CheckBox;
+
+@Connect(CheckBox.class)
+public class CheckBoxConnector extends AbstractFieldConnector
+ implements ClickHandler {
+
+ @Override
+ public boolean delegateCaptionHandling() {
+ return false;
+ }
+
+ @Override
+ protected void init() {
+ super.init();
+
+ getWidget().addClickHandler(this);
+ getWidget().client = getConnection();
+ getWidget().id = getConnectorId();
+
+ ConnectorFocusAndBlurHandler.addHandlers(this);
+ }
+
+ @Override
+ public void onStateChanged(StateChangeEvent stateChangeEvent) {
+ super.onStateChanged(stateChangeEvent);
+
+ if (null != getState().errorMessage) {
+ getWidget().setAriaInvalid(true);
+
+ if (getWidget().errorIndicatorElement == null) {
+ getWidget().errorIndicatorElement = DOM.createSpan();
+ getWidget().errorIndicatorElement.setInnerHTML("&nbsp;");
+ DOM.setElementProperty(getWidget().errorIndicatorElement,
+ "className", "v-errorindicator");
+ DOM.appendChild(getWidget().getElement(),
+ getWidget().errorIndicatorElement);
+ DOM.sinkEvents(getWidget().errorIndicatorElement,
+ VTooltip.TOOLTIP_EVENTS | Event.ONCLICK);
+ } else {
+ getWidget().errorIndicatorElement.getStyle().clearDisplay();
+ }
+ } else if (getWidget().errorIndicatorElement != null) {
+ getWidget().errorIndicatorElement.getStyle()
+ .setDisplay(Display.NONE);
+
+ getWidget().setAriaInvalid(false);
+ }
+
+ getWidget().setAriaRequired(isRequiredIndicatorVisible());
+ if (isReadOnly()) {
+ getWidget().setEnabled(false);
+ }
+
+ if (getWidget().icon != null) {
+ getWidget().getElement().removeChild(getWidget().icon.getElement());
+ getWidget().icon = null;
+ }
+ Icon icon = getIcon();
+ if (icon != null) {
+ getWidget().icon = icon;
+ DOM.insertChild(getWidget().getElement(), icon.getElement(), 1);
+ icon.sinkEvents(VTooltip.TOOLTIP_EVENTS);
+ icon.sinkEvents(Event.ONCLICK);
+ }
+
+ // Set text
+ VCaption.setCaptionText(getWidget(), getState());
+
+ getWidget().setValue(getState().checked);
+ getWidget().immediate = getState().immediate;
+ }
+
+ @Override
+ public CheckBoxState getState() {
+ return (CheckBoxState) super.getState();
+ }
+
+ @Override
+ public VCheckBox getWidget() {
+ return (VCheckBox) super.getWidget();
+ }
+
+ @Override
+ public void onClick(ClickEvent event) {
+ if (!isEnabled()) {
+ return;
+ }
+
+ // We get click events also from the label text, which do not alter the
+ // actual value. The server-side is only interested in real changes to
+ // the state.
+ if (getState().checked != getWidget().getValue()) {
+ getState().checked = getWidget().getValue();
+
+ // Add mouse details
+ MouseEventDetails details = MouseEventDetailsBuilder
+ .buildMouseEventDetails(event.getNativeEvent(),
+ getWidget().getElement());
+ getRpcProxy(CheckBoxServerRpc.class).setChecked(getState().checked,
+ details);
+ if (getState().immediate) {
+ getConnection().sendPendingVariableChanges();
+ }
+ }
+ }
+
+ private boolean contextEventSunk = false;
+
+ @OnStateChange("registeredEventListeners")
+ void sinkContextClickEvent() {
+ if (!contextEventSunk && hasEventListener(EventId.CONTEXT_CLICK)) {
+ // CheckBox.sinkEvents works differently than all other widgets:
+ // "Unlike other widgets the CheckBox sinks on its inputElement, not
+ // its wrapper"
+ DOM.sinkEvents(getWidget().getElement(), Event.ONCONTEXTMENU);
+ contextEventSunk = true;
+ }
+ }
+}
diff --git a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/combobox/ComboBoxConnector.java b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/combobox/ComboBoxConnector.java
index 4a632b9071..f9790bb94e 100644
--- a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/combobox/ComboBoxConnector.java
+++ b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/combobox/ComboBoxConnector.java
@@ -25,13 +25,13 @@ import com.vaadin.client.Profiler;
import com.vaadin.client.UIDL;
import com.vaadin.client.communication.RpcProxy;
import com.vaadin.client.communication.StateChangeEvent;
-import com.vaadin.client.ui.AbstractFieldConnector;
import com.vaadin.client.ui.SimpleManagedLayout;
import com.vaadin.shared.EventId;
import com.vaadin.shared.communication.FieldRpc.FocusAndBlurServerRpc;
import com.vaadin.shared.ui.Connect;
import com.vaadin.shared.ui.combobox.ComboBoxServerRpc;
import com.vaadin.shared.ui.combobox.ComboBoxState;
+import com.vaadin.v7.client.ui.AbstractFieldConnector;
import com.vaadin.v7.client.ui.VFilterSelect;
import com.vaadin.v7.client.ui.VFilterSelect.DataReceivedHandler;
import com.vaadin.v7.client.ui.VFilterSelect.FilterSelectSuggestion;
diff --git a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/datefield/AbstractDateFieldConnector.java b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/datefield/AbstractDateFieldConnector.java
index e5da960a9d..0b110d66a4 100644
--- a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/datefield/AbstractDateFieldConnector.java
+++ b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/datefield/AbstractDateFieldConnector.java
@@ -22,10 +22,10 @@ import com.vaadin.client.LocaleNotLoadedException;
import com.vaadin.client.Paintable;
import com.vaadin.client.UIDL;
import com.vaadin.client.VConsole;
-import com.vaadin.client.ui.AbstractFieldConnector;
import com.vaadin.client.ui.VDateField;
import com.vaadin.shared.ui.datefield.DateFieldConstants;
import com.vaadin.shared.ui.datefield.Resolution;
+import com.vaadin.v7.client.ui.AbstractFieldConnector;
public class AbstractDateFieldConnector extends AbstractFieldConnector
implements Paintable {
diff --git a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/optiongroup/OptionGroupBaseConnector.java b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/optiongroup/OptionGroupBaseConnector.java
index 6a89498c7c..e24ae92742 100644
--- a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/optiongroup/OptionGroupBaseConnector.java
+++ b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/optiongroup/OptionGroupBaseConnector.java
@@ -20,11 +20,11 @@ import com.vaadin.client.ApplicationConnection;
import com.vaadin.client.Paintable;
import com.vaadin.client.StyleConstants;
import com.vaadin.client.UIDL;
-import com.vaadin.client.ui.AbstractFieldConnector;
import com.vaadin.client.ui.VNativeButton;
import com.vaadin.client.ui.VOptionGroupBase;
import com.vaadin.client.v7.ui.VLegacyTextField;
import com.vaadin.shared.ui.select.AbstractSelectState;
+import com.vaadin.v7.client.ui.AbstractFieldConnector;
public abstract class OptionGroupBaseConnector extends AbstractFieldConnector
implements Paintable {
diff --git a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/progressindicator/ProgressBarConnector.java b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/progressindicator/ProgressBarConnector.java
index 9cfc910426..77602a4974 100644
--- a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/progressindicator/ProgressBarConnector.java
+++ b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/progressindicator/ProgressBarConnector.java
@@ -17,10 +17,10 @@
package com.vaadin.v7.client.ui.progressindicator;
import com.vaadin.client.communication.StateChangeEvent;
-import com.vaadin.client.ui.AbstractFieldConnector;
import com.vaadin.client.ui.VProgressBar;
import com.vaadin.shared.ui.Connect;
import com.vaadin.shared.ui.progressindicator.ProgressBarState;
+import com.vaadin.v7.client.ui.AbstractFieldConnector;
import com.vaadin.v7.ui.ProgressBar;
/**
diff --git a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/richtextarea/RichTextAreaConnector.java b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/richtextarea/RichTextAreaConnector.java
index a24ac6b7db..fc96e9b16f 100644
--- a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/richtextarea/RichTextAreaConnector.java
+++ b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/richtextarea/RichTextAreaConnector.java
@@ -20,12 +20,12 @@ import com.google.gwt.event.dom.client.BlurHandler;
import com.vaadin.client.ApplicationConnection;
import com.vaadin.client.Paintable;
import com.vaadin.client.UIDL;
-import com.vaadin.client.ui.AbstractFieldConnector;
import com.vaadin.client.ui.SimpleManagedLayout;
import com.vaadin.shared.ui.Connect;
import com.vaadin.shared.ui.Connect.LoadStyle;
import com.vaadin.shared.ui.textarea.RichTextAreaState;
import com.vaadin.shared.util.SharedUtil;
+import com.vaadin.v7.client.ui.AbstractFieldConnector;
import com.vaadin.v7.client.ui.VRichTextArea;
import com.vaadin.v7.ui.RichTextArea;
diff --git a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/table/TableConnector.java b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/table/TableConnector.java
index 69395cd8ba..405fdd1393 100644
--- a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/table/TableConnector.java
+++ b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/table/TableConnector.java
@@ -37,12 +37,12 @@ import com.vaadin.client.ServerConnector;
import com.vaadin.client.TooltipInfo;
import com.vaadin.client.UIDL;
import com.vaadin.client.WidgetUtil;
-import com.vaadin.client.ui.AbstractFieldConnector;
import com.vaadin.client.ui.PostLayoutListener;
import com.vaadin.shared.MouseEventDetails;
import com.vaadin.shared.ui.Connect;
import com.vaadin.shared.ui.table.TableConstants;
import com.vaadin.shared.ui.table.TableConstants.Section;
+import com.vaadin.v7.client.ui.AbstractFieldConnector;
import com.vaadin.v7.client.ui.VScrollTable;
import com.vaadin.v7.client.ui.VScrollTable.ContextMenuDetails;
import com.vaadin.v7.client.ui.VScrollTable.FooterCell;
diff --git a/server/src/main/java/com/vaadin/v7/ui/CheckBox.java b/compatibility-server/src/main/java/com/vaadin/v7/ui/CheckBox.java
index 84488bc875..84488bc875 100644
--- a/server/src/main/java/com/vaadin/v7/ui/CheckBox.java
+++ b/compatibility-server/src/main/java/com/vaadin/v7/ui/CheckBox.java