use of com.evolveum.midpoint.gui.impl.prism.panel.ItemPanelSettingsBuilder in project midpoint by Evolveum.
the class DefinitionStagePanel method initLayout.
protected void initLayout(PageBase pageBase) {
TextField nameField = new TextField<>(ID_NAME, new PropertyModel<>(getModel(), StageDefinitionDto.F_NAME));
add(nameField);
TextArea descriptionField = new TextArea<>(ID_DESCRIPTION, new PropertyModel<>(getModel(), StageDefinitionDto.F_DESCRIPTION));
add(descriptionField);
TextField durationField = new TextField<>(ID_DURATION, new PropertyModel<>(getModel(), StageDefinitionDto.F_DURATION));
add(durationField);
add(WebComponentUtil.createHelp(ID_STAGE_DURATION_HELP));
TextField notifyBeforeDeadlineField = new TextField<>(ID_NOTIFY_BEFORE_DEADLINE, new PropertyModel<>(getModel(), StageDefinitionDto.F_NOTIFY_BEFORE_DEADLINE));
add(notifyBeforeDeadlineField);
add(WebComponentUtil.createHelp(ID_NOTIFY_BEFORE_DEADLINE_HELP));
add(new CheckBox(ID_NOTIFY_ONLY_WHEN_NO_DECISION, new PropertyModel<>(getModel(), StageDefinitionDto.F_NOTIFY_ONLY_WHEN_NO_DECISION)));
add(WebComponentUtil.createHelp(ID_NOTIFY_WHEN_NO_DECISION_HELP));
TextField reviewerNameField = new TextField<>(ID_REVIEWER_NAME, new PropertyModel<>(getModel(), StageDefinitionDto.F_REVIEWER_DTO + "." + AccessCertificationReviewerDto.F_NAME));
add(reviewerNameField);
TextArea reviewerDescriptionField = new TextArea<>(ID_REVIEWER_DESCRIPTION, new PropertyModel<>(getModel(), StageDefinitionDto.F_REVIEWER_DTO + "." + AccessCertificationReviewerDto.F_DESCRIPTION));
add(reviewerDescriptionField);
add(new CheckBox(ID_USE_TARGET_OWNER, new PropertyModel<>(getModel(), StageDefinitionDto.F_REVIEWER_DTO + "." + AccessCertificationReviewerDto.F_USE_TARGET_OWNER)));
add(new CheckBox(ID_USE_TARGET_APPROVER, new PropertyModel<>(getModel(), StageDefinitionDto.F_REVIEWER_DTO + "." + AccessCertificationReviewerDto.F_USE_TARGET_APPROVER)));
add(WebComponentUtil.createHelp(ID_TARGET_HELP));
add(new CheckBox(ID_USE_OBJECT_OWNER, new PropertyModel<>(getModel(), StageDefinitionDto.F_REVIEWER_DTO + "." + AccessCertificationReviewerDto.F_USE_OBJECT_OWNER)));
add(new CheckBox(ID_USE_OBJECT_APPROVER, new PropertyModel<>(getModel(), StageDefinitionDto.F_REVIEWER_DTO + "." + AccessCertificationReviewerDto.F_USE_OBJECT_APPROVER)));
add(WebComponentUtil.createHelp(ID_OBJECT_HELP));
AjaxCheckBox useObjectManagerCheckbox = new AjaxCheckBox(ID_USE_OBJECT_MANAGER, new PropertyModel<>(getModel(), StageDefinitionDto.F_REVIEWER_DTO + "." + AccessCertificationReviewerDto.F_USE_OBJECT_MANAGER_PRESENT)) {
@Override
protected void onUpdate(AjaxRequestTarget target) {
target.add(DefinitionStagePanel.this.get(ID_USE_OBJECT_MANAGER_DETAILS));
}
};
add(useObjectManagerCheckbox);
WebMarkupContainer useObjectManagerDetails = new WebMarkupContainer(ID_USE_OBJECT_MANAGER_DETAILS);
useObjectManagerDetails.add(new VisibleEnableBehaviour() {
@Override
public boolean isEnabled() {
return useObjectManagerCheckbox.getModelObject();
}
});
useObjectManagerDetails.setOutputMarkupId(true);
add(useObjectManagerDetails);
add(WebComponentUtil.createHelp(ID_USE_OBJECT_MANAGER_HELP));
TextField orgTypeField = new TextField<>(ID_USE_OBJECT_MANAGER_ORG_TYPE, new PropertyModel<>(getModel(), StageDefinitionDto.F_REVIEWER_DTO + "." + AccessCertificationReviewerDto.F_USE_OBJECT_MANAGER + "." + ManagerSearchDto.F_ORG_TYPE));
orgTypeField.add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
useObjectManagerDetails.add(orgTypeField);
useObjectManagerDetails.add(WebComponentUtil.createHelp(ID_USE_OBJECT_MANAGER_ORG_TYPE_HELP));
CheckBox allowSelf = new CheckBox(ID_USE_OBJECT_MANAGER_ALLOW_SELF, new PropertyModel<>(getModel(), StageDefinitionDto.F_REVIEWER_DTO + "." + AccessCertificationReviewerDto.F_USE_OBJECT_MANAGER + "." + ManagerSearchDto.F_ALLOW_SELF));
allowSelf.add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
useObjectManagerDetails.add(allowSelf);
useObjectManagerDetails.add(WebComponentUtil.createHelp(ID_USE_OBJECT_MANAGER_ALLOW_SELF_HELP));
try {
ItemPanelSettingsBuilder builder = new ItemPanelSettingsBuilder().visibilityHandler(iw -> ItemVisibility.AUTO);
Panel defaultOwnerRefPanel = pageBase.initItemPanel(ID_DEFAULT_REVIEWER_REF, ObjectReferenceType.COMPLEX_TYPE, new PropertyModel<>(getModel(), StageDefinitionDto.F_REVIEWER_DTO + "." + AccessCertificationReviewerDto.F_DEFAULT_REVIEWERS), builder.build());
add(defaultOwnerRefPanel);
add(WebComponentUtil.createHelp(ID_DEFAULT_REVIEWER_REF_HELP));
Panel additionalOwnerRefPanel = pageBase.initItemPanel(ID_ADDITIONAL_REVIEWER_REF, ObjectReferenceType.COMPLEX_TYPE, new PropertyModel<>(getModel(), StageDefinitionDto.F_REVIEWER_DTO + "." + AccessCertificationReviewerDto.F_ADDITIONAL_REVIEWERS), builder.build());
add(additionalOwnerRefPanel);
add(WebComponentUtil.createHelp(ID_ADDITIONAL_REVIEWER_REF_HELP));
} catch (SchemaException e) {
}
DropDownChoice outcomeStrategy1 = new DropDownChoice<>(ID_OUTCOME_STRATEGY, new PropertyModel<>(getModel(), StageDefinitionDto.F_OUTCOME_STRATEGY), WebComponentUtil.createReadonlyModelFromEnum(AccessCertificationCaseOutcomeStrategyType.class), new EnumChoiceRenderer<>(this));
add(outcomeStrategy1);
add(WebComponentUtil.createHelp(ID_OUTCOME_STRATEGY_HELP));
DropDownChoice<AccessCertificationResponseType> outcomeIfNoReviewers = new DropDownChoice<>(ID_OUTCOME_IF_NO_REVIEWERS, new PropertyModel<>(getModel(), StageDefinitionDto.F_OUTCOME_IF_NO_REVIEWERS), WebComponentUtil.createReadonlyModelFromEnum(AccessCertificationResponseType.class), new EnumChoiceRenderer<>(this));
add(outcomeIfNoReviewers);
add(WebComponentUtil.createHelp(ID_OUTCOME_IF_NO_REVIEWERS_HELP));
Label stopReviewOn = new Label(ID_STOP_REVIEW_ON, new IModel<String>() {
@Override
public String getObject() {
List<AccessCertificationResponseType> stopOn = getModelObject().getStopReviewOn();
return CertMiscUtil.getStopReviewOnText(stopOn, getPageBase());
}
});
add(stopReviewOn);
add(WebComponentUtil.createHelp(ID_STOP_REVIEW_ON_HELP));
}
use of com.evolveum.midpoint.gui.impl.prism.panel.ItemPanelSettingsBuilder in project midpoint by Evolveum.
the class ObjectBasicPanel method initLayout.
protected void initLayout() {
try {
getModelObject();
ItemPanelSettingsBuilder builder = new ItemPanelSettingsBuilder().visibilityHandler(this::getBasicTabVisibility);
Panel panel = getPageBase().initItemPanel(ID_BASIC_CONTAINER, getType(), getModel(), builder.build());
add(panel);
} catch (SchemaException e) {
LOGGER.error("Cannot create basic panel for system configuration.");
getSession().error("Cannot create basic panel for system configuration.");
}
}
use of com.evolveum.midpoint.gui.impl.prism.panel.ItemPanelSettingsBuilder in project midpoint by Evolveum.
the class TaskBasicTabPanel method initLayout.
private void initLayout() {
ItemPanelSettings settings = new ItemPanelSettingsBuilder().editabilityHandler(wrapper -> getTask().getHandlerUri() == null).build();
TaskHandlerSelectorPanel handlerSelectorPanel = new TaskHandlerSelectorPanel(ID_HANDLER, PrismPropertyWrapperModel.fromContainerWrapper(getModel(), TaskType.F_HANDLER_URI), settings) {
@Override
protected void onUpdatePerformed(AjaxRequestTarget target) {
String newHandlerUri = getTask().getHandlerUri();
if (StringUtils.isBlank(newHandlerUri) || !newHandlerUri.startsWith("http://")) {
LOGGER.trace("Nothing to do, handler still not set");
return;
}
TaskHandler taskHandler = getPageBase().getTaskManager().getHandler(newHandlerUri);
if (taskHandler == null) {
LOGGER.trace("Nothing to do, cannot find TaskHandler for {}", newHandlerUri);
return;
}
if (!WebComponentUtil.hasAnyArchetypeAssignment(getTask())) {
String archetypeOid = taskHandler.getArchetypeOid(newHandlerUri);
WebComponentUtil.addNewArchetype(TaskBasicTabPanel.this.getModelObject(), archetypeOid, target, getPageBase());
}
PrismObjectWrapperFactory<TaskType> wrapperFactory = TaskBasicTabPanel.this.getPageBase().findObjectWrapperFactory(getTask().asPrismObject().getDefinition());
Task task = getPageBase().createSimpleTask(OPERATION_UPDATE_WRAPPER);
OperationResult result = task.getResult();
WrapperContext ctx = new WrapperContext(task, result);
ctx.setDetailsPageTypeConfiguration(getDetailsPanelsConfiguration(getTask().asPrismObject()));
try {
wrapperFactory.updateWrapper(TaskBasicTabPanel.this.getModelObject(), ctx);
// TODO ugly hack: after updateWrapper method is called, both previously set items (handlerUri and assignments)
// are marked as NOT_CHANGED with the same value. We need to find a way how to force the ValueStatus
// or change the mechanism for computing deltas. Probably only the first will work
PrismPropertyWrapper<String> handlerWrapper = TaskBasicTabPanel.this.getModelObject().findProperty(ItemPath.create(TaskType.F_HANDLER_URI));
handlerWrapper.getValue().setStatus(ValueStatus.ADDED);
PrismContainerWrapper<AssignmentType> assignmentWrapper = TaskBasicTabPanel.this.getModelObject().findContainer(ItemPath.create(TaskType.F_ASSIGNMENT));
for (PrismContainerValueWrapper<AssignmentType> assignmentWrapperValue : assignmentWrapper.getValues()) {
if (WebComponentUtil.isArchetypeAssignment(assignmentWrapperValue.getRealValue())) {
assignmentWrapperValue.setStatus(ValueStatus.ADDED);
}
}
} catch (SchemaException | IllegalArgumentException e) {
LOGGER.error("Unexpected problem occurs during updating wrapper. Reason: {}", e.getMessage(), e);
}
updateHandlerPerformed(target);
}
};
handlerSelectorPanel.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return satisfyArchetypeAssignment();
}
});
add(handlerSelectorPanel);
ItemVisibilityHandler visibilityHandler = wrapper -> getBasicTabVisibility(wrapper.getPath());
ItemEditabilityHandler editabilityHandler = wrapper -> getBasicTabEditability(wrapper.getPath());
try {
ItemPanelSettingsBuilder builder = new ItemPanelSettingsBuilder().visibilityHandler(visibilityHandler).editabilityHandler(editabilityHandler).mandatoryHandler(getItemMandatoryHandler());
Panel panel = getPageBase().initItemPanel(ID_MAIN_PANEL, TaskType.COMPLEX_TYPE, getModel(), builder.build());
add(panel);
} catch (SchemaException e) {
LOGGER.error("Cannot create task basic panel: {}", e.getMessage(), e);
// TODO opertion result? localization?
getSession().error("Cannot create task basic panel");
throw new RestartResponseException(PageTasks.class);
}
}
use of com.evolveum.midpoint.gui.impl.prism.panel.ItemPanelSettingsBuilder in project midpoint by Evolveum.
the class AbstractObjectMainPanel method addPrismPropertyPanel.
/**
* Used in overlay
* @param parentComponent
* @param id
* @param typeName
* @param propertyPath
* @return
*/
protected Panel addPrismPropertyPanel(MarkupContainer parentComponent, String id, QName typeName, ItemPath propertyPath) {
try {
ItemPanelSettingsBuilder settingsBuilder = new ItemPanelSettingsBuilder();
settingsBuilder.visibilityHandler(wrapper -> ItemVisibility.AUTO);
Panel panel = getPageBase().initItemPanel(id, typeName, PrismPropertyWrapperModel.fromContainerWrapper(getObjectWrapperModel(), propertyPath), settingsBuilder.build());
parentComponent.add(panel);
return panel;
} catch (SchemaException e) {
LOGGER.error("Cannot create panel for {}", typeName, e);
getSession().error("Cannot create panel for " + typeName + ", reason: " + e.getMessage());
}
return null;
}
use of com.evolveum.midpoint.gui.impl.prism.panel.ItemPanelSettingsBuilder in project midpoint by Evolveum.
the class MultivalueContainerDetailsPanel method getBasicContainerValuePanel.
protected Panel getBasicContainerValuePanel(String idPanel) {
ItemPanelSettingsBuilder builder = new ItemPanelSettingsBuilder().visibilityHandler(wrapper -> getBasicTabVisibity(wrapper)).editabilityHandler(wrapper -> getBasicTabEditability(wrapper));
if (getMandatoryHandler() != null) {
builder.mandatoryHandler(getMandatoryHandler());
}
if (config != null) {
builder.panelConfiguration(config);
}
ItemPanelSettings settings = builder.build();
Panel containerValue = getPageBase().initContainerValuePanel(idPanel, getModel(), settings);
return containerValue;
}
Aggregations