use of com.evolveum.midpoint.gui.api.component.ObjectBrowserPanel in project midpoint by Evolveum.
the class ResourceContentPanel method createRowMenuItems.
private List<InlineMenuItem> createRowMenuItems() {
List<InlineMenuItem> items = new ArrayList<>();
items.add(new InlineMenuItem(createStringResource("pageContentAccounts.menu.enableAccount"), true) {
private static final long serialVersionUID = 1L;
@Override
public InlineMenuItemAction initAction() {
return new ColumnMenuAction<SelectableBeanImpl<ShadowType>>() {
private static final long serialVersionUID = 1L;
@Override
public void onSubmit(AjaxRequestTarget target) {
if (getRowModel() == null) {
updateResourceObjectStatusPerformed(null, target, true);
} else {
SelectableBeanImpl<ShadowType> shadow = getRowModel().getObject();
updateResourceObjectStatusPerformed(shadow.getValue(), target, true);
}
}
};
}
});
items.add(new InlineMenuItem(createStringResource("pageContentAccounts.menu.disableAccount"), true) {
private static final long serialVersionUID = 1L;
@Override
public InlineMenuItemAction initAction() {
return new ColumnMenuAction<SelectableBeanImpl<ShadowType>>() {
private static final long serialVersionUID = 1L;
@Override
public void onSubmit(AjaxRequestTarget target) {
if (getRowModel() == null) {
updateResourceObjectStatusPerformed(null, target, false);
} else {
SelectableBeanImpl<ShadowType> shadow = getRowModel().getObject();
updateResourceObjectStatusPerformed(shadow.getValue(), target, false);
}
}
};
}
});
items.add(new InlineMenuItem(createStringResource("pageContentAccounts.menu.deleteAccount"), true) {
private static final long serialVersionUID = 1L;
@Override
public InlineMenuItemAction initAction() {
return new ColumnMenuAction<SelectableBeanImpl<ShadowType>>() {
private static final long serialVersionUID = 1L;
@Override
public void onSubmit(AjaxRequestTarget target) {
if (getRowModel() == null) {
deleteResourceObjectPerformed(null, target);
} else {
SelectableBeanImpl<ShadowType> shadow = getRowModel().getObject();
deleteResourceObjectPerformed(shadow.getValue(), target);
}
}
};
}
});
items.add(new ButtonInlineMenuItem(createStringResource("pageContentAccounts.menu.importAccount"), true) {
private static final long serialVersionUID = 1L;
@Override
public InlineMenuItemAction initAction() {
return new ColumnMenuAction<SelectableBeanImpl<ShadowType>>() {
private static final long serialVersionUID = 1L;
@Override
public void onSubmit(AjaxRequestTarget target) {
if (getRowModel() == null) {
importResourceObject(null, target);
} else {
SelectableBeanImpl<ShadowType> shadow = getRowModel().getObject();
importResourceObject(shadow.getValue(), target);
}
}
};
}
@Override
public CompositedIconBuilder getIconCompositedBuilder() {
return getDefaultCompositedIconBuilder(GuiStyleConstants.CLASS_IMPORT_MENU_ITEM);
}
});
// items.add(new InlineMenuItem());
items.add(new InlineMenuItem(createStringResource("pageContentAccounts.menu.removeOwner"), true) {
private static final long serialVersionUID = 1L;
@Override
public InlineMenuItemAction initAction() {
return new ColumnMenuAction<SelectableBeanImpl<ShadowType>>() {
private static final long serialVersionUID = 1L;
@Override
public void onSubmit(AjaxRequestTarget target) {
if (getRowModel() == null) {
changeOwner(null, target, null, Operation.REMOVE);
} else {
SelectableBeanImpl<ShadowType> shadow = getRowModel().getObject();
changeOwner(shadow.getValue(), target, null, Operation.REMOVE);
}
}
};
}
});
items.add(new ButtonInlineMenuItem(createStringResource("pageContentAccounts.menu.changeOwner"), true) {
private static final long serialVersionUID = 1L;
@Override
public InlineMenuItemAction initAction() {
return new ColumnMenuAction<SelectableBeanImpl<ShadowType>>() {
private static final long serialVersionUID = 1L;
@Override
public void onSubmit(AjaxRequestTarget target) {
final SelectableBeanImpl<ShadowType> shadow = getRowModel().getObject();
ObjectBrowserPanel<FocusType> browser = new ObjectBrowserPanel<>(getPageBase().getMainPopupBodyId(), UserType.class, WebComponentUtil.createFocusTypeList(), false, getPageBase()) {
@Override
protected void onSelectPerformed(AjaxRequestTarget target, FocusType focus) {
changeOwner(shadow.getValue(), target, focus, Operation.MODIFY);
}
};
getPageBase().showMainPopup(browser, target);
}
};
}
@Override
public CompositedIconBuilder getIconCompositedBuilder() {
return getDefaultCompositedIconBuilder(GuiStyleConstants.CLASS_RECONCILE_MENU_ITEM);
}
@Override
public boolean isHeaderMenuItem() {
return false;
}
});
return items;
}
use of com.evolveum.midpoint.gui.api.component.ObjectBrowserPanel in project midpoint by Evolveum.
the class UserDelegationsPanel method initLayout.
protected void initLayout() {
WebMarkupContainer delegations = new WebMarkupContainer(ID_DELEGATIONS_CONTAINER);
delegations.setOutputMarkupId(true);
add(delegations);
AssignmentTablePanel panel = new AssignmentTablePanel<UserType>(ID_DELEGATIONS_PANEL, getObjectDetailsModels().getDelegationsModel()) {
private static final long serialVersionUID = 1L;
@Override
public void populateAssignmentDetailsPanel(ListItem<AssignmentEditorDto> item) {
DelegationEditorPanel editor = new DelegationEditorPanel(ID_ROW, item.getModel(), false, getObjectDetailsModels().getPrivilegesListModel());
item.add(editor);
}
@Override
public String getExcludeOid() {
return getObjectWrapper().getOid();
}
public IModel<String> getLabel() {
return createStringResource("FocusType.delegations");
}
@Override
protected List<InlineMenuItem> createAssignmentMenu() {
List<InlineMenuItem> items = new ArrayList<>();
InlineMenuItem item;
if (WebComponentUtil.isAuthorized(AuthorizationConstants.AUTZ_UI_DELEGATE_ACTION_URL)) {
item = new InlineMenuItem(createStringResource("AssignmentTablePanel.menu.addDelegation")) {
private static final long serialVersionUID = 1L;
@Override
public InlineMenuItemAction initAction() {
return new InlineMenuItemAction() {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
List<QName> supportedTypes = new ArrayList<>();
supportedTypes.add(UserType.COMPLEX_TYPE);
ObjectFilter filter = getPrismContext().queryFactory().createInOid(getObjectWrapper().getOid());
ObjectFilter notFilter = getPrismContext().queryFactory().createNot(filter);
ObjectBrowserPanel<UserType> panel = new ObjectBrowserPanel<UserType>(getPageBase().getMainPopupBodyId(), UserType.class, supportedTypes, false, getPageBase(), notFilter) {
private static final long serialVersionUID = 1L;
@Override
protected void onSelectPerformed(AjaxRequestTarget target, UserType user) {
getPageBase().hideMainPopup(target);
List<ObjectType> newAssignmentsList = new ArrayList<>();
newAssignmentsList.add(user);
addSelectedAssignablePerformed(target, newAssignmentsList, null, getPageBase().getMainPopup().getId());
}
};
panel.setOutputMarkupId(true);
getPageBase().showMainPopup(panel, target);
}
};
}
};
items.add(item);
}
if (WebComponentUtil.isAuthorized(AuthorizationConstants.AUTZ_UI_ADMIN_UNASSIGN_ACTION_URI)) {
item = new InlineMenuItem(createStringResource("AssignmentTablePanel.menu.deleteDelegation")) {
private static final long serialVersionUID = 1L;
@Override
public InlineMenuItemAction initAction() {
return new InlineMenuItemAction() {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
deleteAssignmentPerformed(target, null);
}
};
}
};
items.add(item);
}
return items;
}
@Override
protected String getNoAssignmentsSelectedMessage() {
return getString("AssignmentTablePanel.message.noDelegationsSelected");
}
@Override
protected String getAssignmentsDeleteMessage(AssignmentEditorDto dto) {
return createStringResource("AssignmentTablePanel.modal.message.deleteDelegation", getSelectedAssignments().size()).getString();
}
@Override
protected List<AssignmentEditorDto> getAssignmentListToProcess(AssignmentEditorDto dto) {
if (dto != null) {
return Collections.singletonList(dto);
} else {
return getSelectedAssignments();
}
}
@Override
protected void addSelectedAssignablePerformed(AjaxRequestTarget target, List<ObjectType> newAssignments, QName relation, String popupId) {
ModalWindow window = (ModalWindow) get(popupId);
if (window != null) {
window.close(target);
}
getPageBase().hideMainPopup(target);
if (newAssignments.isEmpty()) {
warn(getString("AssignmentTablePanel.message.noAssignmentSelected"));
target.add(getPageBase().getFeedbackPanel());
return;
}
for (ObjectType object : newAssignments) {
try {
AssignmentEditorDto dto = AssignmentEditorDto.createDtoAddFromSelectedObject(((PrismObject<UserType>) getObjectWrapper().getObject()).asObjectable(), WebComponentUtil.getDefaultRelationOrFail(RelationKindType.DELEGATION), getPageBase(), (UserType) object);
dto.setPrivilegeLimitationList(getPrivilegesListModel().getObject());
getDelegationModel().getObject().add(dto);
} catch (Exception e) {
error(getString("AssignmentTablePanel.message.couldntAssignObject", object.getName(), e.getMessage()));
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't assign object", e);
}
}
reloadAssignmentsPanel(target);
reloadMainFormButtons(target);
}
};
delegations.add(panel);
}
use of com.evolveum.midpoint.gui.api.component.ObjectBrowserPanel in project midpoint by Evolveum.
the class UserDelegationsTabPanel method initLayout.
private void initLayout() {
WebMarkupContainer delegations = new WebMarkupContainer(ID_DELEGATIONS_CONTAINER);
delegations.setOutputMarkupId(true);
add(delegations);
AssignmentTablePanel panel = new AssignmentTablePanel<UserType>(ID_DELEGATIONS_PANEL, delegationsModel) {
private static final long serialVersionUID = 1L;
@Override
public void populateAssignmentDetailsPanel(ListItem<AssignmentEditorDto> item) {
DelegationEditorPanel editor = new DelegationEditorPanel(ID_ROW, item.getModel(), false, privilegesListModel);
item.add(editor);
}
@Override
public String getExcludeOid() {
return getObjectWrapper().getOid();
}
public IModel<String> getLabel() {
return createStringResource("FocusType.delegations");
}
@Override
protected List<InlineMenuItem> createAssignmentMenu() {
List<InlineMenuItem> items = new ArrayList<>();
InlineMenuItem item;
if (WebComponentUtil.isAuthorized(AuthorizationConstants.AUTZ_UI_DELEGATE_ACTION_URL)) {
item = new InlineMenuItem(createStringResource("AssignmentTablePanel.menu.addDelegation")) {
private static final long serialVersionUID = 1L;
@Override
public InlineMenuItemAction initAction() {
return new InlineMenuItemAction() {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
List<QName> supportedTypes = new ArrayList<>();
supportedTypes.add(UserType.COMPLEX_TYPE);
ObjectFilter filter = getPrismContext().queryFactory().createInOid(getObjectWrapper().getOid());
ObjectFilter notFilter = getPrismContext().queryFactory().createNot(filter);
ObjectBrowserPanel<UserType> panel = new ObjectBrowserPanel<UserType>(getPageBase().getMainPopupBodyId(), UserType.class, supportedTypes, false, getPageBase(), notFilter) {
private static final long serialVersionUID = 1L;
@Override
protected void onSelectPerformed(AjaxRequestTarget target, UserType user) {
getPageBase().hideMainPopup(target);
List<ObjectType> newAssignmentsList = new ArrayList<>();
newAssignmentsList.add(user);
addSelectedAssignablePerformed(target, newAssignmentsList, null, getPageBase().getMainPopup().getId());
}
};
panel.setOutputMarkupId(true);
getPageBase().showMainPopup(panel, target);
}
};
}
};
items.add(item);
}
if (WebComponentUtil.isAuthorized(AuthorizationConstants.AUTZ_UI_ADMIN_UNASSIGN_ACTION_URI)) {
item = new InlineMenuItem(createStringResource("AssignmentTablePanel.menu.deleteDelegation")) {
private static final long serialVersionUID = 1L;
@Override
public InlineMenuItemAction initAction() {
return new InlineMenuItemAction() {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
deleteAssignmentPerformed(target, null);
}
};
}
};
items.add(item);
}
return items;
}
@Override
protected String getNoAssignmentsSelectedMessage() {
return getString("AssignmentTablePanel.message.noDelegationsSelected");
}
@Override
protected String getAssignmentsDeleteMessage(AssignmentEditorDto dto) {
return createStringResource("AssignmentTablePanel.modal.message.deleteDelegation", getSelectedAssignments().size()).getString();
}
@Override
protected List<AssignmentEditorDto> getAssignmentListToProcess(AssignmentEditorDto dto) {
if (dto != null) {
return Collections.singletonList(dto);
} else {
return getSelectedAssignments();
}
}
@Override
protected void addSelectedAssignablePerformed(AjaxRequestTarget target, List<ObjectType> newAssignments, QName relation, String popupId) {
ModalWindow window = (ModalWindow) get(popupId);
if (window != null) {
window.close(target);
}
getPageBase().hideMainPopup(target);
if (newAssignments.isEmpty()) {
warn(getString("AssignmentTablePanel.message.noAssignmentSelected"));
target.add(getPageBase().getFeedbackPanel());
return;
}
for (ObjectType object : newAssignments) {
try {
AssignmentEditorDto dto = AssignmentEditorDto.createDtoAddFromSelectedObject(((PrismObject<UserType>) getObjectWrapper().getObject()).asObjectable(), WebComponentUtil.getDefaultRelationOrFail(RelationKindType.DELEGATION), getPageBase(), (UserType) object);
dto.setPrivilegeLimitationList(privilegesListModel.getObject());
delegationsModel.getObject().add(dto);
} catch (Exception e) {
error(getString("AssignmentTablePanel.message.couldntAssignObject", object.getName(), e.getMessage()));
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't assign object", e);
}
}
reloadAssignmentsPanel(target);
reloadMainFormButtons(target);
}
};
delegations.add(panel);
}
use of com.evolveum.midpoint.gui.api.component.ObjectBrowserPanel in project midpoint by Evolveum.
the class ConstructionAssociationPanel method addNewShadowRefValuePerformed.
private void addNewShadowRefValuePerformed(AjaxRequestTarget target, ResourceAssociationDefinition def) {
ObjectFilter filter = WebComponentUtil.createAssociationShadowRefFilter(def, getPageBase().getPrismContext(), resourceModel.getObject().getOid());
ObjectBrowserPanel<ShadowType> objectBrowserPanel = new ObjectBrowserPanel<ShadowType>(getPageBase().getMainPopupBodyId(), ShadowType.class, Collections.singletonList(ShadowType.COMPLEX_TYPE), false, getPageBase(), filter) {
private static final long serialVersionUID = 1L;
@Override
protected void onSelectPerformed(AjaxRequestTarget target, ShadowType object) {
getPageBase().hideMainPopup(target);
try {
PrismContainerWrapper<ConstructionType> constructionContainerWrapper = ConstructionAssociationPanel.this.getModelObject();
PrismContainerWrapper<ResourceObjectAssociationType> associationWrapper = constructionContainerWrapper.findContainer(ConstructionType.F_ASSOCIATION);
List<PrismContainerValue<ResourceObjectAssociationType>> associationValueList = associationWrapper.getItem().getValues();
PrismContainerValue<ResourceObjectAssociationType> associationValue;
if (CollectionUtils.isEmpty(associationValueList)) {
associationValue = associationWrapper.getItem().createNewValue();
} else {
associationValue = associationValueList.get(0);
}
ItemName associationRefPath = def.getName();
associationValue.asContainerable().setRef(new ItemPathType(associationRefPath));
ExpressionType newAssociationExpression = associationValue.asContainerable().beginOutbound().beginExpression();
ExpressionUtil.addShadowRefEvaluatorValue(newAssociationExpression, object.getOid(), getPageBase().getPrismContext());
} catch (SchemaException ex) {
LOGGER.error("Couldn't find association container: {}", ex.getLocalizedMessage());
}
target.add(ConstructionAssociationPanel.this);
}
};
getPageBase().showMainPopup(objectBrowserPanel, target);
}
Aggregations