summaryrefslogtreecommitdiffstats
path: root/compatibility-client
diff options
context:
space:
mode:
authorArtur Signell <artur@vaadin.com>2016-08-18 21:51:13 +0300
committerArtur Signell <artur@vaadin.com>2016-08-20 00:08:46 +0300
commit34852cdb88c6c27b1341684204d78db0fdd061a6 (patch)
treef55c6f9d900167a57c7eb2c96c25e1dfe0451dd8 /compatibility-client
parent6e0f2efe996cfd3b38c960e04cbced0a91215cf0 (diff)
downloadvaadin-framework-34852cdb88c6c27b1341684204d78db0fdd061a6.tar.gz
vaadin-framework-34852cdb88c6c27b1341684204d78db0fdd061a6.zip
Move selects to compatibility package
Change-Id: I7ee02d34b230e8752174a7f19824f81cbb616c33
Diffstat (limited to 'compatibility-client')
-rw-r--r--compatibility-client/src/main/java/com/vaadin/client/ui/listselect/ListSelectConnector.java31
-rw-r--r--compatibility-client/src/main/java/com/vaadin/client/ui/nativeselect/NativeSelectConnector.java38
-rw-r--r--compatibility-client/src/main/java/com/vaadin/client/ui/optiongroup/OptionGroupBaseConnector.java106
-rw-r--r--compatibility-client/src/main/java/com/vaadin/client/ui/optiongroup/OptionGroupConnector.java83
-rw-r--r--compatibility-client/src/main/java/com/vaadin/client/ui/twincolselect/TwinColSelectConnector.java84
5 files changed, 342 insertions, 0 deletions
diff --git a/compatibility-client/src/main/java/com/vaadin/client/ui/listselect/ListSelectConnector.java b/compatibility-client/src/main/java/com/vaadin/client/ui/listselect/ListSelectConnector.java
new file mode 100644
index 0000000000..a69043548b
--- /dev/null
+++ b/compatibility-client/src/main/java/com/vaadin/client/ui/listselect/ListSelectConnector.java
@@ -0,0 +1,31 @@
+/*
+ * 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.listselect;
+
+import com.vaadin.client.ui.VListSelect;
+import com.vaadin.client.ui.optiongroup.OptionGroupBaseConnector;
+import com.vaadin.shared.ui.Connect;
+import com.vaadin.ui.ListSelect;
+
+@Connect(ListSelect.class)
+public class ListSelectConnector extends OptionGroupBaseConnector {
+
+ @Override
+ public VListSelect getWidget() {
+ return (VListSelect) super.getWidget();
+ }
+}
diff --git a/compatibility-client/src/main/java/com/vaadin/client/ui/nativeselect/NativeSelectConnector.java b/compatibility-client/src/main/java/com/vaadin/client/ui/nativeselect/NativeSelectConnector.java
new file mode 100644
index 0000000000..1780d20c69
--- /dev/null
+++ b/compatibility-client/src/main/java/com/vaadin/client/ui/nativeselect/NativeSelectConnector.java
@@ -0,0 +1,38 @@
+/*
+ * 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.nativeselect;
+
+import com.vaadin.client.ui.ConnectorFocusAndBlurHandler;
+import com.vaadin.client.ui.VNativeSelect;
+import com.vaadin.client.ui.optiongroup.OptionGroupBaseConnector;
+import com.vaadin.shared.ui.Connect;
+import com.vaadin.ui.NativeSelect;
+
+@Connect(NativeSelect.class)
+public class NativeSelectConnector extends OptionGroupBaseConnector {
+
+ @Override
+ protected void init() {
+ super.init();
+ ConnectorFocusAndBlurHandler.addHandlers(this, getWidget().getSelect());
+ }
+
+ @Override
+ public VNativeSelect getWidget() {
+ return (VNativeSelect) super.getWidget();
+ }
+}
diff --git a/compatibility-client/src/main/java/com/vaadin/client/ui/optiongroup/OptionGroupBaseConnector.java b/compatibility-client/src/main/java/com/vaadin/client/ui/optiongroup/OptionGroupBaseConnector.java
new file mode 100644
index 0000000000..24454c833d
--- /dev/null
+++ b/compatibility-client/src/main/java/com/vaadin/client/ui/optiongroup/OptionGroupBaseConnector.java
@@ -0,0 +1,106 @@
+/*
+ * 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.optiongroup;
+
+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;
+
+public abstract class OptionGroupBaseConnector extends AbstractFieldConnector
+ implements Paintable {
+
+ @Override
+ public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
+
+ // Save details
+ getWidget().client = client;
+ getWidget().paintableId = uidl.getId();
+
+ if (!isRealUpdate(uidl)) {
+ return;
+ }
+
+ getWidget().selectedKeys = uidl.getStringArrayVariableAsSet("selected");
+
+ getWidget().setReadonly(isReadOnly());
+ getWidget().multiselect = getState().multiSelect;
+ getWidget().immediate = getState().immediate;
+ getWidget().nullSelectionAllowed = uidl
+ .getBooleanAttribute("nullselect");
+ getWidget().nullSelectionItemAvailable = uidl
+ .getBooleanAttribute("nullselectitem");
+
+ if (uidl.hasAttribute("rows")) {
+ getWidget().rows = uidl.getIntAttribute("rows");
+ }
+
+ final UIDL ops = uidl.getChildUIDL(0);
+
+ getWidget().buildOptions(ops);
+
+ if (uidl.getBooleanAttribute("allownewitem")) {
+ if (getWidget().newItemField == null) {
+ getWidget().newItemButton = new VNativeButton();
+ getWidget().newItemButton.setText("+");
+ getWidget().newItemButton.addClickHandler(getWidget());
+ getWidget().newItemButton
+ .addStyleName(StyleConstants.UI_WIDGET);
+ getWidget().newItemField = new VLegacyTextField();
+ getWidget().newItemField.client = getConnection();
+ getWidget().newItemField.paintableId = getConnectorId();
+ getWidget().newItemField.addKeyPressHandler(getWidget());
+ getWidget().newItemField.addStyleName(StyleConstants.UI_WIDGET);
+
+ }
+ getWidget().newItemField.setEnabled(
+ getWidget().isEnabled() && !getWidget().isReadonly());
+ getWidget().newItemButton.setEnabled(
+ getWidget().isEnabled() && !getWidget().isReadonly());
+
+ if (getWidget().newItemField == null || getWidget().newItemField
+ .getParent() != getWidget().container) {
+ getWidget().container.add(getWidget().newItemField);
+ getWidget().container.add(getWidget().newItemButton);
+ final int w = getWidget().container.getOffsetWidth()
+ - getWidget().newItemButton.getOffsetWidth();
+ getWidget().newItemField.setWidth(Math.max(w, 0) + "px");
+ }
+ } else if (getWidget().newItemField != null) {
+ getWidget().container.remove(getWidget().newItemField);
+ getWidget().container.remove(getWidget().newItemButton);
+ }
+
+ getWidget().setTabIndex(getState().tabIndex);
+
+ }
+
+ @Override
+ public VOptionGroupBase getWidget() {
+ return (VOptionGroupBase) super.getWidget();
+ }
+
+ @Override
+ public AbstractSelectState getState() {
+ return (AbstractSelectState) super.getState();
+ }
+}
diff --git a/compatibility-client/src/main/java/com/vaadin/client/ui/optiongroup/OptionGroupConnector.java b/compatibility-client/src/main/java/com/vaadin/client/ui/optiongroup/OptionGroupConnector.java
new file mode 100644
index 0000000000..3dd3b897a5
--- /dev/null
+++ b/compatibility-client/src/main/java/com/vaadin/client/ui/optiongroup/OptionGroupConnector.java
@@ -0,0 +1,83 @@
+/*
+ * 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.optiongroup;
+
+import java.util.ArrayList;
+
+import com.google.gwt.event.shared.HandlerRegistration;
+import com.google.gwt.user.client.ui.CheckBox;
+import com.google.gwt.user.client.ui.Widget;
+import com.vaadin.client.ApplicationConnection;
+import com.vaadin.client.UIDL;
+import com.vaadin.client.ui.VOptionGroup;
+import com.vaadin.shared.EventId;
+import com.vaadin.shared.ui.Connect;
+import com.vaadin.shared.ui.optiongroup.OptionGroupState;
+import com.vaadin.ui.OptionGroup;
+
+@Connect(OptionGroup.class)
+public class OptionGroupConnector extends OptionGroupBaseConnector {
+
+ @Override
+ public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
+ super.updateFromUIDL(uidl, client);
+
+ getWidget().sendFocusEvents = client.hasEventListeners(this,
+ EventId.FOCUS);
+ getWidget().sendBlurEvents = client.hasEventListeners(this,
+ EventId.BLUR);
+
+ if (getWidget().focusHandlers != null) {
+ for (HandlerRegistration reg : getWidget().focusHandlers) {
+ reg.removeHandler();
+ }
+ getWidget().focusHandlers.clear();
+ getWidget().focusHandlers = null;
+
+ for (HandlerRegistration reg : getWidget().blurHandlers) {
+ reg.removeHandler();
+ }
+ getWidget().blurHandlers.clear();
+ getWidget().blurHandlers = null;
+ }
+
+ if (getWidget().sendFocusEvents || getWidget().sendBlurEvents) {
+ getWidget().focusHandlers = new ArrayList<HandlerRegistration>();
+ getWidget().blurHandlers = new ArrayList<HandlerRegistration>();
+
+ // add focus and blur handlers to checkboxes / radio buttons
+ for (Widget wid : getWidget().panel) {
+ if (wid instanceof CheckBox) {
+ getWidget().focusHandlers
+ .add(((CheckBox) wid).addFocusHandler(getWidget()));
+ getWidget().blurHandlers
+ .add(((CheckBox) wid).addBlurHandler(getWidget()));
+ }
+ }
+ }
+ }
+
+ @Override
+ public VOptionGroup getWidget() {
+ return (VOptionGroup) super.getWidget();
+ }
+
+ @Override
+ public OptionGroupState getState() {
+ return (OptionGroupState) super.getState();
+ }
+}
diff --git a/compatibility-client/src/main/java/com/vaadin/client/ui/twincolselect/TwinColSelectConnector.java b/compatibility-client/src/main/java/com/vaadin/client/ui/twincolselect/TwinColSelectConnector.java
new file mode 100644
index 0000000000..81e32e5711
--- /dev/null
+++ b/compatibility-client/src/main/java/com/vaadin/client/ui/twincolselect/TwinColSelectConnector.java
@@ -0,0 +1,84 @@
+/*
+ * 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.twincolselect;
+
+import com.vaadin.client.ApplicationConnection;
+import com.vaadin.client.DirectionalManagedLayout;
+import com.vaadin.client.UIDL;
+import com.vaadin.client.ui.VTwinColSelect;
+import com.vaadin.client.ui.optiongroup.OptionGroupBaseConnector;
+import com.vaadin.shared.ui.Connect;
+import com.vaadin.shared.ui.twincolselect.TwinColSelectState;
+import com.vaadin.ui.TwinColSelect;
+
+@Connect(TwinColSelect.class)
+public class TwinColSelectConnector extends OptionGroupBaseConnector
+ implements DirectionalManagedLayout {
+
+ @Override
+ public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
+ // Captions are updated before super call to ensure the widths are set
+ // correctly
+ if (isRealUpdate(uidl)) {
+ getWidget().updateCaptions(uidl);
+ getLayoutManager().setNeedsHorizontalLayout(this);
+ }
+
+ super.updateFromUIDL(uidl, client);
+ }
+
+ @Override
+ protected void init() {
+ super.init();
+ getLayoutManager().registerDependency(this,
+ getWidget().captionWrapper.getElement());
+ }
+
+ @Override
+ public void onUnregister() {
+ getLayoutManager().unregisterDependency(this,
+ getWidget().captionWrapper.getElement());
+ }
+
+ @Override
+ public VTwinColSelect getWidget() {
+ return (VTwinColSelect) super.getWidget();
+ }
+
+ @Override
+ public TwinColSelectState getState() {
+ return (TwinColSelectState) super.getState();
+ }
+
+ @Override
+ public void layoutVertically() {
+ if (isUndefinedHeight()) {
+ getWidget().clearInternalHeights();
+ } else {
+ getWidget().setInternalHeights();
+ }
+ }
+
+ @Override
+ public void layoutHorizontally() {
+ if (isUndefinedWidth()) {
+ getWidget().clearInternalWidths();
+ } else {
+ getWidget().setInternalWidths();
+ }
+ }
+}