Example usage for org.apache.wicket.extensions.markup.html.repeater.util SortableDataProvider SortableDataProvider

List of usage examples for org.apache.wicket.extensions.markup.html.repeater.util SortableDataProvider SortableDataProvider

Introduction

In this page you can find the example usage for org.apache.wicket.extensions.markup.html.repeater.util SortableDataProvider SortableDataProvider.

Prototype

SortableDataProvider

Source Link

Usage

From source file:de.inren.frontend.banking.common.PrincipalTablePanel.java

License:Apache License

private SortableDataProvider<PrincipalInfo, String> getDataProvider() {
    return new SortableDataProvider<PrincipalInfo, String>() {

        @Override/*from  w w  w .  j  av a 2 s.co  m*/
        public Iterator<PrincipalInfo> iterator(long first, long count) {
            return getModel().getObject().subList((int) first, (int) first + (int) count).iterator();
        }

        @Override
        public long size() {
            return getModel().getObject().size();
        }

        @Override
        public IModel<PrincipalInfo> model(PrincipalInfo object) {
            return Model.of(object);
        }

    };
}

From source file:de.inren.frontend.banking.summery.TransactionSummeryPanel.java

License:Apache License

private SortableDataProvider<TransactionSummary, String> getDataProvider() {
    return new SortableDataProvider<TransactionSummary, String>() {

        @Override/*w  w  w.j  av a2  s . com*/
        public Iterator<? extends TransactionSummary> iterator(long first, long count) {
            return transactionSummaryModel.getObject().subList((int) first, (int) first + (int) count)
                    .iterator();
        }

        @Override
        public long size() {
            return transactionSummaryModel.getObject().size();
        }

        @Override
        public IModel<TransactionSummary> model(TransactionSummary object) {
            return Model.of(object);
        }

    };
}

From source file:de.inren.frontend.storehouse.FolderContentPanel.java

License:Apache License

private SortableDataProvider<AuthorizedDomainObject, String> createDataProvider() {
    return new SortableDataProvider<AuthorizedDomainObject, String>() {

        @Override//from   www  . j a  v  a 2s . c  om
        public Iterator<? extends AuthorizedDomainObject> iterator(long first, long count) {
            List<AuthorizedDomainObject> res = new ArrayList<AuthorizedDomainObject>();
            res.addAll(getModel().getObject().getItems());
            return res.subList((int) first, (int) (first + count)).iterator();
        }

        @Override
        public long size() {
            return getModel().getObject().getItems().size();
        }

        @Override
        public IModel<AuthorizedDomainObject> model(AuthorizedDomainObject object) {
            return Model.of(object);
        }
    };
}

From source file:dk.teachus.frontend.components.list.ListPanel.java

License:Apache License

public ListPanel(String id, List<IColumn<T>> columns, List<T> data) {
    super(id);//  w  w  w .j  a  v  a  2  s  . co m

    final IDataProvider<T> listDataProvider = new ListDataProvider<T>(data);

    ISortableDataProvider<T> dataProvider = new SortableDataProvider<T>() {
        private static final long serialVersionUID = 1L;

        public Iterator<? extends T> iterator(int first, int count) {
            return listDataProvider.iterator(first, count);
        }

        public IModel<T> model(T object) {
            return listDataProvider.model(object);
        }

        public int size() {
            return listDataProvider.size();
        }
    };

    createList(columns, dataProvider, null);
}

From source file:name.marcelomorales.siqisiqi.examples.crud.parameters.ListParameters.java

License:Apache License

public ListParameters() {

    add(table = new AjaxFallbackDefaultDataTable<>("parameters", new ArrayList<IColumn<Parameter, String>>() {
        {/* w ww.j a  va 2 s . c o  m*/
            add(new PropertyColumn<Parameter, String>(Model.of("Name"), "name"));
        }
    }, new SortableDataProvider<Parameter, String>() {

        @Override
        public Iterator<? extends Parameter> iterator(long first, long count) {
            return parametersEdit.list(null, first, count).iterator();
        }

        @Override
        public long size() {
            return parametersEdit.count(null);
        }

        @Override
        public IModel<Parameter> model(Parameter object) {
            return Model.of(object);
        }
    }, 10).setOutputMarkupId(true));

    add(queryForm = new Form<String>("query param form", Model.of("")) {

        private final Component queryParamValueLabel;

        {
            setOutputMarkupId(true);

            add(queryParamValueLabel = new Label("value", new AbstractReadOnlyModel<Object>() {

                @Override
                public Object getObject() {
                    final String formModelObject = getModelObject();
                    if (Strings.isEmpty(formModelObject)) {
                        return "";
                    }

                    try {
                        return parametersEdit.getString(formModelObject);
                    } catch (ExecutionException e) {
                        return "Error: " + e.getMessage();
                    }
                }
            }).setOutputMarkupId(true));

            add(new TextField<>("param", getModel()).setOutputMarkupId(true).add(new OnChangeAjaxBehavior() {

                @Override
                protected void onUpdate(AjaxRequestTarget target) {
                    target.add(queryParamValueLabel);
                }
            }));
        }
    });

    add(new Form<ArrayList<String>>("set parameter form", new Model<>(Lists.newArrayList("", ""))) {

        {
            setOutputMarkupId(true);

            add(new TextField<>("param name", new PropertyModel<>(getModel(), "0"))
                    .add(StringValidator.maximumLength(200)).setOutputMarkupId(true));
            add(new TextField<>("param value", new PropertyModel<>(getModel(), "1"))
                    .add(StringValidator.maximumLength(2000)).setOutputMarkupId(true));

            add(new AjaxButton("submit", this) {

                @Override
                protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
                    ArrayList<String> strings = (ArrayList<String>) form.getModelObject();

                    Parameter parameter = new Parameter();
                    parameter.setName(strings.get(0));

                    parametersEdit.customize(parameter, strings.get(1));

                    target.add(form);
                    target.add(queryForm);
                    target.add(table);
                }
            });

        }
    });
}

From source file:name.marcelomorales.siqisiqi.examples.crud.webapp.HomePage.java

License:Apache License

public HomePage(final PageParameters parameters) {
    super(parameters);

    add(new Form<Void>("newdept") {

        final Model<String> deptNameModel;
        final Model<String> buildingModel;

        {/*from w w  w  .  ja v  a2s .  co  m*/
            add(new TextField<>("deptname", deptNameModel = Model.of("")));
            add(new TextField<>("building", buildingModel = Model.of("")));
        }

        @Override
        protected void onSubmit() {
            empDeptDao.newDept(deptNameModel.getObject(), buildingModel.getObject());
            setResponsePage(HomePage.class);
        }
    });

    add(new DefaultDataTable<>("depts",
            ImmutableList.<IColumn<Dept, String>>of(new PropertyColumn<Dept, String>(Model.of("id"), "deptno"),
                    new PropertyColumn<Dept, String>(Model.of("totalSalaries"), "totalSalaries"),
                    new PropertyColumn<Dept, String>(Model.of("building"), "building"),
                    new PropertyColumn<Dept, String>(Model.of("deptname"), "deptname")),
            new SortableDataProvider<Dept, String>() {

                @Override
                public Iterator<? extends Dept> iterator(long first, long count) {
                    return deptRepository.findByExample(null, null, null, first, count).iterator();
                }

                @Override
                public long size() {
                    return deptRepository.count();
                }

                @Override
                public IModel<Dept> model(Dept object) {
                    Dept dept = new Dept();
                    BeanUtils.copyProperties(object, dept);
                    return Model.of(dept);
                }
            }, 5));

    add(new Form<Emp>("newemp", new CompoundPropertyModel<>(Model.of(new Emp()))) {
        {
            add(new TextField<String>("fname"));
            add(new TextField<String>("lname"));
            add(new DropDownChoice<>("sex", ImmutableList.copyOf(Sex.values())));
            add(new TextField<String>("ssn"));
            add(new TextField<BigDecimal>("salary"));
            add(new DropDownChoice<>("dept", new LoadableDetachableModel<List<Dept>>() {

                @Override
                protected List<Dept> load() {
                    return Lists.newLinkedList(deptRepository.findAll());
                }
            }, new ChoiceRenderer<Dept>("deptname")));
        }

        @Override
        protected void onSubmit() {
            empDeptDao.saveEmp(getModelObject());
            setResponsePage(HomePage.class);
        }
    });

    add(new DefaultDataTable<>("emps",
            ImmutableList.<IColumn<Emp, String>>of(new PropertyColumn<Emp, String>(Model.of("id"), "empid"),
                    new PropertyColumn<Emp, String>(Model.of("fname"), "fname"),
                    new PropertyColumn<Emp, String>(Model.of("lname"), "lname"),
                    new PropertyColumn<Emp, String>(Model.of("sex"), "sex"),
                    new PropertyColumn<Emp, String>(Model.of("ssn"), "ssn"),
                    new PropertyColumn<Emp, String>(Model.of("salary"), "salary"),
                    new PropertyColumn<Emp, String>(Model.of("dept"), "dept.deptname")),
            new SortableDataProvider<Emp, String>() {

                @Override
                public Iterator<? extends Emp> iterator(long first, long count) {
                    return empRepository.findByExample(null, null, null, first, count).iterator();
                }

                @Override
                public long size() {
                    return empRepository.count();
                }

                @Override
                public IModel<Emp> model(Emp object) {
                    Emp emp = new Emp();
                    BeanUtils.copyProperties(object, emp);
                    return Model.of(emp);
                }
            }, 5));

    fullTextModel = Model.of("");
    add(new Form<String>("fulltexts", fullTextModel) {
        {
            add(new TextField<>("search", getModel()));
        }
    });

    add(new DefaultDataTable<>("fulltextdept",
            ImmutableList.<IColumn<Dept, String>>of(new PropertyColumn<Dept, String>(Model.of("id"), "deptno"),
                    new PropertyColumn<Dept, String>(Model.of("totalSalaries"), "totalSalaries"),
                    new PropertyColumn<Dept, String>(Model.of("building"), "building"),
                    new PropertyColumn<Dept, String>(Model.of("deptname"), "deptname")),
            new SortableDataProvider<Dept, String>() {

                @Override
                public Iterator<? extends Dept> iterator(long first, long count) {
                    return deptRepository.findByFullTexts(fullTextModel.getObject(), null, first, count)
                            .iterator();
                }

                @Override
                public long size() {
                    return deptRepository.countByFullTexts(fullTextModel.getObject());
                }

                @Override
                public IModel<Dept> model(Dept object) {
                    Dept dept = new Dept();
                    BeanUtils.copyProperties(object, dept);
                    return Model.of(dept);
                }
            }, 5));

    sexModel = Model.of();
    add(new Form<Sex>("findBySex", sexModel) {
        {
            add(new DropDownChoice<>("sex", getModel(), ImmutableList.copyOf(Sex.values())));
        }
    });

    add(new DefaultDataTable<>("empbysex",
            ImmutableList.<IColumn<Emp, String>>of(new PropertyColumn<Emp, String>(Model.of("id"), "empid"),
                    new PropertyColumn<Emp, String>(Model.of("fname"), "fname"),
                    new PropertyColumn<Emp, String>(Model.of("lname"), "lname"),
                    new PropertyColumn<Emp, String>(Model.of("sex"), "sex"),
                    new PropertyColumn<Emp, String>(Model.of("ssn"), "ssn"),
                    new PropertyColumn<Emp, String>(Model.of("salary"), "salary"),
                    new PropertyColumn<Emp, String>(Model.of("dept"), "dept.deptname")),
            new SortableDataProvider<Emp, String>() {

                @Override
                public Iterator<? extends Emp> iterator(long first, long count) {
                    if (sexModel.getObject() == null) {
                        return Collections.emptyIterator();
                    }
                    return empRepository.findBySex(sexModel.getObject(), new PageRequest((int) (first / 5), 5))
                            .iterator();
                }

                @Override
                public long size() {
                    if (sexModel.getObject() == null) {
                        return 0;
                    }
                    return empRepository.countBySex(sexModel.getObject());
                }

                @Override
                public IModel<Emp> model(Emp object) {
                    Emp emp = new Emp();
                    BeanUtils.copyProperties(object, emp);
                    return Model.of(emp);
                }
            }, 5));

    add(new WebMarkupContainer("stats", new CompoundPropertyModel<>(new LoadableDetachableModel<Statistics>() {

        @Override
        protected Statistics load() {
            return boneCPAdm.getStatistics();
        }
    })) {
        {
            add(new Label("connectionsRequested"));
            add(new Label("statementExecuteTimeAvg"));
            add(new Label("statementsExecuted"));
            add(new Label("totalCreatedConnections"));
            add(new Label("totalFree"));
        }
    });

}

From source file:name.marcelomorales.siqisiqi.examples.simple.webapp.HomePage.java

License:Apache License

public HomePage() {
    final ArrayList<IColumn<Map<String, Object>, String>> iColumns = Lists.newArrayList();
    iColumns.add(new PropertyColumn<Map<String, Object>, String>(Model.of("if"), "EMPID"));
    iColumns.add(new PropertyColumn<Map<String, Object>, String>(Model.of("first"), "FNAME"));
    iColumns.add(new PropertyColumn<Map<String, Object>, String>(Model.of("last"), "LNAME"));
    iColumns.add(new PropertyColumn<Map<String, Object>, String>(Model.of("sex"), "SEX"));
    iColumns.add(new PropertyColumn<Map<String, Object>, String>(Model.of("ssn"), "SSN"));
    iColumns.add(new PropertyColumn<Map<String, Object>, String>(Model.of("sal"), "SALARY"));
    iColumns.add(new PropertyColumn<Map<String, Object>, String>(Model.of("dep"), "DEPTNO"));
    add(new DefaultDataTable<>("emp", iColumns, new SortableDataProvider<Map<String, Object>, String>() {

        @Override/* w w  w  . j  a va 2s  .c  om*/
        public Iterator<? extends Map<String, Object>> iterator(long first, long count) {
            // FIXME: bad usage of first and count
            return initialData.emp().subList((int) first, (int) (first + count)).iterator();
        }

        @Override
        public long size() {
            return initialData.countemp();
        }

        @SuppressWarnings("unchecked")
        @Override
        public IModel<Map<String, Object>> model(Map<String, Object> object) {
            final IModel of = Model.of(ImmutableMap.copyOf(object));
            return (IModel<Map<String, Object>>) of;
        }
    }, 5));

    final ArrayList<IColumn<Map<String, Object>, String>> iCols = Lists.newArrayList();
    iCols.add(new PropertyColumn<Map<String, Object>, String>(Model.of("dep"), "DEPTNO"));
    iCols.add(new PropertyColumn<Map<String, Object>, String>(Model.of("name"), "DEPTNAME"));
    iCols.add(new PropertyColumn<Map<String, Object>, String>(Model.of("building"), "BUILDING"));
    add(new DefaultDataTable<>("dept", iCols, new SortableDataProvider<Map<String, Object>, String>() {

        @Override
        public Iterator<? extends Map<String, Object>> iterator(long first, long count) {
            // FIXME: bad usage of first and count
            return initialData.dept().subList((int) first, (int) (first + count)).iterator();
        }

        @Override
        public long size() {
            return initialData.countdept();
        }

        @SuppressWarnings("unchecked")
        @Override
        public IModel<Map<String, Object>> model(Map<String, Object> object) {
            final IModel of = Model.of(ImmutableMap.copyOf(object));
            return (IModel<Map<String, Object>>) of;
        }
    }, 5));

    add(new Form<Void>("pop") {

        @Override
        protected void onSubmit() {
            initialData.populate();
            setResponsePage(HomePage.class);
        }
    });
}

From source file:org.apache.syncope.client.console.bulk.BulkContent.java

License:Apache License

public BulkContent(final String id, final BaseModal<?> modal, final Collection<T> items,
        final List<IColumn<T, S>> columns, final Collection<ActionLink.ActionType> actions,
        final RestClient bulkActionExecutor, final String keyFieldName) {

    super(id);/*from   w  w w.j  a  va  2  s.  co  m*/

    final WebMarkupContainer container = new WebMarkupContainer("container");
    container.setOutputMarkupId(true);
    add(container);

    final SortableDataProvider<T, S> dataProvider = new SortableDataProvider<T, S>() {

        private static final long serialVersionUID = 5291903859908641954L;

        @Override
        public Iterator<? extends T> iterator(final long first, final long count) {
            return items.iterator();
        }

        @Override
        public long size() {
            return items.size();
        }

        @Override
        public IModel<T> model(final T object) {
            return new CompoundPropertyModel<>(object);
        }
    };

    container
            .add(new AjaxFallbackDefaultDataTable<>("selectedObjects", columns, dataProvider, Integer.MAX_VALUE)
                    .setMarkupId("selectedObjects").setVisible(items != null && !items.isEmpty()));

    final ActionLinksPanel<Serializable> actionPanel = ActionLinksPanel.builder().build("actions");
    container.add(actionPanel);

    for (ActionLink.ActionType action : actions) {
        final ActionType actionToBeAddresed = action;

        actionPanel.add(new ActionLink<Serializable>() {

            private static final long serialVersionUID = -3722207913631435501L;

            @Override
            protected boolean statusCondition(final Serializable modelObject) {
                return CollectionUtils.isNotEmpty(items);
            }

            @Override
            public void onClick(final AjaxRequestTarget target, final Serializable ignore) {
                try {
                    if (CollectionUtils.isEmpty(items)) {
                        throw new IllegalArgumentException("Invalid items");
                    }

                    String fieldName = keyFieldName;

                    BulkActionResult res = null;
                    try {
                        if (items.iterator().next() instanceof StatusBean) {
                            throw new IllegalArgumentException("Invalid items");
                        }

                        final BulkAction bulkAction = new BulkAction();
                        bulkAction.setType(BulkAction.Type.valueOf(actionToBeAddresed.name()));
                        for (T item : items) {
                            try {
                                bulkAction.getTargets().add(getTargetId(item, keyFieldName).toString());
                            } catch (IllegalAccessException | InvocationTargetException e) {
                                LOG.error("Error retrieving item id {}", keyFieldName, e);
                            }
                        }
                        res = BulkActionResult.class
                                .cast(bulkActionExecutor.getClass().getMethod("bulkAction", BulkAction.class)
                                        .invoke(bulkActionExecutor, bulkAction));
                    } catch (IllegalArgumentException biae) {
                        if (!(items.iterator().next() instanceof StatusBean)) {
                            throw new IllegalArgumentException("Invalid items");
                        }

                        if (!(bulkActionExecutor instanceof AbstractAnyRestClient)) {
                            throw new IllegalArgumentException("Invalid bulk action executor");
                        }

                        final AbstractAnyRestClient<?, ?> anyRestClient = AbstractAnyRestClient.class
                                .cast(bulkActionExecutor);

                        // Group bean information by anyKey
                        final Map<String, List<StatusBean>> beans = new HashMap<>();
                        for (T bean : items) {
                            final StatusBean sb = StatusBean.class.cast(bean);
                            final List<StatusBean> sblist;
                            if (beans.containsKey(sb.getAnyKey())) {
                                sblist = beans.get(sb.getAnyKey());
                            } else {
                                sblist = new ArrayList<>();
                                beans.put(sb.getAnyKey(), sblist);
                            }
                            sblist.add(sb);
                        }

                        for (Map.Entry<String, List<StatusBean>> entry : beans.entrySet()) {
                            final String etag = anyRestClient.read(entry.getKey()).getETagValue();
                            switch (actionToBeAddresed.name()) {
                            case "DEPROVISION":
                                res = anyRestClient.deprovision(etag, entry.getKey(), entry.getValue());
                                break;
                            case "UNASSIGN":
                                res = anyRestClient.unassign(etag, entry.getKey(), entry.getValue());
                                break;
                            case "UNLINK":
                                res = anyRestClient.unlink(etag, entry.getKey(), entry.getValue());
                                break;
                            case "ASSIGN":
                                res = anyRestClient.assign(etag, entry.getKey(), entry.getValue());
                                break;
                            case "LINK":
                                res = anyRestClient.link(etag, entry.getKey(), entry.getValue());
                                break;
                            case "PROVISION":
                                res = anyRestClient.provision(etag, entry.getKey(), entry.getValue());
                                break;
                            case "REACTIVATE":
                                res = ((UserRestClient) anyRestClient).reactivate(etag, entry.getKey(),
                                        entry.getValue());
                                fieldName = "resourceName";
                                break;
                            case "SUSPEND":
                                res = ((UserRestClient) anyRestClient).suspend(etag, entry.getKey(),
                                        entry.getValue());
                                fieldName = "resourceName";
                                break;
                            default:
                                break;
                            }
                        }
                    }

                    if (modal != null) {
                        modal.changeCloseButtonLabel(getString("close", null, "Close"), target);
                    }

                    final List<IColumn<T, S>> newColumnList = new ArrayList<>(columns);
                    newColumnList.add(newColumnList.size(), new BulkActionResultColumn<T, S>(res, fieldName));

                    container.addOrReplace(new AjaxFallbackDefaultDataTable<>("selectedObjects", newColumnList,
                            dataProvider, Integer.MAX_VALUE).setVisible(!items.isEmpty()));

                    actionPanel.setEnabled(false);
                    actionPanel.setVisible(false);
                    target.add(container);
                    target.add(actionPanel);

                    SyncopeConsoleSession.get().info(getString(Constants.OPERATION_SUCCEEDED));
                } catch (Exception e) {
                    LOG.error("Bulk action failure", e);
                    SyncopeConsoleSession.get()
                            .error("Operation " + actionToBeAddresed.getActionId() + " not supported");
                }
                ((BasePage) getPage()).getNotificationPanel().refresh(target);
            }
        }, action, StandardEntitlement.CONFIGURATION_LIST, !items.isEmpty());
    }
}

From source file:org.apache.syncope.client.console.pages.BulkActionModalPage.java

License:Apache License

public BulkActionModalPage(final ModalWindow window, final Collection<T> items,
        final List<IColumn<T, S>> columns, final Collection<ActionLink.ActionType> actions,
        final BaseRestClient bulkActionExecutor, final String idFieldName, final String pageId) {

    super();//  w  w w  .j  av a  2  s  .  c  om

    final SortableDataProvider<T, S> dataProvider = new SortableDataProvider<T, S>() {

        private static final long serialVersionUID = 5291903859908641954L;

        @Override
        public Iterator<? extends T> iterator(final long first, final long count) {
            return items.iterator();
        }

        @Override
        public long size() {
            return items.size();
        }

        @Override
        public IModel<T> model(final T object) {
            return new CompoundPropertyModel<>(object);
        }
    };

    add(new AjaxFallbackDefaultDataTable<>("selectedObjects",
            new ArrayList<>(columns.subList(1, columns.size() - 1)), dataProvider, Integer.MAX_VALUE)
                    .setVisible(items != null && !items.isEmpty()));

    @SuppressWarnings("rawtypes")
    final ActionLinksPanel actionPanel = new ActionLinksPanel("actions", new Model(), getPageReference());
    add(actionPanel);

    for (ActionLink.ActionType action : actions) {
        final BulkAction bulkAction = new BulkAction();
        for (T item : items) {
            try {
                bulkAction.getTargets().add(getTargetId(item, idFieldName).toString());
            } catch (Exception e) {
                LOG.error("Error retrieving item id {}", idFieldName, e);
            }
        }

        switch (action) {
        case DELETE:
            bulkAction.setOperation(BulkAction.Type.DELETE);
            break;
        case SUSPEND:
            bulkAction.setOperation(BulkAction.Type.SUSPEND);
            break;
        case REACTIVATE:
            bulkAction.setOperation(BulkAction.Type.REACTIVATE);
            break;
        case EXECUTE:
            bulkAction.setOperation(BulkAction.Type.EXECUTE);
            break;
        case DRYRUN:
            bulkAction.setOperation(BulkAction.Type.DRYRUN);
            break;
        default:
            LOG.error("Bulk action type not supported");
        }

        actionPanel.add(new ActionLink() {

            private static final long serialVersionUID = -3722207913631435501L;

            @Override
            public void onClick(final AjaxRequestTarget target) {
                try {
                    final BulkActionResult res = (BulkActionResult) bulkActionExecutor.getClass()
                            .getMethod("bulkAction", BulkAction.class).invoke(bulkActionExecutor, bulkAction);

                    setResponsePage(new BulkActionResultModalPage<>(window, items, columns, res, idFieldName));
                } catch (Exception e) {
                    error(getString(Constants.ERROR) + ": Operation " + bulkAction.getOperation()
                            + " not supported");
                    feedbackPanel.refresh(target);
                }

            }
        }, action, pageId, !items.isEmpty());
    }

    final Form<Void> form = new Form<>(FORM);
    add(form);

    final AjaxButton cancel = new ClearIndicatingAjaxButton(CANCEL, new ResourceModel(CANCEL),
            getPageReference()) {

        private static final long serialVersionUID = -958724007591692537L;

        @Override
        protected void onSubmitInternal(final AjaxRequestTarget target, final Form<?> form) {
            window.close(target);
        }
    };

    cancel.setDefaultFormProcessing(false);
    form.add(cancel);
}

From source file:org.apache.syncope.client.console.pages.BulkActionResultModalPage.java

License:Apache License

public BulkActionResultModalPage(final ModalWindow window, final Collection<T> items,
        final List<IColumn<T, S>> columns, final BulkActionResult results, final String idFieldName) {

    super();/*from   www .  j a v a2 s  . co m*/

    final List<IColumn<T, S>> newColumnList = new ArrayList<>(columns.subList(1, columns.size() - 1));
    newColumnList.add(newColumnList.size(), new ActionResultColumn<T, S>(results, idFieldName));

    final SortableDataProvider<T, S> dataProvider = new SortableDataProvider<T, S>() {

        private static final long serialVersionUID = 5291903859908641954L;

        @Override
        public Iterator<? extends T> iterator(final long first, final long count) {
            return items.iterator();
        }

        @Override
        public long size() {
            return items.size();
        }

        @Override
        public IModel<T> model(final T object) {
            return new CompoundPropertyModel<T>(object);
        }
    };

    add(new AjaxFallbackDefaultDataTable<T, S>("selectedObjects", newColumnList, dataProvider,
            Integer.MAX_VALUE).setVisible(items != null && !items.isEmpty()));

    final AjaxLink<Void> close = new IndicatingAjaxLink<Void>("close") {

        private static final long serialVersionUID = -7978723352517770644L;

        @Override
        public void onClick(final AjaxRequestTarget target) {
            window.close(target);
        }
    };

    add(close);
}