use of org.apache.wicket.ajax.form.OnChangeAjaxBehavior in project midpoint by Evolveum.
the class AutoCompleteItemDefinitionPanel method initLayout.
private void initLayout(final IModel<ItemDefinition<?>> model) {
final Model<String> itemDefinitionAsStringModel = new Model<String>(null);
AutoCompleteTextField<String> input = new AutoCompleteTextField<String>(ID_INPUT, itemDefinitionAsStringModel, String.class, createAutoCompleteSettings()) {
private static final long serialVersionUID = 1L;
@Override
protected Iterator<String> getChoices(String input) {
List<String> defsAsString = new ArrayList<>();
for (ItemDefinition<?> def : listChoices(input).values()) {
defsAsString.add(def.getName().getLocalPart());
}
return defsAsString.iterator();
}
@Override
protected void onConfigure() {
itemDefinitionAsStringModel.setObject(null);
}
};
input.add(new OnChangeAjaxBehavior() {
private static final long serialVersionUID = 1L;
@Override
protected void onUpdate(AjaxRequestTarget target) {
String newValue = itemDefinitionAsStringModel.getObject();
if (StringUtils.isNotBlank(newValue)) {
ItemDefinition<?> def = listChoices("").get(newValue);
if (def != null) {
model.setObject(def);
}
}
}
});
add(input);
}
use of org.apache.wicket.ajax.form.OnChangeAjaxBehavior in project midpoint by Evolveum.
the class AutoCompleteQNamePanel method initLayout.
private void initLayout(final IModel<QName> model) {
setOutputMarkupId(true);
AutoCompleteSettings autoCompleteSettings = createAutoCompleteSettings();
final IModel<String> stringModel = new Model<String>() {
@Override
public void setObject(String object) {
super.setObject(object);
model.setObject(convertToQname(object));
}
};
// The inner autocomplete field is always String. Non-string auto-complete fields are problematic
final AutoCompleteTextField<String> input = new AutoCompleteTextField<String>(ID_INPUT, stringModel, String.class, autoCompleteSettings) {
private static final long serialVersionUID = 1L;
@Override
protected Iterator<String> getChoices(String input) {
return getIterator(input);
}
};
input.add(new OnChangeAjaxBehavior() {
private static final long serialVersionUID = 1L;
@Override
protected void onUpdate(AjaxRequestTarget target) {
String inputString = stringModel.getObject();
if (StringUtils.isBlank(inputString)) {
QName modelObject = model.getObject();
if (modelObject != null) {
model.setObject(null);
AutoCompleteQNamePanel.this.onChange(target);
}
} else {
QName inputQName = convertToQname(stringModel.getObject());
if (inputQName == null) {
// We have some input, but it does not match any QName. Just do nothing.
} else {
QName modelObject = model.getObject();
if (inputQName.equals(modelObject)) {
model.setObject(inputQName);
AutoCompleteQNamePanel.this.onChange(target);
}
}
}
}
});
add(input);
}
use of org.apache.wicket.ajax.form.OnChangeAjaxBehavior in project midpoint by Evolveum.
the class ObjectBrowserPanel method initLayout.
private void initLayout(Class<? extends O> type, final List<QName> supportedTypes, final boolean multiselect) {
WebMarkupContainer typePanel = new WebMarkupContainer(ID_TYPE_PANEL);
typePanel.setOutputMarkupId(true);
typePanel.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
return supportedTypes.size() != 1;
}
});
add(typePanel);
DropDownChoice<QName> typeSelect = new DropDownChoice<QName>(ID_TYPE, typeModel, new ListModel<QName>(supportedTypes), new QNameChoiceRenderer());
typeSelect.add(new OnChangeAjaxBehavior() {
private static final long serialVersionUID = 1L;
@Override
protected void onUpdate(AjaxRequestTarget target) {
ObjectListPanel<O> listPanel = (ObjectListPanel<O>) get(ID_TABLE);
listPanel = createObjectListPanel(qnameToCompileTimeClass(typeModel.getObject()), multiselect);
addOrReplace(listPanel);
target.add(listPanel);
}
});
typePanel.add(typeSelect);
ObjectListPanel<O> listPanel = createObjectListPanel(type, multiselect);
add(listPanel);
AjaxButton addButton = new AjaxButton(ID_BUTTON_ADD, createStringResource("userBrowserDialog.button.addButton")) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
List<O> selected = ((PopupObjectListPanel) getParent().get(ID_TABLE)).getSelectedObjects();
QName type = ObjectBrowserPanel.this.typeModel.getObject();
ObjectBrowserPanel.this.addPerformed(target, type, selected);
}
};
addButton.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
return multiselect;
}
});
add(addButton);
}
use of org.apache.wicket.ajax.form.OnChangeAjaxBehavior in project midpoint by Evolveum.
the class OrgMemberPanel method initSearch.
@Override
protected void initSearch(Form form) {
/// TODO: move to utils class??
List<ObjectTypes> objectTypes = Arrays.asList(ObjectTypes.values());
Collections.sort(objectTypes, new Comparator<ObjectTypes>() {
@Override
public int compare(ObjectTypes o1, ObjectTypes o2) {
Validate.notNull(o1);
Validate.notNull(o2);
String type1 = o1.getValue();
String type2 = o2.getValue();
return String.CASE_INSENSITIVE_ORDER.compare(type1, type2);
}
});
DropDownChoice<ObjectTypes> objectType = new DropDownChoice<ObjectTypes>(ID_SEARCH_BY_TYPE, Model.of(OBJECT_TYPES_DEFAULT), objectTypes, new EnumChoiceRenderer<ObjectTypes>());
objectType.add(new OnChangeAjaxBehavior() {
private static final long serialVersionUID = 1L;
@Override
protected void onUpdate(AjaxRequestTarget target) {
refreshTable(target);
}
});
objectType.setOutputMarkupId(true);
form.add(objectType);
DropDownChoice<String> seachScrope = new DropDownChoice<String>(ID_SEARCH_SCOPE, Model.of(SEARCH_SCOPE_SUBTREE), SEARCH_SCOPE_VALUES, new StringResourceChoiceRenderer("TreeTablePanel.search.scope"));
seachScrope.add(new OnChangeAjaxBehavior() {
private static final long serialVersionUID = 1L;
@Override
protected void onUpdate(AjaxRequestTarget target) {
refreshTable(target);
}
});
seachScrope.setOutputMarkupId(true);
form.add(seachScrope);
}
use of org.apache.wicket.ajax.form.OnChangeAjaxBehavior in project midpoint by Evolveum.
the class ResourceContentTabPanel method initLayout.
private void initLayout(final IModel<PrismObject<ResourceType>> model, final PageBase parentPage) {
setOutputMarkupId(true);
final Form mainForm = new Form(ID_MAIN_FORM);
mainForm.setOutputMarkupId(true);
mainForm.addOrReplace(initTable(model));
add(mainForm);
AutoCompleteTextPanel<String> intent = new AutoCompleteTextPanel<String>(ID_INTENT, new PropertyModel<String>(resourceContentSearch, "intent"), String.class) {
private static final long serialVersionUID = 1L;
@Override
public Iterator<String> getIterator(String input) {
RefinedResourceSchema refinedSchema = null;
try {
refinedSchema = RefinedResourceSchemaImpl.getRefinedSchema(model.getObject(), parentPage.getPrismContext());
} catch (SchemaException e) {
return new ArrayList<String>().iterator();
}
return RefinedResourceSchemaImpl.getIntentsForKind(refinedSchema, getKind()).iterator();
}
};
intent.getBaseFormComponent().add(new OnChangeAjaxBehavior() {
private static final long serialVersionUID = 1L;
@Override
protected void onUpdate(AjaxRequestTarget target) {
target.add(get(ID_REAL_OBJECT_CLASS));
updateResourceContentSearch();
mainForm.addOrReplace(initTable(model));
target.add(mainForm);
}
});
intent.setOutputMarkupId(true);
intent.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
return !isUseObjectClass();
}
});
add(intent);
Label realObjectClassLabel = new Label(ID_REAL_OBJECT_CLASS, new AbstractReadOnlyModel<String>() {
private static final long serialVersionUID = 1L;
@Override
public String getObject() {
RefinedObjectClassDefinition ocDef;
try {
RefinedResourceSchema refinedSchema = RefinedResourceSchemaImpl.getRefinedSchema(model.getObject(), parentPage.getPrismContext());
if (refinedSchema == null) {
return "NO SCHEMA DEFINED";
}
ocDef = refinedSchema.getRefinedDefinition(getKind(), getIntent());
if (ocDef != null) {
return ocDef.getObjectClassDefinition().getTypeName().getLocalPart();
}
} catch (SchemaException e) {
}
return "NOT FOUND";
}
});
realObjectClassLabel.setOutputMarkupId(true);
add(realObjectClassLabel);
AutoCompleteQNamePanel objectClassPanel = new AutoCompleteQNamePanel(ID_OBJECT_CLASS, new PropertyModel<QName>(resourceContentSearch, "objectClass")) {
private static final long serialVersionUID = 1L;
@Override
public Collection<QName> loadChoices() {
return createObjectClassChoices(model);
}
@Override
protected void onChange(AjaxRequestTarget target) {
LOGGER.trace("Object class panel update: {}", isUseObjectClass());
updateResourceContentSearch();
mainForm.addOrReplace(initTable(model));
target.add(mainForm);
}
};
objectClassPanel.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
return isUseObjectClass();
}
});
add(objectClassPanel);
AjaxLink<Boolean> repoSearch = new AjaxLink<Boolean>(ID_REPO_SEARCH, new PropertyModel<Boolean>(resourceContentSearch, "resourceSearch")) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
isRepoSearch = true;
getContentStorage(kind, SessionStorage.KEY_RESOURCE_PAGE_REPOSITORY_CONTENT).setResourceSearch(Boolean.FALSE);
getContentStorage(kind, SessionStorage.KEY_RESOURCE_PAGE_RESOURCE_CONTENT).setResourceSearch(Boolean.FALSE);
resourceContentSearch.getObject().setResourceSearch(Boolean.FALSE);
updateResourceContentSearch();
mainForm.addOrReplace(initRepoContent(model));
target.add(getParent().addOrReplace(mainForm));
target.add(this);
target.add(getParent().get(ID_RESOURCE_SEARCH).add(AttributeModifier.replace("class", "btn btn-sm btn-default")));
}
@Override
protected void onBeforeRender() {
super.onBeforeRender();
if (!getModelObject().booleanValue())
add(AttributeModifier.replace("class", "btn btn-sm btn-default active"));
}
};
add(repoSearch);
AjaxLink<Boolean> resourceSearch = new AjaxLink<Boolean>(ID_RESOURCE_SEARCH, new PropertyModel<Boolean>(resourceContentSearch, "resourceSearch")) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
isRepoSearch = false;
getContentStorage(kind, SessionStorage.KEY_RESOURCE_PAGE_REPOSITORY_CONTENT).setResourceSearch(Boolean.TRUE);
getContentStorage(kind, SessionStorage.KEY_RESOURCE_PAGE_RESOURCE_CONTENT).setResourceSearch(Boolean.TRUE);
updateResourceContentSearch();
resourceContentSearch.getObject().setResourceSearch(Boolean.TRUE);
mainForm.addOrReplace(initResourceContent(model));
target.add(getParent().addOrReplace(mainForm));
target.add(this.add(AttributeModifier.append("class", " active")));
target.add(getParent().get(ID_REPO_SEARCH).add(AttributeModifier.replace("class", "btn btn-sm btn-default")));
}
@Override
protected void onBeforeRender() {
super.onBeforeRender();
getModelObject().booleanValue();
if (getModelObject().booleanValue())
add(AttributeModifier.replace("class", "btn btn-sm btn-default active"));
}
};
add(resourceSearch);
}
Aggregations