/** * {@inheritDoc} */ @Override // to make public public int getChildCount() { return super.getChildCount(); }
/** * {@inheritDoc} */ @Override // to make public public int getChildCount() { return super.getChildCount(); }
/** * {@inheritDoc} */ @Override // to make public public int getChildCount() { return super.getChildCount(); }
/** * Creates a String representation of this component, for debugging purposes. * * @param details some additional details to display in the output. * @return a String representation of this component. */ final String toString(final String details) { return toString(details, 0, getChildCount() - 1); }
/** * {@inheritDoc} */ @Override public void setLocked(final boolean lock) { this.locked = lock; for (int i = 0; i < getChildCount(); i++) { getChildAt(i).setLocked(lock); } }
/** * Removes all of the children from this component. */ void removeAll() { while (getChildCount() > 0) { remove(getChildAt(0)); } }
if (this instanceof Container && childStartIndex >= 0 && childEndIndex < getChildCount() && childStartIndex <= childEndIndex) { WComponent[] children = new WComponent[childEndIndex - childStartIndex + 1];
/** * test removeAll - child from shared list. */ @Test public void testRemoveAllCommon() { AbstractWComponent comp = new MockContainer(); WText text1 = new WText("XYZ"); WText text2 = new WText("ABC"); comp.add(text1); comp.add(text2); comp.removeAll(); // from shared list Assert.assertEquals("shared should not contain any children", 0, comp.getChildCount()); Assert.assertEquals("uic should not contain any children", 0, comp.getChildCount()); }
Assert.assertEquals("Incorrect number of static children", 1, a.getChildCount()); Assert.assertEquals("Incorrect parent for static child", a, b.getParent()); Assert.assertEquals("Incorrect child count for 'a'", 2, a.getChildCount()); Assert.assertEquals("Incorrect child count for 'd1'", 1, d1.getChildCount()); Assert.assertEquals("Incorrect parent for 'd1'", a, d1.getParent()); Assert.assertEquals("Incorrect parent for 'd2'", d1, d2.getParent()); getChildCount()); a.remove(b); Assert.assertEquals("Incorrect number of children for 'a' after remove", 0, a. getChildCount()); Assert.assertFalse("'a' should not be in default state after remove", a.isDefaultState()); Assert.assertNull("Incorrect parent for 'b' after remove", b.getParent());
Assert.assertEquals("getChildCount() incorrect for 1 child", 1, parent.getChildCount()); setActiveContext(uic); Assert.assertEquals("getChildCount(uic) incorrect for 1 child", 1, parent.getChildCount()); resetContext(); Assert.assertEquals("getChildCount() incorrect for 0 children", 0, child1.getChildCount()); setActiveContext(uic); Assert. assertEquals("getChildCount(uic) incorrect for 0 children", 0, child1. getChildCount()); resetContext(); Assert.assertEquals("getChildAt(0) incorrect", child1, parent.getChildAt(0)); Assert.assertEquals("getChildCount() incorrect for 2 children", 2, parent.getChildCount()); setActiveContext(uic); Assert. assertEquals("getChildCount(uic) incorrect for 2 children", 2, parent. getChildCount()); resetContext(); Assert.assertEquals("getChildAt(1) incorrect", child2, parent.getChildAt(1)); Assert.assertEquals("getChildCount() incorrect after remove", 1, parent.getChildCount()); setActiveContext(uic); Assert.assertEquals("getChildCount(uic) incorrect after remove", 1, parent.getChildCount()); resetContext(); Assert.assertNull("Removed child's parent should be null", child1.getParent()); Assert.assertNull("Removed child's parent should be null", child2.getParent()); Assert.assertEquals("getChildCount() incorrect after remove", 0, parent.getChildCount()); setActiveContext(uic);
final int childCount = getChildCount(); List<WComponent> children = null;
@Test public void testDynamicChildOverride() { AbstractWComponent parent = new MockContainer(); AbstractWComponent staticChild = new SimpleComponent(); AbstractWComponent dynamicChild = new SimpleComponent(); parent.add(staticChild); setActiveContext(createUIContext()); parent.removeAll(); parent.add(dynamicChild); Assert.assertEquals("Incorrect number of children", 1, parent.getChildCount()); Assert.assertSame("Incorrect child component", dynamicChild, parent.getChildAt(0)); }
/** * test removeAll - child from specific uic list. */ @Test public void testRemoveAllSpecific() { AbstractWComponent comp = new MockContainer(); WText text1 = new WText("XYZ"); WText text2 = new WText("ABC"); comp.add(text1); comp.add(text2); comp.setLocked(true); UIContext uic1 = createUIContext(); UIContext uic2 = createUIContext(); setActiveContext(uic2); comp.removeAll(); // from uic2 list resetContext(); Assert.assertSame("shared should contain text1", text1, comp.getChildAt(0)); Assert.assertSame("shared should contain text2", text2, comp.getChildAt(1)); setActiveContext(uic1); Assert.assertSame("uic1 should contain text1", text1, comp.getChildAt(0)); Assert.assertSame("uic1 should contain text2", text2, comp.getChildAt(1)); setActiveContext(uic2); Assert.assertEquals("uic2 should not contain any children", 0, comp.getChildCount()); }