use of com.evolveum.midpoint.gui.impl.component.MultivalueContainerListPanelWithDetailsPanel 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.gui.impl.component.MultivalueContainerListPanelWithDetailsPanel in project midpoint by Evolveum.
the class AssignmentPanel method initLayout.
private void initLayout() {
MultivalueContainerListPanelWithDetailsPanel<AssignmentType> multivalueContainerListPanel = new MultivalueContainerListPanelWithDetailsPanel<>(ID_ASSIGNMENTS, AssignmentType.class) {
private static final long serialVersionUID = 1L;
@Override
protected boolean isCreateNewObjectVisible() {
return isNewObjectButtonVisible(getFocusObject());
}
@Override
protected IModel<PrismContainerWrapper<AssignmentType>> getContainerModel() {
return AssignmentPanel.this.getModel();
}
@Override
protected void cancelItemDetailsPerformed(AjaxRequestTarget target) {
AssignmentPanel.this.cancelAssignmentDetailsPerformed(target);
}
protected List<IColumn<PrismContainerValueWrapper<AssignmentType>, String>> createDefaultColumns() {
if (AssignmentPanel.this.getModelObject() == null) {
return new ArrayList<>();
}
return initBasicColumns();
}
@Override
protected List<Component> createToolbarButtonsList(String idButton) {
List<Component> bar = new ArrayList<>();
AjaxIconButton newObjectButton = new AjaxIconButton(idButton, new Model<>(GuiStyleConstants.EVO_ASSIGNMENT_ICON), createStringResource("MainObjectListPanel.newObject")) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
newAssignmentClickPerformed(target);
}
};
newObjectButton.add(AttributeAppender.append("class", "btn btn-default btn-sm"));
bar.add(newObjectButton);
newObjectButton.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return isNewObjectButtonVisible(getFocusObject());
}
@Override
public boolean isEnabled() {
return !isAssignmentsLimitReached();
}
});
return bar;
}
@Override
public void deleteItemPerformed(AjaxRequestTarget target, List<PrismContainerValueWrapper<AssignmentType>> toDeleteList) {
int countAddedAssignments = 0;
for (PrismContainerValueWrapper<AssignmentType> assignment : toDeleteList) {
if (ValueStatus.ADDED.equals(assignment.getStatus())) {
countAddedAssignments++;
}
}
boolean isLimitReached = isAssignmentsLimitReached(toDeleteList.size() - countAddedAssignments, true);
if (isLimitReached) {
warn(getParentPage().getString("AssignmentPanel.assignmentsLimitReachedWarning", assignmentsRequestsLimit));
target.add(getPageBase().getFeedbackPanel());
return;
}
super.deleteItemPerformed(target, toDeleteList);
}
@Override
protected AssignmentListProvider createProvider() {
PageStorage pageStorage = getPageStorage(getAssignmentsTabStorageKey());
return createAssignmentProvider(pageStorage, getSearchModel(), loadValuesModel());
}
@Override
protected MultivalueContainerDetailsPanel<AssignmentType> getMultivalueContainerDetailsPanel(ListItem<PrismContainerValueWrapper<AssignmentType>> item) {
return createMultivalueContainerDetailsPanel(item);
}
@Override
protected UserProfileStorage.TableId getTableId() {
return AssignmentPanel.this.getTableId();
}
@Override
protected List<SearchItemDefinition> initSearchableItems(PrismContainerDefinition<AssignmentType> containerDef) {
return createSearchableItems(containerDef);
}
@Override
public void refreshTable(AjaxRequestTarget ajaxRequestTarget) {
super.refreshTable(ajaxRequestTarget);
AssignmentPanel.this.refreshTable(ajaxRequestTarget);
}
@Override
protected boolean isCollectionViewPanel() {
return config != null && config.getListView() != null;
}
@Override
protected CompiledObjectCollectionView getObjectCollectionView() {
if (config == null) {
return super.getObjectCollectionView();
}
GuiObjectListViewType listView = config.getListView();
if (listView == null) {
return null;
}
CollectionRefSpecificationType collectionRefSpecificationType = listView.getCollection();
if (collectionRefSpecificationType == null) {
return null;
}
Task task = getPageBase().createSimpleTask("Compile collection");
OperationResult result = task.getResult();
try {
return getPageBase().getModelInteractionService().compileObjectCollectionView(collectionRefSpecificationType, AssignmentType.class, task, result);
} catch (Throwable e) {
e.printStackTrace();
}
return null;
}
};
multivalueContainerListPanel.add(new VisibleBehaviour(() -> getModel() != null && getModelObject() != null));
add(multivalueContainerListPanel);
setOutputMarkupId(true);
}
use of com.evolveum.midpoint.gui.impl.component.MultivalueContainerListPanelWithDetailsPanel 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);
}
use of com.evolveum.midpoint.gui.impl.component.MultivalueContainerListPanelWithDetailsPanel in project midpoint by Evolveum.
the class ResourceSchemaHandlingTabPanel method initLayout.
private void initLayout() {
MidpointForm<?> form = new MidpointForm<>(ID_FORM);
add(form);
MultivalueContainerListPanelWithDetailsPanel<ResourceObjectTypeDefinitionType> objectTypesPanel = new MultivalueContainerListPanelWithDetailsPanel<>(ID_TABLE, ResourceObjectTypeDefinitionType.class) {
@Override
protected MultivalueContainerDetailsPanel<ResourceObjectTypeDefinitionType> getMultivalueContainerDetailsPanel(ListItem<PrismContainerValueWrapper<ResourceObjectTypeDefinitionType>> item) {
return createMultivalueContainerDetailsPanel(ID_ITEM_DETAILS, item.getModel());
}
@Override
protected boolean isCreateNewObjectVisible() {
return false;
}
@Override
protected IModel<PrismContainerWrapper<ResourceObjectTypeDefinitionType>> getContainerModel() {
return PrismContainerWrapperModel.fromContainerWrapper(ResourceSchemaHandlingTabPanel.this.getModel(), SchemaHandlingType.F_OBJECT_TYPE);
}
@Override
protected UserProfileStorage.TableId getTableId() {
return null;
}
@Override
protected List<IColumn<PrismContainerValueWrapper<ResourceObjectTypeDefinitionType>, String>> createDefaultColumns() {
List<IColumn<PrismContainerValueWrapper<ResourceObjectTypeDefinitionType>, String>> columns = new ArrayList<>();
columns.add(new PrismPropertyWrapperColumn<>(getContainerModel(), ResourceObjectTypeDefinitionType.F_DISPLAY_NAME, AbstractItemWrapperColumn.ColumnType.STRING, getPageBase()));
columns.add(new PrismPropertyWrapperColumn<>(getContainerModel(), ResourceObjectTypeDefinitionType.F_KIND, AbstractItemWrapperColumn.ColumnType.STRING, getPageBase()));
columns.add(new PrismPropertyWrapperColumn<>(getContainerModel(), ResourceObjectTypeDefinitionType.F_INTENT, AbstractItemWrapperColumn.ColumnType.STRING, getPageBase()));
columns.add(new PrismPropertyWrapperColumn<>(getContainerModel(), ResourceObjectTypeDefinitionType.F_DEFAULT, AbstractItemWrapperColumn.ColumnType.STRING, getPageBase()));
columns.add(new PrismPropertyWrapperColumn<>(getContainerModel(), ResourceObjectTypeDefinitionType.F_DESCRIPTION, AbstractItemWrapperColumn.ColumnType.STRING, getPageBase()));
List<InlineMenuItem> menuActionsList = getMultivalueContainerListPanel().getDefaultMenuActions();
columns.add(new InlineMenuButtonColumn(menuActionsList, getPageBase()) {
private static final long serialVersionUID = 1L;
@Override
public String getCssClass() {
return " col-md-1 ";
}
});
return columns;
}
};
form.add(objectTypesPanel);
}
use of com.evolveum.midpoint.gui.impl.component.MultivalueContainerListPanelWithDetailsPanel in project midpoint by Evolveum.
the class ListMappingPanel method initLayout.
private void initLayout() {
MultivalueContainerListPanelWithDetailsPanel<MappingType> table = new MultivalueContainerListPanelWithDetailsPanel<MappingType>(ID_TABLE, MappingType.class) {
@Override
protected MultivalueContainerDetailsPanel<MappingType> getMultivalueContainerDetailsPanel(ListItem<PrismContainerValueWrapper<MappingType>> item) {
return new MultivalueContainerDetailsPanel<>(MultivalueContainerListPanelWithDetailsPanel.ID_ITEM_DETAILS, item.getModel(), true) {
@Override
protected DisplayNamePanel<MappingType> createDisplayNamePanel(String displayNamePanelId) {
ItemRealValueModel<MappingType> displayNameModel = new ItemRealValueModel<>(item.getModel());
return new DisplayNamePanel<>(displayNamePanelId, displayNameModel) {
@Override
protected IModel<String> createHeaderModel() {
IModel<String> headerModel = super.createHeaderModel();
if (StringUtils.isEmpty(headerModel.getObject())) {
return getPageBase().createStringResource("feedbackMessagePanel.message.undefined");
}
return headerModel;
}
};
}
@Override
protected ItemVisibility getBasicTabVisibity(ItemWrapper<?, ?> itemWrapper) {
if (itemWrapper.getPath().isSubPathOrEquivalent(ItemPath.create(ItemPath.EMPTY_PATH, MappingType.F_METADATA_MAPPING))) {
return ItemVisibility.HIDDEN;
}
return ItemVisibility.AUTO;
}
};
}
@Override
protected boolean isCreateNewObjectVisible() {
return true;
}
@Override
protected IModel<PrismContainerWrapper<MappingType>> getContainerModel() {
return ListMappingPanel.this.getModel();
}
@Override
protected UserProfileStorage.TableId getTableId() {
return null;
}
@Override
protected List<IColumn<PrismContainerValueWrapper<MappingType>, String>> createDefaultColumns() {
List<IColumn<PrismContainerValueWrapper<MappingType>, String>> columns = new ArrayList<>();
columns.add(new PrismPropertyWrapperColumn<>(ListMappingPanel.this.getModel(), MappingType.F_DESCRIPTION, AbstractItemWrapperColumn.ColumnType.STRING, getPageBase()));
columns.add(new PrismPropertyWrapperColumn<>(ListMappingPanel.this.getModel(), MappingType.F_ENABLED, AbstractItemWrapperColumn.ColumnType.VALUE, getPageBase()));
columns.add(new AbstractColumn<>(createStringResource("ListMappingPanel.mappingDescription")) {
@Override
public void populateItem(Item<ICellPopulator<PrismContainerValueWrapper<MappingType>>> cellItem, String componentId, IModel<PrismContainerValueWrapper<MappingType>> rowModel) {
cellItem.add(new Label(componentId, WebComponentUtil.createMappingDescription(rowModel)));
}
});
List<InlineMenuItem> items = new ArrayList<>();
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) {
deleteItemPerformed(target, 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) {
editItemPerformed(target, getRowModel(), getSelectedItems());
target.add(getFeedbackPanel());
}
};
}
};
items.add(item);
columns.add(new InlineMenuButtonColumn(items, getPageBase()) {
@Override
public String getCssClass() {
return "col-xs-1";
}
});
return columns;
}
@Override
protected IColumn<PrismContainerValueWrapper<MappingType>, String> createNameColumn(IModel<String> displayModel, GuiObjectColumnType customColumn, ItemPath itemPath, ExpressionType expression) {
return new PrismPropertyWrapperColumn<>(ListMappingPanel.this.getModel(), MappingType.F_NAME, AbstractItemWrapperColumn.ColumnType.LINK, getPageBase()) {
@Override
protected void onClick(AjaxRequestTarget target, IModel<PrismContainerValueWrapper<MappingType>> model) {
itemDetailsPerformed(target, model);
}
};
}
@Override
protected IColumn<PrismContainerValueWrapper<MappingType>, String> createCheckboxColumn() {
return new CheckBoxHeaderColumn<>();
}
@Override
protected PrismContainerDefinition<MappingType> getTypeDefinitionForSearch() {
return getPrismContext().getSchemaRegistry().findContainerDefinitionByType(MappingType.COMPLEX_TYPE);
}
};
add(table);
}
Aggregations