Coverage Report - org.eclipse.swtbot.swt.finder.widgets.SWTBotTableColumn
 
Classes in this File Line Coverage Branch Coverage Complexity
SWTBotTableColumn
76%
10/13
N/A
1
SWTBotTableColumn$1
0%
0/3
N/A
1
 
 1  0
 /*******************************************************************************
 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.widgets;
 12  
 
 13  
 import org.eclipse.swt.SWT;
 14  
 import org.eclipse.swt.widgets.Table;
 15  
 import org.eclipse.swt.widgets.TableColumn;
 16  
 import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;
 17  
 import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable;
 18  
 import org.eclipse.swtbot.swt.finder.results.WidgetResult;
 19  
 import org.hamcrest.SelfDescribing;
 20  
 
 21  
 /**
 22  
  * @author Ketan Padegaonkar <KetanPadegaonkar [at] gmail [dot] com>
 23  
  * @version $Id$
 24  
  */
 25  
 public class SWTBotTableColumn extends AbstractSWTBot<TableColumn> {
 26  
 
 27  
         private final Table        parent;
 28  
 
 29  
         /**
 30  
          * Constructs a new instance of this object.
 31  
          * 
 32  
          * @param w the widget.
 33  
          * @throws WidgetNotFoundException if the widget is <code>null</code> or widget has been disposed.
 34  
          * @since 2.0
 35  
          */
 36  
         public SWTBotTableColumn(final TableColumn w) throws WidgetNotFoundException {
 37  0
                 this(w, UIThreadRunnable.syncExec(new WidgetResult<Table>() {
 38  
                         public Table run() {
 39  0
                                 return w.getParent();
 40  
                         }
 41  
                 }));
 42  0
         }
 43  
         
 44  
         /**
 45  
          * Constructs a new instance of this object.
 46  
          * 
 47  
          * @param w the widget.
 48  
          * @param parent the parent table.
 49  
          * @throws WidgetNotFoundException if the widget is <code>null</code> or widget has been disposed.
 50  
          * @since 2.0
 51  
          */
 52  
         public SWTBotTableColumn(TableColumn w, Table parent) throws WidgetNotFoundException {
 53  2
                 this(w, parent, null);
 54  2
         }
 55  
 
 56  
         /**
 57  
          * Constructs a new instance of this object.
 58  
          * 
 59  
          * @param w the widget.
 60  
          * @param parent the parent table.
 61  
          * @param description the description of the widget, this will be reported by {@link #toString()}
 62  
          * @throws WidgetNotFoundException if the widget is <code>null</code> or widget has been disposed.
 63  
          * @since 2.0
 64  
          */
 65  
         public SWTBotTableColumn(TableColumn w, Table parent, SelfDescribing description) throws WidgetNotFoundException {
 66  2
                 super(w, description);
 67  2
                 this.parent = parent;
 68  2
         }
 69  
 
 70  
         /**
 71  
          * Clicks the item.
 72  
          */
 73  
         public SWTBotTableColumn click() {
 74  1
                 waitForEnabled();
 75  1
                 notify(SWT.Selection);
 76  1
                 notify(SWT.MouseUp, createMouseEvent(0, 0, 1, SWT.BUTTON1, 1), parent);
 77  1
                 return this;
 78  
         }
 79  
 
 80  
         @Override
 81  
         public boolean isEnabled() {
 82  1
                 return true;
 83  
         }
 84  
 
 85  
 }