use of com.evolveum.midpoint.web.component.menu.cog.InlineMenuItemAction in project midpoint by Evolveum.
the class AssignmentPanel method getAssignmentMenuActions.
private <AH extends FocusType> List<InlineMenuItem> getAssignmentMenuActions() {
List<InlineMenuItem> menuItems = new ArrayList<>();
PrismObject<AH> obj = getMultivalueContainerListPanel().getFocusObject();
try {
boolean isUnassignAuthorized = getParentPage().isAuthorized(AuthorizationConstants.AUTZ_UI_ADMIN_UNASSIGN_ACTION_URI, AuthorizationPhaseType.REQUEST, obj, null, null, null);
if (isUnassignAuthorized) {
menuItems.add(new ButtonInlineMenuItem(getAssignmentsLimitReachedUnassignTitleModel()) {
private static final long serialVersionUID = 1L;
@Override
public CompositedIconBuilder getIconCompositedBuilder() {
return getDefaultCompositedIconBuilder(GuiStyleConstants.CLASS_DELETE_MENU_ITEM);
}
@Override
public InlineMenuItemAction initAction() {
return getMultivalueContainerListPanel().createDeleteColumnAction();
}
});
}
} catch (Exception ex) {
LOGGER.error("Couldn't check unassign authorization for the object: {}, {}", obj.getName(), ex.getLocalizedMessage());
if (WebComponentUtil.isAuthorized(AuthorizationConstants.AUTZ_UI_ADMIN_ASSIGN_ACTION_URI)) {
menuItems.add(new ButtonInlineMenuItem(createStringResource("PageBase.button.unassign")) {
private static final long serialVersionUID = 1L;
@Override
public CompositedIconBuilder getIconCompositedBuilder() {
return getDefaultCompositedIconBuilder(GuiStyleConstants.CLASS_DELETE_MENU_ITEM);
}
@Override
public InlineMenuItemAction initAction() {
return getMultivalueContainerListPanel().createDeleteColumnAction();
}
});
}
}
menuItems.add(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 getMultivalueContainerListPanel().createEditColumnAction();
}
});
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) {
PrismContainerValueWrapper<AssignmentType> assignmentContainer = getRowModel().getObject();
PrismReferenceWrapper<ObjectReferenceType> targetRef;
try {
targetRef = assignmentContainer.findReference(ItemPath.create(AssignmentType.F_TARGET_REF));
} catch (SchemaException e) {
getSession().error("Couldn't show details page. More information provided in log.");
LOGGER.error("Couldn't show details page, no targetRef reference wrapper found: {}", e.getMessage(), e);
target.add(getPageBase().getFeedbackPanel());
return;
}
if (targetRef != null && targetRef.getValues() != null && targetRef.getValues().size() > 0) {
PrismReferenceValueWrapperImpl<ObjectReferenceType> refWrapper = targetRef.getValues().get(0);
if (!StringUtils.isEmpty(refWrapper.getNewValue().getOid())) {
Class<? extends ObjectType> targetClass = ObjectTypes.getObjectTypeFromTypeQName(refWrapper.getRealValue().getType()).getClassDefinition();
WebComponentUtil.dispatchToObjectDetailsPage(targetClass, refWrapper.getNewValue().getOid(), AssignmentPanel.this, false);
}
}
}
};
}
@Override
public boolean isHeaderMenuItem() {
return false;
}
};
menu.setVisibilityChecker((InlineMenuItem.VisibilityChecker) (rowModel, isHeader) -> {
PrismContainerValueWrapper<AssignmentType> assignment = (PrismContainerValueWrapper<AssignmentType>) rowModel.getObject();
if (assignment == null) {
return false;
}
PrismReferenceWrapper<Referencable> target = null;
try {
target = assignment.findReference(AssignmentType.F_TARGET_REF);
} catch (Exception e) {
LOGGER.error("Couldn't find targetRef in assignment");
}
return target != null && !target.isEmpty();
});
menuItems.add(menu);
return menuItems;
}
use of com.evolveum.midpoint.web.component.menu.cog.InlineMenuItemAction in project midpoint by Evolveum.
the class SearchPanel method getSavedSearchList.
private List<InlineMenuItem> getSavedSearchList() {
ContainerableListPanel listPanel = findParent(ContainerableListPanel.class);
List<InlineMenuItem> savedSearchItems = new ArrayList<>();
List<AvailableFilterType> availableFilterList = null;
if (listPanel != null) {
CompiledObjectCollectionView view = listPanel.getObjectCollectionView();
availableFilterList = view != null ? getAvailableFilterList(view.getSearchBoxConfiguration()) : null;
} else {
FocusType principalFocus = getPageBase().getPrincipalFocus();
GuiObjectListViewType view = WebComponentUtil.getPrincipalUserObjectListView(getPageBase(), principalFocus, getModelObject().getTypeClass(), false);
availableFilterList = view != null ? getAvailableFilterList(view.getSearchBoxConfiguration()) : null;
}
if (availableFilterList != null) {
availableFilterList.stream().filter(filter -> getModelObject().getSearchMode().equals(filter.getSearchMode())).forEach(filter -> {
PolyStringType filterLabel = filter.getDisplay() != null ? filter.getDisplay().getLabel() : null;
InlineMenuItem searchItem = new InlineMenuItem(Model.of(WebComponentUtil.getTranslatedPolyString(filterLabel))) {
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) {
if (filter == null) {
return;
}
if (SearchBoxModeType.BASIC.equals(filter.getSearchMode())) {
applyFilterToBasicMode(filter.getSearchItem());
} else if (SearchBoxModeType.AXIOM_QUERY.equals(filter.getSearchMode())) {
applyFilterToAxiomMode(filter.getSearchItem());
} else if (SearchBoxModeType.FULLTEXT.equals(filter.getSearchMode())) {
applyFilterToFulltextMode(filter.getSearchItem());
}
searchPerformed(target);
}
};
}
};
savedSearchItems.add(searchItem);
});
}
return savedSearchItems;
}
use of com.evolveum.midpoint.web.component.menu.cog.InlineMenuItemAction in project midpoint by Evolveum.
the class SearchPanel method getSearchBoxTypesList.
private List<InlineMenuItem> getSearchBoxTypesList() {
List<InlineMenuItem> searchItems = new ArrayList<>();
List<SearchBoxModeType> modeList = getSearchConfigurationWrapper().getAllowedModeList();
for (SearchBoxModeType searchBoxModeType : modeList) {
InlineMenuItem searchItem = new InlineMenuItem(createStringResource(searchBoxModeType)) {
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) {
searchBoxTypeUpdated(target, searchBoxModeType);
}
};
}
@Override
public IModel<Boolean> getVisible() {
if (SearchBoxModeType.AXIOM_QUERY.equals(searchBoxModeType)) {
return Model.of(WebModelServiceUtils.isEnableExperimentalFeature(getPageBase()) && getSearchConfigurationWrapper().getAllowedModeList().contains(searchBoxModeType));
}
return Model.of(getSearchConfigurationWrapper().getAllowedModeList().contains(searchBoxModeType));
}
};
searchItems.add(searchItem);
}
return searchItems;
}
use of com.evolveum.midpoint.web.component.menu.cog.InlineMenuItemAction 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.menu.cog.InlineMenuItemAction in project midpoint by Evolveum.
the class ExecuteChangeOptionsPanel method createTracingDropdownButton.
// todo rework, this now creates only one item in dropdown with multiple input[option], therefore dropdown is not correctly rendered (each item should be created separately, like for options)
private void createTracingDropdownButton() {
List<InlineMenuItem> items = new ArrayList<>();
items.add(new InlineMenuItem(createStringResource("ExecuteChangeOptionsPanel.tracing")) {
@Override
public InlineMenuItemAction initAction() {
return null;
}
});
DropdownButtonDto model = new DropdownButtonDto(null, GuiStyleConstants.CLASS_TRACING_BUTTON_ICON, getString("ExecuteChangeOptionsPanel.tracing"), items);
DropdownButtonPanel dropdownButtonPanel = new DropdownButtonPanel(ID_TRACING, model) {
@Override
protected void populateMenuItem(String componentId, ListItem<InlineMenuItem> menuItem) {
menuItem.add(createTracingRadioChoicesFragment(componentId));
}
@Override
protected String getSpecialButtonClass() {
return "mr-2 btn-sm btn-default";
}
};
add(dropdownButtonPanel);
dropdownButtonPanel.setOutputMarkupId(true);
dropdownButtonPanel.add(new VisibleBehaviour(this::isTracingEnabled));
}
Aggregations