Example usage for org.apache.wicket.markup.html.list ListItem setModel

List of usage examples for org.apache.wicket.markup.html.list ListItem setModel

Introduction

In this page you can find the example usage for org.apache.wicket.markup.html.list ListItem setModel.

Prototype

default C setModel(IModel<T> model) 

Source Link

Document

Typesafe setter for the model

Usage

From source file:ca.travelagency.components.formdetail.DetailsPanel.java

License:Apache License

public DetailsPanel(String id, IModel<T> model) {
    super(id, model);
    setOutputMarkupId(true);//from   w w w  .  j a  v a 2s  .co  m

    webMarkupContainer = new WebMarkupContainer(ROWS_CONTAINER);
    webMarkupContainer.setOutputMarkupId(true);
    add(webMarkupContainer);

    webMarkupContainer.add(makeDetailFormPanel(FORM).setVisible(isEditable()));
    webMarkupContainer.add(makeDetailHeaderPanel(HEADER));

    LoadableDetachableModel<List<D>> listModel = new LoadableDetachableModel<List<D>>() {
        private static final long serialVersionUID = 1L;

        @Override
        protected List<D> load() {
            return getDetails();
        }
    };

    details = new ListView<D>(ROWS, listModel) {
        private static final long serialVersionUID = 1L;

        @Override
        protected ListItem<D> newItem(int index, IModel<D> itemModel) {
            return new OddEvenListItem<D>(index, itemModel);
        }

        @Override
        protected void populateItem(ListItem<D> item) {
            item.setModel(DaoEntityModelFactory.make(item.getModelObject()));
            item.add(makeDetailRowPanel(ROW, item.getModel()));
        }
    };

    webMarkupContainer.add(details);
}

From source file:ca.travelagency.invoice.view.InvoicePanel.java

License:Apache License

private Component addInvoiceItems(IModel<Invoice> model) {
    ListView<InvoiceItem> listView = new ListView<InvoiceItem>(Invoice.Properties.invoiceItems.name(),
            model.getObject().getInvoiceItems()) {
        private static final long serialVersionUID = 1L;

        @Override//from  w ww  .  j  a v  a 2 s.c o m
        protected ListItem<InvoiceItem> newItem(int index, IModel<InvoiceItem> itemModel) {
            return new OddEvenListItem<InvoiceItem>(index, itemModel);
        }

        @Override
        protected void populateItem(ListItem<InvoiceItem> item) {
            item.setModel(DaoEntityModelFactory.make(item.getModelObject()));

            item.add(new Label(InvoiceItem.Properties.description.name()));
            item.add(new Label(InvoiceItem.Properties.supplier.name()));
            item.add(new Label(InvoiceItem.Properties.commissionAsString.name()));
            item.add(new Label(InvoiceItem.Properties.salesAmounts.name() + Condition.SEPARATOR
                    + SalesAmounts.Properties.commissionAsString));
            item.add(new Label(InvoiceItem.Properties.taxOnCommissionAsString.name()));
            item.add(new Label(InvoiceItem.Properties.priceAsString.name()));
            item.add(new Label(InvoiceItem.Properties.taxAsString.name()));
            item.add(new Label(InvoiceItem.Properties.cancelBeforeDeparture.name()));
            item.add(new Label(InvoiceItem.Properties.changeBeforeDeparture.name()));
            item.add(new Label(InvoiceItem.Properties.changeAfterDeparture.name()));
            item.add(new Label(InvoiceItem.Properties.qty.name()));
            item.add(new Label(InvoiceItem.Properties.salesAmounts.name() + Condition.SEPARATOR
                    + SalesAmounts.Properties.saleAsString.name()));
            item.add(new Label(InvoiceItem.Properties.bookingNumber.name()));
            item.add(DateLabel.forDateStyle(InvoiceItem.Properties.bookingDate.name(), DateUtils.DATE_STYLE));
            item.add(new Label(InvoiceItem.Properties.commissionStatus.name()));
        }
    };

    return listView;
}

From source file:ca.travelagency.salesreports.SalesSummaryPanel.java

License:Apache License

public SalesSummaryPanel(String id, SalesSearch salesSearch) {
    super(id, new CompoundPropertyModel<InvoiceSales>(InvoiceSalesModel.make(salesSearch)));

    ListView<MonthlyDistribution> listView = new ListView<MonthlyDistribution>(
            InvoiceSales.Properties.monthlyDistribution.name()) {
        private static final long serialVersionUID = 1L;

        @Override//from  w w  w.j  a  v a  2s  .c om
        protected ListItem<MonthlyDistribution> newItem(int index, IModel<MonthlyDistribution> itemModel) {
            return new OddEvenListItem<MonthlyDistribution>(index, itemModel);
        }

        @Override
        protected void populateItem(final ListItem<MonthlyDistribution> item) {
            item.setModel(new CompoundPropertyModel<MonthlyDistribution>(item.getModelObject()));

            item.add(new Label(MonthlyDistribution.Properties.dateAsString.name()));

            Link<Void> link = new Link<Void>(LINK_TO_INVOICES) {
                private static final long serialVersionUID = 1L;

                @Override
                public void onClick() {
                    getAuthenticatedSession().clearInvoiceFilter();
                    InvoiceFilter invoiceFilter = getAuthenticatedSession().getInvoiceFilter();
                    invoiceFilter.setSystemUser(getSystemUser());
                    Date date = item.getModelObject().getDate();
                    invoiceFilter.setInvoiceDateFrom(date);
                    invoiceFilter.setInvoiceDateTo(DateUtils.addDays(DateUtils.addMonths(date, 1), -1));
                    setResponsePage(new InvoicesPage());
                }
            };
            link.add(new Label(MonthlyDistribution.Properties.count.name()));
            item.add(link);

            item.add(new Label(MonthlyDistribution.Properties.salesAmounts.name() + Condition.SEPARATOR
                    + SalesAmounts.Properties.saleAsString.name()));
            item.add(new Label(MonthlyDistribution.Properties.salesAmounts.name() + Condition.SEPARATOR
                    + SalesAmounts.Properties.costAsString.name()));
            item.add(new Label(MonthlyDistribution.Properties.salesAmounts.name() + Condition.SEPARATOR
                    + SalesAmounts.Properties.commissionAsString.name()));
            item.add(new Label(MonthlyDistribution.Properties.salesAmounts.name() + Condition.SEPARATOR
                    + SalesAmounts.Properties.commissionReceivedAsString.name()));
            item.add(new Label(MonthlyDistribution.Properties.salesAmounts.name() + Condition.SEPARATOR
                    + SalesAmounts.Properties.commissionVerifiedAsString.name()));
            item.add(new Label(MonthlyDistribution.Properties.salesAmounts.name() + Condition.SEPARATOR
                    + SalesAmounts.Properties.taxOnCommissionAsString.name()));
            item.add(new Label(MonthlyDistribution.Properties.salesAmounts.name() + Condition.SEPARATOR
                    + SalesAmounts.Properties.paidAsString.name()));
        }
    };
    add(listView);

    Link<String> downloadLink = new Link<String>(EXPORT_TO_CSV, Model.of(makeCsvOutput())) {
        private static final long serialVersionUID = 1L;

        @Override
        public void onClick() {
            StringBufferResourceStream resourceStream = new StringBufferResourceStream("text/csv");
            resourceStream.append((CharSequence) getDefaultModelObject());

            ResourceStreamRequestHandler handler = new ResourceStreamRequestHandler(resourceStream)
                    .setFileName("export.csv").setContentDisposition(ContentDisposition.ATTACHMENT);

            getRequestCycle().scheduleRequestHandlerAfterCurrent(handler);
        }
    };
    downloadLink.setVisible(!getSales().getMonthlyDistribution().isEmpty());
    add(downloadLink);
}

From source file:com.googlecode.refit.web.SummaryPage.java

License:Open Source License

public SummaryPage(final Summary summary) {
    setDefaultModel(new CompoundPropertyModel<Summary>(summary));

    add(new Label("inputDir"));
    add(new Label("outputDir"));
    add(new Label("passed"));
    add(new Label("numTests"));

    add(new ListView<TestResult>("test", summary.getTest()) {

        private static final long serialVersionUID = 1L;

        @Override/*from ww w .  ja  va  2  s .c  om*/
        protected void populateItem(ListItem<TestResult> item) {
            TestResult testResult = item.getModelObject();
            item.setModel(new CompoundPropertyModel<TestResult>(testResult));
            String uri = String.format("static%s/%s", summary.getInputDir(), testResult.getPath());
            StaticLink link = new StaticLink("link", new Model<String>(uri));
            item.add(link);
            link.add(new Label("path"));
            item.add(new Label("right"));
            item.add(new Label("wrong"));
            item.add(new Label("ignored"));
            item.add(new Label("exceptions"));
        }

    });
}

From source file:com.tysanclan.site.projectewok.components.UserContactInfoPanel.java

License:Open Source License

public UserContactInfoPanel(String id, User user) {
    super(id, ModelMaker.wrap(user));

    add(new MemberListItem("user", user));

    String aimAddress = user.getProfile() != null ? user.getProfile().getInstantMessengerAddress() : "";

    add(new Label("aim", aimAddress)
            .add(AttributeModifier.replace("href", "aim:addbuddy?screenname=" + aimAddress))
            .setVisible(aimAddress != null && !aimAddress.isEmpty()));
    add(new DateLabel("lastlogin", user.getLastAction()));

    WebMarkupContainer accounts = new WebMarkupContainer("accounts");

    accounts.add(new ListView<UserGameRealm>("realms", ModelMaker.wrap(user.getPlayedGames())) {
        private static final long serialVersionUID = 1L;

        @Override/*from w ww .java 2s  .  c  o m*/
        protected void populateItem(ListItem<UserGameRealm> item) {
            item.setModel(new CompoundPropertyModel<UserGameRealm>(item.getModel()));

            StringBuilder builder = new StringBuilder();

            for (GameAccount acc : item.getModelObject().getAccounts()) {
                if (builder.length() > 0) {
                    builder.append(", ");
                }

                builder.append(acc.toString());
            }

            item.add(new Label("realm.name"));
            item.add(new Label("accountlist", builder.length() > 0 ? builder.toString() : "-"));
        }
    });

    accounts.setVisible(!user.getPlayedGames().isEmpty());

    add(accounts);
}

From source file:com.wickettraining.modelproxy.example.HomePage.java

License:Apache License

public HomePage(final PageParameters parameters) {
    final IModel<? extends List<? extends Person>> ldm = new LoadAllPeopleModel();
    Form<Void> form = new Form<Void>("form");
    form.add(new Button("cancel") {
        private static final long serialVersionUID = 1L;

        @Override/* w w  w  .j a  v a2 s  .co  m*/
        public void onSubmit() {
            logger.debug("Button('cancel').onSubmit()");
            setResponsePage(getPageClass());
        }
    });
    form.add(new Button("save") {
        private static final long serialVersionUID = 1L;

        @Override
        public void onSubmit() {
            logger.debug("Button('save').onSubmit()");
            doSaveAll(ldm);
            setResponsePage(getPageClass());
        }
    });
    add(form);
    form.add(new ListView<Person>("people", ldm) {
        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(final ListItem<Person> item) {
            item.setModel(wrapListItemModel(item.getModel()));
            final PersonViewPanel personViewPanel = new PersonViewPanel("content", item.getModel()) {
                private static final long serialVersionUID = 1L;

                protected void onEditClicked() {
                    logger.debug("HomePage#PersonViewPanel#onEditClicked()");
                    final PersonViewPanel pvp = this;
                    replaceWith(new PersonEditPanel(getId(), item.getModel()) {
                        private static final long serialVersionUID = 1L;

                        protected void formSubmitted() {
                            replaceWith(pvp);
                        }
                    });
                };
            };
            item.add(personViewPanel);
        }
    }.setReuseItems(true));
}

From source file:cz.zcu.kiv.eegdatabase.wui.ui.groups.MyGroupsPage.java

License:Apache License

private void setupComponents() {
    add(new ButtonPageMenu("leftMenu", prepareLeftMenu()));

    List<ResearchGroup> ownedGroups = researchGroupFacade
            .getResearchGroupsWhereOwner(EEGDataBaseSession.get().getLoggedUser());
    List<ResearchGroup> memberGroups = researchGroupFacade
            .getResearchGroupsWhereMember(EEGDataBaseSession.get().getLoggedUser());

    PropertyListView<ResearchGroup> ownedGroupsList = new PropertyListView<ResearchGroup>("ownedGroups",
            new ListModel<ResearchGroup>(ownedGroups)) {

        private static final long serialVersionUID = 1L;

        @Override/*  w  w w .  ja  va2s.co m*/
        protected void populateItem(ListItem<ResearchGroup> item) {
            item.setModel(new CompoundPropertyModel<ResearchGroup>(item.getModel()));
            item.add(new Label("title"));
            item.add(new Label("description"));
            item.add(new ViewLinkPanel("detail", ResearchGroupsDetailPage.class, "researchGroupId",
                    item.getModel(), ResourceUtils.getModel("link.detail")));
        }
    };

    PropertyListView<ResearchGroup> memberGroupsList = new PropertyListView<ResearchGroup>("memberGroups",
            new ListModel<ResearchGroup>(memberGroups)) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(ListItem<ResearchGroup> item) {
            item.setModel(new CompoundPropertyModel<ResearchGroup>(item.getModel()));
            item.add(new Label("title"));
            item.add(new Label("description"));
            item.add(new ViewLinkPanel("detail", ResearchGroupsDetailPage.class, "researchGroupId",
                    item.getModel(), ResourceUtils.getModel("link.detail")));
        }
    };

    add(ownedGroupsList, memberGroupsList);
}

From source file:cz.zcu.kiv.eegdatabase.wui.ui.pricing.PriceListPage.java

License:Apache License

private void setupComponents() {

    person = EEGDataBaseSession.get().getLoggedUser();
    selectModel = new Model<ResearchGroup>();
    packagesModel = new ListModel<ExperimentPackage>();

    final WebMarkupContainer experimentsContainer = new WebMarkupContainer("experimentsContainer");
    experimentsContainer.setOutputMarkupId(true);

    Label emptyExperiments = new Label("emptyExperimentsLabel",
            ResourceUtils.getModel("label.myexperiments.empty")) {

        private static final long serialVersionUID = 1L;

        @Override//w ww .  j a v  a  2  s.c om
        public boolean isVisible() {
            return experimentProvider.size() == 0;
        }
    };
    experimentProvider = new ListExperimentsDataProvider(experimentFacade, person, true, false);
    DefaultDataTable<Experiment, String> list = new DefaultDataTable<Experiment, String>("list",
            createListColumns(experimentsContainer), experimentProvider, ITEMS_PER_PAGE) {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return experimentProvider.size() != 0;
        }
    };
    experimentsContainer.add(list, emptyExperiments);

    final WebMarkupContainer priceListForPackageContainer = new WebMarkupContainer("expPackagesContainer");
    priceListForPackageContainer.setOutputMarkupId(true);
    priceListForPackageContainer.setVisibilityAllowed(securityFacade.userIsGroupAdmin());

    List<ResearchGroup> selectGroupChoice = groupFacade.getResearchGroupsWhereUserIsGroupAdmin(person);
    final DropDownChoice<ResearchGroup> selectGroup = new DropDownChoice<ResearchGroup>("selectGroup",
            selectModel, selectGroupChoice);
    selectGroup.add(new AjaxFormComponentUpdatingBehavior("onChange") {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            ResearchGroup selection = selectModel.getObject();
            List<ExperimentPackage> selectPackages = expPackageFacade.listExperimentPackagesByGroup(selection);
            packagesModel.setObject(selectPackages);
            target.add(priceListForPackageContainer);
        }

    });
    priceListForPackageContainer.add(selectGroup);

    PageableListView<ExperimentPackage> packageList = new PageableListView<ExperimentPackage>("packageList",
            packagesModel, ITEMS_PER_PAGE) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(final ListItem<ExperimentPackage> item) {
            item.setModel(new CompoundPropertyModel<ExperimentPackage>(item.getModel()));
            item.add(new Label("experimentPackageId"));
            item.add(new Label("name"));
            item.add(new Label("price"));
            item.add(new PriceChangePanel("changePrice",
                    new PropertyModel<BigDecimal>(item.getModel(), "price"), getFeedback(), "width: 80px;") {

                private static final long serialVersionUID = 1L;

                @Override
                void onUpdate(AjaxRequestTarget target) {
                    ExperimentPackage experimentPackage = item.getModelObject();
                    expPackageFacade.update(experimentPackage);
                    target.add(priceListForPackageContainer);
                }

            });
        }

        @Override
        public boolean isVisible() {
            List<ExperimentPackage> list = packagesModel.getObject();
            return list != null && !list.isEmpty();
        }
    };

    Label emptyListLabel = new Label("emptyListLabel",
            ResourceUtils.getModel("label.experimentPackage.select.empty")) {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            List<ExperimentPackage> list = packagesModel.getObject();
            return selectModel.getObject() != null && !(list != null && !list.isEmpty());
        }
    };

    priceListForPackageContainer.add(emptyListLabel);
    priceListForPackageContainer.add(packageList);
    add(priceListForPackageContainer, experimentsContainer);
}

From source file:org.cipango.littleims.scscf.oam.browser.ServiceProfilePanel.java

License:Apache License

@SuppressWarnings("unchecked")
public ServiceProfilePanel(String id, ServiceProfile serviceProfile) {
    super(id);//from ww w  .j  ava 2s .c  om
    new CompoundPropertyModel(serviceProfile);
    List l = new ArrayList();
    Iterator it = serviceProfile.getIFCsIterator();
    while (it.hasNext())
        l.add(it.next());
    add(new ListView("ifc", l) {

        @Override
        protected void populateItem(ListItem item) {
            item.setModel(new CompoundPropertyModel(item.getModelObject()));
            item.add(new Label("priority"));
            item.add(new Label("triggerPoint"));
            item.add(new Label("as"));
        }

    });

}

From source file:org.forgerock.amutils.web.codec.DecodingPage.java

License:CDDL license

private void addBootstrapComponents() {
    Form<Void> form = new BootstrapForm<Void>("bootstrap").type(FormType.Inline);
    form.add(new TextArea<>("bootstrapContent", new PropertyModel<>(this, "bootstrapContent")));
    final WebMarkupContainer wmc = new WebMarkupContainer("bootstrapContainer");
    LoadableDetachableModel<List<BootstrapData>> listViewModel = new LoadableDetachableModel<List<BootstrapData>>() {

        @Override//from w w w . j a  v a 2s  . co m
        protected List<BootstrapData> load() {
            List<BootstrapData> ret = new ArrayList<>();
            if (bootstrapContent != null && !bootstrapContent.isEmpty()) {
                String[] lines = bootstrapContent.split("\n");
                for (String line : lines) {
                    try {
                        ret.add(BootstrapData.valueOf(line));
                    } catch (IllegalArgumentException iae) {
                        iae.printStackTrace();
                    }
                }
            }
            return ret;
        }
    };
    final ListView<BootstrapData> listView = new ListView<BootstrapData>("servers", listViewModel) {

        @Override
        protected void populateItem(ListItem<BootstrapData> item) {
            item.setModel(new CompoundPropertyModel<>(item.getModelObject()));
            item.add(new Label("directoryServer"));
            item.add(new Label("deploymentUrl"));
            item.add(new Label("adminUser"));
            item.add(new Label("adminPassword"));
            item.add(new Label("baseDN"));
            item.add(new Label("directoryUser"));
            item.add(new Label("directoryPassword"));
        }
    };
    wmc.add(listView);
    wmc.setOutputMarkupPlaceholderTag(true);
    wmc.setVisible(false);
    add(wmc);
    form.add(new AjaxButton("parse") {

        @Override
        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
            wmc.setVisible(!listView.getModelObject().isEmpty());
            if (target != null) {
                target.add(wmc);
            }
        }
    });
    add(form);
}