diff options
author | Anastasia Smirnova <anasmi@utu.fi> | 2018-04-16 18:00:31 +0300 |
---|---|---|
committer | Ilia Motornyi <elmot@vaadin.com> | 2018-05-02 16:19:02 +0300 |
commit | 913daf5c6d3df10774fe16b4d2efc77e448422a4 (patch) | |
tree | 6034ac198b1c72703a0468642171518bed2f4590 /server | |
parent | bcea998f993a618bc81c11b6c7fbc802bcf233e1 (diff) | |
download | vaadin-framework-913daf5c6d3df10774fe16b4d2efc77e448422a4.tar.gz vaadin-framework-913daf5c6d3df10774fe16b4d2efc77e448422a4.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; + } } |