summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--server/src/main/java/com/vaadin/ui/AbstractColorPicker.java34
-rw-r--r--server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerPopup.java5
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/colorpicker/ColorPickerModal.java44
-rw-r--r--uitest/src/test/java/com/vaadin/tests/components/colorpicker/ColorPickerModalTest.java20
4 files changed, 101 insertions, 2 deletions
diff --git a/server/src/main/java/com/vaadin/ui/AbstractColorPicker.java b/server/src/main/java/com/vaadin/ui/AbstractColorPicker.java
index 8cba9af5df..f73aa74414 100644
--- a/server/src/main/java/com/vaadin/ui/AbstractColorPicker.java
+++ b/server/src/main/java/com/vaadin/ui/AbstractColorPicker.java
@@ -110,6 +110,7 @@ public abstract class AbstractColorPicker extends AbstractField<Color> {
protected boolean swatchesVisible = true;
protected boolean historyVisible = true;
protected boolean textfieldVisible = true;
+ private boolean modal;
private ColorPickerServerRpc rpc = new ColorPickerServerRpc() {
@Override
@@ -122,7 +123,7 @@ public abstract class AbstractColorPicker extends AbstractField<Color> {
Color valueC = new Color(
Integer.parseInt(col.substring(1, col.length()), 16));
color = valueC;
- setValue(color,true);
+ setValue(color, true);
}
};
@@ -471,6 +472,7 @@ public abstract class AbstractColorPicker extends AbstractField<Color> {
window.setPositionY(positionY);
window.setVisible(true);
window.setValue(color);
+ window.setModal(modal);
parent.addWindow(window);
window.focus();
@@ -486,7 +488,7 @@ public abstract class AbstractColorPicker extends AbstractField<Color> {
window.setValue(color);
window.getHistory().setValue(color);
window.setVisible(true);
-
+ window.setModal(modal);
parent.addWindow(window);
window.focus();
}
@@ -557,4 +559,32 @@ public abstract class AbstractColorPicker extends AbstractField<Color> {
public Color getEmptyValue() {
return Color.WHITE;
}
+
+ /**
+ * Sets ColorPicker modality. When a modal ColorPicker is open, components
+ * outside that ColorPicker cannot be accessed.
+ * <p>
+ * Note: It must be set to {@code true} if ColorPicker is a child of modal
+ * {@link Window}
+ * </p>
+ *
+ * @see Window#setModal
+ * @since
+ * @param modal
+ * true if modality is to be turned on
+ */
+ public void setModal(boolean modal) {
+ this.modal = modal;
+ }
+
+ /**
+ * Checks the modality of the dialog.
+ *
+ * @see #setModal(boolean)
+ * @since
+ * @return true if the dialog is modal, false otherwise
+ */
+ public boolean isModal() {
+ return this.modal;
+ }
}
diff --git a/server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerPopup.java b/server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerPopup.java
index c2ca3d012f..79e00eb6ae 100644
--- a/server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerPopup.java
+++ b/server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerPopup.java
@@ -770,4 +770,9 @@ public class ColorPickerPopup extends Window implements HasValue<Color> {
}
}
}
+
+ @Override
+ public void setModal(boolean modal) {
+ getState().modal = modal;
+ }
}
diff --git a/uitest/src/main/java/com/vaadin/tests/components/colorpicker/ColorPickerModal.java b/uitest/src/main/java/com/vaadin/tests/components/colorpicker/ColorPickerModal.java
new file mode 100644
index 0000000000..931de3aaed
--- /dev/null
+++ b/uitest/src/main/java/com/vaadin/tests/components/colorpicker/ColorPickerModal.java
@@ -0,0 +1,44 @@
+package com.vaadin.tests.components.colorpicker;
+
+import com.vaadin.annotations.Widgetset;
+import com.vaadin.server.DefaultErrorHandler;
+import com.vaadin.server.ErrorHandler;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.shared.ui.colorpicker.Color;
+import com.vaadin.tests.components.AbstractTestUIWithLog;
+import com.vaadin.ui.ColorPicker;
+import com.vaadin.ui.VerticalLayout;
+import com.vaadin.ui.Window;
+
+@Widgetset("com.vaadin.DefaultWidgetSet")
+public class ColorPickerModal extends AbstractTestUIWithLog
+ implements ErrorHandler {
+
+ @Override
+ protected void setup(VaadinRequest req) {
+ getSession().setErrorHandler(this);
+ Window modalWindow = new Window("Modal window");
+ modalWindow.setModal(true);
+ VerticalLayout vl = new VerticalLayout();
+ ColorPicker cp = new ColorPicker("Color Picker test", Color.GREEN);
+ cp.setId("colorP");
+ cp.setModal(true);
+ vl.addComponent(cp);
+ modalWindow.setContent(vl);
+ addWindow(modalWindow);
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 9511;
+ }
+
+ @Override
+ public void error(com.vaadin.server.ErrorEvent event) {
+ log("Exception caught on execution with "
+ + event.getClass().getSimpleName() + " : "
+ + event.getThrowable().getClass().getName());
+
+ DefaultErrorHandler.doDefault(event);
+ }
+}
diff --git a/uitest/src/test/java/com/vaadin/tests/components/colorpicker/ColorPickerModalTest.java b/uitest/src/test/java/com/vaadin/tests/components/colorpicker/ColorPickerModalTest.java
new file mode 100644
index 0000000000..0af1f52735
--- /dev/null
+++ b/uitest/src/test/java/com/vaadin/tests/components/colorpicker/ColorPickerModalTest.java
@@ -0,0 +1,20 @@
+package com.vaadin.tests.components.colorpicker;
+
+import com.vaadin.tests.tb3.MultiBrowserTest;
+import org.junit.Assert;
+import org.junit.Test;
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebElement;
+
+public class ColorPickerModalTest extends MultiBrowserTest {
+
+ @Test
+ public void testNoError() {
+ openTestURL();
+ WebElement cp = getDriver().findElement(By.id("colorP"));
+ cp.click();
+ WebElement label = findElement(By.id("Log_row_0"));
+ Assert.assertEquals(false,
+ label.getText().contains("Exception caught"));
+ }
+} \ No newline at end of file