use of org.apache.wicket.model.AbstractReadOnlyModel in project midpoint by Evolveum.
the class SceneButtonPanel method initLayout.
private void initLayout(final IModel<SceneDto> model) {
AjaxLink<String> minimize = new AjaxLink<String>(ID_MINIMIZE_BUTTON) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
minimizeOnClick(target);
}
};
add(minimize);
Label icon = new Label(ID_ICON);
icon.add(AttributeModifier.append("class", new AbstractReadOnlyModel<String>() {
private static final long serialVersionUID = 1L;
@Override
public String getObject() {
SceneDto dto = model.getObject();
if (dto.isMinimized()) {
return GuiStyleConstants.CLASS_ICON_EXPAND;
}
return GuiStyleConstants.CLASS_ICON_COLLAPSE;
}
}));
minimize.add(icon);
icon.add(new AttributeAppender("title", new AbstractReadOnlyModel<String>() {
private static final long serialVersionUID = 1L;
@Override
public String getObject() {
SceneDto dto = model.getObject();
if (dto.isMinimized()) {
return getString("prismOptionButtonPanel.maximize");
}
return getString("prismOptionButtonPanel.minimize");
}
}, ""));
}
use of org.apache.wicket.model.AbstractReadOnlyModel in project midpoint by Evolveum.
the class AutoRefreshPanel method initLayout.
private void initLayout(final Refreshable refreshable, boolean inSummaryPanel) {
final LinkIconPanel refreshNow = new LinkIconPanel(ID_REFRESH_NOW, new Model("fa fa-refresh"), createStringResource("autoRefreshPanel.refreshNow")) {
@Override
protected void onClickPerformed(AjaxRequestTarget target) {
refreshable.refresh(target);
}
};
refreshNow.setRenderBodyOnly(true);
add(refreshNow);
final LinkIconPanel resumeRefreshing = new LinkIconPanel(ID_START, new Model("fa fa-play"), createStringResource("autoRefreshPanel.resumeRefreshing")) {
@Override
protected void onClickPerformed(AjaxRequestTarget target) {
getModelObject().setEnabled(true);
refreshable.refresh(target);
startRefreshing(refreshable, target);
}
};
resumeRefreshing.setRenderBodyOnly(true);
resumeRefreshing.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return !getModelObject().isEnabled();
}
});
add(resumeRefreshing);
final LinkIconPanel pauseRefreshing = new LinkIconPanel(ID_PAUSE, new Model("fa fa-pause"), createStringResource("autoRefreshPanel.pauseRefreshing")) {
@Override
protected void onClickPerformed(AjaxRequestTarget target) {
getModelObject().setEnabled(false);
refreshable.refresh(target);
stopRefreshing(refreshable, target);
}
};
pauseRefreshing.setRenderBodyOnly(true);
pauseRefreshing.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return getModelObject().isEnabled();
}
});
add(pauseRefreshing);
final Label status = new Label(ID_STATUS, new AbstractReadOnlyModel<String>() {
@Override
public String getObject() {
AutoRefreshDto dto = getModelObject();
if (dto.isEnabled()) {
return createStringResource("autoRefreshPanel.refreshingEach", dto.getInterval() / 1000).getString();
} else {
return createStringResource("autoRefreshPanel.noRefreshing").getString();
}
}
});
status.setRenderBodyOnly(true);
add(status);
if (inSummaryPanel) {
add(new AttributeModifier("class", "summary-tag"));
}
}
use of org.apache.wicket.model.AbstractReadOnlyModel in project midpoint by Evolveum.
the class ObjectPolicyPanel method initLayout.
// public void updateModel(AjaxRequestTarget target, ObjectPolicyConfigurationTypeDto config) {
// model.setObject(new ObjectPolicyDialogDto(config, getPageBase()));
// target.add(getContent());
// }
public void initLayout() {
Form form = new Form(ID_FORM);
form.setOutputMarkupId(true);
add(form);
DropDownFormGroup type = new DropDownFormGroup<>(ID_TYPE, new PropertyModel<QName>(model, ObjectPolicyDialogDto.F_TYPE), createTypeChoiceList(), new QNameChoiceRenderer(), createStringResource("ObjectPolicyDialog.type"), ID_LABEL_SIZE, ID_INPUT_SIZE, false);
form.add(type);
type.getInput().setNullValid(false);
type.getInput().setRequired(true);
TextField<String> fieldSubtype = new TextField<>(ID_SUBTYPE, new PropertyModel<String>(model, ObjectPolicyDialogDto.F_SUBTYPE));
form.add(fieldSubtype);
form.add(fieldSubtype);
DropDownFormGroup template = new DropDownFormGroup<>(ID_OBJECT_TEMPLATE, new PropertyModel<ObjectTemplateConfigTypeReferenceDto>(model, ObjectPolicyDialogDto.F_TEMPLATE_REF), createObjectTemplateList(), new ChoiceableChoiceRenderer<ObjectTemplateConfigTypeReferenceDto>(), createStringResource("ObjectPolicyDialog.template"), ID_LABEL_SIZE, ID_INPUT_SIZE, false);
form.add(template);
template.getInput().setNullValid(false);
template.getInput().setRequired(true);
ListView repeater = new ListView<PropertyConstraintTypeDto>(ID_REPEATER, new PropertyModel<List<PropertyConstraintTypeDto>>(model, ObjectPolicyDialogDto.F_PROPERTY_LIST)) {
@Override
protected void populateItem(final ListItem item) {
WebMarkupContainer textWrapper = new WebMarkupContainer(ID_TEXT_WRAPPER);
textWrapper.add(AttributeAppender.prepend("class", new AbstractReadOnlyModel<String>() {
@Override
public String getObject() {
if (item.getIndex() > 0) {
return OFFSET_CLASS + " " + CLASS_MULTI_VALUE;
}
return null;
}
}));
item.add(textWrapper);
TextField property = new TextField<>(ID_PROPERTY, new PropertyModel<String>(item.getModel(), PropertyConstraintTypeDto.F_PROPERTY_PATH));
property.add(new AjaxFormComponentUpdatingBehavior("blur") {
@Override
protected void onUpdate(AjaxRequestTarget target) {
}
});
property.add(AttributeAppender.replace("placeholder", createStringResource("ObjectPolicyDialog.property.placeholder")));
textWrapper.add(property);
CheckBox oidBound = new CheckBox(ID_OID_BOUND, new PropertyModel<Boolean>(item.getModel(), PropertyConstraintTypeDto.F_OID_BOUND));
oidBound.add(AttributeModifier.replace("title", createStringResource("ObjectPolicyDialog.label.oidBound.help")));
textWrapper.add(oidBound);
WebMarkupContainer buttonGroup = new WebMarkupContainer(ID_BUTTON_GROUP);
buttonGroup.add(AttributeAppender.append("class", new AbstractReadOnlyModel<String>() {
@Override
public String getObject() {
if (item.getIndex() > 0) {
return CLASS_MULTI_VALUE;
}
return null;
}
}));
item.add(buttonGroup);
initButtons(buttonGroup, item);
}
};
form.add(repeater);
AjaxSubmitButton cancel = new AjaxSubmitButton(ID_BUTTON_CANCEL, createStringResource("ObjectPolicyDialog.button.cancel")) {
@Override
protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
cancelPerformed(target);
}
@Override
protected void onError(AjaxRequestTarget target, Form<?> form) {
cancelPerformed(target);
}
};
form.add(cancel);
AjaxSubmitButton save = new AjaxSubmitButton(ID_BUTTON_SAVE, createStringResource("ObjectPolicyDialog.button.save")) {
@Override
protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
savePerformed(target);
}
@Override
protected void onError(AjaxRequestTarget target, Form<?> form) {
target.add(form);
}
};
form.add(save);
}
use of org.apache.wicket.model.AbstractReadOnlyModel in project midpoint by Evolveum.
the class AssignmentEditorPanel method initBodyLayout.
protected void initBodyLayout(WebMarkupContainer body) {
WebMarkupContainer propertyContainer = new WebMarkupContainer(ID_PROPERTY_CONTAINER);
propertyContainer.setOutputMarkupId(true);
body.add(propertyContainer);
WebMarkupContainer descriptionContainer = new WebMarkupContainer(ID_DESCRIPTION_CONTAINER);
descriptionContainer.setOutputMarkupId(true);
descriptionContainer.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
return isItemAllowed(new ItemPath(FocusType.F_ASSIGNMENT, AssignmentType.F_DESCRIPTION));
}
});
body.add(descriptionContainer);
TextArea<String> description = new TextArea<>(ID_DESCRIPTION, new PropertyModel<String>(getModel(), AssignmentEditorDto.F_DESCRIPTION));
description.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isEnabled() {
return getModel().getObject().isEditable();
}
});
descriptionContainer.add(description);
WebMarkupContainer relationContainer = new WebMarkupContainer(ID_RELATION_CONTAINER);
relationContainer.setOutputMarkupId(true);
relationContainer.setOutputMarkupPlaceholderTag(true);
relationContainer.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
if (!isItemAllowed(new ItemPath(FocusType.F_ASSIGNMENT, AssignmentType.F_TARGET_REF, ObjectReferenceType.F_RELATION))) {
return false;
}
AssignmentEditorDto dto = getModel().getObject();
if (dto != null) {
if (AssignmentEditorDtoType.ORG_UNIT.equals(dto.getType()) || AssignmentEditorDtoType.SERVICE.equals(dto.getType()) || AssignmentEditorDtoType.ROLE.equals(dto.getType())) {
return true;
}
}
return false;
}
});
body.add(relationContainer);
addRelationDropDown(relationContainer);
WebMarkupContainer focusTypeContainer = new WebMarkupContainer(ID_FOCUS_TYPE_CONTAINER);
focusTypeContainer.setOutputMarkupId(true);
focusTypeContainer.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
return isItemAllowed(new ItemPath(FocusType.F_ASSIGNMENT, AssignmentType.F_FOCUS_TYPE));
}
});
body.add(focusTypeContainer);
ObjectTypeSelectPanel<FocusType> focusType = new ObjectTypeSelectPanel<>(ID_FOCUS_TYPE, new PropertyModel<>(getModel(), AssignmentEditorDto.F_FOCUS_TYPE), FocusType.class);
focusTypeContainer.add(focusType);
Label relationLabel = new Label(ID_RELATION_LABEL, new AbstractReadOnlyModel<String>() {
@Override
public String getObject() {
if (getModel() == null || getModel().getObject() == null) {
return getString("AssignmentEditorPanel.relation.notSpecified");
}
AssignmentEditorDto object = getModel().getObject();
String propertyKey = RelationTypes.class.getSimpleName() + "." + (object.getTargetRef() == null || object.getTargetRef().getRelation() == null ? RelationTypes.MEMBER : RelationTypes.getRelationType(object.getTargetRef().getRelation()));
return createStringResource(propertyKey).getString();
}
});
relationLabel.setOutputMarkupId(true);
relationLabel.setOutputMarkupPlaceholderTag(true);
relationLabel.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return !isCreatingNewAssignment();
}
});
relationContainer.add(relationLabel);
WebMarkupContainer tenantRefContainer = createTenantContainer();
tenantRefContainer.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
return isItemAllowed(new ItemPath(FocusType.F_ASSIGNMENT, AssignmentType.F_TENANT_REF));
}
});
body.add(tenantRefContainer);
WebMarkupContainer orgRefContainer = createOrgContainer();
orgRefContainer.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
return isItemAllowed(new ItemPath(FocusType.F_ASSIGNMENT, AssignmentType.F_ORG_REF));
}
});
body.add(orgRefContainer);
propertyContainer.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
return isItemAllowed(new ItemPath(FocusType.F_ASSIGNMENT, AssignmentType.F_DESCRIPTION)) || isItemAllowed(new ItemPath(FocusType.F_ASSIGNMENT, AssignmentType.F_TARGET_REF, ObjectReferenceType.F_RELATION)) || isItemAllowed(new ItemPath(FocusType.F_ASSIGNMENT, AssignmentType.F_FOCUS_TYPE)) || isItemAllowed(new ItemPath(FocusType.F_ASSIGNMENT, AssignmentType.F_TENANT_REF)) || isItemAllowed(new ItemPath(FocusType.F_ASSIGNMENT, AssignmentType.F_ORG_REF));
}
});
WebMarkupContainer activationBlock = new WebMarkupContainer(ID_ACTIVATION_BLOCK);
body.add(activationBlock);
WebMarkupContainer adminStatusContainer = new WebMarkupContainer(ID_ADMIN_STATUS_CONTAINER);
adminStatusContainer.setOutputMarkupId(true);
adminStatusContainer.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
return isItemAllowed(new ItemPath(FocusType.F_ASSIGNMENT, AssignmentType.F_ACTIVATION, ActivationType.F_ADMINISTRATIVE_STATUS));
}
});
activationBlock.add(adminStatusContainer);
DropDownChoicePanel administrativeStatus = WebComponentUtil.createEnumPanel(ActivationStatusType.class, ID_ADMINISTRATIVE_STATUS, new PropertyModel<ActivationStatusType>(getModel(), AssignmentEditorDto.F_ACTIVATION + "." + ActivationType.F_ADMINISTRATIVE_STATUS.getLocalPart()), this);
administrativeStatus.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isEnabled() {
return getModel().getObject().isEditable();
}
});
adminStatusContainer.add(administrativeStatus);
WebMarkupContainer validFromContainer = new WebMarkupContainer(ID_VALID_FROM_CONTAINER);
validFromContainer.setOutputMarkupId(true);
validFromContainer.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
return isItemAllowed(new ItemPath(FocusType.F_ASSIGNMENT, AssignmentType.F_ACTIVATION, ActivationType.F_VALID_FROM));
}
});
activationBlock.add(validFromContainer);
DateInput validFrom = new DateInput(ID_VALID_FROM, createDateModel(new PropertyModel<>(getModel(), AssignmentEditorDto.F_ACTIVATION + ".validFrom")));
validFrom.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isEnabled() {
return getModel().getObject().isEditable();
}
});
validFromContainer.add(validFrom);
WebMarkupContainer validToContainer = new WebMarkupContainer(ID_VALID_TO_CONTAINER);
validToContainer.setOutputMarkupId(true);
validToContainer.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
return isItemAllowed(new ItemPath(FocusType.F_ASSIGNMENT, AssignmentType.F_ACTIVATION, ActivationType.F_VALID_TO));
}
});
activationBlock.add(validToContainer);
DateInput validTo = new DateInput(ID_VALID_TO, createDateModel(new PropertyModel<>(getModel(), AssignmentEditorDto.F_ACTIVATION + ".validTo")));
validTo.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isEnabled() {
return getModel().getObject().isEditable();
}
});
validToContainer.add(validTo);
activationBlock.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
// enabled activation in assignments for now.
return true;
}
});
WebMarkupContainer targetContainer = new WebMarkupContainer(ID_TARGET_CONTAINER);
targetContainer.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
if (!isItemAllowed(new ItemPath(FocusType.F_ASSIGNMENT, AssignmentType.F_TARGET))) {
return false;
}
AssignmentEditorDto dto = getModel().getObject();
return !AssignmentEditorDtoType.CONSTRUCTION.equals(dto.getType());
}
});
body.add(targetContainer);
Label target = new Label(ID_TARGET, createTargetModel());
targetContainer.add(target);
WebMarkupContainer constructionContainer = new WebMarkupContainer(ID_CONSTRUCTION_CONTAINER);
constructionContainer.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
AssignmentEditorDto dto = getModel().getObject();
return AssignmentEditorDtoType.CONSTRUCTION.equals(dto.getType());
}
});
body.add(constructionContainer);
AjaxLink showEmpty = new AjaxLink(ID_SHOW_EMPTY) {
@Override
public void onClick(AjaxRequestTarget target) {
showEmptyPerformed(target);
}
};
constructionContainer.add(showEmpty);
Label showEmptyLabel = new Label(ID_SHOW_EMPTY_LABEL, createShowEmptyLabel());
showEmptyLabel.setOutputMarkupId(true);
showEmpty.add(showEmptyLabel);
initAttributesLayout(constructionContainer);
Component metadataPanel;
if (UserDtoStatus.ADD.equals(getModel().getObject().getStatus()) || getModelObject().getOldValue().asContainerable() == null) {
metadataPanel = new WebMarkupContainer(ID_METADATA_CONTAINER);
} else {
metadataPanel = new MetadataPanel(ID_METADATA_CONTAINER, new AbstractReadOnlyModel<MetadataType>() {
@Override
public MetadataType getObject() {
return getModelObject().getOldValue().getValue().getMetadata();
}
}, "", "row");
}
metadataPanel.setOutputMarkupId(true);
metadataPanel.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return !UserDtoStatus.ADD.equals(getModel().getObject().getStatus());
}
});
body.add(metadataPanel);
addAjaxOnUpdateBehavior(body);
}
use of org.apache.wicket.model.AbstractReadOnlyModel in project midpoint by Evolveum.
the class ShoppingCartEditorPanel method initHeaderRow.
@Override
protected void initHeaderRow() {
WebMarkupContainer box = new WebMarkupContainer(ID_BOX);
headerRow.add(box);
box.add(new AttributeModifier("class", BOX_CSS_CLASS + " " + getBoxAdditionalCssClass()));
box.add(new Label(ID_DISPLAY_NAME, new PropertyModel<AssignmentEditorDto>(getModel(), AssignmentEditorDto.F_NAME)));
box.add(new Label(ID_DESCRIPTION, new AbstractReadOnlyModel<String>() {
@Override
public String getObject() {
return getModelObject().getTargetRef() != null && getModelObject().getTargetRef().getDescription() != null ? getModelObject().getTargetRef().getDescription() : "";
}
}));
WebMarkupContainer iconBox = new WebMarkupContainer(ID_ICON_BOX);
box.add(iconBox);
if (getIconBoxAdditionalCssClass() != null) {
iconBox.add(new AttributeModifier("class", ICON_BOX_CSS_CLASS + " " + getIconBoxAdditionalCssClass()));
}
Label icon = new Label(ID_ICON, "");
icon.add(new AttributeModifier("class", getIconCssClass()));
iconBox.add(icon);
}
Aggregations