use of com.evolveum.midpoint.web.page.self.PageSelfProfile in project midpoint by Evolveum.
the class PasswordPanel method initLayout.
private void initLayout(final IModel<ProtectedStringType> model, final boolean isReadOnly) {
setOutputMarkupId(true);
final WebMarkupContainer inputContainer = new WebMarkupContainer(ID_INPUT_CONTAINER) {
@Override
public boolean isVisible() {
return passwordInputVisble;
}
};
inputContainer.setOutputMarkupId(true);
add(inputContainer);
final PasswordTextField password1 = new PasswordTextField(ID_PASSWORD_ONE, new PasswordModel(model));
password1.setRequired(false);
password1.setResetPassword(false);
password1.setOutputMarkupId(true);
password1.add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
inputContainer.add(password1);
final PasswordTextField password2 = new PasswordTextField(ID_PASSWORD_TWO, new Model<String>());
password2.setRequired(false);
password2.setResetPassword(false);
password2.setOutputMarkupId(true);
password2.add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
inputContainer.add(password2);
password1.add(new AjaxFormComponentUpdatingBehavior("change") {
@Override
protected void onUpdate(AjaxRequestTarget target) {
boolean required = !StringUtils.isEmpty(password1.getModel().getObject());
password2.setRequired(required);
//fix of MID-2463
// target.add(password2);
// target.appendJavaScript("$(\"#"+ password2.getMarkupId() +"\").focus()");
}
});
password2.add(new PasswordValidator(password1, password2));
final WebMarkupContainer linkContainer = new WebMarkupContainer(ID_LINK_CONTAINER) {
@Override
public boolean isVisible() {
return !passwordInputVisble;
}
};
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 link = new AjaxLink(ID_CHANGE_PASSWORD_LINK) {
@Override
public void onClick(AjaxRequestTarget target) {
onLinkClick(target);
}
@Override
public boolean isVisible() {
return !passwordInputVisble;
}
};
link.add(new VisibleEnableBehaviour() {
@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 removePassword = new AjaxLink(ID_REMOVE_PASSWORD_LINK) {
@Override
public void onClick(AjaxRequestTarget target) {
onRemovePassword(model, target);
}
};
removePassword.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
PageBase pageBase = (PageBase) getPage();
if (pageBase == null) {
return false;
}
if (pageBase instanceof PageSelfProfile) {
return false;
}
if (pageBase instanceof PageUser && model.getObject() != null && !model.getObject().isEmpty()) {
return true;
}
return false;
}
});
removePassword.setBody(new ResourceModel("passwordPanel.passwordRemove"));
removePassword.setOutputMarkupId(true);
removeButtonContainer.add(removePassword);
add(removeButtonContainer);
}
use of com.evolveum.midpoint.web.page.self.PageSelfProfile in project midpoint by Evolveum.
the class FocusMainPanel method addDefaultTabs.
protected void addDefaultTabs(final PageAdminObjectDetails<F> parentPage, List<ITab> tabs) {
FocusTabVisibleBehavior authorization = new FocusTabVisibleBehavior(unwrapModel(), ComponentConstants.UI_FOCUS_TAB_BASIC_URL);
tabs.add(new PanelTab(parentPage.createStringResource("pageAdminFocus.basic"), authorization) {
private static final long serialVersionUID = 1L;
@Override
public WebMarkupContainer createPanel(String panelId) {
return createFocusDetailsTabPanel(panelId, parentPage);
}
});
authorization = new FocusTabVisibleBehavior(unwrapModel(), ComponentConstants.UI_FOCUS_TAB_PROJECTIONS_URL);
tabs.add(new CountablePanelTab(parentPage.createStringResource("pageAdminFocus.projections"), authorization) {
private static final long serialVersionUID = 1L;
@Override
public WebMarkupContainer createPanel(String panelId) {
return createFocusProjectionsTabPanel(panelId, parentPage);
}
@Override
public String getCount() {
return Integer.toString(projectionModel.getObject() == null ? 0 : projectionModel.getObject().size());
}
});
authorization = new FocusTabVisibleBehavior(unwrapModel(), ComponentConstants.UI_FOCUS_TAB_PERSONAS_URL);
tabs.add(new PanelTab(parentPage.createStringResource("pageAdminFocus.personas"), authorization) {
private static final long serialVersionUID = 1L;
@Override
public WebMarkupContainer createPanel(String panelId) {
return new FocusPersonasTabPanel<F>(panelId, getMainForm(), getObjectModel(), parentPage);
}
});
authorization = new FocusTabVisibleBehavior(unwrapModel(), ComponentConstants.UI_FOCUS_TAB_ASSIGNMENTS_URL);
tabs.add(new CountablePanelTab(parentPage.createStringResource("pageAdminFocus.assignments"), authorization) {
private static final long serialVersionUID = 1L;
@Override
public WebMarkupContainer createPanel(String panelId) {
return createFocusAssignmentsTabPanel(panelId, parentPage);
}
@Override
public String getCount() {
return Integer.toString(assignmentsModel.count());
}
});
authorization = new FocusTabVisibleBehavior(unwrapModel(), ComponentConstants.UI_FOCUS_TAB_TASKS_URL);
tabs.add(new CountablePanelTab(parentPage.createStringResource("pageAdminFocus.tasks"), authorization) {
private static final long serialVersionUID = 1L;
@Override
public WebMarkupContainer createPanel(String panelId) {
return new FocusTasksTabPanel<F>(panelId, getMainForm(), getObjectModel(), taskDtoProvider, parentPage);
}
@Override
public String getCount() {
return Long.toString(taskDtoProvider == null ? 0L : taskDtoProvider.size());
}
});
if (!(parentPage instanceof PageSelfProfile)) {
authorization = new FocusTabVisibleBehavior(unwrapModel(), ComponentConstants.UI_FOCUS_TAB_REQUEST_ROLE_URL);
tabs.add(new PanelTab(parentPage.createStringResource("pageAdminFocus.request"), authorization) {
private static final long serialVersionUID = 1L;
@Override
public WebMarkupContainer createPanel(String panelId) {
return createRequestAssignmentTabPanel(panelId, parentPage);
}
});
}
}
Aggregations