Search in sources :

Example 71 with Label

use of org.apache.wicket.markup.html.basic.Label in project wicket by apache.

the class MarkupContainerTest method singleChildShouldAllowReplacingVisitedChildButNotRevisitReplacementChild.

@Test
public void singleChildShouldAllowReplacingVisitedChildButNotRevisitReplacementChild() {
    WebMarkupContainer wmc = new WebMarkupContainer("id");
    Label label1 = new Label("label1", "Label1");
    Label label2 = new Label("label1", "Label2");
    wmc.add(label1);
    Iterator<Component> iterator = wmc.iterator();
    Assert.assertThat(iterator.hasNext(), is(true));
    Assert.assertThat(iterator.next(), is(equalToObject(label1)));
    wmc.replace(label2);
    Assert.assertThat(iterator.hasNext(), is(false));
}
Also used : Label(org.apache.wicket.markup.html.basic.Label) WebComponent(org.apache.wicket.markup.html.WebComponent) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) Test(org.junit.Test)

Example 72 with Label

use of org.apache.wicket.markup.html.basic.Label in project wicket by apache.

the class MarkupContainerTest method iteratorShouldAllowRemovingComponentAfterIterationStarted2.

@Test
public void iteratorShouldAllowRemovingComponentAfterIterationStarted2() {
    WebMarkupContainer wmc = new WebMarkupContainer("id");
    Label label1;
    Label label2;
    Label label3;
    wmc.add(label1 = new Label("label1", "Label1"));
    wmc.add(label2 = new Label("label2", "Label2"));
    wmc.add(label3 = new Label("label3", "Label3"));
    Iterator<Component> iterator = wmc.iterator();
    Assert.assertThat(iterator.next(), is(equalToObject(label1)));
    Assert.assertThat(iterator.next(), is(equalToObject(label2)));
    wmc.remove(label1);
    Assert.assertThat(iterator.next(), is(equalToObject(label3)));
    Assert.assertThat(iterator.hasNext(), is(false));
}
Also used : Label(org.apache.wicket.markup.html.basic.Label) WebComponent(org.apache.wicket.markup.html.WebComponent) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) Test(org.junit.Test)

Example 73 with Label

use of org.apache.wicket.markup.html.basic.Label in project wicket by apache.

the class MarkupContainerTest method noChildAddingAndRemoveChildAfterIteratorAcquiredShouldNotIterate.

@Test
public void noChildAddingAndRemoveChildAfterIteratorAcquiredShouldNotIterate() {
    WebMarkupContainer wmc = new WebMarkupContainer("id");
    Label label1 = new Label("label1", "Label1");
    Iterator<Component> iterator = wmc.iterator();
    wmc.add(label1);
    wmc.remove(label1);
    assertThat(wmc.size(), is(0));
    Assert.assertThat(iterator.hasNext(), is(false));
}
Also used : Label(org.apache.wicket.markup.html.basic.Label) WebComponent(org.apache.wicket.markup.html.WebComponent) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) Test(org.junit.Test)

Example 74 with Label

use of org.apache.wicket.markup.html.basic.Label in project wicket by apache.

the class MarkupContainerTest method replacingTheFirstChildAfterIteratingDoesntIterateTheNewChild.

@Test
public void replacingTheFirstChildAfterIteratingDoesntIterateTheNewChild() {
    WebMarkupContainer wmc = new WebMarkupContainer("id");
    Label label1 = new Label("label1", "Label1");
    Component label2 = new Label("label2", "Label2");
    addNChildren(wmc, NUMBER_OF_CHILDREN_FOR_A_MAP);
    wmc.add(label1);
    wmc.add(label2);
    Iterator<Component> iterator = wmc.iterator();
    takeNChildren(iterator, NUMBER_OF_CHILDREN_FOR_A_MAP);
    iterator.next();
    // replace the first child **after** we already passed the child with the iterator
    Label newChild = new Label("label1", "newChild");
    wmc.replace(newChild);
    // the next child is still label 2
    assertThat(iterator.next(), is(sameInstance(label2)));
    // and the new child is not iterated (was replaced before the current position of the
    // iterator).
    Assert.assertThat(iterator.hasNext(), is(false));
}
Also used : Label(org.apache.wicket.markup.html.basic.Label) WebComponent(org.apache.wicket.markup.html.WebComponent) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) Test(org.junit.Test)

Example 75 with Label

use of org.apache.wicket.markup.html.basic.Label in project wicket by apache.

the class MarkupContainerTest method noChildAddingAndReplaceChildAfterIteratorAcquiredShouldIterateAndReturnNewReplacementChild.

@Test
public void noChildAddingAndReplaceChildAfterIteratorAcquiredShouldIterateAndReturnNewReplacementChild() {
    WebMarkupContainer wmc = new WebMarkupContainer("id");
    Label label1 = new Label("label1", "Label1");
    Label label2 = new Label("label1", "Label2");
    Iterator<Component> iterator = wmc.iterator();
    wmc.add(label1);
    wmc.replace(label2);
    Assert.assertThat(iterator.hasNext(), is(true));
    Assert.assertThat(iterator.next(), is(equalToObject(label2)));
    Assert.assertThat(iterator.hasNext(), is(false));
}
Also used : Label(org.apache.wicket.markup.html.basic.Label) WebComponent(org.apache.wicket.markup.html.WebComponent) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) Test(org.junit.Test)

Aggregations

Label (org.apache.wicket.markup.html.basic.Label)519 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)189 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)181 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)121 IModel (org.apache.wicket.model.IModel)116 ListItem (org.apache.wicket.markup.html.list.ListItem)84 ListView (org.apache.wicket.markup.html.list.ListView)70 ArrayList (java.util.ArrayList)68 AjaxLink (org.apache.wicket.ajax.markup.html.AjaxLink)65 PropertyModel (org.apache.wicket.model.PropertyModel)61 Test (org.junit.Test)56 List (java.util.List)51 InfoTooltipBehavior (com.evolveum.midpoint.web.util.InfoTooltipBehavior)47 VisibleBehaviour (com.evolveum.midpoint.web.component.util.VisibleBehaviour)46 IColumn (org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn)41 Model (org.apache.wicket.model.Model)36 Item (org.apache.wicket.markup.repeater.Item)35 AttributeAppender (org.apache.wicket.behavior.AttributeAppender)34 AttributeModifier (org.apache.wicket.AttributeModifier)32 Component (org.apache.wicket.Component)30