use of com.evolveum.midpoint.web.component.data.column.ColumnMenuAction in project midpoint by Evolveum.
the class FocusListInlineMenuHelper method createRowActions.
public List<InlineMenuItem> createRowActions(Class<F> objectType) {
List<InlineMenuItem> menu = new ArrayList<>();
ButtonInlineMenuItem enableItem = new ButtonInlineMenuItem(parentPage.createStringResource("FocusListInlineMenuHelper.menu.enable")) {
private static final long serialVersionUID = 1L;
@Override
public InlineMenuItemAction initAction() {
return new ColumnMenuAction<SelectableBeanImpl<F>>() {
@Override
public void onClick(AjaxRequestTarget target) {
if (getRowModel() == null) {
updateActivationPerformed(target, true, null);
} else {
SelectableBeanImpl<F> rowDto = getRowModel().getObject();
updateActivationPerformed(target, true, rowDto.getValue());
}
}
};
}
@Override
public CompositedIconBuilder getIconCompositedBuilder() {
return getDefaultCompositedIconBuilder(getEnableActionDefaultIcon(objectType));
}
@Override
public IModel<String> getConfirmationMessageModel() {
String actionName = parentPage.createStringResource("pageUsers.message.enableAction").getString();
return FocusListInlineMenuHelper.this.getConfirmationMessageModel((ColumnMenuAction) getAction(), actionName);
}
};
enableItem.setVisibilityChecker(FocusListInlineMenuHelper::isObjectDisabled);
menu.add(enableItem);
ButtonInlineMenuItem disableItem = new ButtonInlineMenuItem(parentPage.createStringResource("FocusListInlineMenuHelper.menu.disable")) {
private static final long serialVersionUID = 1L;
@Override
public InlineMenuItemAction initAction() {
return new ColumnMenuAction<SelectableBeanImpl<F>>() {
@Override
public void onClick(AjaxRequestTarget target) {
if (getRowModel() == null) {
updateActivationPerformed(target, false, null);
} else {
SelectableBeanImpl<F> rowDto = getRowModel().getObject();
updateActivationPerformed(target, false, rowDto.getValue());
}
}
};
}
@Override
public IModel<String> getConfirmationMessageModel() {
String actionName = parentPage.createStringResource("pageUsers.message.disableAction").getString();
return FocusListInlineMenuHelper.this.getConfirmationMessageModel((ColumnMenuAction) getAction(), actionName);
}
@Override
public CompositedIconBuilder getIconCompositedBuilder() {
CompositedIconBuilder builder = getDefaultCompositedIconBuilder(getEnableActionDefaultIcon(objectType));
builder.appendLayerIcon(WebComponentUtil.createIconType(GuiStyleConstants.CLASS_BAN), IconCssStyle.BOTTOM_RIGHT_STYLE);
return builder;
}
};
disableItem.setVisibilityChecker(FocusListInlineMenuHelper::isObjectEnabled);
menu.add(disableItem);
menu.add(new ButtonInlineMenuItem(parentPage.createStringResource("FocusListInlineMenuHelper.menu.reconcile")) {
private static final long serialVersionUID = 1L;
@Override
public InlineMenuItemAction initAction() {
return new ColumnMenuAction<SelectableBeanImpl<F>>() {
@Override
public void onClick(AjaxRequestTarget target) {
if (getRowModel() == null) {
reconcilePerformed(target, null);
} else {
SelectableBeanImpl<F> rowDto = getRowModel().getObject();
reconcilePerformed(target, rowDto.getValue());
}
}
};
}
@Override
public CompositedIconBuilder getIconCompositedBuilder() {
return getDefaultCompositedIconBuilder(GuiStyleConstants.CLASS_RECONCILE_MENU_ITEM);
}
@Override
public IModel<String> getConfirmationMessageModel() {
String actionName = parentPage.createStringResource("pageUsers.message.reconcileAction").getString();
return FocusListInlineMenuHelper.this.getConfirmationMessageModel((ColumnMenuAction) getAction(), actionName);
}
});
menu.add(new InlineMenuItem(parentPage.createStringResource("FocusListInlineMenuHelper.menu.delete")) {
private static final long serialVersionUID = 1L;
@Override
public InlineMenuItemAction initAction() {
return new ColumnMenuAction<SelectableBeanImpl<F>>() {
@Override
public void onClick(AjaxRequestTarget target) {
if (getRowModel() == null) {
deleteConfirmedPerformed(target, null);
} else {
SelectableBeanImpl<F> rowDto = getRowModel().getObject();
deleteConfirmedPerformed(target, rowDto.getValue());
}
}
};
}
@Override
public IModel<String> getConfirmationMessageModel() {
String actionName = parentPage.createStringResource("pageUsers.message.deleteAction").getString();
return FocusListInlineMenuHelper.this.getConfirmationMessageModel((ColumnMenuAction) getAction(), actionName);
}
});
return menu;
}
use of com.evolveum.midpoint.web.component.data.column.ColumnMenuAction in project midpoint by Evolveum.
the class PageCertCampaigns method createInlineMenuForItem.
private void createInlineMenuForItem(final CertCampaignListItemDto dto) {
dto.getMenuItems().clear();
dto.getMenuItems().add(new InlineMenuItem(createStringResource("PageCertCampaigns.menu.close"), new ColumnMenuAction<CertCampaignListItemDto>() {
@Override
public void onClick(AjaxRequestTarget target) {
closeCampaignConfirmation(target, dto);
}
}) {
@Override
public IModel<Boolean> getEnabled() {
return new AbstractReadOnlyModel<Boolean>() {
@Override
public Boolean getObject() {
return dto.getState() != AccessCertificationCampaignStateType.CLOSED;
}
};
}
});
dto.getMenuItems().add(new InlineMenuItem(createStringResource("PageCertCampaigns.menu.delete"), new ColumnMenuAction<CertCampaignListItemDto>() {
@Override
public void onClick(AjaxRequestTarget target) {
deleteCampaignConfirmation(target, dto);
}
}));
}
use of com.evolveum.midpoint.web.component.data.column.ColumnMenuAction in project midpoint by Evolveum.
the class TreeTablePanel method createTreeChildrenMenu.
private List<InlineMenuItem> createTreeChildrenMenu(OrgType org) {
List<InlineMenuItem> items = new ArrayList<>();
try {
boolean allowModify = org == null || parentPage.getSecurityEnforcer().isAuthorized(AuthorizationConstants.AUTZ_UI_MODIFY_ACTION_URL, AuthorizationPhaseType.REQUEST, org.asPrismObject(), null, null, null);
boolean allowRead = org == null || parentPage.getSecurityEnforcer().isAuthorized(AuthorizationConstants.AUTZ_UI_READ_ACTION_URL, AuthorizationPhaseType.REQUEST, org.asPrismObject(), null, null, null);
InlineMenuItem item;
if (allowModify) {
item = new InlineMenuItem(createStringResource("TreeTablePanel.move"), new ColumnMenuAction<SelectableBean<OrgType>>() {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
moveRootPerformed(getRowModel().getObject(), target);
}
});
items.add(item);
item = new InlineMenuItem(createStringResource("TreeTablePanel.makeRoot"), new ColumnMenuAction<SelectableBean<OrgType>>() {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
makeRootPerformed(getRowModel().getObject(), target);
}
});
items.add(item);
}
boolean allowDelete = org == null || parentPage.getSecurityEnforcer().isAuthorized(AuthorizationConstants.AUTZ_UI_DELETE_ACTION_URL, AuthorizationPhaseType.REQUEST, org.asPrismObject(), null, null, null);
if (allowDelete) {
item = new InlineMenuItem(createStringResource("TreeTablePanel.delete"), new ColumnMenuAction<SelectableBean<OrgType>>() {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
deleteNodePerformed(getRowModel().getObject(), target);
}
});
items.add(item);
}
if (allowModify) {
item = new InlineMenuItem(createStringResource("TreeTablePanel.recompute"), new ColumnMenuAction<SelectableBean<OrgType>>() {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
recomputeRootPerformed(getRowModel().getObject(), target);
}
});
items.add(item);
item = new InlineMenuItem(createStringResource("TreeTablePanel.edit"), Model.of(allowModify), Model.of(allowModify), new ColumnMenuAction<SelectableBean<OrgType>>() {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
editRootPerformed(getRowModel().getObject(), target);
}
});
items.add(item);
} else if (allowRead) {
item = new InlineMenuItem(createStringResource("TreeTablePanel.viewDetails"), Model.of(allowRead), Model.of(allowRead), new ColumnMenuAction<SelectableBean<OrgType>>() {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
editRootPerformed(getRowModel().getObject(), target);
}
});
items.add(item);
}
boolean allowAddNew = parentPage.getSecurityEnforcer().isAuthorized(AuthorizationConstants.AUTZ_UI_ADD_ACTION_URL, AuthorizationPhaseType.REQUEST, (new OrgType(parentPage.getPrismContext())).asPrismObject(), null, null, null);
if (allowModify && allowAddNew) {
item = new InlineMenuItem(createStringResource("TreeTablePanel.createChild"), new ColumnMenuAction<SelectableBean<OrgType>>() {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
try {
initObjectForAdd(ObjectTypeUtil.createObjectRef(getRowModel().getObject().getValue()), OrgType.COMPLEX_TYPE, null, target);
} catch (SchemaException e) {
throw new SystemException(e.getMessage(), e);
}
}
});
items.add(item);
}
} catch (SchemaException ex) {
LoggingUtils.logUnexpectedException(LOGGER, "Failed to check menu items authorizations", ex);
}
return items;
}
use of com.evolveum.midpoint.web.component.data.column.ColumnMenuAction in project midpoint by Evolveum.
the class FocusProjectionsPanel method createShadowMenu.
private List<InlineMenuItem> createShadowMenu() {
List<InlineMenuItem> items = new ArrayList<>();
PrismObjectDefinition<F> def = getObjectWrapperModel().getObject().getObject().getDefinition();
PrismReferenceDefinition ref = def.findReferenceDefinition(UserType.F_LINK_REF);
InlineMenuItem item;
PrismPropertyDefinition<ActivationStatusType> administrativeStatus = def.findPropertyDefinition(SchemaConstants.PATH_ACTIVATION_ADMINISTRATIVE_STATUS);
if (administrativeStatus.canRead() && administrativeStatus.canModify()) {
item = new ButtonInlineMenuItem(createStringResource("pageAdminFocus.button.enable")) {
private static final long serialVersionUID = 1L;
@Override
public InlineMenuItemAction initAction() {
return new ColumnMenuAction() {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
updateShadowActivation(target, getMultivalueContainerListPanel().getPerformedSelectedItems(getRowModel()), true);
}
};
}
@Override
public CompositedIconBuilder getIconCompositedBuilder() {
return getDefaultCompositedIconBuilder("fa fa-check");
}
};
items.add(item);
item = new InlineMenuItem(createStringResource("pageAdminFocus.button.disable")) {
private static final long serialVersionUID = 1L;
@Override
public InlineMenuItemAction initAction() {
return new ColumnMenuAction() {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
updateShadowActivation(target, getMultivalueContainerListPanel().getPerformedSelectedItems(getRowModel()), false);
}
};
}
};
items.add(item);
}
if (ref.canRead() && ref.canAdd()) {
item = new InlineMenuItem(createStringResource("pageAdminFocus.button.unlink")) {
private static final long serialVersionUID = 1L;
@Override
public InlineMenuItemAction initAction() {
return new ColumnMenuAction() {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
unlinkProjectionPerformed(target, getMultivalueContainerListPanel().getPerformedSelectedItems(getRowModel()));
}
};
}
};
items.add(item);
}
PrismPropertyDefinition<LockoutStatusType> locakoutStatus = def.findPropertyDefinition(SchemaConstants.PATH_ACTIVATION_LOCKOUT_STATUS);
if (locakoutStatus.canRead() && locakoutStatus.canModify()) {
item = new InlineMenuItem(createStringResource("pageAdminFocus.button.unlock")) {
private static final long serialVersionUID = 1L;
@Override
public InlineMenuItemAction initAction() {
return new ColumnMenuAction() {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
unlockShadowPerformed(target, getMultivalueContainerListPanel().getPerformedSelectedItems(getRowModel()));
}
};
}
};
items.add(item);
}
if (administrativeStatus.canRead() && administrativeStatus.canModify()) {
// items.add(new InlineMenuItem());
item = new InlineMenuItem(createStringResource("pageAdminFocus.button.delete")) {
private static final long serialVersionUID = 1L;
@Override
public InlineMenuItemAction initAction() {
return new ColumnMenuAction() {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
deleteProjectionPerformed(target, getMultivalueContainerListPanel().getPerformedSelectedItems(getRowModel()));
}
};
}
};
items.add(item);
}
item = new ButtonInlineMenuItem(createStringResource("PageBase.button.edit")) {
private static final long serialVersionUID = 1L;
@Override
public CompositedIconBuilder getIconCompositedBuilder() {
return getDefaultCompositedIconBuilder(GuiStyleConstants.CLASS_EDIT_MENU_ITEM);
}
@Override
public InlineMenuItemAction initAction() {
return new ColumnMenuAction() {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
getMultivalueContainerListPanel().editItemPerformed(target, getRowModel(), getMultivalueContainerListPanel().getSelectedItems());
target.add(getPageBase().getFeedbackPanel());
}
};
}
};
items.add(item);
return items;
}
use of com.evolveum.midpoint.web.component.data.column.ColumnMenuAction in project midpoint by Evolveum.
the class PageCreatedReports method initInlineMenu.
private List<InlineMenuItem> initInlineMenu() {
List<InlineMenuItem> menuItems = new ArrayList<>();
// menuItems.add(new InlineMenuItem(createStringResource("pageCreatedReports.inlineMenu.deleteAll")) {
// private static final long serialVersionUID = 1L;
//
// @Override
// public InlineMenuItemAction initAction() {
// return new HeaderMenuAction(PageCreatedReports.this) {
// private static final long serialVersionUID = 1L;
//
// @Override
// public void onClick(AjaxRequestTarget target) {
// deleteAllPerformed(target, ReportDeleteDialogDto.Operation.DELETE_ALL);
// }
// };
// }
// });
menuItems.add(new ButtonInlineMenuItem(createStringResource("pageCreatedReports.button.delete")) {
private static final long serialVersionUID = 1L;
@Override
public InlineMenuItemAction initAction() {
return new ColumnMenuAction<SelectableBeanImpl<ReportDataType>>() {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
ReportDataType report = null;
if (getRowModel() != null) {
SelectableBeanImpl<ReportDataType> rowDto = getRowModel().getObject();
report = rowDto.getValue();
}
deleteSelectedPerformed(target, ReportDeleteDialogDto.Operation.DELETE_SELECTED, report);
}
};
}
@Override
public CompositedIconBuilder getIconCompositedBuilder() {
return getDefaultCompositedIconBuilder("fa fa-minus");
}
});
boolean canViewTraces;
boolean canReadTraces;
try {
canReadTraces = isAuthorized(ModelAuthorizationAction.READ_TRACE.getUrl());
} catch (Throwable t) {
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't authorize reading traces", t);
canReadTraces = false;
}
canViewTraces = canReadTraces && WebModelServiceUtils.isEnableExperimentalFeature(this);
ButtonInlineMenuItem item = new ButtonInlineMenuItem(createStringResource("DownloadButtonPanel.download")) {
private static final long serialVersionUID = 1L;
@Override
public InlineMenuItemAction initAction() {
return new ColumnMenuAction<SelectableBeanImpl<ReportDataType>>() {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
SelectableBeanImpl<ReportDataType> rowDto = getRowModel().getObject();
currentReport = rowDto.getValue();
downloadPerformed(target, ajaxDownloadBehavior);
}
};
}
@Override
public CompositedIconBuilder getIconCompositedBuilder() {
return getDefaultCompositedIconBuilder("fa fa-download");
}
@Override
public boolean isHeaderMenuItem() {
return false;
}
};
if (!canReadTraces) {
item.setVisibilityChecker((rowModel, isHeader) -> !isTrace(rowModel));
}
menuItems.add(item);
ButtonInlineMenuItem viewTraceItem = new ButtonInlineMenuItem(createStringResource("DownloadButtonPanel.viewTrace")) {
private static final long serialVersionUID = 1L;
@Override
public InlineMenuItemAction initAction() {
return new ColumnMenuAction<SelectableBeanImpl<ReportDataType>>() {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
SelectableBeanImpl<ReportDataType> rowDto = getRowModel().getObject();
currentReport = rowDto.getValue();
PageParameters parameters = new PageParameters();
parameters.add(PageTraceView.PARAM_OBJECT_ID, currentReport.getOid());
navigateToNext(PageTraceView.class, parameters);
}
};
}
@Override
public CompositedIconBuilder getIconCompositedBuilder() {
return getDefaultCompositedIconBuilder("fa fa-eye");
}
@Override
public boolean isHeaderMenuItem() {
return false;
}
};
menuItems.add(viewTraceItem);
viewTraceItem.setVisibilityChecker((rowModel, isHeader) -> canViewTraces && isTrace(rowModel));
return menuItems;
}
Aggregations