/** * {@inheritDoc} */ @Override // to make public public WComponent getChildAt(final int index) { return super.getChildAt(index); }
/** * {@inheritDoc} */ @Override // to make public public WComponent getChildAt(final int index) { return super.getChildAt(index); }
/** * {@inheritDoc} */ @Override // to make public public WComponent getChildAt(final int index) { return super.getChildAt(index); }
/** * {@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)); } }
children[i - childStartIndex] = getChildAt(i);
/** * test remove - child from specific uic list. */ @Test public void testRemoveSpecific() { UIContext uic1 = createUIContext(); UIContext uic2 = createUIContext(); AbstractWComponent comp = new MockContainer(); WText text1 = new WText("XYZ"); WText text2 = new WText("ABC"); comp.add(text1); comp.add(text2); comp.setLocked(true); // from uic2 list setActiveContext(uic2); comp.remove(text1); 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.assertNull("uic2 should not contain text1", text1.getParent()); Assert.assertSame("uic2 should contain text2", text2, comp.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()); }
/** * test remove - child from shared list. */ @Test public void testRemoveCommon() { AbstractWComponent comp = new MockContainer(); WText text1 = new WText("XYZ"); WText text2 = new WText("ABC"); comp.add(text1); comp.add(text2); comp.remove(text1); // from shared list Assert.assertNull("shared should not contain text1", text1.getParent()); Assert.assertSame("shared should contain text2", text2, comp.getChildAt(0)); }
@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)); }
getChildCount()); resetContext(); Assert.assertEquals("getChildAt(0) incorrect", child1, parent.getChildAt(0)); Assert.assertNull("getParent() incorrect for no parent", parent.getParent()); Assert.assertEquals("getParent() incorrect for child", parent, child1.getParent()); getChildCount()); resetContext(); Assert.assertEquals("getChildAt(1) incorrect", child2, parent.getChildAt(1)); setActiveContext(uic); Assert.assertEquals("getParent(uic) incorrect for 2nd child", parent, child2.getParent());