diff --git a/perun-wui-registrar/src/main/java/cz/metacentrum/perun/wui/registrar/widgets/items/ListBox.java b/perun-wui-registrar/src/main/java/cz/metacentrum/perun/wui/registrar/widgets/items/ListBox.java index 6a92b26c..3d0fc0ec 100644 --- a/perun-wui-registrar/src/main/java/cz/metacentrum/perun/wui/registrar/widgets/items/ListBox.java +++ b/perun-wui-registrar/src/main/java/cz/metacentrum/perun/wui/registrar/widgets/items/ListBox.java @@ -34,6 +34,7 @@ public class ListBox extends WidgetBox { private final ListBoxValidator validator; List inputList; Map handlers; + List removeButtons; public ListBox(PerunForm form, ApplicationFormItemData item, String lang) { super(form, item, lang); @@ -44,6 +45,19 @@ public ListBox(PerunForm form, ApplicationFormItemData item, String lang) { } } + @Override + public void setEnabled(boolean enabled) { + if (addButton != null) { + addButton.setEnabled(enabled); + } + for (PerunButton button : removeButtons) { + button.setEnabled(enabled); + } + for (ExtendedTextBox input : inputList) { + input.setEnabled(enabled); + } + } + @Override public String getValue() { StringBuilder value = new StringBuilder(); @@ -83,6 +97,7 @@ public boolean validateLocal() { protected Widget initWidget() { inputList = new ArrayList<>(); handlers = new HashMap<>(); + removeButtons = new ArrayList<>(); return super.initWidget(); } @@ -209,6 +224,7 @@ public void onLoadingStart() { }); } }); + removeButtons.add(removeButton); setupRemoveButton(removeButton); hp.add(input); hp.add(removeButton); diff --git a/perun-wui-registrar/src/main/java/cz/metacentrum/perun/wui/registrar/widgets/items/MapBox.java b/perun-wui-registrar/src/main/java/cz/metacentrum/perun/wui/registrar/widgets/items/MapBox.java index 796593fb..cc373b17 100644 --- a/perun-wui-registrar/src/main/java/cz/metacentrum/perun/wui/registrar/widgets/items/MapBox.java +++ b/perun-wui-registrar/src/main/java/cz/metacentrum/perun/wui/registrar/widgets/items/MapBox.java @@ -34,12 +34,28 @@ public class MapBox extends WidgetBox { private final MapBoxValidator validator; List keys; List values; - + List removeButtons; public MapBox(PerunForm form, ApplicationFormItemData item, String lang) { super(form, item, lang); this.validator = new MapBoxValidator(); } + @Override + public void setEnabled(boolean enabled) { + if (addButton != null) { + addButton.setEnabled(enabled); + } + for (PerunButton button : removeButtons) { + button.setEnabled(enabled); + } + for (ExtendedTextBox box : keys) { + box.setEnabled(enabled); + } + for (ExtendedTextBox box : values) { + box.setEnabled(enabled); + } + } + @Override public String getValue() { StringBuilder value = new StringBuilder(); @@ -100,6 +116,7 @@ public boolean validateLocal() { protected Widget initWidget() { keys = new ArrayList<>(); values = new ArrayList<>(); + removeButtons = new ArrayList<>(); return super.initWidget(); } @@ -213,6 +230,7 @@ public void onClick(ClickEvent event) { validateLocal(); } }); + removeButtons.add(removeButton); setupRemoveButton(removeButton); hp.add(key); hp.add(equals); diff --git a/perun-wui-registrar/src/main/java/cz/metacentrum/perun/wui/registrar/widgets/items/Password.java b/perun-wui-registrar/src/main/java/cz/metacentrum/perun/wui/registrar/widgets/items/Password.java index 8a55b9b4..a10e44ed 100644 --- a/perun-wui-registrar/src/main/java/cz/metacentrum/perun/wui/registrar/widgets/items/Password.java +++ b/perun-wui-registrar/src/main/java/cz/metacentrum/perun/wui/registrar/widgets/items/Password.java @@ -29,6 +29,8 @@ public class Password extends PerunFormItemEditable { public final static int MIN_LENGTH = 8; public final static int MAX_LENGTH = 1024; private final PasswordValidator validator; + private ExtendedPasswordTextBox passwordBox; + private ExtendedPasswordTextBox passwordConfirmBox; private InputGroup widget; @@ -53,23 +55,23 @@ protected Widget initWidget() { InputGroupAddon addon = new InputGroupAddon(); addon.setIcon(IconType.KEY); - ExtendedPasswordTextBox box = new ExtendedPasswordTextBox(); - box.setMaxLength(MAX_LENGTH); - box.addStyleName("passwordFormItemFirst"); - box.setPlaceholder(getTranslation().enterPassword()); + passwordBox = new ExtendedPasswordTextBox(); + passwordBox.setMaxLength(MAX_LENGTH); + passwordBox.addStyleName("passwordFormItemFirst"); + passwordBox.setPlaceholder(getTranslation().enterPassword()); - ExtendedPasswordTextBox box2 = new ExtendedPasswordTextBox(); - box2.setMaxLength(MAX_LENGTH); - box2.addStyleName("passwordFormItemLast"); - box2.setPlaceholder(getTranslation().confirmPassword()); + passwordConfirmBox = new ExtendedPasswordTextBox(); + passwordConfirmBox.setMaxLength(MAX_LENGTH); + passwordConfirmBox.addStyleName("passwordFormItemLast"); + passwordConfirmBox.setPlaceholder(getTranslation().confirmPassword()); if (getItemData().getFormItem().getRegex() != null) { - box.setRegex(getItemData().getFormItem().getRegex()); + passwordBox.setRegex(getItemData().getFormItem().getRegex()); } widget.add(addon); - widget.add(box); - widget.add(box2); + widget.add(passwordBox); + widget.add(passwordConfirmBox); return widget; @@ -90,6 +92,16 @@ public PerunFormItemValidator.Result getLastValidationResult() { return validator.getLastResult(); } + @Override + public void setEnabled(boolean enabled) { + if (this.passwordBox != null) { + this.passwordBox.setEnabled(enabled); + } + if (this.passwordConfirmBox != null) { + this.passwordConfirmBox.setEnabled(enabled); + } + } + @Override public boolean focus() { getPassword().setFocus(true); diff --git a/perun-wui-registrar/src/main/java/cz/metacentrum/perun/wui/registrar/widgets/items/Radiobox.java b/perun-wui-registrar/src/main/java/cz/metacentrum/perun/wui/registrar/widgets/items/Radiobox.java index e8451dfb..e2dd0e05 100644 --- a/perun-wui-registrar/src/main/java/cz/metacentrum/perun/wui/registrar/widgets/items/Radiobox.java +++ b/perun-wui-registrar/src/main/java/cz/metacentrum/perun/wui/registrar/widgets/items/Radiobox.java @@ -81,6 +81,16 @@ public PerunFormItemValidator.Result getLastValidationResult() { return validator.getLastResult(); } + @Override + public void setEnabled(boolean enabled) { + for (Widget widget : getWidget()) { + if (widget instanceof Radio) { + Radio radio = (Radio) widget; + radio.setEnabled(enabled); + } + } + } + @Override public boolean focus() { for (Widget widget : getWidget()) { diff --git a/perun-wui-registrar/src/main/java/cz/metacentrum/perun/wui/registrar/widgets/items/TextArea.java b/perun-wui-registrar/src/main/java/cz/metacentrum/perun/wui/registrar/widgets/items/TextArea.java index 72d7589a..1d341c93 100644 --- a/perun-wui-registrar/src/main/java/cz/metacentrum/perun/wui/registrar/widgets/items/TextArea.java +++ b/perun-wui-registrar/src/main/java/cz/metacentrum/perun/wui/registrar/widgets/items/TextArea.java @@ -43,6 +43,13 @@ protected Widget initWidget() { } + @Override + public void setEnabled(boolean enabled) { + if (getBox() != null) { + getBox().setEnabled(enabled); + } + } + @Override public void validate(Events events) { validator.validate(this, events); diff --git a/perun-wui-registrar/src/main/java/cz/metacentrum/perun/wui/registrar/widgets/items/WidgetBox.java b/perun-wui-registrar/src/main/java/cz/metacentrum/perun/wui/registrar/widgets/items/WidgetBox.java index 291ce45e..31864d69 100644 --- a/perun-wui-registrar/src/main/java/cz/metacentrum/perun/wui/registrar/widgets/items/WidgetBox.java +++ b/perun-wui-registrar/src/main/java/cz/metacentrum/perun/wui/registrar/widgets/items/WidgetBox.java @@ -15,6 +15,7 @@ import org.gwtbootstrap3.client.ui.constants.IconType; import org.gwtbootstrap3.client.ui.html.Paragraph; + /** * WidgetBox represent shared logic for ListBox and MapBox. * @@ -23,6 +24,8 @@ public class WidgetBox extends PerunFormItemEditable { protected Widget widget; + protected PerunButton addButton; + public WidgetBox(PerunForm form, ApplicationFormItemData item, String lang) { super(form, item, lang); @@ -54,7 +57,7 @@ protected Widget initWidget() { VerticalPanel vp = new VerticalPanel(); vp.setWidth("100%"); vp.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); - PerunButton addButton = generateAddButton(vp); + addButton = generateAddButton(vp); addButton.setIcon(IconType.PLUS); addButton.setType(ButtonType.SUCCESS); addButton.setMarginRight(40);