Search in sources :

Example 81 with ListItem

use of org.apache.wicket.markup.html.list.ListItem in project wicket by apache.

the class ComponentQueueingTest method repeater1.

@Test
public void repeater1() {
    TestPage p = new TestPage();
    p.setPageMarkup("<p wicket:id='lv'><p wicket:id='b'><p wicket:id='c'></p></p></p>");
    LV l = new LV(3) {

        @Override
        protected void populateItem(ListItem<Integer> item) {
            item.queue(new B(), new C());
        }
    };
    p.queue(l);
    tester.startPage(p);
    assertThat(l.size(), is(3));
    for (Component item : l) {
        assertThat(p, hasPath(new Path(l, item, new B(), new C())));
    }
}
Also used : WicketMatchers.hasPath(org.apache.wicket.queueing.WicketMatchers.hasPath) ListItem(org.apache.wicket.markup.html.list.ListItem) Component(org.apache.wicket.Component) Test(org.junit.Test)

Example 82 with ListItem

use of org.apache.wicket.markup.html.list.ListItem in project wicket by apache.

the class ComponentQueueingTest method repeater3.

/**
 * repeater with a panel inside
 */
@Test
public void repeater3() {
    TestPage p = new TestPage();
    p.setPageMarkup("<p wicket:id='a'><p wicket:id='lv'><p wicket:id='b'><p wicket:id='q'></p></p></p></p>");
    MarkupContainer a = new A();
    LV l = new LV(3) {

        @Override
        protected void populateItem(ListItem<Integer> item) {
            TestPanel q = new TestPanel("q");
            q.setPanelMarkup("<wicket:panel><p wicket:id='r'><p wicket:id='s'></p></p></wicket:panel>");
            q.queue(new R(), new S());
            item.queue(q, new B());
        }
    };
    p.queue(a, l);
    tester.startPage(p);
    assertThat(l.size(), is(3));
    for (Component item : l) {
        assertThat(p, hasPath(new Path(a, l, item, new B()).add("q").add(new R(), new S())));
    }
}
Also used : WicketMatchers.hasPath(org.apache.wicket.queueing.WicketMatchers.hasPath) MarkupContainer(org.apache.wicket.MarkupContainer) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) TransparentWebMarkupContainer(org.apache.wicket.markup.html.TransparentWebMarkupContainer) ListItem(org.apache.wicket.markup.html.list.ListItem) Component(org.apache.wicket.Component) Test(org.junit.Test)

Example 83 with ListItem

use of org.apache.wicket.markup.html.list.ListItem in project oc-explorer by devgateway.

the class FileInputBootstrapFormComponentWrapper method addPendingFilesComponent.

/**
 * pending files section
 */
private void addPendingFilesComponent() {
    pendingFiles = new WebMarkupContainer("pendingFiles") {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onConfigure() {
            if (filesModel != null && filesModel.size() > 0) {
                for (FileMetadata file : filesModel) {
                    if (file.isNew()) {
                        setVisibilityAllowed(true);
                        return;
                    }
                }
            }
            setVisibilityAllowed(false);
        }
    };
    pendingFiles.setOutputMarkupPlaceholderTag(true);
    pendingFiles.setOutputMarkupId(true);
    add(pendingFiles);
    pendingFiles.add(new Label("pendingFilesTitle", new StringResourceModel("pendingFilesTitle", this, null)));
    AbstractReadOnlyModel<List<FileMetadata>> pendingFilesModel = new AbstractReadOnlyModel<List<FileMetadata>>() {

        private static final long serialVersionUID = 1L;

        @Override
        public List<FileMetadata> getObject() {
            List<FileMetadata> fileObject = new ArrayList<>();
            // upload)
            for (FileMetadata file : filesModel) {
                if (file.isNew()) {
                    fileObject.add(file);
                }
            }
            return fileObject;
        }
    };
    ListView<FileMetadata> list = new ListView<FileMetadata>("list", pendingFilesModel) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(final ListItem<FileMetadata> item) {
            item.add(new Label("fileTitle", item.getModelObject().getName()));
            IndicatingAjaxLink<Void> delete = new IndicatingAjaxLink<Void>("delete") {

                private static final long serialVersionUID = 1L;

                @SuppressWarnings("unchecked")
                @Override
                public void onClick(final AjaxRequestTarget target) {
                    filesModel.remove(item.getModelObject());
                    FileInputBootstrapFormComponentWrapper.this.getModel().setObject((T) filesModel);
                    target.add(pendingFiles);
                }
            };
            delete.add(new IconBehavior(GlyphIconType.remove));
            delete.add(new TooltipBehavior(new StringResourceModel("removeUploadedFileTooltip", FileInputBootstrapFormComponentWrapper.this, null), TOOLTIP_CONFIG));
            delete.setVisible(true);
            item.add(delete);
        }
    };
    pendingFiles.add(list);
}
Also used : AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) FileMetadata(org.devgateway.toolkit.persistence.dao.FileMetadata) Label(org.apache.wicket.markup.html.basic.Label) ArrayList(java.util.ArrayList) IconBehavior(de.agilecoders.wicket.core.markup.html.bootstrap.image.IconBehavior) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) TooltipBehavior(de.agilecoders.wicket.core.markup.html.bootstrap.components.TooltipBehavior) ListView(org.apache.wicket.markup.html.list.ListView) IndicatingAjaxLink(org.apache.wicket.extensions.ajax.markup.html.IndicatingAjaxLink) ArrayList(java.util.ArrayList) List(java.util.List) ListItem(org.apache.wicket.markup.html.list.ListItem) StringResourceModel(org.apache.wicket.model.StringResourceModel)

Example 84 with ListItem

use of org.apache.wicket.markup.html.list.ListItem in project the-app by devops-dojo.

the class OrderItemListPanel method orderItemList.

private Component orderItemList() {
    return new ListView<OrderItemInfo>("orderItems", new PropertyModel<List<OrderItemInfo>>(getDefaultModel(), "orderItems")) {

        private int orderItemCounter = 1;

        @Override
        protected void populateItem(ListItem<OrderItemInfo> orderItem) {
            orderItem.add(new Label("orderItemCounter", Model.of(orderItemCounter++)));
            orderItem.add(new Label("product", new PropertyModel<String>(orderItem.getModel(), "product.name")));
            orderItem.add(new Label("description", new PropertyModel<String>(orderItem.getModel(), "product.description")));
            orderItem.add(new Label("totalSum", new PriceModel(new PropertyModel<>(orderItem.getModel(), "totalSum"))));
        }

        @Override
        protected void onDetach() {
            orderItemCounter = 1;
            super.onDetach();
        }
    };
}
Also used : ListView(org.apache.wicket.markup.html.list.ListView) Label(org.apache.wicket.markup.html.basic.Label) PropertyModel(org.apache.wicket.model.PropertyModel) List(java.util.List) ListItem(org.apache.wicket.markup.html.list.ListItem) PriceModel(io.github.zutherb.appstash.shop.ui.model.PriceModel)

Example 85 with ListItem

use of org.apache.wicket.markup.html.list.ListItem in project the-app by devops-dojo.

the class NavigationPanel method navigationEntryView.

private ListView<NavigationEntry> navigationEntryView(final String id, final IModel<List<NavigationEntry>> listModel) {
    return new ListView<NavigationEntry>(id, listModel) {

        private static final long serialVersionUID = -2695266767809997711L;

        @Override
        protected void populateItem(ListItem<NavigationEntry> listItem) {
            WebMarkupContainer item = new WebMarkupContainer("item");
            NavigationEntry navigationEntry = listItem.getModelObject();
            WebMarkupContainer pageLink = navigationLink(navigationEntry);
            pageLink.add(new AttributeAppender("class", new AbstractReadOnlyModel<String>() {

                final String template = "%sLink";

                @Override
                public String getObject() {
                    return String.format(template, navigationEntry.getName().toLowerCase());
                }
            }, " "));
            pageLink.add(new Label("name", Model.of(navigationEntry.getName())));
            if (navigationEntry.getPageClass().isAnnotationPresent(ModalPanelItem.class)) {
                pageLink.add(new AjaxEventBehavior("click") {

                    private static final long serialVersionUID = 8111739824971748968L;

                    @Override
                    protected void onEvent(AjaxRequestTarget target) {
                        target.appendJavaScript(loginModalPanel.generateToggleScript());
                    }
                });
                pageLink.add(new AttributeModifier("href", "#"));
            }
            item.add(pageLink);
            item.setVisibilityAllowed(navigationEntry.isVisible());
            item.add(new AttributeModifier("class", activeModel(navigationEntry)));
            listItem.add(item);
        }

        private IModel<String> activeModel(NavigationEntry navigationEntry) {
            Class<? extends Page> currentPageClazz = getPage().getPageClass();
            Class<? extends Page> navigationPageClazz = navigationEntry.getPageClass();
            boolean assignableFrom = navigationPageClazz.isAssignableFrom(currentPageClazz);
            if (!assignableFrom)
                return Model.of("");
            if (!currentPageClazz.isAnnotationPresent(EnumProductTypeNavigationItem.class))
                return Model.of("active");
            PageParameters currentParameters = getPage().getPageParameters();
            PageParameters navigationParameters = navigationEntry.getPageParameters();
            if (currentParameters == null || currentParameters.isEmpty()) {
                String enumName = navigationParameters.get("type").toString();
                EnumProductTypeNavigationItem enumNavigationItem = currentPageClazz.getAnnotation(EnumProductTypeNavigationItem.class);
                return Model.of(StringUtils.equals(enumNavigationItem.defaultEnum(), enumName) ? "active" : "");
            }
            return Model.of(currentParameters.equals(navigationParameters) ? "active" : "");
        }
    };
}
Also used : AjaxEventBehavior(org.apache.wicket.ajax.AjaxEventBehavior) Label(org.apache.wicket.markup.html.basic.Label) PageParameters(org.apache.wicket.request.mapper.parameter.PageParameters) AttributeModifier(org.apache.wicket.AttributeModifier) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ListView(org.apache.wicket.markup.html.list.ListView) ListItem(org.apache.wicket.markup.html.list.ListItem) AttributeAppender(org.apache.wicket.behavior.AttributeAppender)

Aggregations

ListItem (org.apache.wicket.markup.html.list.ListItem)131 ListView (org.apache.wicket.markup.html.list.ListView)107 Label (org.apache.wicket.markup.html.basic.Label)82 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)73 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)72 IModel (org.apache.wicket.model.IModel)44 List (java.util.List)42 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)40 ArrayList (java.util.ArrayList)38 PropertyModel (org.apache.wicket.model.PropertyModel)28 VisibleBehaviour (com.evolveum.midpoint.web.component.util.VisibleBehaviour)23 AjaxLink (org.apache.wicket.ajax.markup.html.AjaxLink)23 TextField (org.apache.wicket.markup.html.form.TextField)17 AjaxButton (com.evolveum.midpoint.web.component.AjaxButton)14 AbstractReadOnlyModel (org.apache.wicket.model.AbstractReadOnlyModel)14 QName (javax.xml.namespace.QName)13 AjaxFormComponentUpdatingBehavior (org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior)13 Model (org.apache.wicket.model.Model)12 InlineMenuItem (com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem)11 AttributeModifier (org.apache.wicket.AttributeModifier)11