]> source.dussan.org Git - vaadin-framework.git/commitdiff
Clean up state hierarchy for AbstractFieldState
authorTeemu Suo-Anttila <teemusa@vaadin.com>
Wed, 2 Nov 2016 09:02:16 +0000 (11:02 +0200)
committerPekka Hyvönen <pekka@vaadin.com>
Wed, 2 Nov 2016 10:07:49 +0000 (10:07 +0000)
Change-Id: I33c8c977bf8cd2d4c637d7988586496ce963465f

client/src/main/java/com/vaadin/client/connectors/AbstractMultiSelectConnector.java
client/src/main/java/com/vaadin/client/ui/AbstractFieldConnector.java
server/src/main/java/com/vaadin/ui/AbstractComponent.java
server/src/main/java/com/vaadin/ui/AbstractMultiSelect.java
shared/src/main/java/com/vaadin/shared/AbstractFieldState.java
shared/src/main/java/com/vaadin/shared/ui/AbstractSingleSelectState.java
shared/src/main/java/com/vaadin/shared/ui/RequiredIndicatorState.java [deleted file]
shared/src/main/java/com/vaadin/shared/ui/listselect/ListSelectState.java
shared/src/main/java/com/vaadin/shared/ui/optiongroup/CheckBoxGroupState.java
shared/src/main/java/com/vaadin/shared/ui/optiongroup/RadioButtonGroupState.java
shared/src/main/java/com/vaadin/shared/ui/twincolselect/TwinColSelectState.java

index 0dbe3cb33144603103fbc6acf2141471abe95eee..60966c39a964835cb3f29f04c6d240e1348d670a 100644 (file)
@@ -26,12 +26,12 @@ import com.google.gwt.user.client.ui.IsWidget;
 import com.google.gwt.user.client.ui.Widget;
 import com.vaadin.client.data.DataSource;
 import com.vaadin.client.ui.HasRequiredIndicator;
+import com.vaadin.shared.AbstractFieldState;
 import com.vaadin.shared.Range;
 import com.vaadin.shared.Registration;
 import com.vaadin.shared.data.selection.MultiSelectServerRpc;
 import com.vaadin.shared.data.selection.SelectionModel;
 import com.vaadin.shared.ui.ListingJsonConstants;
-import com.vaadin.shared.ui.RequiredIndicatorState;
 
 import elemental.json.JsonObject;
 
@@ -158,8 +158,8 @@ public abstract class AbstractMultiSelectConnector
     }
 
     @Override
-    public RequiredIndicatorState getState() {
-        return (RequiredIndicatorState) super.getState();
+    public AbstractFieldState getState() {
+        return (AbstractFieldState) super.getState();
     }
 
     @Override
index 015b805ee131579f2e40dac3272d995e18bbfee0..fde1f548a07463bbbcca647c4ee3471671f8a437 100644 (file)
@@ -26,27 +26,15 @@ public abstract class AbstractFieldConnector extends AbstractComponentConnector
         return (AbstractFieldState) super.getState();
     }
 
-    public boolean isModified() {
-        return getState().modified;
-    }
-
     @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());
index 5d8c422a7c9e0f43b6e007fced995e6681eae20c..f03f1f438f53f8d0cbee97be67f237f2255e631a 100644 (file)
@@ -55,13 +55,13 @@ import com.vaadin.server.Sizeable;
 import com.vaadin.server.UserError;
 import com.vaadin.server.VaadinSession;
 import com.vaadin.shared.AbstractComponentState;
+import com.vaadin.shared.AbstractFieldState;
 import com.vaadin.shared.ComponentConstants;
 import com.vaadin.shared.ContextClickRpc;
 import com.vaadin.shared.EventId;
 import com.vaadin.shared.MouseEventDetails;
 import com.vaadin.shared.Registration;
 import com.vaadin.shared.ui.ComponentStateUtil;
-import com.vaadin.shared.ui.RequiredIndicatorState;
 import com.vaadin.shared.util.SharedUtil;
 import com.vaadin.ui.declarative.DesignAttributeHandler;
 import com.vaadin.ui.declarative.DesignContext;
@@ -1386,27 +1386,27 @@ public abstract class AbstractComponent extends AbstractClientConnector
      * apply for all components!</strong>.
      * <p>
      * If the component supports the required indicator (state extends
-     * {@link RequiredIndicatorState}), then expose this method and
+     * {@link AbstractFieldState}), then expose this method and
      * {@link #isRequiredIndicatorVisible()} as {@code public} in the component
      * and call this method.
      * <p>
      * This method will throw a {@link IllegalStateException} if the component
      * state (returned by {@link #getState()}) does not inherit
-     * {@link RequiredIndicatorState}.
+     * {@link AbstractFieldState}.
      *
      * @param visible
      *            <code>true</code> to make the required indicator visible,
      *            <code>false</code> if not
      */
     protected void setRequiredIndicatorVisible(boolean visible) {
-        if (getState(false) instanceof RequiredIndicatorState) {
-            ((RequiredIndicatorState) getState()).required = visible;
+        if (getState(false) instanceof AbstractFieldState) {
+            ((AbstractFieldState) getState()).required = visible;
         } else {
             throw new IllegalStateException(
                     "This component does not support the required indicator, since state is of type "
                             + getStateType().getSimpleName()
                             + " and does not inherit "
-                            + RequiredIndicatorState.class.getSimpleName());
+                            + AbstractFieldState.class.getSimpleName());
         }
     }
 
@@ -1416,20 +1416,20 @@ public abstract class AbstractComponent extends AbstractClientConnector
      * <p>
      * This method will throw a {@link IllegalStateException} if the component
      * state (returned by {@link #getState()}) does not inherit
-     * {@link RequiredIndicatorState}.
+     * {@link AbstractFieldState}.
      *
      * @return <code>true</code> if visible, <code>false</code> if not
      * @see #setRequiredIndicatorVisible(boolean)
      */
     protected boolean isRequiredIndicatorVisible() {
-        if (getState(false) instanceof RequiredIndicatorState) {
-            return ((RequiredIndicatorState) getState(false)).required;
+        if (getState(false) instanceof AbstractFieldState) {
+            return ((AbstractFieldState) getState(false)).required;
         } else {
             throw new IllegalStateException(
                     "This component does not support the required indicator, since state is of type "
                             + getStateType().getSimpleName()
                             + " and does not inherit "
-                            + RequiredIndicatorState.class.getSimpleName());
+                            + AbstractFieldState.class.getSimpleName());
         }
     }
 
index 52cd02481c43a0ada314652e1d5642e2f3c93d61..bd1fc8937a5cb04bd0cc14191a1d69b6deb2297d 100644 (file)
@@ -32,12 +32,12 @@ import com.vaadin.server.Resource;
 import com.vaadin.server.ResourceReference;
 import com.vaadin.server.SerializablePredicate;
 import com.vaadin.server.data.DataGenerator;
+import com.vaadin.shared.AbstractFieldState;
 import com.vaadin.shared.Registration;
 import com.vaadin.shared.data.selection.MultiSelectServerRpc;
 import com.vaadin.shared.data.selection.SelectionModel;
 import com.vaadin.shared.data.selection.SelectionModel.Multi;
 import com.vaadin.shared.ui.ListingJsonConstants;
-import com.vaadin.shared.ui.RequiredIndicatorState;
 import com.vaadin.util.ReflectTools;
 
 import elemental.json.JsonObject;
@@ -484,13 +484,13 @@ public abstract class AbstractMultiSelect<T>
     }
 
     @Override
-    protected RequiredIndicatorState getState() {
-        return (RequiredIndicatorState) super.getState();
+    protected AbstractFieldState getState() {
+        return (AbstractFieldState) super.getState();
     }
 
     @Override
-    protected RequiredIndicatorState getState(boolean markAsDirty) {
-        return (RequiredIndicatorState) super.getState(markAsDirty);
+    protected AbstractFieldState getState(boolean markAsDirty) {
+        return (AbstractFieldState) super.getState(markAsDirty);
     }
 
     @Override
index e24880c3af2cc75154e361f287a18c689967f291..6ac39efe693e9f4eb1bb361274197bc0ddf2133a 100644 (file)
  */
 package com.vaadin.shared;
 
-import com.vaadin.shared.ui.RequiredIndicatorState;
+import com.vaadin.shared.ui.TabIndexState;
 
 /**
- * Shared state for {@link com.vaadin.ui.AbstractField}.
+ * State for components that can show the required indicator.
  *
  * @author Vaadin Ltd
- * @since 7.0.0
+ * @since 8.0.0
  *
  */
-public class AbstractFieldState extends RequiredIndicatorState {
-    public boolean hideErrors = false;
-    public boolean modified = false;
+public class AbstractFieldState extends TabIndexState {
+
+    /**
+     * Is the required indicator visible or not.
+     */
+    public boolean required = false;
+
 }
index da4510bfdb6e7b59ec75468c751d57abc77a1753..4cd9bdc9a24d941330ed602e4aa248d3cca18cda 100644 (file)
@@ -15,6 +15,8 @@
  */
 package com.vaadin.shared.ui;
 
+import com.vaadin.shared.AbstractFieldState;
+
 /**
  * Shared state for {@code AbstractSingleSelect}.
  *
@@ -22,7 +24,7 @@ package com.vaadin.shared.ui;
  *
  * @since 8.0
  */
-public class AbstractSingleSelectState extends RequiredIndicatorState {
+public class AbstractSingleSelectState extends AbstractFieldState {
 
     /**
      * The key of the currently selected item or {@code null} if no item is
diff --git a/shared/src/main/java/com/vaadin/shared/ui/RequiredIndicatorState.java b/shared/src/main/java/com/vaadin/shared/ui/RequiredIndicatorState.java
deleted file mode 100644 (file)
index b26a8ce..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * 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.shared.ui;
-
-/**
- * State for components that can show the required indicator.
- *
- * @author Vaadin Ltd
- * @since 8.0.0
- *
- */
-public class RequiredIndicatorState extends TabIndexState {
-
-    /**
-     * Is the required indicator visible or not.
-     */
-    public boolean required;
-
-}
index 8992dc66473496f5b0697882cc9dd10ae5618071..f90ca79368a32ac2f202b34a224e2abc18a0dded 100644 (file)
@@ -15,8 +15,8 @@
  */
 package com.vaadin.shared.ui.listselect;
 
+import com.vaadin.shared.AbstractFieldState;
 import com.vaadin.shared.annotations.DelegateToWidget;
-import com.vaadin.shared.ui.RequiredIndicatorState;
 
 /**
  * Shared state for ListSelect component.
@@ -24,7 +24,7 @@ import com.vaadin.shared.ui.RequiredIndicatorState;
  * @author Vaadin Ltd
  *
  */
-public class ListSelectState extends RequiredIndicatorState {
+public class ListSelectState extends AbstractFieldState {
     {
         primaryStyleName = "v-select";
     }
index 82695a913cfc0cae2140a54931913b4db759fdbc..93647c2a22f25131545824f471b12ef9bb3f3993 100644 (file)
@@ -15,8 +15,8 @@
  */
 package com.vaadin.shared.ui.optiongroup;
 
+import com.vaadin.shared.AbstractFieldState;
 import com.vaadin.shared.annotations.DelegateToWidget;
-import com.vaadin.shared.ui.RequiredIndicatorState;
 
 /**
  * Shared state for the CheckBoxGroup component.
@@ -24,7 +24,7 @@ import com.vaadin.shared.ui.RequiredIndicatorState;
  * @author Vaadin Ltd.
  * @since 8.0
  */
-public class CheckBoxGroupState extends RequiredIndicatorState {
+public class CheckBoxGroupState extends AbstractFieldState {
 
     {
         primaryStyleName = "v-select-optiongroup";
index bdd007613ce51040d765a9a7da21dd913e8b81e2..a7282b146d1b0d15d1b063870a4cca7930a13399 100644 (file)
@@ -15,7 +15,6 @@
  */
 package com.vaadin.shared.ui.optiongroup;
 
-import com.vaadin.shared.AbstractFieldState;
 import com.vaadin.shared.annotations.DelegateToWidget;
 import com.vaadin.shared.ui.AbstractSingleSelectState;
 
index fe1f1fab2313388e129052b23d0689d237e121f2..b0e148e656578796e6ea5b4f01485e327ca54970 100644 (file)
  */
 package com.vaadin.shared.ui.twincolselect;
 
+import com.vaadin.shared.AbstractFieldState;
 import com.vaadin.shared.annotations.DelegateToWidget;
-import com.vaadin.shared.ui.RequiredIndicatorState;
 
 /**
  * Shared state for the TwinColSelect component.
  *
  * @since 7.0
  */
-public class TwinColSelectState extends RequiredIndicatorState {
+public class TwinColSelectState extends AbstractFieldState {
     {
         primaryStyleName = "v-select-twincol";
     }