use of com.evolveum.midpoint.web.component.data.column.ColumnMenuAction 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 com.evolveum.midpoint.web.component.data.column.ColumnMenuAction in project midpoint by Evolveum.
the class FocusListInlineMenuHelper method createRowActions.
public List<InlineMenuItem> createRowActions(boolean isHeader) {
List<InlineMenuItem> menu = new ArrayList<>();
menu.add(new InlineMenuItem(parentPage.createStringResource("FocusListInlineMenuHelper.menu.enable"), new Model<Boolean>(false), new Model<Boolean>(false), false, new ColumnMenuAction<SelectableBean<F>>() {
@Override
public void onClick(AjaxRequestTarget target) {
if (getRowModel() == null) {
updateActivationPerformed(target, true, null);
} else {
SelectableBean<F> rowDto = getRowModel().getObject();
updateActivationPerformed(target, true, rowDto.getValue());
}
}
}, isHeader ? InlineMenuItem.FOCUS_LIST_INLINE_MENU_ITEM_ID.HEADER_ENABLE.getMenuItemId() : InlineMenuItem.FOCUS_LIST_INLINE_MENU_ITEM_ID.ENABLE.getMenuItemId(), GuiStyleConstants.CLASS_OBJECT_USER_ICON, DoubleButtonColumn.BUTTON_COLOR_CLASS.SUCCESS.toString()) {
private static final long serialVersionUID = 1L;
@Override
public boolean isShowConfirmationDialog() {
return FocusListInlineMenuHelper.this.isShowConfirmationDialog((ColumnMenuAction) getAction());
}
@Override
public IModel<String> getConfirmationMessageModel() {
String actionName = parentPage.createStringResource("pageUsers.message.enableAction").getString();
return FocusListInlineMenuHelper.this.getConfirmationMessageModel((ColumnMenuAction) getAction(), actionName);
}
});
menu.add(new InlineMenuItem(parentPage.createStringResource("FocusListInlineMenuHelper.menu.disable"), isHeader ? new Model<Boolean>(true) : new Model<Boolean>(false), isHeader ? new Model<Boolean>(true) : new Model<Boolean>(false), false, new ColumnMenuAction<SelectableBean<F>>() {
@Override
public void onClick(AjaxRequestTarget target) {
if (getRowModel() == null) {
updateActivationPerformed(target, false, null);
} else {
SelectableBean<F> rowDto = getRowModel().getObject();
updateActivationPerformed(target, false, rowDto.getValue());
}
}
}, isHeader ? InlineMenuItem.FOCUS_LIST_INLINE_MENU_ITEM_ID.HEADER_DISABLE.getMenuItemId() : InlineMenuItem.FOCUS_LIST_INLINE_MENU_ITEM_ID.DISABLE.getMenuItemId(), GuiStyleConstants.CLASS_OBJECT_USER_ICON, DoubleButtonColumn.BUTTON_COLOR_CLASS.DANGER.toString()) {
private static final long serialVersionUID = 1L;
@Override
public boolean isShowConfirmationDialog() {
return FocusListInlineMenuHelper.this.isShowConfirmationDialog((ColumnMenuAction) getAction());
}
@Override
public IModel<String> getConfirmationMessageModel() {
String actionName = parentPage.createStringResource("pageUsers.message.disableAction").getString();
return FocusListInlineMenuHelper.this.getConfirmationMessageModel((ColumnMenuAction) getAction(), actionName);
}
});
menu.add(new InlineMenuItem(parentPage.createStringResource("FocusListInlineMenuHelper.menu.reconcile"), new Model<Boolean>(false), new Model<Boolean>(false), false, new ColumnMenuAction<SelectableBean<F>>() {
@Override
public void onClick(AjaxRequestTarget target) {
if (getRowModel() == null) {
reconcilePerformed(target, null);
} else {
SelectableBean<F> rowDto = getRowModel().getObject();
reconcilePerformed(target, rowDto.getValue());
}
}
}, isHeader ? InlineMenuItem.FOCUS_LIST_INLINE_MENU_ITEM_ID.HEADER_RECONCILE.getMenuItemId() : InlineMenuItem.FOCUS_LIST_INLINE_MENU_ITEM_ID.RECONCILE.getMenuItemId(), GuiStyleConstants.CLASS_RECONCILE_MENU_ITEM, DoubleButtonColumn.BUTTON_COLOR_CLASS.INFO.toString()) {
private static final long serialVersionUID = 1L;
@Override
public boolean isShowConfirmationDialog() {
return FocusListInlineMenuHelper.this.isShowConfirmationDialog((ColumnMenuAction) getAction());
}
@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"), new ColumnMenuAction<SelectableBean<F>>() {
@Override
public void onClick(AjaxRequestTarget target) {
if (getRowModel() == null) {
deleteConfirmedPerformed(target, null);
} else {
SelectableBean<F> rowDto = getRowModel().getObject();
deleteConfirmedPerformed(target, rowDto.getValue());
}
}
}) {
private static final long serialVersionUID = 1L;
@Override
public boolean isShowConfirmationDialog() {
return FocusListInlineMenuHelper.this.isShowConfirmationDialog((ColumnMenuAction) getAction());
}
@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 TreeTablePanel method createTreeChildrenMenu.
private List<InlineMenuItem> createTreeChildrenMenu(TreeSelectableBean<OrgType> org) {
List<InlineMenuItem> items = new ArrayList<>();
boolean isAllowModify = isAllowModify(org.getValue());
boolean isAllowRead = isAllowRead(org.getValue());
InlineMenuItem item;
if (WebComponentUtil.isAuthorized(AuthorizationConstants.AUTZ_UI_ADMIN_ORG_MOVE_ACTION_URI)) {
item = new InlineMenuItem(createStringResource("TreeTablePanel.move")) {
private static final long serialVersionUID = 1L;
@Override
public InlineMenuItemAction initAction() {
return new ColumnMenuAction<SelectableBeanImpl<OrgType>>() {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
moveRootPerformed(org, target);
}
};
}
};
items.add(item);
}
if (WebComponentUtil.isAuthorized(AuthorizationConstants.AUTZ_UI_ADMIN_ORG_MAKE_ROOT_ACTION_URI)) {
item = new InlineMenuItem(createStringResource("TreeTablePanel.makeRoot")) {
private static final long serialVersionUID = 1L;
@Override
public InlineMenuItemAction initAction() {
return new ColumnMenuAction<SelectableBeanImpl<OrgType>>() {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
makeRootPerformed(org, target);
}
};
}
};
items.add(item);
}
item = new InlineMenuItem(createStringResource("TreeTablePanel.delete")) {
private static final long serialVersionUID = 1L;
@Override
public InlineMenuItemAction initAction() {
return new ColumnMenuAction<SelectableBeanImpl<OrgType>>() {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
deleteNodePerformed(org, target);
}
};
}
@Override
public IModel<Boolean> getVisible() {
return Model.of(isAllowDelete(org.getValue()));
}
};
items.add(item);
item = new InlineMenuItem(createStringResource("TreeTablePanel.recompute")) {
private static final long serialVersionUID = 1L;
@Override
public InlineMenuItemAction initAction() {
return new ColumnMenuAction<SelectableBeanImpl<OrgType>>() {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
recomputeRootPerformed(org, target);
}
};
}
@Override
public IModel<Boolean> getVisible() {
return Model.of(isAllowModify);
}
};
items.add(item);
InlineMenuItem editMenuItem = new InlineMenuItem(createStringResource("TreeTablePanel.edit")) {
private static final long serialVersionUID = 1L;
@Override
public InlineMenuItemAction initAction() {
return new ColumnMenuAction<SelectableBeanImpl<OrgType>>() {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
editRootPerformed(org);
}
};
}
@Override
public IModel<Boolean> getVisible() {
return Model.of(isAllowModify);
}
};
items.add(editMenuItem);
item = new InlineMenuItem(createStringResource("TreeTablePanel.viewDetails")) {
private static final long serialVersionUID = 1L;
@Override
public InlineMenuItemAction initAction() {
return new ColumnMenuAction<SelectableBeanImpl<OrgType>>() {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
editRootPerformed(org);
}
};
}
@Override
public IModel<Boolean> getVisible() {
return Model.of(!editMenuItem.getVisible().getObject() && isAllowRead);
}
};
items.add(item);
item = new InlineMenuItem(createStringResource("TreeTablePanel.createChild")) {
private static final long serialVersionUID = 1L;
@Override
public InlineMenuItemAction initAction() {
return new ColumnMenuAction<SelectableBeanImpl<OrgType>>() {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
try {
initObjectForAdd(ObjectTypeUtil.createObjectRef(org.getValue(), getPageBase().getPrismContext()), target);
} catch (SchemaException e) {
throw new SystemException(e.getMessage(), e);
}
}
};
}
@Override
public IModel<Boolean> getVisible() {
return Model.of(isAllowRead && isAllowAddNew());
}
};
items.add(item);
return items;
}
use of com.evolveum.midpoint.web.component.data.column.ColumnMenuAction in project midpoint by Evolveum.
the class AbstractAssignmentTypePanel method createViewTargetObjectAction.
private ButtonInlineMenuItem createViewTargetObjectAction() {
ButtonInlineMenuItem menu = new ButtonInlineMenuItem(createStringResource("AssignmentPanel.viewTargetObject")) {
private static final long serialVersionUID = 1L;
@Override
public CompositedIconBuilder getIconCompositedBuilder() {
return getDefaultCompositedIconBuilder(GuiStyleConstants.CLASS_NAVIGATE_ARROW);
}
@Override
public InlineMenuItemAction initAction() {
return new ColumnMenuAction<PrismContainerValueWrapper<AssignmentType>>() {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
targetObjectDetailsPerformed(target, getRowModel().getObject());
}
};
}
@Override
public boolean isHeaderMenuItem() {
return false;
}
};
menu.setVisibilityChecker(isViewTargetObjectMenuVisible());
return menu;
}
use of com.evolveum.midpoint.web.component.data.column.ColumnMenuAction in project midpoint by Evolveum.
the class WebComponentUtil method createMenuItemsFromActions.
@NotNull
public static List<InlineMenuItem> createMenuItemsFromActions(@NotNull List<GuiActionType> actions, String operation, PageBase pageBase, @NotNull Supplier<Collection<? extends ObjectType>> selectedObjectsSupplier) {
List<InlineMenuItem> menuItems = new ArrayList<>();
actions.forEach(action -> {
if (action.getTaskTemplateRef() == null) {
return;
}
String templateOid = action.getTaskTemplateRef().getOid();
if (StringUtils.isEmpty(templateOid)) {
return;
}
String label = action.getDisplay() != null && PolyStringUtils.isNotEmpty(action.getDisplay().getLabel()) ? action.getDisplay().getLabel().getOrig() : action.getName();
menuItems.add(new InlineMenuItem(Model.of(label)) {
private static final long serialVersionUID = 1L;
@Override
public InlineMenuItemAction initAction() {
return new ColumnMenuAction<SelectableBean<ObjectType>>() {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
OperationResult result = new OperationResult(operation);
try {
Collection<String> oids;
if (getRowModel() != null) {
oids = Collections.singletonList(getRowModel().getObject().getValue().getOid());
} else {
oids = CollectionUtils.emptyIfNull(selectedObjectsSupplier.get()).stream().filter(o -> o.getOid() != null).map(o -> o.getOid()).collect(Collectors.toSet());
}
if (!oids.isEmpty()) {
@NotNull Item<PrismValue, ItemDefinition> extensionQuery = prepareExtensionValues(oids);
MidPointPrincipal principal = pageBase.getPrincipal();
if (principal == null) {
throw new SecurityViolationException("No current user");
}
TaskType newTask = pageBase.getModelService().getObject(TaskType.class, templateOid, createCollection(createExecutionPhase()), pageBase.createSimpleTask(operation), result).asObjectable();
newTask.setName(PolyStringType.fromOrig(newTask.getName().getOrig() + " " + (int) (Math.random() * 10000)));
newTask.setOid(null);
newTask.setTaskIdentifier(null);
newTask.setOwnerRef(createObjectRef(principal.getFocus()));
newTask.setExecutionState(RUNNABLE);
newTask.setSchedulingState(READY);
newTask.asPrismObject().getOrCreateExtension().add(extensionQuery);
ObjectSetBasedWorkDefinitionType workDef = ObjectSetUtil.getObjectSetDefinitionFromTask(newTask);
QueryType query = (QueryType) extensionQuery.getRealValue();
ObjectSetType objectSet = workDef.getObjects();
if (objectSet == null) {
objectSet = new ObjectSetType();
objectSet.setType(ObjectType.COMPLEX_TYPE);
}
objectSet.setQuery(query);
workDef.setObjects(objectSet);
ObjectDelta<TaskType> delta = DeltaFactory.Object.createAddDelta(newTask.asPrismObject());
Collection<ObjectDeltaOperation<? extends ObjectType>> executedChanges = saveTask(delta, result, pageBase);
String newTaskOid = ObjectDeltaOperation.findAddDeltaOid(executedChanges, newTask.asPrismObject());
newTask.setOid(newTaskOid);
newTask.setTaskIdentifier(newTaskOid);
result.setInProgress();
result.setBackgroundTaskOid(newTask.getOid());
} else {
result.recordWarning(pageBase.createStringResource("WebComponentUtil.message.createMenuItemsFromActions.warning").getString());
}
} catch (Exception ex) {
result.recordFatalError(result.getOperation(), ex);
target.add(pageBase.getFeedbackPanel());
} finally {
pageBase.showResult(result);
target.add(pageBase.getFeedbackPanel());
}
}
};
}
/**
* Extension values are task-dependent. Therefore, in the future we will probably make
* this behaviour configurable. For the time being we assume that the task template will be
* of "iterative task handler" type and so it will expect mext:objectQuery extension property.
*
* FIXME
*/
@NotNull
private Item<PrismValue, ItemDefinition> prepareExtensionValues(Collection<String> oids) throws SchemaException {
PrismContext prismContext = pageBase.getPrismContext();
ObjectQuery objectQuery = prismContext.queryFor(ObjectType.class).id(oids.toArray(new String[0])).build();
QueryType queryBean = pageBase.getQueryConverter().createQueryType(objectQuery);
PrismContainerDefinition<?> extDef = PrismContext.get().getSchemaRegistry().findObjectDefinitionByCompileTimeClass(TaskType.class).findContainerDefinition(TaskType.F_EXTENSION);
ItemDefinition<Item<PrismValue, ItemDefinition>> def = extDef != null ? extDef.findItemDefinition(SchemaConstants.MODEL_EXTENSION_OBJECT_QUERY) : null;
if (def == null) {
throw new SchemaException("No definition of " + SchemaConstants.MODEL_EXTENSION_OBJECT_QUERY + " in the extension");
}
Item<PrismValue, ItemDefinition> extensionItem = def.instantiate();
extensionItem.add(prismContext.itemFactory().createValue(queryBean));
return extensionItem;
}
});
});
return menuItems;
}
Aggregations