/** * {@inheritDoc} */ @Override // to make public public int getIndexOfChild(final WComponent childComponent) { return super.getIndexOfChild(childComponent); }
/** * {@inheritDoc} */ @Override // to make public public int getIndexOfChild(final WComponent childComponent) { return super.getIndexOfChild(childComponent); }
/** * {@inheritDoc} */ @Override // to make public public int getIndexOfChild(final WComponent childComponent) { return super.getIndexOfChild(childComponent); }
StringBuffer nameBuf = new StringBuffer(nameLen + 3); nameBuf.append(iid); nameBuf.append(getIndexOfChild(parent, this));
/** * Internal utility method to find the index of a child within a container. This method makes use of the additional * methods offered by the AbstractWComponent implementation (if available), otherwise it falls back the methods * declared in the {@link WComponent} interface. * * @param parent the container to search for the child in * @param childComponent the component to search for. * @return the index of the <code>childComponent</code> in <code>parent</code>, or -1 if <code>childComponent</code> * is not a child of <code>parent</code>. */ private static int getIndexOfChild(final Container parent, final WComponent childComponent) { if (parent instanceof AbstractWComponent) { return ((AbstractWComponent) parent).getIndexOfChild(childComponent); } else { // We have to do this the hard way... for (int i = 0; i < parent.getChildCount(); i++) { if (childComponent == parent.getChildAt(i)) { return i; } } } return -1; }
int idx = getIndexOfChild(parent, this);
int index = getIndexOfChild(parent, node); reversedIndexList.add(index); node = parent;
@Test public void testDynamicAddAndReset() { AbstractWComponent parent = new MockContainer(); AbstractWComponent child = new SimpleComponent(); setActiveContext(createUIContext()); parent.add(child); child.reset(); Assert.assertEquals("Child component should have reference to parent", parent, child. getParent()); Assert.assertEquals("Parent component should have reference to child", 0, parent. getIndexOfChild(child)); }
if (dynamicParent != null && getParent() != dynamicParent && getIndexOfChild( dynamicParent, this) != -1) {
Assert.assertEquals("getParent(uic) incorrect for child", parent, child1.getParent()); resetContext(); Assert.assertEquals("Incorrect indexOfChild for child", 0, parent.getIndexOfChild(child1)); resetContext(); Assert.assertEquals("Incorrect indexOfChild for 2nd child", 1, parent. getIndexOfChild(child2));