use of com.evolveum.midpoint.web.component.util.SelectableBean in project midpoint by Evolveum.
the class PageAccounts method createAccountsColumns.
private List<IColumn> createAccountsColumns() {
List<IColumn> columns = new ArrayList<>();
columns.add(new PropertyColumn(createStringResource("PageAccounts.accounts.oid"), SelectableBean.F_VALUE + ".oid"));
columns.add(new PropertyColumn<>(createStringResource("PageAccounts.accounts.name"), ShadowType.F_NAME.getLocalPart(), SelectableBean.F_VALUE + ".name"));
columns.add(new PropertyColumn<>(createStringResource("PageAccounts.accounts.kind"), ShadowType.F_KIND.getLocalPart(), SelectableBean.F_VALUE + ".kind"));
columns.add(new PropertyColumn<>(createStringResource("PageAccounts.accounts.intent"), ShadowType.F_INTENT.getLocalPart(), SelectableBean.F_VALUE + ".intent"));
columns.add(new PropertyColumn<QName, String>(createStringResource("PageAccounts.accounts.objectClass"), ShadowType.F_OBJECT_CLASS.getLocalPart(), SelectableBean.F_VALUE + ".objectClass.localPart"));
columns.add(new PropertyColumn<>(createStringResource("PageAccounts.accounts.synchronizationSituation"), ShadowType.F_SYNCHRONIZATION_SITUATION.getLocalPart(), SelectableBean.F_VALUE + ".synchronizationSituation"));
columns.add(new PropertyColumn<>(createStringResource("PageAccounts.accounts.synchronizationTimestamp"), ShadowType.F_SYNCHRONIZATION_TIMESTAMP.getLocalPart(), SelectableBean.F_VALUE + ".synchronizationTimestamp"));
// columns.add(new PropertyColumn<>(createStringResource("PageAccounts.accounts.result"),
// ShadowType.F_RESULT.getLocalPart(), SelectableBean.F_VALUE + ".result.status"));
columns.add(new LinkColumn<SelectableBean>(createStringResource("PageAccounts.accounts.result")) {
@Override
protected IModel<String> createLinkModel(final IModel<SelectableBean> rowModel) {
return new AbstractReadOnlyModel<String>() {
@Override
public String getObject() {
OperationResultType result = getResult(rowModel);
if (result == null) {
return "";
}
return createStringResource("OperationResultStatusType." + result.getStatus()).getObject();
}
};
}
@Override
public void onClick(AjaxRequestTarget target, IModel<SelectableBean> rowModel) {
showShadowResult(target, rowModel);
}
});
columns.add(new LinkColumn<SelectableBean>(createStringResource("PageAccounts.accounts.owner")) {
@Override
protected IModel<String> createLinkModel(final IModel<SelectableBean> rowModel) {
return new AbstractReadOnlyModel<String>() {
@Override
public String getObject() {
FocusType focus = loadShadowOwner(rowModel);
return WebComponentUtil.getName(focus);
}
};
}
@Override
public void onClick(AjaxRequestTarget target, IModel<SelectableBean> rowModel) {
ownerDetailsPerformed(target, rowModel);
}
});
return columns;
}
use of com.evolveum.midpoint.web.component.util.SelectableBean in project midpoint by Evolveum.
the class ExportingPanel method createTable.
private BoxedTablePanel<SelectableBean<Integer>> createTable(String id, DataTable<?, ?> dataTable) {
List<? extends IColumn<?, ?>> allColumns = dataTable.getColumns();
List<Integer> exportableColumnIndex = getExportableColumns(dataTable);
if (exportableColumnIndex.isEmpty()) {
throw new IllegalArgumentException("List of exportable columns is empty");
}
List<IColumn<SelectableBean<Integer>, String>> columns = new ArrayList<>();
CheckBoxHeaderColumn<SelectableBean<Integer>> checkboxColumn = new CheckBoxHeaderColumn<>();
columns.add(checkboxColumn);
StringResourceModel nameString = getPageBase().createStringResource("ExportingPopupPanel.nameColumn");
IColumn<SelectableBean<Integer>, String> nameColumn = new AbstractColumn<SelectableBean<Integer>, String>(nameString) {
@Override
public void populateItem(Item<ICellPopulator<SelectableBean<Integer>>> cellItem, String componentId, IModel<SelectableBean<Integer>> rowModel) {
IModel stringModel = ((IExportableColumn) allColumns.get(rowModel.getObject().getValue())).getDisplayModel();
cellItem.add(new Label(componentId, stringModel));
}
};
columns.add(nameColumn);
SelectableListDataProvider<SelectableBean<Integer>, Integer> provider = new SelectableListDataProvider<SelectableBean<Integer>, Integer>(getPageBase(), Model.ofList(exportableColumnIndex)) {
@Override
public Iterator<SelectableBean<Integer>> internalIterator(long first, long count) {
if (getAvailableData().isEmpty()) {
return super.internalIterator(first, count);
} else {
return getAvailableData().iterator();
}
}
};
BoxedTablePanel<SelectableBean<Integer>> table = new BoxedTablePanel<SelectableBean<Integer>>(id, provider, columns) {
private static final long serialVersionUID = 1L;
@Override
protected WebMarkupContainer createHeader(String headerId) {
return new WebMarkupContainer(headerId);
}
@Override
public String getAdditionalBoxCssClasses() {
return null;
}
@Override
protected WebMarkupContainer createButtonToolbar(String id) {
return new WebMarkupContainer(id);
}
@Override
protected boolean hideFooterIfSinglePage() {
return true;
}
@Override
public int getAutoRefreshInterval() {
return 0;
}
@Override
public boolean isAutoRefreshEnabled() {
return false;
}
};
table.setOutputMarkupId(true);
return table;
}
use of com.evolveum.midpoint.web.component.util.SelectableBean in project midpoint by Evolveum.
the class ExportingPanel method initLayout.
private void initLayout() {
MidpointForm form = new MidpointForm<>(ID_MAIN_FORM, true);
MessagePanel warningMessage = new MessagePanel(ID_WARNING_MESSAGE, MessagePanel.MessagePanelType.WARN, getWarningMessageModel());
warningMessage.setOutputMarkupId(true);
warningMessage.add(new VisibleBehaviour(() -> getWarningMessageModel() != null));
form.add(warningMessage);
FeedbackAlerts feedbackList = new FeedbackAlerts(ID_FEEDBACK);
feedbackList.setOutputMarkupId(true);
feedbackList.setOutputMarkupPlaceholderTag(true);
form.add(feedbackList);
TextPanel<String> nameField = new TextPanel<>(ID_NAME, nameModel);
form.add(nameField);
BoxedTablePanel<SelectableBean<Integer>> table = createTable(ID_TABLE, dataTable);
form.add(table);
AjaxSubmitButton exportSelected = new AjaxSubmitButton(ID_EXPORT, getPageBase().createStringResource("ExportingPopupPanel.exportSelected")) {
private static final long serialVersionUID = 1L;
@Override
public void onSubmit(AjaxRequestTarget target) {
performSelectedColumns(table);
if (exportedColumnsIndex.isEmpty()) {
LOGGER.warn("None columns selected");
getPageBase().warn(getPageBase().createStringResource("ExportingPanel.message.error.selectColumn").getString());
target.add(feedbackList);
return;
}
((PageBase) getPage()).hideMainPopup(target);
exportPerformed(target);
}
@Override
protected void onError(AjaxRequestTarget target) {
target.add(getPageBase().getFeedbackPanel());
}
};
form.add(exportSelected);
AjaxButton cancelButton = new AjaxButton(ID_CANCEL, new StringResourceModel("Button.cancel", this, null)) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
cancelPerformed(target);
}
};
form.add(cancelButton);
add(form);
}
use of com.evolveum.midpoint.web.component.util.SelectableBean in project midpoint by Evolveum.
the class ReportObjectsListPanel method createProvider.
@Override
protected ISelectableDataProvider<C, SelectableBean<C>> createProvider() {
SelectableBeanContainerDataProvider<C> provider = new SelectableBeanContainerDataProvider<>(this, getSearchModel(), null, false) {
@Override
public List<SelectableBean<C>> createDataObjectWrappers(Class<? extends C> type, ObjectQuery query, Collection<SelectorOptions<GetOperationOptions>> options, Task task, OperationResult result) throws CommunicationException, ObjectNotFoundException, SchemaException, SecurityViolationException, ConfigurationException, ExpressionEvaluationException {
Collection<SelectorOptions<GetOperationOptions>> defaultOptions = DefaultColumnUtils.createOption(getObjectCollectionView().getTargetClass(getPrismContext()), getSchemaService());
QName qNameType = WebComponentUtil.containerClassToQName(getPrismContext(), type);
VariablesMap variables = new VariablesMap();
if (getSearchModel().getObject() != null) {
variables.putAll(getSearchModel().getObject().getFilterVariables(getVariables(), getPageBase()));
processReferenceVariables(variables);
}
List<C> list = (List<C>) getModelInteractionService().searchObjectsFromCollection(getReport().getObjectCollection().getCollection(), qNameType, defaultOptions, query.getPaging(), variables, task, result);
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Query {} resulted in {} objects", type.getSimpleName(), list.size());
}
List<SelectableBean<C>> data = new ArrayList<SelectableBean<C>>();
for (C object : list) {
data.add(createDataObjectWrapper(object));
}
return data;
}
@Override
protected Integer countObjects(Class<? extends C> type, ObjectQuery query, Collection<SelectorOptions<GetOperationOptions>> currentOptions, Task task, OperationResult result) throws CommunicationException, ObjectNotFoundException, SchemaException, SecurityViolationException, ConfigurationException, ExpressionEvaluationException {
Collection<SelectorOptions<GetOperationOptions>> defaultOptions = DefaultColumnUtils.createOption(getObjectCollectionView().getTargetClass(getPrismContext()), getSchemaService());
QName qNameType = WebComponentUtil.containerClassToQName(getPrismContext(), type);
VariablesMap variables = new VariablesMap();
if (getSearchModel().getObject() != null) {
variables.putAll(getSearchModel().getObject().getFilterVariables(getVariables(), getPageBase()));
processReferenceVariables(variables);
}
return getModelInteractionService().countObjectsFromCollection(getReport().getObjectCollection().getCollection(), qNameType, defaultOptions, null, variables, task, result);
}
@Override
protected boolean isUseObjectCounting() {
return !isDisableCounting();
}
@Override
public boolean isOrderingDisabled() {
return isDisableSorting();
}
@Override
public ObjectQuery getQuery() {
// fake query because of we need paging in method createDataObjectWrappers
return getPrismContext().queryFor(ObjectType.class).build();
}
@Override
@NotNull
protected List<ObjectOrdering> createObjectOrderings(SortParam<String> sortParam) {
if (AuditEventRecordType.class.equals(getDefaultType()) && sortParam != null && sortParam.getProperty() != null) {
OrderDirection order = sortParam.isAscending() ? OrderDirection.ASCENDING : OrderDirection.DESCENDING;
return Collections.singletonList(getPrismContext().queryFactory().createOrdering(ItemPath.create(new QName(AuditEventRecordType.COMPLEX_TYPE.getNamespaceURI(), sortParam.getProperty())), order));
}
return super.createObjectOrderings(sortParam);
}
};
if (provider.getSort() == null && hasView()) {
if (ObjectType.class.isAssignableFrom(getDefaultType())) {
provider.setSort("name", SortOrder.ASCENDING);
} else if (AuditEventRecordType.class.isAssignableFrom(getDefaultType())) {
provider.setSort("timestamp", SortOrder.ASCENDING);
}
}
return provider;
}
use of com.evolveum.midpoint.web.component.util.SelectableBean in project midpoint by Evolveum.
the class InternalsLoggedInUsersPanel method initInlineMenu.
private List<InlineMenuItem> initInlineMenu() {
List<InlineMenuItem> menuItems = new ArrayList<>();
menuItems.add(new ButtonInlineMenuItem(createStringResource("InternalsLoggedInUsers.refresh")) {
private static final long serialVersionUID = 1L;
@Override
public CompositedIconBuilder getIconCompositedBuilder() {
return getDefaultCompositedIconBuilder(GuiStyleConstants.CLASS_ICON_SIGN_OUT);
}
@Override
public InlineMenuItemAction initAction() {
return new ColumnMenuAction<SelectableBean<F>>() {
@Override
public void onClick(AjaxRequestTarget target) {
if (getRowModel() == null) {
terminateSessions(target, null);
} else {
SelectableBean<F> rowDto = getRowModel().getObject();
terminateSessions(target, rowDto.getValue());
}
}
};
}
@Override
public boolean isHeaderMenuItem() {
return true;
}
});
return menuItems;
}
Aggregations