use of org.apache.wicket.ajax.markup.html.AjaxLink 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.ajax.markup.html.AjaxLink in project midpoint by Evolveum.
the class AssignmentEditorPanel method initHeaderRow.
protected void initHeaderRow() {
AjaxCheckBox selected = new AjaxCheckBox(ID_SELECTED, new PropertyModel<>(getModel(), AssignmentEditorDto.F_SELECTED)) {
private static final long serialVersionUID = 1L;
@Override
protected void onUpdate(AjaxRequestTarget target) {
// do we want to update something?
}
};
selected.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return !getModel().getObject().isSimpleView();
}
});
headerRow.add(selected);
WebMarkupContainer typeImage = new WebMarkupContainer(ID_TYPE_IMAGE);
typeImage.add(AttributeModifier.append("class", createImageTypeModel(getModel())));
headerRow.add(typeImage);
Label errorIcon = new Label(ID_ERROR_ICON);
errorIcon.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
return !isTargetValid();
}
});
headerRow.add(errorIcon);
AjaxLink name = new AjaxLink(ID_NAME) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
nameClickPerformed(target);
}
};
headerRow.add(name);
AjaxLink errorLink = new AjaxLink(ID_BUTTON_SHOW_MORE) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
showErrorPerformed(target);
}
};
errorLink.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
return !isTargetValid();
}
});
headerRow.add(errorLink);
Label nameLabel = new Label(ID_NAME_LABEL, createAssignmentNameLabelModel(false));
nameLabel.setOutputMarkupId(true);
name.add(nameLabel);
Label activation = new Label(ID_ACTIVATION, createActivationModel());
headerRow.add(activation);
ToggleIconButton expandButton = new ToggleIconButton(ID_EXPAND, GuiStyleConstants.CLASS_ICON_EXPAND, GuiStyleConstants.CLASS_ICON_COLLAPSE) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
nameClickPerformed(target);
}
@Override
public boolean isOn() {
return !AssignmentEditorPanel.this.getModelObject().isMinimized();
}
};
expandButton.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return !getModel().getObject().isSimpleView();
}
});
headerRow.add(expandButton);
}
use of org.apache.wicket.ajax.markup.html.AjaxLink in project midpoint by Evolveum.
the class SimpleParametricRoleSelector method initLayout.
private void initLayout() {
IModel<String> labelParamModel = new IModel<String>() {
@Override
public void detach() {
}
@Override
public String getObject() {
return getLabelParam();
}
@Override
public void setObject(String object) {
}
};
add(new Label(ID_LABEL_PARAM, labelParamModel) {
@Override
protected void onConfigure() {
setVisible(getLabelParam() != null);
super.onConfigure();
}
});
IModel<String> labelRoleModel = new IModel<String>() {
@Override
public void detach() {
}
@Override
public String getObject() {
return getLabelRole();
}
@Override
public void setObject(String object) {
}
};
add(new Label(ID_LABEL_ROLE, labelRoleModel) {
@Override
protected void onConfigure() {
setVisible(getLabelRole() != null);
super.onConfigure();
}
});
paramList = new ListView<String>(ID_LIST_PARAM, paramListModel) {
@Override
protected void populateItem(ListItem<String> item) {
item.add(createParamLink(ID_ITEM_PARAM, item.getModel()));
}
};
paramList.setOutputMarkupId(true);
add(paramList);
final Model<String> addInputModel = new Model<String>();
TextField<String> addInput = new TextField<>(ID_ADD_INPUT, addInputModel);
addInput.setOutputMarkupId(true);
addInput.add(new AjaxFormComponentUpdatingBehavior("blur") {
@Override
protected void onUpdate(AjaxRequestTarget target) {
// nothing to do, Ajax behavior is there only to get data to model
}
});
add(addInput);
AjaxLink<String> addLink = new AjaxLink<String>(ID_ADD_LINK) {
@Override
public void onClick(AjaxRequestTarget target) {
String newParam = addInputModel.getObject();
LOGGER.debug("ADD cliked, input field value: {}", newParam);
if (!StringUtils.isBlank(newParam)) {
addParam(newParam);
}
addInputModel.setObject(null);
target.add(SimpleParametricRoleSelector.this);
}
};
add(addLink);
AjaxLink<String> deleteLink = new AjaxLink<String>(ID_DELETE_LINK) {
@Override
public void onClick(AjaxRequestTarget target) {
LOGGER.debug("DELETE cliked, selected param: {}", selectedParam);
deleteParam(selectedParam);
target.add(SimpleParametricRoleSelector.this);
}
};
add(deleteLink);
}
use of org.apache.wicket.ajax.markup.html.AjaxLink in project midpoint by Evolveum.
the class ACAttributeValuePanel method initLayout.
private void initLayout(Form form, boolean ignoreMandatoryAttributes) {
ACValueConstructionDto dto = getModel().getObject();
PrismPropertyDefinition definition = dto.getAttribute().getDefinition();
InputPanel input = createTypedInputComponent(ID_INPUT, definition);
for (FormComponent comp : input.getFormComponents()) {
comp.setLabel(new PropertyModel(dto.getAttribute(), ACAttributeDto.F_NAME));
if (!ignoreMandatoryAttributes) {
comp.setRequired(definition.getMinOccurs() > 0);
}
comp.add(new AjaxFormComponentUpdatingBehavior("blur") {
@Override
protected void onUpdate(AjaxRequestTarget target) {
}
});
}
add(input);
AjaxLink addLink = new AjaxLink(ID_ADD) {
@Override
public void onClick(AjaxRequestTarget target) {
addPerformed(target);
}
};
add(addLink);
addLink.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return isAddVisible();
}
});
AjaxLink removeLink = new AjaxLink(ID_REMOVE) {
@Override
public void onClick(AjaxRequestTarget target) {
removePerformed(target);
}
};
add(removeLink);
removeLink.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return isRemoveVisible();
}
});
}
use of org.apache.wicket.ajax.markup.html.AjaxLink in project midpoint by Evolveum.
the class AssignmentEditorPanel method updateAssignmentName.
private void updateAssignmentName(AjaxRequestTarget target, Boolean isManager) {
Label nameLabel = new Label(ID_NAME_LABEL, createAssignmentNameLabelModel(isManager));
nameLabel.setOutputMarkupId(true);
AjaxLink name = (AjaxLink) get(createComponentPath(ID_HEADER_ROW, ID_NAME));
name.addOrReplace(nameLabel);
target.add(name);
}
Aggregations