Search in sources :

Example 1 with PageOperationResult

use of com.evolveum.midpoint.web.page.error.PageOperationResult in project midpoint by Evolveum.

the class ObjectNameColumn method populateItem.

@Override
public void populateItem(final Item<ICellPopulator<SelectableBean<O>>> cellItem, String componentId, final IModel<SelectableBean<O>> rowModel) {
    IModel<String> labelModel = new AbstractReadOnlyModel<String>() {

        private static final long serialVersionUID = 1L;

        @Override
        public String getObject() {
            SelectableBean<O> selectableBean = rowModel.getObject();
            O value = selectableBean.getValue();
            if (value == null) {
                OperationResult result = selectableBean.getResult();
                OperationResultStatusPresentationProperties props = OperationResultStatusPresentationProperties.parseOperationalResultStatus(result.getStatus());
                return cellItem.getString(props.getStatusLabelKey());
            } else {
                String name = WebComponentUtil.getName(value);
                if (selectableBean.getResult() != null) {
                    StringBuilder complexName = new StringBuilder();
                    complexName.append(name);
                    complexName.append(" (");
                    complexName.append(selectableBean.getResult().getStatus());
                    complexName.append(")");
                    return complexName.toString();
                }
                return name;
            }
        }
    };
    if (isClickable(rowModel)) {
        // beware: rowModel is very probably resolved at this moment; but it seems to cause no problems
        cellItem.add(new LinkPanel(componentId, labelModel) {

            private static final long serialVersionUID = 1L;

            @Override
            public void onClick(AjaxRequestTarget target) {
                SelectableBean<O> selectableBean = rowModel.getObject();
                O value = selectableBean.getValue();
                if (value == null) {
                    OperationResult result = selectableBean.getResult();
                    throw new RestartResponseException(new PageOperationResult(result));
                } else {
                    if (selectableBean.getResult() != null) {
                        throw new RestartResponseException(new PageOperationResult(selectableBean.getResult()));
                    } else {
                        ObjectNameColumn.this.onClick(target, rowModel);
                    }
                }
            }
        });
    } else {
        cellItem.add(new Label(componentId, labelModel));
    }
}
Also used : AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) Label(org.apache.wicket.markup.html.basic.Label) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PageOperationResult(com.evolveum.midpoint.web.page.error.PageOperationResult) OperationResultStatusPresentationProperties(com.evolveum.midpoint.web.page.admin.server.dto.OperationResultStatusPresentationProperties) PageOperationResult(com.evolveum.midpoint.web.page.error.PageOperationResult) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) RestartResponseException(org.apache.wicket.RestartResponseException) SelectableBean(com.evolveum.midpoint.web.component.util.SelectableBean)

Example 2 with PageOperationResult

use of com.evolveum.midpoint.web.page.error.PageOperationResult in project midpoint by Evolveum.

the class ObjectNameColumn method onClickPerformed.

private void onClickPerformed(AjaxRequestTarget target, IModel<SelectableBean<O>> rowModel) {
    SelectableBean<O> selectableBean = rowModel.getObject();
    O value = selectableBean.getValue();
    if (value == null) {
        OperationResult result = selectableBean.getResult();
        throw new RestartResponseException(new PageOperationResult(result));
    } else {
        if (selectableBean.getResult() != null) {
            throw new RestartResponseException(new PageOperationResult(selectableBean.getResult()));
        } else {
            ObjectNameColumn.this.onClick(target, rowModel);
        }
    }
}
Also used : RestartResponseException(org.apache.wicket.RestartResponseException) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PageOperationResult(com.evolveum.midpoint.web.page.error.PageOperationResult) PageOperationResult(com.evolveum.midpoint.web.page.error.PageOperationResult)

Aggregations

OperationResult (com.evolveum.midpoint.schema.result.OperationResult)2 PageOperationResult (com.evolveum.midpoint.web.page.error.PageOperationResult)2 RestartResponseException (org.apache.wicket.RestartResponseException)2 SelectableBean (com.evolveum.midpoint.web.component.util.SelectableBean)1 OperationResultStatusPresentationProperties (com.evolveum.midpoint.web.page.admin.server.dto.OperationResultStatusPresentationProperties)1 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)1 Label (org.apache.wicket.markup.html.basic.Label)1 AbstractReadOnlyModel (org.apache.wicket.model.AbstractReadOnlyModel)1