diff options
author | Anastasia Smirnova <anasmi@utu.fi> | 2018-04-16 18:00:31 +0300 |
---|---|---|
committer | Ilia Motornyi <elmot@vaadin.com> | 2018-04-16 18:00:31 +0300 |
commit | 9eb3119dbaf9342064f1e3a0733478e3c97ba5ea (patch) | |
tree | 50f4c16741801ac39dc02555ae0e65957fd8d10e /server | |
parent | d0bc2ad8f940506d2d2aa1a79725b5ed636a914b (diff) | |
download | vaadin-framework-9eb3119dbaf9342064f1e3a0733478e3c97ba5ea.tar.gz vaadin-framework-9eb3119dbaf9342064f1e3a0733478e3c97ba5ea.zip |
Add modality support to ColorPicker (#10815)
Diffstat (limited to 'server')
-rw-r--r-- | server/src/main/java/com/vaadin/ui/AbstractColorPicker.java | 34 | ||||
-rw-r--r-- | server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerPopup.java | 5 |
2 files changed, 37 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; + } } |