use of com.evolveum.midpoint.web.component.input.QNameObjectTypeChoiceRenderer in project midpoint by Evolveum.
the class DropDownChoicePanelFactory method getPanel.
@Override
protected InputPanel getPanel(PrismPropertyPanelContext<QName> panelCtx) {
List<QName> typesList;
if (AssignmentType.F_FOCUS_TYPE.equals(panelCtx.getDefinitionName())) {
typesList = WebComponentUtil.createFocusTypeList();
} else if ((ObjectCollectionType.F_TYPE.equals(panelCtx.getDefinitionName()) || GuiObjectListViewType.F_TYPE.equals(panelCtx.getDefinitionName())) && panelCtx.unwrapWrapperModel().getParent().getDefinition() != null && (ObjectCollectionType.class.equals(panelCtx.unwrapWrapperModel().getParent().getDefinition().getTypeClass()) || GuiObjectListViewType.class.equals(panelCtx.unwrapWrapperModel().getParent().getDefinition().getTypeClass()))) {
typesList = WebComponentUtil.createContainerableTypesQnameList();
} else {
typesList = WebComponentUtil.createObjectTypeList();
}
DropDownChoicePanel<QName> typePanel = new DropDownChoicePanel<QName>(panelCtx.getComponentId(), panelCtx.getRealValueModel(), Model.ofList(typesList), new QNameObjectTypeChoiceRenderer(), true);
typePanel.getBaseFormComponent().add(new EmptyOnChangeAjaxFormUpdatingBehavior());
typePanel.setOutputMarkupId(true);
return typePanel;
}
use of com.evolveum.midpoint.web.component.input.QNameObjectTypeChoiceRenderer in project midpoint by Evolveum.
the class ReferenceValueSearchPopupPanel method customizationPopoverForm.
@Override
protected void customizationPopoverForm(MidpointForm midpointForm) {
FeedbackAlerts feedback = new FeedbackAlerts(ID_FEEDBACK);
feedback.setOutputMarkupId(true);
midpointForm.add(feedback);
PropertyModel<String> oidModel = new PropertyModel<>(getModel(), "oid") {
@Override
public void setObject(String object) {
super.setObject(object);
if (StringUtils.isBlank(object)) {
ReferenceValueSearchPopupPanel.this.getModelObject().asReferenceValue().setObject(null);
ReferenceValueSearchPopupPanel.this.getModelObject().setTargetName(null);
ReferenceValueSearchPopupPanel.this.getModelObject().setRelation(null);
}
}
};
TextField<String> oidField = new TextField<>(ID_OID, oidModel);
oidField.add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
oidField.setOutputMarkupId(true);
oidField.add(new EnableBehaviour(this::isItemPanelEnabled));
midpointForm.add(oidField);
ReferenceAutocomplete nameField = new ReferenceAutocomplete(ID_NAME, Model.of(getModelObject()), new AutoCompleteReferenceRenderer(), getPageBase()) {
private static final long serialVersionUID = 1L;
@Override
protected boolean isAllowedNotFoundObjectRef() {
return ReferenceValueSearchPopupPanel.this.isAllowedNotFoundObjectRef();
}
@Override
protected <O extends ObjectType> Class<O> getReferenceTargetObjectType() {
if (getModelObject() != null && getModelObject().getType() != null) {
return (Class<O>) WebComponentUtil.qnameToClass(PrismContext.get(), getModelObject().getType());
}
return super.getReferenceTargetObjectType();
}
};
feedback.setFilter(new ComponentFeedbackMessageFilter(nameField));
nameField.getBaseFormComponent().add(new AjaxFormComponentUpdatingBehavior("blur") {
private static final long serialVersionUID = 1L;
@Override
protected void onUpdate(AjaxRequestTarget target) {
updateModel(nameField.getBaseFormComponent().getModelObject(), midpointForm, target);
}
});
nameField.setOutputMarkupId(true);
nameField.add(new EnableBehaviour(this::isItemPanelEnabled));
midpointForm.add(nameField);
DropDownChoicePanel<QName> type = new DropDownChoicePanel<>(ID_TYPE, new PropertyModel<>(getModel(), "type"), Model.ofList(getSupportedTargetList()), new QNameObjectTypeChoiceRenderer(), true);
type.setOutputMarkupId(true);
type.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isEnabled() {
return getSupportedTargetList().size() > 1 && isItemPanelEnabled();
}
});
type.getBaseFormComponent().add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
type.getBaseFormComponent().add(new AjaxFormComponentUpdatingBehavior("change") {
private static final long serialVersionUID = 1L;
@Override
protected void onUpdate(AjaxRequestTarget target) {
ObjectReferenceType ref = nameField.getAutoCompleteConverter(ObjectReferenceType.class, null).convertToObject(nameField.getBaseFormComponent().getValue(), WebComponentUtil.getCurrentLocale());
updateModel(ref, midpointForm, target);
target.add(oidField);
target.add(ReferenceValueSearchPopupPanel.this);
}
});
midpointForm.add(type);
WebMarkupContainer relationContainer = new WebMarkupContainer(ID_RELATION_CONTAINER);
midpointForm.add(relationContainer);
relationContainer.add(new VisibleBehaviour(() -> getAllowedRelations().size() > 0));
List<QName> allowedRelations = new ArrayList<>(getAllowedRelations());
DropDownChoicePanel<QName> relation = new DropDownChoicePanel<>(ID_RELATION, new PropertyModel<>(getModel(), "relation"), Model.ofList(allowedRelations), new QNameObjectTypeChoiceRenderer(), true);
relation.setOutputMarkupId(true);
relation.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isEnabled() {
return getAllowedRelations().size() > 1 && isItemPanelEnabled();
}
});
relation.getBaseFormComponent().add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
relationContainer.add(relation);
AjaxButton selectObject = new AjaxButton(ID_SELECT_OBJECT_BUTTON, createStringResource("ReferenceValueSearchPopupPanel.selectObject")) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
List<QName> supportedTypes = getSupportedTargetList();
if (CollectionUtils.isEmpty(supportedTypes)) {
supportedTypes = WebComponentUtil.createObjectTypeList();
}
ObjectBrowserPanel<O> objectBrowserPanel = new ObjectBrowserPanel<>(getPageBase().getMainPopupBodyId(), null, supportedTypes, false, getPageBase(), null) {
private static final long serialVersionUID = 1L;
@Override
protected void onSelectPerformed(AjaxRequestTarget target, O object) {
getPageBase().hideMainPopup(target);
if (ReferenceValueSearchPopupPanel.this.getModel().getObject() == null) {
ReferenceValueSearchPopupPanel.this.getModel().setObject(new ObjectReferenceType());
}
ReferenceValueSearchPopupPanel.this.getModelObject().setOid(object.getOid());
ReferenceValueSearchPopupPanel.this.getModelObject().setTargetName(object.getName());
ReferenceValueSearchPopupPanel.this.getModelObject().setType(object.asPrismObject().getComplexTypeDefinition().getTypeName());
target.add(oidField);
target.add(nameField);
target.add(type);
}
};
getPageBase().showMainPopup(objectBrowserPanel, target);
}
};
selectObject.add(new VisibleBehaviour(() -> getPageBase().getMainPopup().getContentComponent() == null));
midpointForm.add(selectObject);
}
use of com.evolveum.midpoint.web.component.input.QNameObjectTypeChoiceRenderer in project midpoint by Evolveum.
the class ChooseFocusTypeAndRelationDialogPanel method initLayout.
private void initLayout() {
MessagePanel warningMessage = new MessagePanel(ID_WARNING_FEEDBACK, MessagePanel.MessagePanelType.WARN, getWarningMessageModel());
warningMessage.setOutputMarkupId(true);
warningMessage.add(new VisibleBehaviour(() -> getWarningMessageModel() != null));
add(warningMessage);
DropDownFormGroup<QName> type = new DropDownFormGroup<>(ID_OBJECT_TYPE, Model.of(getDefaultObjectType()), Model.ofList(getSupportedObjectTypes()), new QNameObjectTypeChoiceRenderer(), createStringResource("chooseFocusTypeAndRelationDialogPanel.type"), "chooseFocusTypeAndRelationDialogPanel.tooltip.type", "col-md-4", "col-md-8", true);
type.getInput().add(new EmptyOnChangeAjaxFormUpdatingBehavior());
type.setOutputMarkupId(true);
type.add(new VisibleBehaviour(this::isFocusTypeSelectorVisible));
add(type);
IModel<Map<String, String>> options = new Model(null);
options.setObject(new HashMap<>());
ListMultipleChoicePanel<QName> relation = new ListMultipleChoicePanel<>(ID_RELATION, Model.ofList(getDefaultRelations()), new ListModel<>(getSupportedRelations()), WebComponentUtil.getRelationChoicesRenderer(getPageBase()), options);
relation.getBaseFormComponent().add(new EmptyOnChangeAjaxFormUpdatingBehavior());
relation.setOutputMarkupId(true);
add(relation);
WebMarkupContainer relationRequired = new WebMarkupContainer(ID_RELATION_REQUIRED);
relationRequired.add(new VisibleBehaviour((this::isRelationRequired)));
add(relationRequired);
Label label = new Label(ID_INFO_MESSAGE, getModel());
label.add(new VisibleBehaviour(() -> getModel() != null && getModelObject() != null));
add(label);
AjaxButton confirmButton = new AjaxButton(ID_BUTTON_OK, createStringResource("Button.ok")) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
DropDownFormGroup<QName> type = getTypePanel(getParent());
QName typeChosen = type.getModelObject();
ListMultipleChoicePanel<QName> relation = getRelationPanel(getParent());
Collection<QName> relationChosen = relation.getModelObject();
if (relationChosen.contains(PrismConstants.Q_ANY)) {
relationChosen = getSupportedRelations();
}
ChooseFocusTypeAndRelationDialogPanel.this.okPerformed(typeChosen, relationChosen, target);
getPageBase().hideMainPopup(target);
}
};
add(confirmButton);
AjaxButton cancelButton = new AjaxButton(ID_CANCEL_OK, createStringResource("Button.cancel")) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
getPageBase().hideMainPopup(target);
}
};
add(cancelButton);
AjaxButton configuredButton = new AjaxButton(ID_CONFIGURE_TASK, new StringResourceModel("ConfigureTaskConfirmationPanel.configure", this, null)) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
DropDownFormGroup<QName> type = getTypePanel(getParent());
QName typeChosen = type.getModelObject();
ListMultipleChoicePanel<QName> relation = getRelationPanel(getParent());
Collection<QName> relationChosen = relation.getModelObject();
PrismObject<TaskType> task = getTask(typeChosen, relationChosen, target);
if (task == null) {
return;
}
((PageBase) getPage()).hideMainPopup(target);
WebComponentUtil.dispatchToObjectDetailsPage(task, true, ChooseFocusTypeAndRelationDialogPanel.this);
}
};
configuredButton.add(new VisibleBehaviour(this::isTaskConfigureButtonVisible));
add(configuredButton);
}
use of com.evolveum.midpoint.web.component.input.QNameObjectTypeChoiceRenderer in project midpoint by Evolveum.
the class DefinitionScopePanel method initLayout.
protected void initLayout() {
final TextField nameField = new TextField(ID_NAME, new PropertyModel<>(getModel(), DefinitionScopeDto.F_NAME));
nameField.add(new VisibleEnableBehaviour() {
@Override
public boolean isEnabled() {
return true;
}
});
add(nameField);
final TextArea descriptionField = new TextArea(ID_DESCRIPTION, new PropertyModel<>(getModel(), DefinitionScopeDto.F_DESCRIPTION));
descriptionField.add(new VisibleEnableBehaviour() {
@Override
public boolean isEnabled() {
return true;
}
});
add(descriptionField);
DropDownChoicePanel objectTypeChooser = new DropDownChoicePanel(ID_OBJECT_TYPE_CHOOSER, new PropertyModel(getModel(), DefinitionScopeDto.F_OBJECT_TYPE), WebComponentUtil.createReadonlyModelFromEnum(DefinitionScopeObjectType.class), new EnumChoiceRenderer<DefinitionScopeObjectType>());
add(objectTypeChooser);
add(WebComponentUtil.createHelp(ID_OBJECT_TYPE_HELP));
TextArea filterTextArea = new TextArea(ID_SEARCH_FILTER, new PropertyModel<String>(getModel(), DefinitionScopeDto.F_SEARCH_FILTER_TEXT));
filterTextArea.setOutputMarkupId(true);
add(filterTextArea);
add(WebComponentUtil.createHelp(ID_SEARCH_FILTER_HELP));
add(new CheckBox(ID_INCLUDE_ASSIGNMENTS, new PropertyModel<>(getModel(), DefinitionScopeDto.F_INCLUDE_ASSIGNMENTS)));
add(new CheckBox(ID_INCLUDE_INDUCEMENTS, new PropertyModel<>(getModel(), DefinitionScopeDto.F_INCLUDE_INDUCEMENTS)));
add(WebComponentUtil.createHelp(ID_ASSIGNMENTS_INDUCEMENTS_HELP));
add(new CheckBox(ID_INCLUDE_RESOURCES, new PropertyModel<>(getModel(), DefinitionScopeDto.F_INCLUDE_RESOURCES)));
add(new CheckBox(ID_INCLUDE_ROLES, new PropertyModel<>(getModel(), DefinitionScopeDto.F_INCLUDE_ROLES)));
add(new CheckBox(ID_INCLUDE_ORGS, new PropertyModel<>(getModel(), DefinitionScopeDto.F_INCLUDE_ORGS)));
add(new CheckBox(ID_INCLUDE_SERVICES, new PropertyModel<>(getModel(), DefinitionScopeDto.F_INCLUDE_SERVICES)));
add(new CheckBox(ID_INCLUDE_USERS, new PropertyModel<>(getModel(), DefinitionScopeDto.F_INCLUDE_USERS)));
add(WebComponentUtil.createHelp(ID_INCLUDE_TARGET_TYPES_HELP));
add(new CheckBox(ID_INCLUDE_ENABLED_ITEMS_ONLY, new PropertyModel<>(getModel(), DefinitionScopeDto.F_INCLUDE_ENABLED_ITEMS_ONLY)));
add(WebComponentUtil.createHelp(ID_INCLUDE_BY_STATUS_HELP));
List<QName> relationsList = WebComponentUtil.getAllRelations(getPageBase());
relationsList.add(0, new QName(PrismConstants.NS_QUERY, "any"));
ListMultipleChoicePanel<QName> relationsPanel = new ListMultipleChoicePanel<QName>(ID_SCOPE_RELATIONS, new ListModel<QName>(getModelObject().getRelationList()), new ListModel<QName>(relationsList), new QNameObjectTypeChoiceRenderer(), null);
relationsPanel.setOutputMarkupId(true);
add(relationsPanel);
add(WebComponentUtil.createHelp(ID_SCOPE_RELATION_HELP));
}
Aggregations