use of org.apache.wicket.ajax.AjaxRequestTarget in project midpoint by Evolveum.
the class PageResources method createRowMenuItems.
private List<InlineMenuItem> createRowMenuItems(boolean isHeader) {
List<InlineMenuItem> menuItems = new ArrayList<>();
menuItems.add(new InlineMenuItem(createStringResource("PageResources.inlineMenuItem.test"), new Model<Boolean>(false), new Model<Boolean>(false), false, new ColumnMenuAction<SelectableBean<ResourceType>>() {
@Override
public void onClick(AjaxRequestTarget target) {
SelectableBean<ResourceType> rowDto = getRowModel().getObject();
testResourcePerformed(target, rowDto.getValue());
}
}, isHeader ? InlineMenuItem.RESOURCE_INLINE_MENU_ITEM_ID.HEADER_TEST_CONNECTION.getMenuItemId() : InlineMenuItem.RESOURCE_INLINE_MENU_ITEM_ID.TEST_CONNECTION.getMenuItemId(), GuiStyleConstants.CLASS_TEST_CONNECTION_MENU_ITEM, DoubleButtonColumn.BUTTON_COLOR_CLASS.INFO.toString()));
menuItems.add(new InlineMenuItem(createStringResource("PageBase.button.delete"), new Model<Boolean>(true), new Model<Boolean>(true), false, new ColumnMenuAction<SelectableBean<ResourceType>>() {
@Override
public void onClick(AjaxRequestTarget target) {
if (getRowModel() == null) {
deleteResourcePerformed(target, null);
} else {
SelectableBean<ResourceType> rowDto = getRowModel().getObject();
deleteResourcePerformed(target, rowDto.getValue());
}
}
}, isHeader ? InlineMenuItem.RESOURCE_INLINE_MENU_ITEM_ID.HEADER_DELETE.getMenuItemId() : InlineMenuItem.RESOURCE_INLINE_MENU_ITEM_ID.DELETE_RESOURCE.getMenuItemId(), GuiStyleConstants.CLASS_DELETE_MENU_ITEM, DoubleButtonColumn.BUTTON_COLOR_CLASS.DANGER.toString()));
menuItems.add(new InlineMenuItem(createStringResource("pageResources.inlineMenuItem.deleteSyncToken"), isHeader ? new Model<Boolean>(false) : new Model<Boolean>(true), isHeader ? new Model<Boolean>(false) : new Model<Boolean>(true), false, new ColumnMenuAction<SelectableBean<ResourceType>>() {
@Override
public void onClick(AjaxRequestTarget target) {
SelectableBean<ResourceType> rowDto = getRowModel().getObject();
deleteResourceSyncTokenPerformed(target, rowDto.getValue());
}
}));
menuItems.add(new InlineMenuItem(createStringResource("pageResources.inlineMenuItem.editResource"), isHeader ? new Model<Boolean>(false) : new Model<Boolean>(true), isHeader ? new Model<Boolean>(false) : new Model<Boolean>(true), false, new ColumnMenuAction<SelectableBean<ResourceType>>() {
@Override
public void onClick(AjaxRequestTarget target) {
SelectableBean<ResourceType> rowDto = getRowModel().getObject();
editResourcePerformed(rowDto.getValue());
}
}));
menuItems.add(new InlineMenuItem(createStringResource("pageResources.button.editAsXml"), new Model<Boolean>(false), new Model<Boolean>(false), false, new ColumnMenuAction<SelectableBean<ResourceType>>() {
@Override
public void onClick(AjaxRequestTarget target) {
SelectableBean<ResourceType> rowDto = getRowModel().getObject();
editAsXmlPerformed(rowDto.getValue());
}
}, InlineMenuItem.RESOURCE_INLINE_MENU_ITEM_ID.EDIT_XML.getMenuItemId(), GuiStyleConstants.CLASS_EDIT_MENU_ITEM, DoubleButtonColumn.BUTTON_COLOR_CLASS.INFO.toString()));
return menuItems;
}
use of org.apache.wicket.ajax.AjaxRequestTarget in project midpoint by Evolveum.
the class PageResources method deleteResourcePerformed.
private void deleteResourcePerformed(AjaxRequestTarget target, ResourceType single) {
List<ResourceType> selected = isAnyResourceSelected(target, single);
singleDelete = single;
if (selected.isEmpty()) {
return;
}
ConfirmationPanel dialog = new ConfirmationPanel(((PageBase) getPage()).getMainPopupBodyId(), createDeleteConfirmString("pageResources.message.deleteResourceConfirm", "pageResources.message.deleteResourcesConfirm", true)) {
@Override
public void yesPerformed(AjaxRequestTarget target) {
((PageBase) getPage()).hideMainPopup(target);
deleteResourceConfirmedPerformed(target);
}
};
((PageBase) getPage()).showMainPopup(dialog, target);
}
use of org.apache.wicket.ajax.AjaxRequestTarget in project midpoint by Evolveum.
the class PageAccount method initButtons.
private void initButtons(Form mainForm) {
AjaxSubmitButton save = new AjaxSubmitButton("save", createStringResource("pageAccount.button.save")) {
@Override
protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
savePerformed(target);
}
@Override
protected void onError(AjaxRequestTarget target, Form<?> form) {
target.add(getFeedbackPanel());
}
};
save.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
ObjectWrapper wrapper = accountModel.getObject();
return !wrapper.isProtectedAccount();
}
});
mainForm.add(save);
AjaxButton back = new AjaxButton("back", createStringResource("pageAccount.button.back")) {
@Override
public void onClick(AjaxRequestTarget target) {
cancelPerformed(target);
}
};
mainForm.add(back);
}
use of org.apache.wicket.ajax.AjaxRequestTarget in project midpoint by Evolveum.
the class PageRoles method initLayout.
private void initLayout() {
Form mainForm = new Form(ID_MAIN_FORM);
add(mainForm);
MainObjectListPanel<RoleType> roleListPanel = new MainObjectListPanel<RoleType>(ID_TABLE, RoleType.class, TableId.TABLE_ROLES, null, this) {
@Override
protected List<InlineMenuItem> createInlineMenu() {
return listInlineMenuHelper.createRowActions(false);
}
@Override
protected List<IColumn<SelectableBean<RoleType>, String>> createColumns() {
return PageRoles.this.initColumns();
}
@Override
protected IColumn<SelectableBean<RoleType>, String> createActionsColumn() {
return PageRoles.this.createActionsColumn();
}
@Override
protected void objectDetailsPerformed(AjaxRequestTarget target, RoleType object) {
PageRoles.this.roleDetailsPerformed(target, object.getOid());
;
}
@Override
protected void newObjectPerformed(AjaxRequestTarget target) {
navigateToNext(PageRole.class);
}
};
roleListPanel.setOutputMarkupId(true);
roleListPanel.setAdditionalBoxCssClasses(GuiStyleConstants.CLASS_OBJECT_ROLE_BOX_CSS_CLASSES);
mainForm.add(roleListPanel);
}
use of org.apache.wicket.ajax.AjaxRequestTarget in project midpoint by Evolveum.
the class DelegationEditorPanel method initBodyLayout.
protected void initBodyLayout(WebMarkupContainer body) {
DateInput validFrom = new DateInput(ID_DELEGATION_VALID_FROM, createDateModel(new PropertyModel<XMLGregorianCalendar>(getModel(), AssignmentEditorDto.F_ACTIVATION + ".validFrom")));
validFrom.setEnabled(getModel().getObject().isEditable());
body.add(validFrom);
DateInput validTo = new DateInput(ID_DELEGATION_VALID_TO, createDateModel(new PropertyModel<XMLGregorianCalendar>(getModel(), AssignmentEditorDto.F_ACTIVATION + ".validTo")));
validTo.setEnabled(getModel().getObject().isEditable());
body.add(validTo);
TextArea<String> description = new TextArea<>(ID_DESCRIPTION, new PropertyModel<String>(getModel(), AssignmentEditorDto.F_DESCRIPTION));
description.setEnabled(getModel().getObject().isEditable());
body.add(description);
WebMarkupContainer assignmentPrivilegesContainer = new WebMarkupContainer(ID_ASSIGNMENT_PRIVILEGES_CONTAINER);
assignmentPrivilegesContainer.setOutputMarkupId(true);
assignmentPrivilegesContainer.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
if (!UserDtoStatus.ADD.equals(getModelObject().getStatus())) {
return true;
}
List<AssignmentsPreviewDto> privilegesList = privilegesListModel.getObject();
return privilegesList != null && privilegesList.size() > 0;
}
});
body.add(assignmentPrivilegesContainer);
AjaxCheckBox assignmentPrivilegesCheckbox = new AjaxCheckBox(ID_ASSIGNMENT_PRIVILEGES_CHECKBOX, new IModel<Boolean>() {
private static final long serialVersionUID = 1L;
@Override
public Boolean getObject() {
return getModelObject().getPrivilegeLimitationList() != null && getModelObject().getPrivilegeLimitationList().size() > 0;
}
@Override
public void setObject(Boolean value) {
if (value) {
getModelObject().setPrivilegeLimitationList(privilegesListModel.getObject());
} else {
getModelObject().setPrivilegeLimitationList(new ArrayList<>());
}
}
@Override
public void detach() {
}
}) {
private static final long serialVersionUID = 1L;
@Override
protected void onUpdate(AjaxRequestTarget target) {
target.add(DelegationEditorPanel.this.get(ID_BODY).get(ID_ASSIGNMENT_PRIVILEGES_CONTAINER));
}
};
assignmentPrivilegesCheckbox.setOutputMarkupId(true);
assignmentPrivilegesCheckbox.add(new AjaxFormComponentUpdatingBehavior("blur") {
@Override
protected void onUpdate(AjaxRequestTarget target) {
}
});
assignmentPrivilegesCheckbox.add(new VisibleEnableBehaviour() {
@Override
public boolean isEnabled() {
return UserDtoStatus.ADD.equals(getModelObject().getStatus());
}
});
assignmentPrivilegesContainer.add(assignmentPrivilegesCheckbox);
WebMarkupContainer labelContainer = new WebMarkupContainer(ID_ASSIGNMENT_PRIVILEGES_LABEL_CONTAINER);
labelContainer.setOutputMarkupId(true);
assignmentPrivilegesContainer.add(labelContainer);
Label assignmentPrivilegesLabel = new Label(ID_ASSIGNMENT_PRIVILEGES_LABEL, createStringResource("DelegationEditorPanel.allPrivilegesLabel"));
assignmentPrivilegesLabel.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return true;
}
});
assignmentPrivilegesLabel.setOutputMarkupId(true);
labelContainer.add(assignmentPrivilegesLabel);
addPrivilegesPanel(assignmentPrivilegesContainer);
AjaxButton limitPrivilegesButton = new AjaxButton(ID_LIMIT_PRIVILEGES_BUTTON, pageBase.createStringResource("DelegationEditorPanel.limitPrivilegesButton")) {
@Override
public void onClick(AjaxRequestTarget target) {
AssignmentPreviewDialog assignmentPreviewDialog = new AssignmentPreviewDialog(pageBase.getMainPopupBodyId(), selectExistingPrivileges(privilegesListModel.getObject()), null, pageBase, true) {
@Override
protected boolean isDelegationPreview() {
return true;
}
@Override
public StringResourceModel getTitle() {
return new StringResourceModel("AssignmentPreviewDialog.delegationPreviewLabel");
}
@Override
protected void addButtonClicked(AjaxRequestTarget target, List<AssignmentsPreviewDto> dtoList) {
DelegationEditorPanel.this.getModelObject().setPrivilegeLimitationList(dtoList);
pageBase.hideMainPopup(target);
}
};
pageBase.showMainPopup(assignmentPreviewDialog, target);
}
};
limitPrivilegesButton.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return UserDtoStatus.ADD.equals(getModelObject().getStatus()) && assignmentPrivilegesCheckbox.getModelObject();
}
});
labelContainer.add(limitPrivilegesButton);
AjaxCheckBox approvalRights = new AjaxCheckBox(ID_DELEGATE_APPROVAL_WI, new IModel<Boolean>() {
private static final long serialVersionUID = 1L;
@Override
public Boolean getObject() {
AssignmentEditorDto dto = getModelObject();
if (dto.getPrivilegesLimitation() == null || dto.getPrivilegesLimitation().getApprovalWorkItems() == null || dto.getPrivilegesLimitation().getApprovalWorkItems().isAll() == null) {
return false;
}
return dto.getPrivilegesLimitation().getApprovalWorkItems().isAll();
}
@Override
public void setObject(Boolean value) {
AssignmentEditorDto dto = getModelObject();
OtherPrivilegesLimitationType limitations = dto.getPrivilegesLimitation();
if (limitations == null) {
limitations = new OtherPrivilegesLimitationType();
dto.setPrivilegesLimitation(limitations);
}
WorkItemSelectorType workItemSelector = new WorkItemSelectorType();
workItemSelector.all(value);
limitations.setApprovalWorkItems(workItemSelector);
}
@Override
public void detach() {
}
}) {
private static final long serialVersionUID = 1L;
@Override
protected void onUpdate(AjaxRequestTarget target) {
}
};
approvalRights.setOutputMarkupId(true);
approvalRights.add(new AjaxFormComponentUpdatingBehavior("blur") {
@Override
protected void onUpdate(AjaxRequestTarget target) {
}
});
approvalRights.add(new VisibleEnableBehaviour() {
@Override
public boolean isEnabled() {
return getModel().getObject().isEditable();
}
});
body.add(approvalRights);
AjaxCheckBox certificationRights = new AjaxCheckBox(ID_DELEGATE_CERTIFICATION_WI, new IModel<Boolean>() {
private static final long serialVersionUID = 1L;
@Override
public Boolean getObject() {
AssignmentEditorDto dto = getModelObject();
if (dto.getPrivilegesLimitation() == null || dto.getPrivilegesLimitation().getCertificationWorkItems() == null || dto.getPrivilegesLimitation().getCertificationWorkItems().isAll() == null) {
return false;
}
return dto.getPrivilegesLimitation().getCertificationWorkItems().isAll();
}
@Override
public void setObject(Boolean value) {
AssignmentEditorDto dto = getModelObject();
OtherPrivilegesLimitationType limitations = dto.getPrivilegesLimitation();
if (limitations == null) {
limitations = new OtherPrivilegesLimitationType();
dto.setPrivilegesLimitation(limitations);
}
WorkItemSelectorType workItemSelector = new WorkItemSelectorType();
workItemSelector.all(value);
limitations.setCertificationWorkItems(workItemSelector);
}
@Override
public void detach() {
}
}) {
private static final long serialVersionUID = 1L;
@Override
protected void onUpdate(AjaxRequestTarget target) {
}
};
certificationRights.add(new AjaxFormComponentUpdatingBehavior("blur") {
@Override
protected void onUpdate(AjaxRequestTarget target) {
}
});
certificationRights.add(new VisibleEnableBehaviour() {
@Override
public boolean isEnabled() {
return getModel().getObject().isEditable();
}
});
certificationRights.setOutputMarkupId(true);
body.add(certificationRights);
AjaxCheckBox managementWorkItems = new AjaxCheckBox(ID_DELEGATE_MANAGEMENT_WI, new Model<Boolean>(false)) {
private static final long serialVersionUID = 1L;
@Override
protected void onUpdate(AjaxRequestTarget target) {
}
};
managementWorkItems.setOutputMarkupId(true);
managementWorkItems.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
//TODO not implemented yet
return false;
}
});
body.add(managementWorkItems);
addAjaxOnUpdateBehavior(body);
}
Aggregations