Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 414550
Collapse All | Expand All

(-)a/org.eclipse.jubula.rc.common/src/org/eclipse/jubula/rc/common/tester/AbstractTreeTester.java (-5 lines)
Lines 555-565 public abstract class AbstractTreeTester extends WidgetTester { Link Here
555
        AbstractTreeOperationContext context = getTreeAdapter().getContext();
555
        AbstractTreeOperationContext context = getTreeAdapter().getContext();
556
        Object selectedNode = 
556
        Object selectedNode = 
557
            getSelectedNode(context);
557
            getSelectedNode(context);
558
        if (selectedNode == null) {
559
            throw new StepExecutionException("No tree item selected", //$NON-NLS-1$ 
560
                EventFactory.createActionError(TestErrorEvent.NO_SELECTION));
561
        }
562
        
563
        return context.getRenderedText(selectedNode);
558
        return context.getRenderedText(selectedNode);
564
    }
559
    }
565
    
560
    
(-)a/org.eclipse.jubula.rc.common/src/org/eclipse/jubula/rc/common/tester/ListTester.java (-13 / +4 lines)
Lines 20-25 import org.eclipse.jubula.rc.common.driver.ClickOptions; Link Here
20
import org.eclipse.jubula.rc.common.driver.DragAndDropHelper;
20
import org.eclipse.jubula.rc.common.driver.DragAndDropHelper;
21
import org.eclipse.jubula.rc.common.exception.StepExecutionException;
21
import org.eclipse.jubula.rc.common.exception.StepExecutionException;
22
import org.eclipse.jubula.rc.common.tester.adapter.interfaces.IListComponent;
22
import org.eclipse.jubula.rc.common.tester.adapter.interfaces.IListComponent;
23
import org.eclipse.jubula.rc.common.util.ArrayValidator;
23
import org.eclipse.jubula.rc.common.util.IndexConverter;
24
import org.eclipse.jubula.rc.common.util.IndexConverter;
24
import org.eclipse.jubula.rc.common.util.ListSelectionVerifier;
25
import org.eclipse.jubula.rc.common.util.ListSelectionVerifier;
25
import org.eclipse.jubula.rc.common.util.MatchUtil;
26
import org.eclipse.jubula.rc.common.util.MatchUtil;
Lines 58-67 public class ListTester extends AbstractTextVerifiableTester { Link Here
58
     */
59
     */
59
    private int[] getCheckedSelectedIndices() throws StepExecutionException {
60
    private int[] getCheckedSelectedIndices() throws StepExecutionException {
60
        int[] selected = getListAdapter().getSelectedIndices();
61
        int[] selected = getListAdapter().getSelectedIndices();
61
        if (selected.length == 0) {
62
        ArrayValidator.validateSelectionArray(selected);
62
            throw new StepExecutionException("No list element selected", //$NON-NLS-1$
63
                EventFactory.createActionError(TestErrorEvent.NO_SELECTION));
64
        }
65
        return selected;
63
        return selected;
66
    }
64
    }
67
65
Lines 131-140 public class ListTester extends AbstractTextVerifiableTester { Link Here
131
    public void rcVerifyText(String text, String operator) {
129
    public void rcVerifyText(String text, String operator) {
132
        String[] selected = getListAdapter().getSelectedValues();
130
        String[] selected = getListAdapter().getSelectedValues();
133
        final int selCount = selected.length;
131
        final int selCount = selected.length;
134
        if (selCount < 1) {
132
        ArrayValidator.validateSelectionArray(selected);
135
            throw new StepExecutionException("No selection", //$NON-NLS-1$
136
                EventFactory.createActionError(TestErrorEvent.NO_SELECTION));
137
        }
138
        for (int i = 0; i < selCount; i++) {
133
        for (int i = 0; i < selCount; i++) {
139
            Verifier.match(selected[i], text, operator);
134
            Verifier.match(selected[i], text, operator);
140
        }
135
        }
Lines 211-221 public class ListTester extends AbstractTextVerifiableTester { Link Here
211
     */
206
     */
212
    public String rcReadValue(String variable) {
207
    public String rcReadValue(String variable) {
213
        String[] selected = getListAdapter().getSelectedValues();
208
        String[] selected = getListAdapter().getSelectedValues();
214
        if (selected.length > 0) {
209
        return (String) ArrayValidator.validateSelectionArray(selected);
215
            return selected[0];
216
        }
217
        throw new StepExecutionException("No list item selected", //$NON-NLS-1$
218
            EventFactory.createActionError(TestErrorEvent.NO_SELECTION));
219
    }
210
    }
220
    
211
    
221
    /**
212
    /**
(-)a/org.eclipse.jubula.rc.common/src/org/eclipse/jubula/rc/common/util/ArrayValidator.java (+58 lines)
Added Link Here
1
package org.eclipse.jubula.rc.common.util;
2
3
import org.eclipse.jubula.rc.common.exception.StepExecutionException;
4
import org.eclipse.jubula.tools.objects.event.EventFactory;
5
import org.eclipse.jubula.tools.objects.event.TestErrorEvent;
6
7
/**
8
 * Utility methods to check whether an array is valid or not.
9
 * 
10
 * @author BREDEX GmbH
11
 * @created Aug 06, 2013
12
 *
13
 */
14
public class ArrayValidator {
15
16
    /**
17
     * private constructor
18
     */
19
    private ArrayValidator() {
20
        //do nothing
21
    }
22
    
23
    /**
24
     * Checks if there is any selection on the widget
25
     * 
26
     * @param array an array of Objects to be validated
27
     * @throws StepExecutionException thrown if 
28
     * @return The first selected Item
29
     */
30
    public static Object validateSelectionArray(Object[] array) 
31
        throws StepExecutionException {
32
                
33
        if (array == null || array.length == 0) {
34
            throw new StepExecutionException("No selection found", //$NON-NLS-1$
35
                    EventFactory.createActionError(
36
                            TestErrorEvent.NO_SELECTION));
37
        }
38
        return array[0];
39
    }
40
    
41
    /**
42
     * Checks if there is any selection on the widget
43
     * 
44
     * @param array an array of Objects to be validated
45
     * @throws StepExecutionException thrown if 
46
     * @return The first selected Item
47
     */
48
    public static int validateSelectionArray(int[] array) 
49
        throws StepExecutionException {
50
                    
51
        if (array == null || array.length == 0) {
52
            throw new StepExecutionException("No selection found", //$NON-NLS-1$
53
                    EventFactory.createActionError(
54
                            TestErrorEvent.NO_SELECTION));
55
        }
56
        return array[0];
57
    }
58
}
(-)a/org.eclipse.jubula.rc.swing/src/org/eclipse/jubula/rc/swing/tester/adapter/JListAdapter.java (-5 / +2 lines)
Lines 21-26 import org.eclipse.jubula.rc.common.driver.ClickOptions; Link Here
21
import org.eclipse.jubula.rc.common.driver.IRunnable;
21
import org.eclipse.jubula.rc.common.driver.IRunnable;
22
import org.eclipse.jubula.rc.common.exception.StepExecutionException;
22
import org.eclipse.jubula.rc.common.exception.StepExecutionException;
23
import org.eclipse.jubula.rc.common.tester.adapter.interfaces.IListComponent;
23
import org.eclipse.jubula.rc.common.tester.adapter.interfaces.IListComponent;
24
import org.eclipse.jubula.rc.common.util.ArrayValidator;
24
import org.eclipse.jubula.rc.common.util.MatchUtil;
25
import org.eclipse.jubula.rc.common.util.MatchUtil;
25
import org.eclipse.jubula.rc.swing.tester.util.TesterUtil;
26
import org.eclipse.jubula.rc.swing.tester.util.TesterUtil;
26
import org.eclipse.jubula.tools.objects.event.EventFactory;
27
import org.eclipse.jubula.tools.objects.event.EventFactory;
Lines 48-58 public class JListAdapter extends JComponentAdapter implements IListComponent { Link Here
48
     */
49
     */
49
    public String getText() {
50
    public String getText() {
50
        String[] selected = getSelectedValues();
51
        String[] selected = getSelectedValues();
51
        if (selected.length > 0) {
52
        return (String) ArrayValidator.validateSelectionArray(selected);
52
            return selected[0];
53
        }
54
        throw new StepExecutionException("No list item selected", //$NON-NLS-1$
55
            EventFactory.createActionError(TestErrorEvent.NO_SELECTION));
56
    }
53
    }
57
54
58
    /**
55
    /**
(-)a/org.eclipse.jubula.rc.swing/src/org/eclipse/jubula/rc/swing/tester/adapter/JTableAdapter.java (-1 / +1 lines)
Lines 266-272 public class JTableAdapter extends JComponentAdapter Link Here
266
                                                    .Property
266
                                                    .Property
267
                                                    .DESCRIPTION_KEY)))) {
267
                                                    .DESCRIPTION_KEY)))) {
268
                // set "invalid index" to "no selection" -> better description!
268
                // set "invalid index" to "no selection" -> better description!
269
                                throw new StepExecutionException("No selection", //$NON-NLS-1$
269
                                throw new StepExecutionException("No selection found", //$NON-NLS-1$
270
                                        EventFactory.createActionError(
270
                                        EventFactory.createActionError(
271
                                                TestErrorEvent.NO_SELECTION));
271
                                                TestErrorEvent.NO_SELECTION));
272
                            }
272
                            }
(-)a/org.eclipse.jubula.rc.swing/src/org/eclipse/jubula/rc/swing/tester/util/TreeOperationContext.java (-6 / +2 lines)
Lines 31-39 import org.eclipse.jubula.rc.common.driver.IRunnable; Link Here
31
import org.eclipse.jubula.rc.common.exception.StepExecutionException;
31
import org.eclipse.jubula.rc.common.exception.StepExecutionException;
32
import org.eclipse.jubula.rc.common.implclasses.tree.AbstractTreeOperationContext;
32
import org.eclipse.jubula.rc.common.implclasses.tree.AbstractTreeOperationContext;
33
import org.eclipse.jubula.rc.common.logger.AutServerLogger;
33
import org.eclipse.jubula.rc.common.logger.AutServerLogger;
34
import org.eclipse.jubula.rc.common.util.ArrayValidator;
34
import org.eclipse.jubula.rc.swing.driver.EventThreadQueuerAwtImpl;
35
import org.eclipse.jubula.rc.swing.driver.EventThreadQueuerAwtImpl;
35
import org.eclipse.jubula.tools.objects.event.EventFactory;
36
import org.eclipse.jubula.tools.objects.event.TestErrorEvent;
37
36
38
37
39
/**
38
/**
Lines 512-521 public class TreeOperationContext extends AbstractTreeOperationContext { Link Here
512
     */
511
     */
513
    private TreePath[] getCheckedSelectedPaths() {
512
    private TreePath[] getCheckedSelectedPaths() {
514
        TreePath[] paths = (TreePath[])getSelectionPaths();
513
        TreePath[] paths = (TreePath[])getSelectionPaths();
515
        if (paths == null) {
514
        ArrayValidator.validateSelectionArray(paths);
516
            throw new StepExecutionException("No tree node(s) selected", //$NON-NLS-1$
517
                EventFactory.createActionError(TestErrorEvent.NO_SELECTION));
518
        }
519
        return paths;
515
        return paths;
520
    }
516
    }
521
    /**
517
    /**
(-)a/org.eclipse.jubula.rc.swt/src/org/eclipse/jubula/rc/swt/tester/TreeTester.java (-2 / +5 lines)
Lines 32-37 import org.eclipse.jubula.rc.common.implclasses.tree.StandardDepthFirstTraverser Link Here
32
import org.eclipse.jubula.rc.common.implclasses.tree.TreeNodeOperation;
32
import org.eclipse.jubula.rc.common.implclasses.tree.TreeNodeOperation;
33
import org.eclipse.jubula.rc.common.implclasses.tree.TreeNodeOperationConstraint;
33
import org.eclipse.jubula.rc.common.implclasses.tree.TreeNodeOperationConstraint;
34
import org.eclipse.jubula.rc.common.tester.AbstractTreeTester;
34
import org.eclipse.jubula.rc.common.tester.AbstractTreeTester;
35
import org.eclipse.jubula.rc.common.tester.adapter.interfaces.ITreeComponent;
35
import org.eclipse.jubula.rc.common.util.IndexConverter;
36
import org.eclipse.jubula.rc.common.util.IndexConverter;
36
import org.eclipse.jubula.rc.common.util.KeyStrokeUtil;
37
import org.eclipse.jubula.rc.common.util.KeyStrokeUtil;
37
import org.eclipse.jubula.rc.common.util.MatchUtil;
38
import org.eclipse.jubula.rc.common.util.MatchUtil;
Lines 785-792 public class TreeTester extends AbstractTreeTester { Link Here
785
        throws StepExecutionException {        
786
        throws StepExecutionException {        
786
        Boolean checkSelected = ((Boolean)getEventThreadQueuer().invokeAndWait(
787
        Boolean checkSelected = ((Boolean)getEventThreadQueuer().invokeAndWait(
787
                "rcVerifyTreeCheckbox", new IRunnable() { //$NON-NLS-1$
788
                "rcVerifyTreeCheckbox", new IRunnable() { //$NON-NLS-1$
788
                    public Object run() {             
789
                    public Object run() {
789
                        TreeItem node = getTree().getSelection()[0];
790
                        AbstractTreeOperationContext context = 
791
                                ((ITreeComponent)getComponent()).getContext();
792
                        TreeItem node = (TreeItem) getSelectedNode(context);
790
                        return new Boolean(node.getChecked());
793
                        return new Boolean(node.getChecked());
791
                    }            
794
                    }            
792
                }));       
795
                }));       
(-)a/org.eclipse.jubula.rc.swt/src/org/eclipse/jubula/rc/swt/tester/adapter/ListAdapter.java (-7 / +2 lines)
Lines 14-22 import org.eclipse.jubula.rc.common.driver.ClickOptions; Link Here
14
import org.eclipse.jubula.rc.common.driver.IRunnable;
14
import org.eclipse.jubula.rc.common.driver.IRunnable;
15
import org.eclipse.jubula.rc.common.exception.StepExecutionException;
15
import org.eclipse.jubula.rc.common.exception.StepExecutionException;
16
import org.eclipse.jubula.rc.common.tester.adapter.interfaces.IListComponent;
16
import org.eclipse.jubula.rc.common.tester.adapter.interfaces.IListComponent;
17
import org.eclipse.jubula.rc.common.util.ArrayValidator;
17
import org.eclipse.jubula.rc.swt.utils.SwtUtils;
18
import org.eclipse.jubula.rc.swt.utils.SwtUtils;
18
import org.eclipse.jubula.tools.objects.event.EventFactory;
19
import org.eclipse.jubula.tools.objects.event.TestErrorEvent;
20
import org.eclipse.swt.graphics.Rectangle;
19
import org.eclipse.swt.graphics.Rectangle;
21
import org.eclipse.swt.widgets.List;
20
import org.eclipse.swt.widgets.List;
22
/**
21
/**
Lines 39-49 public class ListAdapter extends ControlAdapter implements IListComponent { Link Here
39
     */
38
     */
40
    public String getText() {
39
    public String getText() {
41
        String[] selected = getSelectedValues();
40
        String[] selected = getSelectedValues();
42
        if (selected.length > 0) {
41
        return (String) ArrayValidator.validateSelectionArray(selected);
43
            return selected[0];
44
        }
45
        throw new StepExecutionException("No list item selected", //$NON-NLS-1$
46
            EventFactory.createActionError(TestErrorEvent.NO_SELECTION));
47
    }
42
    }
48
    
43
    
49
    /**
44
    /**
(-)a/org.eclipse.jubula.rc.swt/src/org/eclipse/jubula/rc/swt/tester/tree/TreeOperationContext.java (-17 / +3 lines)
Lines 21-33 import org.eclipse.jubula.rc.common.driver.IRunnable; Link Here
21
import org.eclipse.jubula.rc.common.exception.StepExecutionException;
21
import org.eclipse.jubula.rc.common.exception.StepExecutionException;
22
import org.eclipse.jubula.rc.common.implclasses.tree.AbstractTreeOperationContext;
22
import org.eclipse.jubula.rc.common.implclasses.tree.AbstractTreeOperationContext;
23
import org.eclipse.jubula.rc.common.logger.AutServerLogger;
23
import org.eclipse.jubula.rc.common.logger.AutServerLogger;
24
import org.eclipse.jubula.rc.common.util.ArrayValidator;
24
import org.eclipse.jubula.rc.common.util.Verifier;
25
import org.eclipse.jubula.rc.common.util.Verifier;
25
import org.eclipse.jubula.rc.swt.tester.CAPUtil;
26
import org.eclipse.jubula.rc.swt.tester.CAPUtil;
26
import org.eclipse.jubula.rc.swt.utils.SwtPointUtil;
27
import org.eclipse.jubula.rc.swt.utils.SwtPointUtil;
27
import org.eclipse.jubula.rc.swt.utils.SwtUtils;
28
import org.eclipse.jubula.rc.swt.utils.SwtUtils;
28
import org.eclipse.jubula.tools.constants.SwtAUTHierarchyConstants;
29
import org.eclipse.jubula.tools.constants.SwtAUTHierarchyConstants;
29
import org.eclipse.jubula.tools.objects.event.EventFactory;
30
import org.eclipse.jubula.tools.objects.event.TestErrorEvent;
31
import org.eclipse.swt.SWT;
30
import org.eclipse.swt.SWT;
32
import org.eclipse.swt.widgets.Control;
31
import org.eclipse.swt.widgets.Control;
33
import org.eclipse.swt.widgets.Event;
32
import org.eclipse.swt.widgets.Event;
Lines 454-466 public class TreeOperationContext extends AbstractTreeOperationContext { Link Here
454
                public Object run() {
453
                public Object run() {
455
                    TreeItem [] selectedItems = 
454
                    TreeItem [] selectedItems = 
456
                        ((Tree)getTree()).getSelection();
455
                        ((Tree)getTree()).getSelection();
457
                    if (selectedItems == null || selectedItems.length == 0) {
456
                    return ArrayValidator.validateSelectionArray(selectedItems);
458
                        throw new StepExecutionException(
459
                            "No tree node(s) selected", //$NON-NLS-1$
460
                            EventFactory.createActionError(
461
                                TestErrorEvent.NO_SELECTION));
462
                    }
463
                    return selectedItems[0];
464
                }
457
                }
465
458
466
            });
459
            });
Lines 476-488 public class TreeOperationContext extends AbstractTreeOperationContext { Link Here
476
                public Object run() {
469
                public Object run() {
477
                    TreeItem [] selectedItems = 
470
                    TreeItem [] selectedItems = 
478
                        ((Tree)getTree()).getSelection();
471
                        ((Tree)getTree()).getSelection();
479
                    if (selectedItems == null || selectedItems.length == 0) {
472
                    return ArrayValidator.validateSelectionArray(selectedItems);
480
                        throw new StepExecutionException(
481
                            "No tree node(s) selected", //$NON-NLS-1$
482
                            EventFactory.createActionError(
483
                                TestErrorEvent.NO_SELECTION));
484
                    }
485
                    return selectedItems;
486
                }
473
                }
487
474
488
            });
475
            });
489
- 

Return to bug 414550