Coverage Report - org.eclipse.swtbot.swt.finder.resolvers.DefaultParentResolver
 
Classes in this File Line Coverage Branch Coverage Complexity
DefaultParentResolver
93%
14/15
80%
8/10
5
 
 1  
 /*******************************************************************************
 2  
  * Copyright (c) 2008 Ketan Padegaonkar and others.
 3  
  * All rights reserved. This program and the accompanying materials
 4  
  * are made available under the terms of the Eclipse Public License v1.0
 5  
  * which accompanies this distribution, and is available at
 6  
  * http://www.eclipse.org/legal/epl-v10.html
 7  
  * 
 8  
  * Contributors:
 9  
  *     Ketan Padegaonkar - initial API and implementation
 10  
  *******************************************************************************/
 11  
 package org.eclipse.swtbot.swt.finder.resolvers;
 12  
 
 13  
 import java.util.Iterator;
 14  
 import java.util.List;
 15  
 
 16  
 import org.eclipse.swt.widgets.Widget;
 17  
 
 18  
 /**
 19  
  * @author Ketan Padegaonkar <KetanPadegaonkar [at] gmail [dot] com>
 20  
  * @version $Id$
 21  
  */
 22  2526
 public class DefaultParentResolver extends Resolvable implements IParentResolver {
 23  
 
 24  
         public Widget getParent(Widget w) {
 25  3261
                 if (!hasParent(w))
 26  506
                         return null;
 27  
 
 28  2755
                 List resolvers = getResolver().getResolvers(w.getClass());
 29  
 
 30  5510
                 for (Iterator iter = resolvers.iterator(); iter.hasNext();) {
 31  2755
                         IParentResolver resolver = (IParentResolver) iter.next();
 32  2755
                         if (resolver.hasParent(w))
 33  2755
                                 return resolver.getParent(w);
 34  
                 }
 35  0
                 return null;
 36  
         }
 37  
 
 38  
         public boolean hasParent(Widget w) {
 39  
 
 40  3261
                 List resolvers = getResolver().getResolvers(w.getClass());
 41  
 
 42  7028
                 for (Iterator iter = resolvers.iterator(); iter.hasNext();) {
 43  3261
                         IParentResolver resolver = (IParentResolver) iter.next();
 44  3261
                         if (resolver.hasParent(w))
 45  2755
                                 return true;
 46  
                 }
 47  506
                 return false;
 48  
         }
 49  
 
 50  
 }