PL-8671 ListEditor does not have focusComponent on opening

This commit is contained in:
Yuriy Artamonov 2017-02-17 18:51:21 +04:00
parent a9b3980813
commit 4cdd396a78

View File

@ -105,6 +105,8 @@ public class ListEditorPopupWindow extends AbstractWindow {
@Inject
private Action commit;
@Inject
private Button commitBtn;
@Override
public void init(Map<String, Object> params) {
@ -115,22 +117,28 @@ public class ListEditorPopupWindow extends AbstractWindow {
.setHeight(theme.getInt("cuba.gui.listEditor.popup.dialog.height"))
.setResizable(true);
if (editable == null) editable = true;
if (editable == null) {
editable = true;
}
initAddComponentLayout();
initValues();
commit.setEnabled(editable);
if (!editable) {
commitBtn.requestFocus();
}
}
public List<Object> getValue() {
return new ArrayList<>(valuesMap.keySet());
}
protected void initValues() {
if (values == null) values = new ArrayList<>();
if (values == null) {
values = new ArrayList<>();
}
valuesMap = values.stream()
.collect(Collectors.toMap(Function.identity(), o -> ListEditorHelper.getValueCaption(o, itemType)));
@ -192,6 +200,9 @@ public class ListEditorPopupWindow extends AbstractWindow {
addItemLayout.expand(componentForAdding);
componentForAdding.setEditable(editable);
if (editable) {
componentForAdding.requestFocus();
}
if (itemType != ListEditor.ItemType.ENTITY) {
Button addBtn = componentsFactory.createComponent(Button.class);
@ -350,4 +361,4 @@ public class ListEditorPopupWindow extends AbstractWindow {
public void cancel() {
close(CLOSE_ACTION_ID);
}
}
}