use of com.evolveum.midpoint.model.api.authentication.CompiledObjectCollectionView in project midpoint by Evolveum.
the class MainObjectListPanel method createNewObjectButton.
private Component createNewObjectButton(String buttonId) {
DisplayType newObjectButtonDisplayType = getNewObjectButtonStandardDisplayType();
CompositedIconBuilder builder = new CompositedIconBuilder();
builder.setBasicIcon(WebComponentUtil.getIconCssClass(newObjectButtonDisplayType), IconCssStyle.IN_ROW_STYLE).appendColorHtmlValue(WebComponentUtil.getIconColor(newObjectButtonDisplayType));
CompiledObjectCollectionView view = getObjectCollectionView();
if (ObjectCollectionViewUtil.isArchetypedCollectionView(view)) {
IconType plusIcon = new IconType();
plusIcon.setCssClass(GuiStyleConstants.CLASS_ADD_NEW_OBJECT);
plusIcon.setColor("green");
builder.appendLayerIcon(plusIcon, LayeredIconCssStyle.BOTTOM_RIGHT_STYLE);
}
String iconTitle = WebComponentUtil.getDisplayTypeTitle(newObjectButtonDisplayType);
AjaxCompositedIconButton createNewObjectButton = new AjaxCompositedIconButton(buttonId, builder.build(), createStringResource(StringUtils.isEmpty(iconTitle) ? "MainObjectListPanel.newObject" : iconTitle)) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
if (isCollectionViewPanelForCompiledView()) {
CompiledObjectCollectionView collectionView = getObjectCollectionView();
// HACK TODO clenup and think about generic mechanism for this
if (isCollectionViewWithoutMorePossibleNewType(collectionView)) {
newObjectPerformed(target, null, collectionView);
return;
}
}
if (!showNewObjectCreationPopup()) {
newObjectPerformed(target, null, getObjectCollectionView());
return;
}
NewObjectCreationPopup buttonsPanel = new NewObjectCreationPopup(getPageBase().getMainPopupBodyId(), new PropertyModel<>(loadButtonDescriptions(), MultiFunctinalButtonDto.F_ADDITIONAL_BUTTONS)) {
private static final long serialVersionUID = 1L;
@Override
protected void buttonClickPerformed(AjaxRequestTarget target, AssignmentObjectRelation relationSpec, CompiledObjectCollectionView collectionViews, Class<? extends WebPage> page) {
getPageBase().hideMainPopup(target);
MainObjectListPanel.this.newObjectPerformed(target, relationSpec, collectionViews);
}
};
getPageBase().showMainPopup(buttonsPanel, target);
}
};
createNewObjectButton.add(new VisibleBehaviour(this::isCreateNewObjectEnabled));
createNewObjectButton.add(AttributeAppender.append("class", "btn btn-default btn-sm"));
return createNewObjectButton;
}
use of com.evolveum.midpoint.model.api.authentication.CompiledObjectCollectionView in project midpoint by Evolveum.
the class PageCreateFromTemplate method loadButtonDescriptions.
protected LoadableModel<MultiFunctinalButtonDto> loadButtonDescriptions() {
return new LoadableModel<>(false) {
@Override
protected MultiFunctinalButtonDto load() {
List<CompositedIconButtonDto> additionalButtons = new ArrayList<>();
Collection<CompiledObjectCollectionView> compiledObjectCollectionViews = getCompiledGuiProfile().findAllApplicableArchetypeViews(getType(), OperationTypeType.ADD);
if (CollectionUtils.isNotEmpty(compiledObjectCollectionViews)) {
compiledObjectCollectionViews.forEach(collection -> {
CompositedIconButtonDto buttonDesc = new CompositedIconButtonDto();
buttonDesc.setCompositedIcon(createCompositedIcon(collection));
buttonDesc.setOrCreateDefaultAdditionalButtonDisplayType(collection.getDisplay());
buttonDesc.setCollectionView(collection);
additionalButtons.add(buttonDesc);
});
}
if (isGenericNewButtonVisible()) {
CompositedIconButtonDto defaultButton = new CompositedIconButtonDto();
DisplayType defaultButtonDisplayType = getDefaultButtonDisplayType();
defaultButton.setAdditionalButtonDisplayType(defaultButtonDisplayType);
CompositedIconBuilder defaultButtonIconBuilder = new CompositedIconBuilder();
defaultButtonIconBuilder.setBasicIcon(WebComponentUtil.getIconCssClass(defaultButtonDisplayType), IconCssStyle.IN_ROW_STYLE).appendColorHtmlValue(WebComponentUtil.getIconColor(defaultButtonDisplayType));
defaultButton.setCompositedIcon(defaultButtonIconBuilder.build());
additionalButtons.add(defaultButton);
}
MultiFunctinalButtonDto multifunctionalButton = new MultiFunctinalButtonDto();
multifunctionalButton.setAdditionalButtons(additionalButtons);
return multifunctionalButton;
}
};
}
use of com.evolveum.midpoint.model.api.authentication.CompiledObjectCollectionView in project midpoint by Evolveum.
the class PageCreateFromTemplate method initLayout.
private void initLayout() {
MultiCompositedButtonPanel buttonsPanel = new MultiCompositedButtonPanel(ID_TEMPLATE, new PropertyModel<>(loadButtonDescriptions(), MultiFunctinalButtonDto.F_ADDITIONAL_BUTTONS)) {
private static final long serialVersionUID = 1L;
@Override
protected void buttonClickPerformed(AjaxRequestTarget target, AssignmentObjectRelation relationSpec, CompiledObjectCollectionView collectionViews, Class<? extends WebPage> page) {
List<ObjectReferenceType> archetypeRef = ObjectCollectionViewUtil.getArchetypeReferencesList(collectionViews);
try {
WebComponentUtil.initNewObjectWithReference(getPageBase(), getType(), archetypeRef);
} catch (SchemaException ex) {
getPageBase().getFeedbackMessages().error(PageCreateFromTemplate.this, ex.getUserFriendlyMessage());
target.add(getPageBase().getFeedbackPanel());
}
}
};
add(buttonsPanel);
}
use of com.evolveum.midpoint.model.api.authentication.CompiledObjectCollectionView in project midpoint by Evolveum.
the class ResourceTasksPanel method initLayout.
protected void initLayout() {
final MainObjectListPanel<TaskType> tasksPanel = new MainObjectListPanel<>(ID_TASKS_TABLE, TaskType.class, null) {
private static final long serialVersionUID = 1L;
@Override
protected UserProfileStorage.TableId getTableId() {
return UserProfileStorage.TableId.PAGE_RESOURCE_TASKS_PANEL;
}
@Override
protected ISelectableDataProvider<TaskType, SelectableBean<TaskType>> createProvider() {
return createSelectableBeanObjectDataProvider(() -> createResourceTasksQuery(), null);
}
@Override
protected List<InlineMenuItem> createInlineMenu() {
return null;
}
@Override
protected void newObjectPerformed(AjaxRequestTarget target, AssignmentObjectRelation relation, CompiledObjectCollectionView collectionView) {
if (collectionView == null) {
collectionView = getObjectCollectionView();
}
List<ObjectReferenceType> archetypeRef = ObjectCollectionViewUtil.getArchetypeReferencesList(collectionView);
try {
PrismContext prismContext = getPrismContext();
PrismObjectDefinition<TaskType> def = prismContext.getSchemaRegistry().findObjectDefinitionByType(TaskType.COMPLEX_TYPE);
PrismObject<TaskType> obj = def.instantiate();
TaskType newTask = obj.asObjectable();
ObjectReferenceType resourceRef = new ObjectReferenceType();
resourceRef.setOid(ResourceTasksPanel.this.getModelObject().getOid());
resourceRef.setType(ResourceType.COMPLEX_TYPE);
newTask.setObjectRef(resourceRef);
WebComponentUtil.initNewObjectWithReference(getPageBase(), newTask, archetypeRef);
} catch (SchemaException ex) {
getPageBase().getFeedbackMessages().error(ResourceTasksPanel.this, ex.getUserFriendlyMessage());
target.add(getPageBase().getFeedbackPanel());
}
}
@Override
protected List<IColumn<SelectableBean<TaskType>, String>> createDefaultColumns() {
return ColumnUtils.getDefaultTaskColumns();
}
@Override
protected List<CompiledObjectCollectionView> getNewObjectInfluencesList() {
List<CompiledObjectCollectionView> newObjectInfluencesList = super.getNewObjectInfluencesList();
List<CompiledObjectCollectionView> filteredInfluencesList = new ArrayList<>();
if (newObjectInfluencesList != null) {
newObjectInfluencesList.forEach(influence -> {
if (influence.getCollection() != null && influence.getCollection().getCollectionRef() != null && ArrayUtils.contains(resourceTaskArchetypeOids, influence.getCollection().getCollectionRef().getOid())) {
filteredInfluencesList.add(influence);
}
});
}
return filteredInfluencesList;
}
};
tasksPanel.setAdditionalBoxCssClasses(GuiStyleConstants.CLASS_OBJECT_TASK_BOX_CSS_CLASSES);
add(tasksPanel);
AjaxButton runNow = new AjaxButton(ID_RUN_NOW, getPageBase().createStringResource("pageTaskEdit.button.runNow")) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
List<String> oids = createOidList(getTaskListPanel().getSelectedRealObjects());
if (!oids.isEmpty()) {
OperationResult result = TaskOperationUtils.runNowPerformed(oids, getPageBase());
getPageBase().showResult(result);
} else {
noTasksSelected();
}
target.add(getPageBase().getFeedbackPanel());
}
};
add(runNow);
AjaxButton resume = new AjaxButton(ID_RESUME, getPageBase().createStringResource("pageTaskEdit.button.resume")) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
List<TaskType> tasks = getTaskListPanel().getSelectedRealObjects();
if (!tasks.isEmpty()) {
OperationResult result = TaskOperationUtils.resumeTasks(tasks, getPageBase());
getPageBase().showResult(result);
} else {
noTasksSelected();
}
target.add(getPageBase().getFeedbackPanel());
}
};
add(resume);
AjaxButton suspend = new AjaxButton(ID_SUSPEND, getPageBase().createStringResource("pageTaskEdit.button.suspend")) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
List<TaskType> tasks = getTaskListPanel().getSelectedRealObjects();
if (!tasks.isEmpty()) {
OperationResult result = TaskOperationUtils.suspendTasks(tasks, getPageBase());
getPageBase().showResult(result);
} else {
noTasksSelected();
}
target.add(getPageBase().getFeedbackPanel());
}
};
add(suspend);
}
use of com.evolveum.midpoint.model.api.authentication.CompiledObjectCollectionView in project midpoint by Evolveum.
the class AbstractRoleMemberPanel method initMemberTable.
private <AH extends AssignmentHolderType> void initMemberTable(Form<?> form) {
WebMarkupContainer memberContainer = new WebMarkupContainer(ID_CONTAINER_MEMBER);
memberContainer.setOutputMarkupId(true);
memberContainer.setOutputMarkupPlaceholderTag(true);
form.add(memberContainer);
// TODO QName defines a relation value which will be used for new member creation
MainObjectListPanel<AH> childrenListPanel = new MainObjectListPanel<>(ID_MEMBER_TABLE, getDefaultObjectTypeClass(), getSearchOptions()) {
private static final long serialVersionUID = 1L;
@Override
protected UserProfileStorage.TableId getTableId() {
return AbstractRoleMemberPanel.this.getTableId(getComplexTypeQName());
}
@Override
protected List<IColumn<SelectableBean<AH>, String>> createDefaultColumns() {
List<IColumn<SelectableBean<AH>, String>> columns = super.createDefaultColumns();
columns.add(createRelationColumn());
return columns;
}
@Override
protected boolean isObjectDetailsEnabled(IModel<SelectableBean<AH>> rowModel) {
if (rowModel == null || rowModel.getObject() == null || rowModel.getObject().getValue() == null) {
return false;
}
Class<?> objectClass = rowModel.getObject().getValue().getClass();
return WebComponentUtil.hasDetailsPage(objectClass);
}
@Override
protected boolean showNewObjectCreationPopup() {
return CollectionUtils.isNotEmpty(getNewObjectReferencesList(getObjectCollectionView(), null));
}
@Override
protected List<Component> createToolbarButtonsList(String buttonId) {
List<Component> buttonsList = super.createToolbarButtonsList(buttonId);
AjaxIconButton assignButton = createAssignButton(buttonId);
buttonsList.add(1, assignButton);
return buttonsList;
}
@Override
protected List<InlineMenuItem> createInlineMenu() {
return createRowActions();
}
@Override
protected String getStorageKey() {
return AbstractRoleMemberPanel.this.createStorageKey();
}
protected PageStorage getPageStorage(String storageKey) {
return getSession().getSessionStorage().getPageStorageMap().get(storageKey);
}
@Override
protected Search<AH> createSearch(Class<AH> type) {
return createMemberSearch(type);
}
@Override
protected SelectableBeanObjectDataProvider<AH> createProvider() {
SelectableBeanObjectDataProvider<AH> provider = createSelectableBeanObjectDataProvider(() -> getCustomizedQuery(getSearchModel().getObject()), null);
provider.setIsMemberPanel(true);
provider.addQueryVariables(ExpressionConstants.VAR_PARENT_OBJECT, AbstractRoleMemberPanel.this.getModelObject());
return provider;
}
@Override
public void refreshTable(AjaxRequestTarget target) {
if (getSearchModel().isAttached() && getSearchModel().getObject() != null && getSearchModel().getObject().isTypeChanged()) {
clearCache();
}
if (reloadPageOnRefresh()) {
throw new RestartResponseException(getPage().getClass());
} else {
super.refreshTable(target);
}
}
@Override
protected List<ObjectReferenceType> getNewObjectReferencesList(CompiledObjectCollectionView collectionView, AssignmentObjectRelation relation) {
List<ObjectReferenceType> refList = super.getNewObjectReferencesList(collectionView, relation);
if (refList == null) {
refList = new ArrayList<>();
}
if (relation != null && CollectionUtils.isNotEmpty(relation.getArchetypeRefs())) {
refList.addAll(relation.getArchetypeRefs());
}
ObjectReferenceType membershipRef = new ObjectReferenceType();
membershipRef.setOid(AbstractRoleMemberPanel.this.getModelObject().getOid());
membershipRef.setType(AbstractRoleMemberPanel.this.getModelObject().asPrismObject().getComplexTypeDefinition().getTypeName());
membershipRef.setRelation(relation != null && CollectionUtils.isNotEmpty(relation.getRelations()) ? relation.getRelations().get(0) : null);
refList.add(membershipRef);
return refList;
}
@Override
protected LoadableModel<MultiFunctinalButtonDto> loadButtonDescriptions() {
return loadMultiFunctionalButtonModel(true);
}
@Override
protected String getTitleForNewObjectButton() {
return createStringResource("TreeTablePanel.menu.createMember").getString();
}
};
childrenListPanel.setOutputMarkupId(true);
memberContainer.add(childrenListPanel);
}
Aggregations