summaryrefslogtreecommitdiffstats
path: root/compatibility-client
diff options
context:
space:
mode:
authorArtur Signell <artur@vaadin.com>2016-08-23 15:16:55 +0300
committerVaadin Code Review <review@vaadin.com>2016-08-25 10:11:30 +0000
commitd140deb4bf3bfc615f4e5fbdd45a36a1655c525e (patch)
tree957c7c6b84a37527617c6b07e34ae9497cbbb9b0 /compatibility-client
parentc0117c3baf907c09781c4b56a64d29b4e43c9281 (diff)
downloadvaadin-framework-d140deb4bf3bfc615f4e5fbdd45a36a1655c525e.tar.gz
vaadin-framework-d140deb4bf3bfc615f4e5fbdd45a36a1655c525e.zip
Move Vaadin 7 CheckBox to compatibility package
Adds a v7 AbstractFieldConnector for the compatibility package Remove dependency from core to old AbstractField Change-Id: I5da665de69cf469adfa946cf18aae1a3e56c3486
Diffstat (limited to 'compatibility-client')
-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
8 files changed, 235 insertions, 6 deletions
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;