summaryrefslogtreecommitdiffstats
path: root/shared/src
diff options
context:
space:
mode:
authorHenri Sara <hesara@vaadin.com>2016-08-25 12:57:37 +0300
committerVaadin Code Review <review@vaadin.com>2016-09-12 10:26:25 +0000
commit323d43711c572d7d676e044f1720fcc419a3c9d6 (patch)
tree467e42072ef24be00163ea5d2ead4f346fa95ccf /shared/src
parent376a4d5b897327e957483bd43e7075f180a02e8f (diff)
downloadvaadin-framework-323d43711c572d7d676e044f1720fcc419a3c9d6.tar.gz
vaadin-framework-323d43711c572d7d676e044f1720fcc419a3c9d6.zip
Update ComboBox for new DataSource and communication mechanism
This simplifies the client side state machine. This change does not modify the CSS class name v-filterselect. Change-Id: I2f4a6e5252045cb7698d582be90693e00961b342
Diffstat (limited to 'shared/src')
-rw-r--r--shared/src/main/java/com/vaadin/shared/ui/combobox/ComboBoxClientRpc.java36
-rw-r--r--shared/src/main/java/com/vaadin/shared/ui/combobox/ComboBoxConstants.java30
-rw-r--r--shared/src/main/java/com/vaadin/shared/ui/combobox/ComboBoxServerRpc.java51
-rw-r--r--shared/src/main/java/com/vaadin/shared/ui/combobox/ComboBoxState.java85
4 files changed, 202 insertions, 0 deletions
diff --git a/shared/src/main/java/com/vaadin/shared/ui/combobox/ComboBoxClientRpc.java b/shared/src/main/java/com/vaadin/shared/ui/combobox/ComboBoxClientRpc.java
new file mode 100644
index 0000000000..1e8273c05e
--- /dev/null
+++ b/shared/src/main/java/com/vaadin/shared/ui/combobox/ComboBoxClientRpc.java
@@ -0,0 +1,36 @@
+/*
+ * 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.combobox;
+
+import com.vaadin.shared.communication.ClientRpc;
+
+/**
+ * Server to client RPC interface for ComboBox.
+ *
+ * @since
+ */
+public interface ComboBoxClientRpc extends ClientRpc {
+ /**
+ * Set the current selection.
+ *
+ * @param selectedKey
+ * the id of a single item or null to deselect the current value
+ * @param selectedCaption
+ * the caption of the selected item (used in case selection is
+ * outside the lazy loaded range)
+ */
+ public void setSelectedItem(String selectedKey, String selectedCaption);
+}
diff --git a/shared/src/main/java/com/vaadin/shared/ui/combobox/ComboBoxConstants.java b/shared/src/main/java/com/vaadin/shared/ui/combobox/ComboBoxConstants.java
new file mode 100644
index 0000000000..1944c3a979
--- /dev/null
+++ b/shared/src/main/java/com/vaadin/shared/ui/combobox/ComboBoxConstants.java
@@ -0,0 +1,30 @@
+/*
+ * 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.combobox;
+
+import java.io.Serializable;
+
+/**
+ * Constants related to the combo box component and its client-server
+ * communication.
+ *
+ * @since 8.0
+ * @author Vaadin Ltd
+ */
+public class ComboBoxConstants implements Serializable {
+ public static final String STYLE = "style";
+ public static final String ICON = "icon";
+}
diff --git a/shared/src/main/java/com/vaadin/shared/ui/combobox/ComboBoxServerRpc.java b/shared/src/main/java/com/vaadin/shared/ui/combobox/ComboBoxServerRpc.java
new file mode 100644
index 0000000000..9d6ba6d8a4
--- /dev/null
+++ b/shared/src/main/java/com/vaadin/shared/ui/combobox/ComboBoxServerRpc.java
@@ -0,0 +1,51 @@
+/*
+ * 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.combobox;
+
+import com.vaadin.shared.communication.ServerRpc;
+
+/**
+ * Client to server RPC interface for ComboBox.
+ *
+ * @since
+ */
+public interface ComboBoxServerRpc extends ServerRpc {
+ /**
+ * Create a new item in the combo box. This method can only be used when the
+ * ComboBox is configured to allow the creation of new items by the user.
+ *
+ * @param itemValue
+ * user entered string value for the new item
+ */
+ public void createNewItem(String itemValue);
+
+ /**
+ * Set the current selection.
+ *
+ * @param item
+ * the id of a single item or null to deselect the current value
+ */
+ public void setSelectedItem(String item);
+
+ /**
+ * Sets the filter to use.
+ *
+ * @param filter
+ * filter string interpreted according to the current filtering
+ * mode
+ */
+ public void setFilter(String filter);
+}
diff --git a/shared/src/main/java/com/vaadin/shared/ui/combobox/ComboBoxState.java b/shared/src/main/java/com/vaadin/shared/ui/combobox/ComboBoxState.java
new file mode 100644
index 0000000000..72d10b87d6
--- /dev/null
+++ b/shared/src/main/java/com/vaadin/shared/ui/combobox/ComboBoxState.java
@@ -0,0 +1,85 @@
+/*
+ * 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.combobox;
+
+import com.vaadin.shared.AbstractFieldState;
+import com.vaadin.shared.annotations.DelegateToWidget;
+import com.vaadin.shared.annotations.NoLayout;
+
+/**
+ * Shared state for the ComboBox component.
+ *
+ * @since 7.0
+ */
+public class ComboBoxState extends AbstractFieldState {
+ {
+ // TODO ideally this would be v-combobox, but that would affect a lot of
+ // themes
+ primaryStyleName = "v-filterselect";
+ }
+
+ /**
+ * If text input is not allowed, the ComboBox behaves like a pretty
+ * NativeSelect - the user can not enter any text and clicking the text
+ * field opens the drop down with options.
+ *
+ * @since
+ */
+ @DelegateToWidget
+ public boolean textInputAllowed = true;
+
+ /**
+ * The prompt to display in an empty field. Null when disabled.
+ */
+ @DelegateToWidget
+ @NoLayout
+ public String placeholder = null;
+
+ /**
+ * Number of items to show per page or 0 to disable paging.
+ */
+ @DelegateToWidget
+ public int pageLength = 10;
+
+ /**
+ * Suggestion pop-up's width as a CSS string. By using relative units (e.g.
+ * "50%") it's possible to set the popup's width relative to the ComboBox
+ * itself.
+ */
+ @DelegateToWidget
+ public String suggestionPopupWidth = null;
+
+ /**
+ * True to allow the user to send new items to the server, false to only
+ * select among existing items.
+ */
+ @DelegateToWidget
+ public boolean allowNewItems = false;
+
+ /**
+ * True to allow selecting nothing (a special empty selection item is shown
+ * at the beginning of the list), false not to allow empty selection by the
+ * user.
+ */
+ public boolean emptySelectionAllowed = true;
+
+ /**
+ * True to automatically scroll the ComboBox to show the selected item,
+ * false not to search for it in the results.
+ */
+ public boolean scrollToSelectedItem = false;
+
+}