use of com.evolveum.midpoint.gui.api.component.autocomplete.AutoCompleteQNamePanel 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