private static final long serialVersionUID = 9101744072914090143L;
@Override
protected void populateItem(final ListItem<String> item) {
item.add(new Check("dcheck", item.getModel()));
item.add(new Label("dname", new ResourceModel(item.getModelObject(), item.getModelObject())));
}
};
dgroup.add(details);
if (names.getObject() == null || names.getObject().isEmpty()) {
final Fragment fragment = new Fragment("schemas", "emptyFragment", form);
form.add(fragment);
selectedSchemas.clear();
} else {
final Fragment fragment = new Fragment("schemas", "sfragment", form);
form.add(fragment);
final CheckGroup sgroup = new CheckGroup("sCheckGroup", new PropertyModel(this, "selectedSchemas"));
fragment.add(sgroup);
final ListView<String> schemas = new ListView<String>("schemas", names) {
private static final long serialVersionUID = 9101744072914090143L;
@Override
protected void populateItem(ListItem<String> item) {
item.add(new Check("scheck", item.getModel()));
item.add(new Label("sname", new ResourceModel(item.getModelObject(), item.getModelObject())));
}
};
sgroup.add(schemas);
}
if (dsnames.getObject() == null || dsnames.getObject().isEmpty()) {
final Fragment fragment = new Fragment("dschemas", "emptyFragment", form);
form.add(fragment);
selectedDerSchemas.clear();
} else {
final Fragment fragment = new Fragment("dschemas", "dsfragment", form);
form.add(fragment);
final CheckGroup dsgroup = new CheckGroup("dsCheckGroup", new PropertyModel(this, "selectedDerSchemas"));
fragment.add(dsgroup);
final ListView<String> derSchemas = new ListView<String>("derSchemas", dsnames) {
private static final long serialVersionUID = 9101744072914090143L;
@Override
protected void populateItem(ListItem<String> item) {
item.add(new Check("dscheck", item.getModel()));
item.add(new Label("dsname", new ResourceModel(item.getModelObject(), item.getModelObject())));
}
};
dsgroup.add(derSchemas);
}
if (vsnames.getObject() == null || vsnames.getObject().isEmpty()) {
final Fragment fragment = new Fragment("vschemas", "emptyFragment", form);
form.add(fragment);
selectedVirSchemas.clear();
} else {
final Fragment fragment = new Fragment("vschemas", "vsfragment", form);
form.add(fragment);
final CheckGroup vsgroup = new CheckGroup("vsCheckGroup", new PropertyModel(this, "selectedVirSchemas"));
fragment.add(vsgroup);
final ListView<String> virSchemas = new ListView<String>("virSchemas", vsnames) {
private static final long serialVersionUID = 9101744072914090143L;
@Override
protected void populateItem(ListItem<String> item) {
item.add(new Check("vscheck", item.getModel()));
item.add(new Label("vsname", new ResourceModel(item.getModelObject(), item.getModelObject())));
}
};
vsgroup.add(virSchemas);
}
final AjaxButton submit = new IndicatingAjaxButton("submit", new ResourceModel("submit")) {
private static final long serialVersionUID = -4804368561204623354L;
@Override
protected void onSubmit(final AjaxRequestTarget target, final Form<?> form) {
if (selectedDetails.size() + selectedSchemas.size() + selectedVirSchemas.size() + selectedDerSchemas.size()
> MAX_SELECTIONS) {
error(getString("tooManySelections"));
onError(target, form);
} else {
final Map<String, List<String>> prefs = new HashMap<String, List<String>>();
prefs.put(Constants.PREF_USERS_DETAILS_VIEW, selectedDetails);
prefs.put(Constants.PREF_USERS_ATTRIBUTES_VIEW, selectedSchemas);
prefs.put(Constants.PREF_USERS_DERIVED_ATTRIBUTES_VIEW, selectedDerSchemas);
prefs.put(Constants.PREF_USERS_VIRTUAL_ATTRIBUTES_VIEW, selectedVirSchemas);
prefMan.setList(getRequest(), getResponse(), prefs);
((BasePage) pageRef.getPage()).setModalResult(true);
window.close(target);
}
}
@Override
protected void onError(final AjaxRequestTarget target, final Form<?> form) {
target.add(feedbackPanel);
}
};
form.add(submit);
final AjaxButton cancel = new IndicatingAjaxButton("cancel", new ResourceModel("cancel")) {
private static final long serialVersionUID = -958724007591692537L;
@Override
protected void onSubmit(final AjaxRequestTarget target, final Form<?> form) {