use of org.apache.wicket.markup.repeater.RepeatingView in project midpoint by Evolveum.
the class PageAccountActivation method initLayout.
private void initLayout() {
WebMarkupContainer activationContainer = new WebMarkupContainer(ID_ACTIVATION_CONTAINER);
activationContainer.setOutputMarkupId(true);
add(activationContainer);
activationContainer.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
return !activated;
}
});
Form form = new Form<>(ID_MAIN_FORM);
activationContainer.add(form);
Label usernamePanel = new Label(ID_NAME, createStringResource("PageAccountActivation.activate.accounts.label", new PropertyModel<>(userModel, "name.orig")));
usernamePanel.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isEnabled() {
return false;
}
});
form.add(usernamePanel);
PasswordTextField passwordPanel = new PasswordTextField(ID_PASSWORD, Model.of(new String()));
form.add(passwordPanel);
AjaxSubmitButton confirmPasswrod = new AjaxSubmitButton(ID_CONFIRM) {
private static final long serialVersionUID = 1L;
@Override
protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
propagatePassword(target, form);
}
@Override
protected void onError(AjaxRequestTarget target, Form<?> form) {
getSession().error(getString("PageAccountActivation.account.activation.failed"));
target.add(getFeedbackPanel());
}
};
form.add(confirmPasswrod);
WebMarkupContainer confirmationContainer = new WebMarkupContainer(ID_CONFIRMATION_CONTAINER);
confirmationContainer.setOutputMarkupId(true);
confirmationContainer.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
return activated;
}
});
add(confirmationContainer);
AjaxLink<Void> linkToLogin = new AjaxLink<Void>(ID_LINK_TO_LOGIN) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
setResponsePage(PageLogin.class);
}
};
confirmationContainer.add(linkToLogin);
RepeatingView activatedShadows = new RepeatingView(ID_ACTIVATED_SHADOWS);
confirmationContainer.add(activatedShadows);
List<ShadowType> shadowsToActivate = getShadowsToActivate();
if (shadowsToActivate.isEmpty()) {
LOGGER.error("No accounts to validate for user {}", userModel.getObject());
getSession().warn(getString("PageAccountActivation.nothing.to.activate"));
throw new RestartResponseException(PageLogin.class);
}
for (ShadowType shadow : shadowsToActivate) {
Label shadowDesc = new Label(activatedShadows.newChildId(), WebComponentUtil.getName(shadow) + " on resource " + WebComponentUtil.getName(shadow.getResourceRef()));
activatedShadows.add(shadowDesc);
}
}
use of org.apache.wicket.markup.repeater.RepeatingView in project midpoint by Evolveum.
the class MetadataPanel method initLayout.
private void initLayout() {
WebMarkupContainer metadataBlock = new WebMarkupContainer(ID_METADATA_BLOCK);
metadataBlock.setOutputMarkupId(true);
add(metadataBlock);
WebMarkupContainer headerContainer = new WebMarkupContainer(ID_HEADER_CONTAINER);
headerContainer.setOutputMarkupId(true);
headerContainer.add(new AttributeAppender("class", "prism-header " + additionalHeaderStyle));
metadataBlock.add(headerContainer);
Label metadataHeader = new Label(ID_METADATA_LABEL, createStringResource("AssignmentEditorPanel.metadataBlock", header != null ? header : ""));
metadataHeader.setOutputMarkupId(true);
headerContainer.add(metadataHeader);
RepeatingView metadataRowRepeater = new RepeatingView(ID_METADATA_ROW);
metadataBlock.add(metadataRowRepeater);
for (QName qname : metadataFieldsList) {
WebMarkupContainer metadataRow = new WebMarkupContainer(metadataRowRepeater.newChildId());
metadataRow.setOutputMarkupId(true);
if (metadataFieldsList.indexOf(qname) % 2 != 0) {
metadataRow.add(new AttributeAppender("class", "stripe"));
}
metadataRowRepeater.add(metadataRow);
metadataRow.add(new Label(ID_METADATA_PROPERTY_KEY, createStringResource(DOT_CLASS + qname.getLocalPart())));
AbstractReadOnlyModel<String> metadataFieldModel = new AbstractReadOnlyModel<String>() {
@Override
public String getObject() {
PropertyModel<Object> tempModel = new PropertyModel<Object>(getModel(), qname.getLocalPart());
if (tempModel.getObject() instanceof XMLGregorianCalendar) {
return WebComponentUtil.getLocalizedDate((XMLGregorianCalendar) tempModel.getObject(), DateLabelComponent.MEDIUM_MEDIUM_STYLE);
} else if (tempModel.getObject() instanceof ObjectReferenceType) {
ObjectReferenceType ref = (ObjectReferenceType) tempModel.getObject();
return WebComponentUtil.getName(ref, getPageBase(), OPERATION_LOAD_USER);
} else if (tempModel.getObject() instanceof List) {
List list = (List) tempModel.getObject();
String result = "";
for (Object o : list) {
if (o instanceof ObjectReferenceType) {
if (result.length() > 0) {
result += ", ";
}
result += WebComponentUtil.getName((ObjectReferenceType) o, getPageBase(), OPERATION_LOAD_USER);
}
}
return result;
}
return "";
}
};
metadataRow.add(new Label(ID_METADATA_FILED, metadataFieldModel));
metadataRow.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return StringUtils.isNotEmpty(metadataFieldModel.getObject());
}
});
}
}
use of org.apache.wicket.markup.repeater.RepeatingView in project midpoint by Evolveum.
the class FocusPersonasTabPanel method initLayout.
private void initLayout() {
WebMarkupContainer container = new WebMarkupContainer(ID_PERSONAS_CONTAINER);
container.setOutputMarkupId(true);
add(container);
RepeatingView view = new RepeatingView(ID_PERSONAS_TABLE);
view.setOutputMarkupId(true);
container.add(view);
LoadableModel<List<PrismObject<FocusType>>> personasListModel = loadModel();
if (personasListModel.getObject() == null || personasListModel.getObject().size() == 0) {
WebMarkupContainer viewChild = new WebMarkupContainer(view.newChildId());
viewChild.setOutputMarkupId(true);
view.add(viewChild);
WebMarkupContainer emptyContainer = new WebMarkupContainer(ID_PERSONAS_SUMMARY);
emptyContainer.setOutputMarkupId(true);
viewChild.add(emptyContainer);
return;
}
Task task = pageBase.createSimpleTask(OPERATION_LOAD_PERSONAS);
for (PrismObject<FocusType> personaObject : personasListModel.getObject()) {
ObjectWrapper<FocusType> personaWrapper = ObjectWrapperUtil.createObjectWrapper(WebComponentUtil.getEffectiveName(personaObject, RoleType.F_DISPLAY_NAME), "", personaObject, ContainerStatus.MODIFYING, task, getPageBase());
WebMarkupContainer personaPanel = new WebMarkupContainer(view.newChildId());
personaPanel.setOutputMarkupId(true);
view.add(personaPanel);
if (personaObject.getCompileTimeClass().equals(UserType.class)) {
personaPanel.add(new UserSummaryPanel(ID_PERSONAS_SUMMARY, new Model<ObjectWrapper<UserType>>((ObjectWrapper) personaWrapper)));
} else if (personaObject.getCompileTimeClass().equals(RoleType.class)) {
personaPanel.add(new RoleSummaryPanel(ID_PERSONAS_SUMMARY, new Model<ObjectWrapper<RoleType>>((ObjectWrapper) personaWrapper)));
} else if (personaObject.getCompileTimeClass().equals(OrgType.class)) {
personaPanel.add(new OrgSummaryPanel(ID_PERSONAS_SUMMARY, new Model<ObjectWrapper<OrgType>>((ObjectWrapper) personaWrapper)));
} else if (personaObject.getCompileTimeClass().equals(ServiceType.class)) {
personaPanel.add(new ServiceSummaryPanel(ID_PERSONAS_SUMMARY, new Model<ObjectWrapper<ServiceType>>((ObjectWrapper) personaWrapper)));
}
}
}
use of org.apache.wicket.markup.repeater.RepeatingView in project midpoint by Evolveum.
the class LinksPanel method initLayout.
@Override
protected void initLayout() {
final List<RichHyperlinkType> linksList = getModel().getObject();
RepeatingView rowView = new RepeatingView(ID_LINKS_ROW);
int linksListSize = linksList == null ? 0 : linksList.size();
if (linksListSize > 0) {
int currentColumn = 0;
RepeatingView columnView = null;
WebMarkupContainer row = null;
boolean isRowAdded = false;
for (int i = 0; i < linksListSize; i++) {
final RichHyperlinkType link = linksList.get(i);
if (WebComponentUtil.isAuthorized(link.getAuthorization())) {
if (currentColumn == 0) {
row = new WebMarkupContainer(rowView.newChildId());
isRowAdded = false;
columnView = new RepeatingView(ID_LINKS_COLUMN);
}
WebMarkupContainer column = new WebMarkupContainer(columnView.newChildId());
Link linkItem = new Link(ID_LINK) {
@Override
public void onClick() {
}
@Override
protected void onComponentTag(final ComponentTag tag) {
super.onComponentTag(tag);
String rootContext = "";
//TODO: what is this for???
if (link.getTargetUrl() != null && !link.getTargetUrl().startsWith("http://") && !link.getTargetUrl().startsWith("https://") && !link.getTargetUrl().startsWith("www://") && !link.getTargetUrl().startsWith("//")) {
WebApplication webApplication = WebApplication.get();
if (webApplication != null) {
ServletContext servletContext = webApplication.getServletContext();
if (servletContext != null) {
rootContext = servletContext.getContextPath();
}
}
}
tag.put("href", rootContext + (link.getTargetUrl() == null ? "#" : link.getTargetUrl()));
}
};
linkItem.add(new Label(ID_IMAGE) {
@Override
protected void onComponentTag(final ComponentTag tag) {
super.onComponentTag(tag);
String cssClass = ICON_DEFAULT_CSS_CLASS;
if (link.getIcon() != null) {
cssClass = link.getIcon().getCssClass();
}
tag.put("class", "info-box-icon " + (link.getColor() != null ? (link.getColor().startsWith("bg-") ? link.getColor() : "bg-" + link.getColor()) : "") + " " + cssClass);
}
});
linkItem.add(new Label(ID_LABEL, new Model<String>() {
public String getObject() {
return link.getLabel();
}
}));
Label description = new Label(ID_DESCRIPTION, new Model<String>() {
public String getObject() {
return link.getDescription();
}
});
description.setEnabled(false);
linkItem.add(description);
column.add(linkItem);
columnView.add(column);
if (currentColumn == 1 || (linksList.indexOf(link) == linksListSize - 1)) {
row.add(columnView);
rowView.add(row);
currentColumn = 0;
isRowAdded = true;
} else {
currentColumn++;
}
} else {
LOGGER.trace("Link {} not authorized, skipping", link);
}
}
if (row != null && columnView != null && !isRowAdded) {
row.add(columnView);
rowView.add(row);
}
}
add(rowView);
}
Aggregations