use of com.evolveum.midpoint.web.page.admin.PageAdminFocus in project midpoint by Evolveum.
the class PageBase method createFocusPageNewEditMenu.
private void createFocusPageNewEditMenu(List<MenuItem> submenu, String newKey, String editKey, final Class<? extends PageAdmin> newPageClass, boolean checkAuthorization) {
MenuItem edit = new MenuItem(createStringResource(editKey), newPageClass, null, new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isEnabled() {
return false;
}
@Override
public boolean isVisible() {
if (!getPage().getClass().equals(newPageClass)) {
return false;
}
if (getPage() instanceof PageAdminFocus) {
PageAdminFocus page = (PageAdminFocus) getPage();
return page.isEditingFocus();
} else if (getPage() instanceof PageResourceWizard) {
PageResourceWizard page = (PageResourceWizard) getPage();
return !page.isNewResource();
} else {
return false;
}
}
});
submenu.add(edit);
MenuItem newMenu = new MenuItem(createStringResource(newKey), newPageClass, null, new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
return !checkAuthorization || isMenuItemAuthorized(newPageClass);
}
}) {
private static final long serialVersionUID = 1L;
@Override
protected boolean isMenuActive() {
if (!PageBase.this.getPage().getClass().equals(newPageClass)) {
return false;
}
if (PageBase.this.getPage() instanceof PageAdminFocus) {
PageAdminFocus page = (PageAdminFocus) PageBase.this.getPage();
return !page.isEditingFocus();
} else if (PageBase.this.getPage() instanceof PageResourceWizard) {
PageResourceWizard page = (PageResourceWizard) PageBase.this.getPage();
return page.isNewResource();
} else {
return false;
}
}
};
submenu.add(newMenu);
}
use of com.evolveum.midpoint.web.page.admin.PageAdminFocus in project midpoint by Evolveum.
the class AssignmentEditorPanel method loadSecurityConstraints.
private ItemSecurityConstraints loadSecurityConstraints() {
PageBase pageBase = getPageBase();
if (pageBase == null || getModelObject().getTargetRef() == null) {
return null;
}
PrismObject<? extends FocusType> operationObject = null;
if (pageBase instanceof PageAdminFocus) {
operationObject = ((PageAdminFocus) pageBase).getObjectWrapper().getObject();
} else if (// shopping cart assignment details panels
(pageBase instanceof PageAssignmentDetails || pageBase instanceof PageAssignmentsList) && !pageBase.getSessionStorage().getRoleCatalog().isMultiUserRequest()) {
String targetUserOid = pageBase.getSessionStorage().getRoleCatalog().isSelfRequest() ? pageBase.getPrincipalFocus().getOid() : pageBase.getSessionStorage().getRoleCatalog().getTargetUserOidsList().get(0);
Task task = pageBase.createSimpleTask(OPERATION_LOAD_ASSIGNMENT_TARGET_USER_OBJECT);
OperationResult result = new OperationResult(OPERATION_LOAD_ASSIGNMENT_TARGET_USER_OBJECT);
operationObject = WebModelServiceUtils.loadObject(UserType.class, targetUserOid, pageBase, task, result);
}
if (operationObject == null) {
return null;
}
String targetObjectOid = getModelObject().getTargetRef().getOid();
Task task = pageBase.createSimpleTask(OPERATION_LOAD_TARGET_OBJECT);
OperationResult result = new OperationResult(OPERATION_LOAD_TARGET_OBJECT);
PrismObject<AbstractRoleType> targetRefObject = WebModelServiceUtils.loadObject(AbstractRoleType.class, targetObjectOid, pageBase, task, result);
ItemSecurityConstraints constraints = null;
try {
constraints = pageBase.getModelInteractionService().getAllowedRequestAssignmentItems(operationObject, targetRefObject, task, result);
} catch (SchemaException | SecurityViolationException | ObjectNotFoundException | ExpressionEvaluationException | CommunicationException | ConfigurationException ex) {
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't load security constraints for assignment items.", ex);
}
return constraints;
}
use of com.evolveum.midpoint.web.page.admin.PageAdminFocus in project midpoint by Evolveum.
the class FocusProjectionsTabPanel method initLayout.
private void initLayout() {
IModel<Integer> deadShadows = new ReadOnlyModel<>(() -> countDeadShadows());
Label label = new Label(ID_DEAD_SHADOWS, deadShadows);
label.add(new VisibleBehaviour(() -> deadShadows.getObject() > 0));
add(label);
MultivalueContainerListPanelWithDetailsPanel<ShadowType> multivalueContainerListPanel = new MultivalueContainerListPanelWithDetailsPanel<ShadowType>(ID_SHADOW_TABLE, ShadowType.class) {
private static final long serialVersionUID = 1L;
@Override
protected ISelectableDataProvider<ShadowType, PrismContainerValueWrapper<ShadowType>> createProvider() {
return new ProjectionsListProvider(FocusProjectionsTabPanel.this, getSearchModel(), loadShadowModel()) {
@Override
protected PageStorage getPageStorage() {
PageStorage storage = getSession().getSessionStorage().getPageStorageMap().get(SessionStorage.KEY_FOCUS_PROJECTION_TABLE);
if (storage == null) {
storage = getSession().getSessionStorage().initPageStorage(SessionStorage.KEY_FOCUS_PROJECTION_TABLE);
}
return storage;
}
};
}
@Override
protected void newItemPerformed(AjaxRequestTarget target, AssignmentObjectRelation relation) {
List<QName> supportedTypes = new ArrayList<>(1);
supportedTypes.add(ResourceType.COMPLEX_TYPE);
PageBase pageBase = FocusProjectionsTabPanel.this.getPageBase();
ObjectBrowserPanel<ResourceType> resourceSelectionPanel = new ObjectBrowserPanel<ResourceType>(pageBase.getMainPopupBodyId(), ResourceType.class, supportedTypes, true, pageBase) {
private static final long serialVersionUID = 1L;
@Override
protected void addPerformed(AjaxRequestTarget target, QName type, List<ResourceType> selected) {
FocusProjectionsTabPanel.this.addSelectedAccountPerformed(target, selected);
}
};
resourceSelectionPanel.setOutputMarkupId(true);
pageBase.showMainPopup(resourceSelectionPanel, target);
}
@Override
protected boolean isCreateNewObjectVisible() {
PrismObjectDefinition<F> def = getObjectWrapper().getObject().getDefinition();
PrismReferenceDefinition ref = def.findReferenceDefinition(UserType.F_LINK_REF);
return (ref.canRead() && ref.canAdd());
}
@Override
protected IModel<PrismContainerWrapper<ShadowType>> getContainerModel() {
return null;
}
@Override
protected TableId getTableId() {
return UserProfileStorage.TableId.FOCUS_PROJECTION_TABLE;
}
@Override
protected List<IColumn<PrismContainerValueWrapper<ShadowType>, String>> createDefaultColumns() {
return initBasicColumns();
}
@Override
public void editItemPerformed(AjaxRequestTarget target, IModel<PrismContainerValueWrapper<ShadowType>> rowModel, List<PrismContainerValueWrapper<ShadowType>> listItems) {
loadShadowIfNeeded(rowModel, target);
if (listItems != null) {
listItems.forEach(value -> {
if (((ShadowWrapper) value.getParent()).isLoadWithNoFetch()) {
((PageAdminFocus) getPage()).loadFullShadow((PrismObjectValueWrapper) value, target);
}
});
}
super.editItemPerformed(target, rowModel, listItems);
}
@Override
protected Search createSearch(Class<ShadowType> type) {
Search search = super.createSearch(type);
PropertySearchItem<Boolean> defaultDeadItem = search.findPropertySearchItem(ShadowType.F_DEAD);
if (defaultDeadItem != null) {
defaultDeadItem.setVisible(false);
}
addDeadSearchItem(search);
return search;
}
@Override
protected List<SearchItemDefinition> initSearchableItems(PrismContainerDefinition<ShadowType> containerDef) {
List<SearchItemDefinition> defs = new ArrayList<>();
SearchFactory.addSearchRefDef(containerDef, ShadowType.F_RESOURCE_REF, defs, AreaCategoryType.ADMINISTRATION, getPageBase());
SearchFactory.addSearchPropertyDef(containerDef, ShadowType.F_NAME, defs);
SearchFactory.addSearchPropertyDef(containerDef, ShadowType.F_INTENT, defs);
SearchFactory.addSearchPropertyDef(containerDef, ShadowType.F_KIND, defs);
return defs;
}
@Override
protected MultivalueContainerDetailsPanel<ShadowType> getMultivalueContainerDetailsPanel(ListItem<PrismContainerValueWrapper<ShadowType>> item) {
return FocusProjectionsTabPanel.this.getMultivalueContainerDetailsPanel(item);
}
};
add(multivalueContainerListPanel);
setOutputMarkupId(true);
}
use of com.evolveum.midpoint.web.page.admin.PageAdminFocus in project midpoint by Evolveum.
the class FocusAssignmentsTabPanel method initLayout.
private void initLayout() {
WebMarkupContainer assignments = new WebMarkupContainer(ID_ASSIGNMENTS);
assignments.setOutputMarkupId(true);
add(assignments);
AssignmentTablePanel panel = new AssignmentTablePanel(ID_ASSIGNMENTS_PANEL, createStringResource("FocusType.assignment"), assignmentsModel) {
@Override
protected boolean getAssignmentMenuVisibility() {
return !getObjectWrapper().isReadonly();
}
@Override
protected void showAllAssignments(AjaxRequestTarget target) {
List<AssignmentsPreviewDto> assignmentsPreviewDtos = ((PageAdminFocus) getPageBase()).recomputeAssignmentsPerformed(target);
AssignmentPreviewDialog dialog = new AssignmentPreviewDialog(getPageBase().getMainPopupBodyId(), assignmentsPreviewDtos, new ArrayList<String>(), getPageBase());
getPageBase().showMainPopup(dialog, target);
}
};
assignments.add(panel);
}
use of com.evolveum.midpoint.web.page.admin.PageAdminFocus in project midpoint by Evolveum.
the class PasswordPanel method initLayout.
private <F extends FocusType> void initLayout(final boolean isReadOnly, PrismObject<F> object) {
setOutputMarkupId(true);
final WebMarkupContainer inputContainer = new WebMarkupContainer(ID_INPUT_CONTAINER) {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
return passwordInputVisible;
}
};
inputContainer.setOutputMarkupId(true);
add(inputContainer);
ValuePolicyType valuePolicy = getValuePolicy(object);
LoadableModel<List<StringLimitationResult>> limitationsModel = new LoadableModel<>() {
@Override
protected List<StringLimitationResult> load() {
return getLimitationsForActualPassword(valuePolicy, object);
}
};
final PasswordLimitationsPanel validationPanel = new PasswordLimitationsPanel(ID_VALIDATION_PANEL, limitationsModel);
validationPanel.setOutputMarkupId(true);
inputContainer.add(validationPanel);
final PasswordTextField password1 = new SecureModelPasswordTextField(ID_PASSWORD_ONE, new PasswordModel(model)) {
private static final long serialVersionUID = 1L;
@Override
protected void onComponentTag(ComponentTag tag) {
super.onComponentTag(tag);
if (clearPasswordInput) {
tag.remove("value");
}
}
};
password1.add(AttributeAppender.append("onfocus", "initPasswordValidation({\n" + "container: $('#progress-bar-container'),\n" + "hierarchy: {\n" + " '0': ['progress-bar-danger', '" + PageBase.createStringResourceStatic(null, "PasswordPanel.strength.veryWeak").getString() + "'],\n" + " '25': ['progress-bar-danger', '" + PageBase.createStringResourceStatic(null, "PasswordPanel.strength.weak").getString() + "'],\n" + " '50': ['progress-bar-warning', '" + PageBase.createStringResourceStatic(null, "PasswordPanel.strength.good").getString() + "'],\n" + " '75': ['progress-bar-success', '" + PageBase.createStringResourceStatic(null, "PasswordPanel.strength.strong").getString() + "'],\n" + " '100': ['progress-bar-success', '" + PageBase.createStringResourceStatic(null, "PasswordPanel.strength.veryStrong").getString() + "']\n" + "}\n" + "})"));
password1.setRequired(false);
password1.setOutputMarkupId(true);
password1.add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
inputContainer.add(password1);
final PasswordTextField password2 = new SecureModelPasswordTextField(ID_PASSWORD_TWO, new PasswordModel(Model.of(new ProtectedStringType())));
password2.setRequired(false);
password2.setOutputMarkupId(true);
inputContainer.add(password2);
password1.add(new AjaxFormComponentUpdatingBehavior("change") {
private static final long serialVersionUID = 1L;
@Override
protected void onUpdate(AjaxRequestTarget target) {
boolean required = !StringUtils.isEmpty(password1.getModelObject());
password2.setRequired(required);
changePasswordPerformed();
}
});
IModel<String> password2ValidationModel = (IModel<String>) () -> {
String s1 = password1.getModelObject();
String s2 = password2.getValue();
if (StringUtils.isEmpty(s1) || StringUtils.isEmpty(s2)) {
return "";
}
if (!Objects.equals(s1, s2)) {
return PageBase.createStringResourceStatic(null, "passwordPanel.error").getString();
}
return "";
};
Label password2ValidationMessage = new Label(ID_PASSWORD_TWO_VALIDATION_MESSAGE, password2ValidationModel);
password2ValidationMessage.setOutputMarkupId(true);
inputContainer.add(password2ValidationMessage);
password1.add(new AjaxFormComponentUpdatingBehavior("keyup input") {
private static final long serialVersionUID = 1L;
@Override
protected void onUpdate(AjaxRequestTarget target) {
limitationsModel.reset();
validationPanel.refreshItems(target);
updatePasswordValidation(target);
target.add(password2ValidationMessage);
}
@Override
protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
super.updateAjaxAttributes(attributes);
attributes.setThrottlingSettings(new ThrottlingSettings(Duration.ofMillis(500), true));
attributes.setChannel(new AjaxChannel("Drop", AjaxChannel.Type.DROP));
}
});
PasswordValidator pass2Validator = new PasswordValidator(password1);
password2.add(pass2Validator);
password2.add(new AjaxFormComponentUpdatingBehavior("keyup input") {
private static final long serialVersionUID = 1L;
@Override
protected void onUpdate(AjaxRequestTarget target) {
target.add(password2ValidationMessage);
}
@Override
protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
super.updateAjaxAttributes(attributes);
attributes.setThrottlingSettings(new ThrottlingSettings(Duration.ofMillis(500), true));
attributes.setChannel(new AjaxChannel("Drop", AjaxChannel.Type.DROP));
}
});
final WebMarkupContainer linkContainer = new WebMarkupContainer(ID_LINK_CONTAINER) {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
return !passwordInputVisible;
}
};
inputContainer.setOutputMarkupId(true);
linkContainer.setOutputMarkupId(true);
add(linkContainer);
final Label passwordSetLabel = new Label(ID_PASSWORD_SET, new ResourceModel("passwordPanel.passwordSet"));
linkContainer.add(passwordSetLabel);
final Label passwordRemoveLabel = new Label(ID_PASSWORD_REMOVE, new ResourceModel("passwordPanel.passwordRemoveLabel"));
passwordRemoveLabel.setVisible(false);
linkContainer.add(passwordRemoveLabel);
AjaxLink<Void> link = new AjaxLink<Void>(ID_CHANGE_PASSWORD_LINK) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
clearPasswordInput = true;
setPasswordInput = false;
onLinkClick(target);
}
@Override
public boolean isVisible() {
return !passwordInputVisible && model != null && model.getObject() != null;
}
};
link.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
return !isReadOnly;
}
});
link.setBody(new ResourceModel("passwordPanel.passwordChange"));
link.setOutputMarkupId(true);
linkContainer.add(link);
final WebMarkupContainer removeButtonContainer = new WebMarkupContainer(ID_REMOVE_BUTTON_CONTAINER);
AjaxLink<Void> removePassword = new AjaxLink<Void>(ID_REMOVE_PASSWORD_LINK) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
onRemovePassword(model, target);
}
};
removePassword.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
PageBase pageBase = getPageBase();
if (pageBase == null) {
return false;
}
if (pageBase instanceof PageUserSelfProfile || pageBase instanceof PageOrgSelfProfile || pageBase instanceof PageRoleSelfProfile || pageBase instanceof PageServiceSelfProfile) {
return false;
}
if (pageBase instanceof PageAdminFocus && !((PageAdminFocus) pageBase).isLoggedInFocusPage() && model.getObject() != null) {
return true;
}
return false;
}
});
removePassword.setBody(new ResourceModel("passwordPanel.passwordRemove"));
removePassword.setOutputMarkupId(true);
removeButtonContainer.add(removePassword);
add(removeButtonContainer);
}
Aggregations