Clover Coverage Report - FEST Swing 1.2
Coverage timestamp: Tue Jun 1 2010 15:19:25 PDT
../../../../img/srcFileCovDistChart10.png 0% of files have more coverage
11   72   6   2.2
2   39   0.55   5
5     1.2  
1    
 
  JTableCheckBoxEditorCellWriter       Line # 40 11 0% 6 0 100% 1.0
 
No Tests
 
1    /*
2    * Created on Jun 10, 2008
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5    * in compliance with the License. You may obtain a copy of the License at
6    *
7    * http://www.apache.org/licenses/LICENSE-2.0
8    *
9    * Unless required by applicable law or agreed to in writing, software distributed under the License
10    * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11    * or implied. See the License for the specific language governing permissions and limitations under
12    * the License.
13    *
14    * Copyright @2008-2010 the original author or authors.
15    */
16    package org.fest.swing.driver;
17   
18    import static java.lang.Boolean.parseBoolean;
19    import static org.fest.swing.edt.GuiActionRunner.execute;
20   
21    import java.awt.Point;
22   
23    import javax.swing.JCheckBox;
24    import javax.swing.JTable;
25    import javax.swing.text.JTextComponent;
26   
27    import org.fest.swing.annotation.RunsInEDT;
28    import org.fest.swing.cell.JTableCellWriter;
29    import org.fest.swing.core.Robot;
30    import org.fest.swing.edt.GuiQuery;
31    import org.fest.swing.util.Pair;
32   
33    /**
34    * Understands an implementation of <code>{@link JTableCellWriter}</code> that knows how to use
35    * <code>{@link JTextComponent}</code>s as cell editors.
36    *
37    * @author Alex Ruiz
38    * @author Yvonne Wang
39    */
 
40    public class JTableCheckBoxEditorCellWriter extends AbstractJTableCellWriter {
41   
 
42  178 toggle public JTableCheckBoxEditorCellWriter(Robot robot) {
43  178 super(robot);
44    }
45   
46    /** {@inheritDoc} */
 
47  8 toggle @RunsInEDT
48    public void enterValue(JTable table, int row, int column, String value) {
49  8 boolean realValue = parseBoolean(value);
50  8 Pair<Boolean, Point> editingInfo = doStartCellEditing(table, row, column, location);
51  3 if (editingInfo.i == realValue) return; // JCheckBox already has value to set.
52  4 robot.click(table, editingInfo.ii);
53    }
54   
55    /** {@inheritDoc} */
 
56  1 toggle @RunsInEDT
57    public void startCellEditing(JTable table, int row, int column) {
58  1 doStartCellEditing(table, row, column, location);
59    }
60   
 
61  9 toggle @RunsInEDT
62    private static Pair<Boolean, Point> doStartCellEditing(final JTable table, final int row, final int column,
63    final JTableLocation location) {
64  9 return execute(new GuiQuery<Pair<Boolean, Point>>() {
 
65  9 toggle protected Pair<Boolean, Point> executeInEDT() {
66  9 JCheckBox editor = editor(table, row, column, JCheckBox.class);
67  7 scrollToCell(table, row, column, location);
68  7 return new Pair<Boolean, Point>(editor.isSelected(), location.pointAt(table, row, column));
69    }
70    });
71    }
72    }