use of org.apache.wicket.behavior.AttributeAppender 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())));
IModel<String> metadataFieldModel = new IModel<String>() {
@Override
public String getObject() {
PropertyModel<Object> tempModel = new PropertyModel<>(getModel(), qname.getLocalPart());
if (tempModel.getObject() instanceof XMLGregorianCalendar) {
return WebComponentUtil.getLongDateTimeFormattedValue((XMLGregorianCalendar) tempModel.getObject(), getPageBase());
} 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.behavior.AttributeAppender in project midpoint by Evolveum.
the class RoleCatalogItemButton method initLayout.
private void initLayout() {
setOutputMarkupId(true);
WebMarkupContainer itemButtonContainer = new WebMarkupContainer(ID_ITEM_BUTTON_CONTAINER);
itemButtonContainer.setOutputMarkupId(true);
itemButtonContainer.add(new AttributeAppender("class", getBackgroundClass(getModelObject())));
add(itemButtonContainer);
AjaxLink<Void> inner = new AjaxLink<Void>(ID_INNER) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget ajaxRequestTarget) {
targetObjectDetailsPerformed(RoleCatalogItemButton.this.getModelObject(), ajaxRequestTarget);
}
};
inner.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isEnabled() {
return isAuthorizedForTargetObjectDetailsPage(getModelObject()) && (isMultiUserRequest() || canAssign(RoleCatalogItemButton.this.getModelObject()));
}
});
inner.add(new AttributeAppender("title", getModelObject().getName()));
itemButtonContainer.add(inner);
Label nameLabel = new Label(ID_INNER_LABEL, getModelObject().getName());
inner.add(nameLabel);
Label descriptionLabel = new Label(ID_INNER_DESCRIPTION, getModelObject().getTargetRef() != null ? getModelObject().getTargetRef().getDescription() : "");
descriptionLabel.setOutputMarkupId(true);
inner.add(descriptionLabel);
AjaxLink<Void> detailsLink = new AjaxLink<Void>(ID_DETAILS_LINK) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget ajaxRequestTarget) {
assignmentDetailsPerformed(RoleCatalogItemButton.this.getModelObject(), ajaxRequestTarget);
}
};
detailsLink.add(getAssignmentDetailsLinkVisibleBehavior());
detailsLink.add(AttributeAppender.append("title", AssignmentsUtil.getShoppingCartAssignmentsLimitReachedTitleModel(getPageBase())));
detailsLink.add(AttributeAppender.append("class", new LoadableModel<String>() {
@Override
protected String load() {
return detailsLink.isEnabled() ? "shopping-cart-item-button-details" : "shopping-cart-item-button-details-disabled";
}
}));
itemButtonContainer.add(detailsLink);
Label detailsLinkLabel = new Label(ID_DETAILS_LINK_LABEL, createStringResource("MultiButtonPanel.detailsLink"));
detailsLinkLabel.setRenderBodyOnly(true);
detailsLink.add(detailsLinkLabel);
AjaxLink<Void> detailsLinkIcon = new AjaxLink<Void>(ID_DETAILS_LINK_ICON) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
}
};
detailsLinkIcon.add(getAssignmentDetailsLinkVisibleBehavior());
detailsLink.add(detailsLinkIcon);
AjaxLink<Void> addToCartLink = new AjaxLink<Void>(ID_ADD_TO_CART_LINK) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget ajaxRequestTarget) {
addAssignmentPerformed(RoleCatalogItemButton.this.getModelObject(), ajaxRequestTarget);
}
};
addToCartLink.add(getFooterLinksEnableBehaviour());
addToCartLink.add(AttributeAppender.append("title", AssignmentsUtil.getShoppingCartAssignmentsLimitReachedTitleModel(getPageBase())));
addToCartLink.add(AttributeAppender.append("class", new LoadableModel<String>() {
@Override
protected String load() {
return addToCartLink.isEnabled() ? "shopping-cart-item-button-add" : "shopping-cart-item-button-add-disabled";
}
}));
itemButtonContainer.add(addToCartLink);
AjaxLink<Void> addToCartLinkIcon = new AjaxLink<Void>(ID_ADD_TO_CART_LINK_ICON) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
}
};
addToCartLinkIcon.add(getFooterLinksEnableBehaviour());
addToCartLink.add(addToCartLinkIcon);
WebMarkupContainer icon = new WebMarkupContainer(ID_TYPE_ICON);
icon.add(new AttributeAppender("class", WebComponentUtil.createDefaultBlackIcon(getModelObject().getType().getQname())));
itemButtonContainer.add(icon);
WebMarkupContainer alreadyAssignedIcon = new WebMarkupContainer(ID_ALREADY_ASSIGNED_ICON);
alreadyAssignedIcon.add(new AttributeAppender("title", getAlreadyAssignedIconTitleModel(getModelObject())));
alreadyAssignedIcon.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
return !isMultiUserRequest() && getModelObject().isAlreadyAssigned();
}
});
itemButtonContainer.add(alreadyAssignedIcon);
}
use of org.apache.wicket.behavior.AttributeAppender in project midpoint by Evolveum.
the class DoubleButtonPanel method initLayout.
private void initLayout() {
AjaxButton firstButton = new AjaxButton(ID_BUTTON_FIRST, createButtonStringResource(getFirstCaption())) {
@Override
public void onClick(AjaxRequestTarget target) {
firstPerformed(target, DoubleButtonPanel.this.getModel());
}
@Override
public boolean isEnabled() {
return isFirstEnabled(DoubleButtonPanel.this.getModel());
}
};
firstButton.add(new AttributeAppender("class", getFirstCssClass()));
AjaxButton secondButton = new AjaxButton(ID_BUTTON_SECOND, createButtonStringResource(getSecondCaption())) {
@Override
public void onClick(AjaxRequestTarget target) {
secondPerformed(target, DoubleButtonPanel.this.getModel());
}
@Override
public boolean isEnabled() {
return isSecondEnabled(DoubleButtonPanel.this.getModel());
}
};
secondButton.add(new AttributeAppender("class", getSecondCssClass()));
add(firstButton);
add(secondButton);
}
use of org.apache.wicket.behavior.AttributeAppender in project midpoint by Evolveum.
the class AssignmentConflictPanel method initLayout.
private void initLayout() {
setOutputMarkupId(true);
Form container = new MidpointForm<>(ID_PANEL_CONTAINER);
container.setOutputMarkupId(true);
add(container);
Label statusIconLabel = new Label(ID_STATUS_ICON);
statusIconLabel.add(new AttributeAppender("class", new IModel<String>() {
private static final long serialVersionUID = 1L;
@Override
public String getObject() {
return getModelObject() != null ? (getModelObject().isResolved() ? STATUS_FIXED : (getModelObject().isWarning() ? STATUS_WARNING : STATUS_ERROR)) : STATUS_ERROR;
}
}));
container.add(statusIconLabel);
Label existingAssignment = new Label(ID_EXISTING_ASSIGNMENT, new IModel<String>() {
private static final long serialVersionUID = 1L;
@Override
public String getObject() {
if (getModelObject() != null) {
String name = getModelObject().getAssignment1().getAssignmentTargetObject().asObjectable().getName() != null ? getModelObject().getAssignment1().getAssignmentTargetObject().asObjectable().getName().getOrig() : getModelObject().getAssignment1().getAssignmentTargetObject().getOid();
return name + " " + getMessageLabel(getModelObject().getAssignment1().isOldAssignment());
}
return "";
}
});
existingAssignment.add(new AttributeAppender("style", new IModel<String>() {
private static final long serialVersionUID = 1L;
@Override
public String getObject() {
return getModelObject() != null && getModelObject().getAssignment1().isResolved() ? "text-decoration: line-through;" : "";
}
}));
container.add(existingAssignment);
Label addedAssignment = new Label(ID_ADDED_ASSIGNMENT, new IModel<String>() {
private static final long serialVersionUID = 1L;
@Override
public String getObject() {
if (getModelObject() != null) {
String name = getModelObject().getAssignment2().getAssignmentTargetObject().asObjectable().getName() != null ? getModelObject().getAssignment2().getAssignmentTargetObject().asObjectable().getName().getOrig() : getModelObject().getAssignment2().getAssignmentTargetObject().getOid();
return name + " " + getMessageLabel(getModelObject().getAssignment2().isOldAssignment());
}
return "";
}
});
addedAssignment.add(new AttributeAppender("style", new IModel<String>() {
private static final long serialVersionUID = 1L;
@Override
public String getObject() {
return getModelObject() != null && getModelObject().getAssignment2().isResolved() ? "text-decoration: line-through;" : "";
}
}));
container.add(addedAssignment);
IModel<String> removeButtonTitleModel = new IModel<String>() {
private static final long serialVersionUID = 1L;
@Override
public String getObject() {
return getModelObject().getAssignment1().isResolved() ? createStringResource("AssignmentConflictPanel.undoAction").getString() : createStringResource("AssignmentConflictPanel.removeButton").getString();
}
};
AjaxSubmitButton removeButton = new AjaxSubmitButton(ID_REMOVE_BUTTON, removeButtonTitleModel) {
@Override
public void onSubmit(AjaxRequestTarget target) {
AssignmentConflictPanel.this.removeAssignmentPerformed(getModelObject().getAssignment1(), target);
}
};
removeButton.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
return getModelObject() != null;
}
@Override
public boolean isEnabled() {
return !getModelObject().getAssignment2().isResolved();
}
});
container.add(removeButton);
IModel<String> unselectButtonTitleModel = new IModel<String>() {
private static final long serialVersionUID = 1L;
@Override
public String getObject() {
return getModelObject().getAssignment2().isResolved() ? createStringResource("AssignmentConflictPanel.undoAction").getString() : createStringResource("AssignmentConflictPanel.removeButton").getString();
}
};
AjaxSubmitButton unselectButton = new AjaxSubmitButton(ID_UNSELECT_BUTTON, unselectButtonTitleModel) {
@Override
public void onSubmit(AjaxRequestTarget target) {
AssignmentConflictPanel.this.removeAssignmentPerformed(getModelObject().getAssignment2(), target);
}
};
unselectButton.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
return getModelObject() != null;
}
@Override
public boolean isEnabled() {
return !getModelObject().getAssignment1().isResolved();
}
});
container.add(unselectButton);
}
use of org.apache.wicket.behavior.AttributeAppender in project midpoint by Evolveum.
the class CapabilityStep method initLayout.
protected void initLayout() {
final ListDataProvider<CapabilityDto<CapabilityType>> capabilityProvider = new ListDataProvider<>(this, new PropertyModel<List<CapabilityDto<CapabilityType>>>(dtoModel, CapabilityStepDto.F_CAPABILITIES));
WebMarkupContainer tableBody = new WebMarkupContainer(ID_CAPABILITY_TABLE);
tableBody.setOutputMarkupId(true);
add(tableBody);
WebMarkupContainer configBody = new WebMarkupContainer(ID_CAPABILITY_CONFIG);
configBody.setOutputMarkupId(true);
add(configBody);
DataView<CapabilityDto<CapabilityType>> capabilityDataView = new DataView<CapabilityDto<CapabilityType>>(ID_CAPABILITY_ROW, capabilityProvider) {
@Override
protected void populateItem(final Item<CapabilityDto<CapabilityType>> capabilityRow) {
final CapabilityDto<CapabilityType> dto = capabilityRow.getModelObject();
AjaxLink<Void> name = new AjaxLink<Void>(ID_CAPABILITY_LINK) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
editCapabilityPerformed(target, dto);
}
};
Label label = new Label(ID_CAPABILITY_NAME, new IModel<String>() {
@Override
public String getObject() {
String rv = dto.getDisplayName();
if (Boolean.FALSE.equals(dto.getCapability().isEnabled())) {
rv += " " + getString("CapabilityStep.disabled");
}
return rv;
}
});
name.add(label);
capabilityRow.add(name);
Label tooltipLabel = new Label(ID_TOOLTIP, new Model<>());
if (dto.getTooltipKey() != null) {
tooltipLabel.add(new AttributeAppender("data-original-title", getString(dto.getTooltipKey())));
tooltipLabel.add(new InfoTooltipBehavior());
} else {
tooltipLabel.setVisible(false);
}
tooltipLabel.setOutputMarkupId(true);
tooltipLabel.setOutputMarkupPlaceholderTag(true);
name.add(tooltipLabel);
AjaxLink<Void> deleteLink = new AjaxLink<Void>(ID_CAPABILITY_DELETE) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
deleteCapabilityPerformed(target, dto);
}
};
deleteLink.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return !dto.isAmongNativeCapabilities() && !parentPage.isReadOnly();
}
});
name.add(deleteLink);
capabilityRow.add(AttributeModifier.replace("class", new IModel<Object>() {
@Override
public Object getObject() {
return isSelected(capabilityRow.getModelObject()) ? "success" : null;
}
}));
}
};
tableBody.add(capabilityDataView);
AjaxLink<Void> addLink = new AjaxLink<Void>(ID_CAPABILITY_ADD) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
addCapabilityPerformed(target);
}
};
parentPage.addEditingVisibleBehavior(addLink);
add(addLink);
ModalWindow dialog = new AddCapabilityDialog(DIALOG_SELECT_CAPABILITY, dtoModel) {
@Override
protected void addPerformed(AjaxRequestTarget target) {
addCapabilitiesPerformed(target, getSelectedData());
}
};
add(dialog);
}
Aggregations