use of com.evolveum.midpoint.web.component.util.ProjectionsListProvider in project midpoint by Evolveum.
the class FocusProjectionsPanel method initLayout.
protected void initLayout() {
IModel<Integer> deadShadows = new ReadOnlyModel<>(this::countDeadShadows);
Label label = new Label(ID_DEAD_SHADOWS, deadShadows);
label.add(new VisibleBehaviour(() -> deadShadows.getObject() > 0));
add(label);
MultivalueContainerListPanelWithDetailsPanel<ShadowType> multivalueContainerListPanel = new MultivalueContainerListPanelWithDetailsPanel<ShadowType>(ID_SHADOW_TABLE, ShadowType.class, getPanelConfiguration()) {
private static final long serialVersionUID = 1L;
@Override
protected ISelectableDataProvider<ShadowType, PrismContainerValueWrapper<ShadowType>> createProvider() {
return new ProjectionsListProvider(FocusProjectionsPanel.this, getSearchModel(), loadShadowModel()) {
@Override
protected PageStorage getPageStorage() {
PageStorage storage = getSession().getSessionStorage().getPageStorageMap().get(SessionStorage.KEY_FOCUS_PROJECTION_TABLE);
if (storage == null) {
storage = getSession().getSessionStorage().initPageStorage(SessionStorage.KEY_FOCUS_PROJECTION_TABLE);
}
return storage;
}
};
}
@Override
protected void newItemPerformed(AjaxRequestTarget target, AssignmentObjectRelation relation) {
List<QName> supportedTypes = Arrays.asList(ResourceType.COMPLEX_TYPE);
PageBase pageBase = FocusProjectionsPanel.this.getPageBase();
ObjectBrowserPanel<ResourceType> resourceSelectionPanel = new ObjectBrowserPanel<>(pageBase.getMainPopupBodyId(), ResourceType.class, supportedTypes, true, pageBase) {
private static final long serialVersionUID = 1L;
@Override
protected void addPerformed(AjaxRequestTarget target, QName type, List<ResourceType> selected) {
FocusProjectionsPanel.this.addSelectedAccountPerformed(target, selected);
target.add(getPageBase().getFeedbackPanel());
}
};
resourceSelectionPanel.setOutputMarkupId(true);
pageBase.showMainPopup(resourceSelectionPanel, target);
}
@Override
protected boolean isCreateNewObjectVisible() {
PrismObjectDefinition<F> def = FocusProjectionsPanel.this.getObjectWrapperModel().getObject().getObject().getDefinition();
PrismReferenceDefinition ref = def.findReferenceDefinition(UserType.F_LINK_REF);
return (ref.canRead() && ref.canAdd());
}
@Override
protected IModel<PrismContainerWrapper<ShadowType>> getContainerModel() {
return null;
}
@Override
protected TableId getTableId() {
return TableId.FOCUS_PROJECTION_TABLE;
}
@Override
protected List<IColumn<PrismContainerValueWrapper<ShadowType>, String>> createDefaultColumns() {
return initBasicColumns();
}
@Override
protected List<InlineMenuItem> createInlineMenu() {
return createShadowMenu();
}
@Override
public void editItemPerformed(AjaxRequestTarget target, IModel<PrismContainerValueWrapper<ShadowType>> rowModel, List<PrismContainerValueWrapper<ShadowType>> listItems) {
loadShadowIfNeeded(rowModel, target);
if (listItems != null) {
listItems.forEach(value -> {
if (((ShadowWrapper) value.getParent()).isLoadWithNoFetch()) {
loadFullShadow((PrismObjectValueWrapper) value, target);
}
});
}
super.editItemPerformed(target, rowModel, listItems);
}
@Override
protected Search createSearch(Class<ShadowType> type) {
Search search = super.createSearch(type);
PropertySearchItem<Boolean> defaultDeadItem = search.findPropertySearchItem(ShadowType.F_DEAD);
if (defaultDeadItem != null) {
defaultDeadItem.setVisible(false);
}
addDeadSearchItem(search);
return search;
}
@Override
protected List<SearchItemDefinition> initSearchableItems(PrismContainerDefinition<ShadowType> containerDef) {
List<SearchItemDefinition> defs = new ArrayList<>();
SearchFactory.addSearchRefDef(containerDef, ShadowType.F_RESOURCE_REF, defs, AreaCategoryType.ADMINISTRATION, getPageBase());
SearchFactory.addSearchPropertyDef(containerDef, ShadowType.F_NAME, defs);
SearchFactory.addSearchPropertyDef(containerDef, ShadowType.F_INTENT, defs);
SearchFactory.addSearchPropertyDef(containerDef, ShadowType.F_KIND, defs);
return defs;
}
@Override
protected MultivalueContainerDetailsPanel<ShadowType> getMultivalueContainerDetailsPanel(ListItem<PrismContainerValueWrapper<ShadowType>> item) {
return FocusProjectionsPanel.this.getMultivalueContainerDetailsPanel(item);
}
};
add(multivalueContainerListPanel);
setOutputMarkupId(true);
}
use of com.evolveum.midpoint.web.component.util.ProjectionsListProvider in project midpoint by Evolveum.
the class FocusProjectionsTabPanel method initLayout.
private void initLayout() {
IModel<Integer> deadShadows = new ReadOnlyModel<>(() -> countDeadShadows());
Label label = new Label(ID_DEAD_SHADOWS, deadShadows);
label.add(new VisibleBehaviour(() -> deadShadows.getObject() > 0));
add(label);
MultivalueContainerListPanelWithDetailsPanel<ShadowType> multivalueContainerListPanel = new MultivalueContainerListPanelWithDetailsPanel<ShadowType>(ID_SHADOW_TABLE, ShadowType.class) {
private static final long serialVersionUID = 1L;
@Override
protected ISelectableDataProvider<ShadowType, PrismContainerValueWrapper<ShadowType>> createProvider() {
return new ProjectionsListProvider(FocusProjectionsTabPanel.this, getSearchModel(), loadShadowModel()) {
@Override
protected PageStorage getPageStorage() {
PageStorage storage = getSession().getSessionStorage().getPageStorageMap().get(SessionStorage.KEY_FOCUS_PROJECTION_TABLE);
if (storage == null) {
storage = getSession().getSessionStorage().initPageStorage(SessionStorage.KEY_FOCUS_PROJECTION_TABLE);
}
return storage;
}
};
}
@Override
protected void newItemPerformed(AjaxRequestTarget target, AssignmentObjectRelation relation) {
List<QName> supportedTypes = new ArrayList<>(1);
supportedTypes.add(ResourceType.COMPLEX_TYPE);
PageBase pageBase = FocusProjectionsTabPanel.this.getPageBase();
ObjectBrowserPanel<ResourceType> resourceSelectionPanel = new ObjectBrowserPanel<ResourceType>(pageBase.getMainPopupBodyId(), ResourceType.class, supportedTypes, true, pageBase) {
private static final long serialVersionUID = 1L;
@Override
protected void addPerformed(AjaxRequestTarget target, QName type, List<ResourceType> selected) {
FocusProjectionsTabPanel.this.addSelectedAccountPerformed(target, selected);
}
};
resourceSelectionPanel.setOutputMarkupId(true);
pageBase.showMainPopup(resourceSelectionPanel, target);
}
@Override
protected boolean isCreateNewObjectVisible() {
PrismObjectDefinition<F> def = getObjectWrapper().getObject().getDefinition();
PrismReferenceDefinition ref = def.findReferenceDefinition(UserType.F_LINK_REF);
return (ref.canRead() && ref.canAdd());
}
@Override
protected IModel<PrismContainerWrapper<ShadowType>> getContainerModel() {
return null;
}
@Override
protected TableId getTableId() {
return UserProfileStorage.TableId.FOCUS_PROJECTION_TABLE;
}
@Override
protected List<IColumn<PrismContainerValueWrapper<ShadowType>, String>> createDefaultColumns() {
return initBasicColumns();
}
@Override
public void editItemPerformed(AjaxRequestTarget target, IModel<PrismContainerValueWrapper<ShadowType>> rowModel, List<PrismContainerValueWrapper<ShadowType>> listItems) {
loadShadowIfNeeded(rowModel, target);
if (listItems != null) {
listItems.forEach(value -> {
if (((ShadowWrapper) value.getParent()).isLoadWithNoFetch()) {
((PageAdminFocus) getPage()).loadFullShadow((PrismObjectValueWrapper) value, target);
}
});
}
super.editItemPerformed(target, rowModel, listItems);
}
@Override
protected Search createSearch(Class<ShadowType> type) {
Search search = super.createSearch(type);
PropertySearchItem<Boolean> defaultDeadItem = search.findPropertySearchItem(ShadowType.F_DEAD);
if (defaultDeadItem != null) {
defaultDeadItem.setVisible(false);
}
addDeadSearchItem(search);
return search;
}
@Override
protected List<SearchItemDefinition> initSearchableItems(PrismContainerDefinition<ShadowType> containerDef) {
List<SearchItemDefinition> defs = new ArrayList<>();
SearchFactory.addSearchRefDef(containerDef, ShadowType.F_RESOURCE_REF, defs, AreaCategoryType.ADMINISTRATION, getPageBase());
SearchFactory.addSearchPropertyDef(containerDef, ShadowType.F_NAME, defs);
SearchFactory.addSearchPropertyDef(containerDef, ShadowType.F_INTENT, defs);
SearchFactory.addSearchPropertyDef(containerDef, ShadowType.F_KIND, defs);
return defs;
}
@Override
protected MultivalueContainerDetailsPanel<ShadowType> getMultivalueContainerDetailsPanel(ListItem<PrismContainerValueWrapper<ShadowType>> item) {
return FocusProjectionsTabPanel.this.getMultivalueContainerDetailsPanel(item);
}
};
add(multivalueContainerListPanel);
setOutputMarkupId(true);
}
Aggregations