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 394179 | Differences between
and this patch

Collapse All | Expand All

(-)a/org.eclipse.jubula.rc.common/src/org/eclipse/jubula/rc/common/caps/AbstractButtonCAPs.java (-31 / +2 lines)
Lines 22-40 import org.eclipse.jubula.rc.common.uiadapter.interfaces.IButtonAdapter; Link Here
22
 * @author BREDEX GmbH
22
 * @author BREDEX GmbH
23
 *
23
 *
24
 */
24
 */
25
public abstract class AbstractButtonCAPs extends AbstractWidgetCAPs {
25
public abstract class AbstractButtonCAPs extends AbstractTextVerifiable {
26
26
27
    /**
27
    /**
28
     * Action to read the value of a JButton to store it in a variable in the
29
     * Client
30
     * 
31
     * @param variable the name of the variable
32
     * @return the text value.
33
     */
34
    public String gdReadValue(String variable) {
35
        return ((IButtonAdapter) this.getComponent()).getText();
36
    }
37
    /**
38
     * 
28
     * 
39
     * @return the IButtonAdapter for the component. 
29
     * @return the IButtonAdapter for the component. 
40
     */
30
     */
Lines 51-67 public abstract class AbstractButtonCAPs extends AbstractWidgetCAPs { Link Here
51
41
52
        Verifier.equals(selected, getButtonAdapter().isSelected());
42
        Verifier.equals(selected, getButtonAdapter().isSelected());
53
    }
43
    }
54
    
44
   
55
    /**
56
     * Verifies the passed text.
57
     * 
58
     * @param text The text to verify
59
     * @param operator The RegEx operator used to verify
60
     */
61
    public void gdVerifyText(String text, String operator) {
62
        verifyText(text, operator);
63
    }
64
65
    /**
45
    /**
66
     * Verifies the passed text.
46
     * Verifies the passed text.
67
     * 
47
     * 
Lines 70-83 public abstract class AbstractButtonCAPs extends AbstractWidgetCAPs { Link Here
70
    public void gdVerifyText(String text) {
50
    public void gdVerifyText(String text) {
71
        gdVerifyText(text, MatchUtil.DEFAULT_OPERATOR);
51
        gdVerifyText(text, MatchUtil.DEFAULT_OPERATOR);
72
    }
52
    }
73
    /**
74
     * Verifies the passed text.
75
     * @param text The text to verify
76
     * @param operator The operator used to verify
77
     */
78
    public void verifyText(String text, String operator) {
79
        String value = getButtonAdapter().getText();
80
        Verifier.match(value, text, operator);
81
    }
82
53
83
}
54
}
(-)a/org.eclipse.jubula.rc.common/src/org/eclipse/jubula/rc/common/caps/AbstractListCAPs.java (+476 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2012 BREDEX GmbH.
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
 *     BREDEX GmbH - initial API and implementation 
10
 *******************************************************************************/
11
package org.eclipse.jubula.rc.common.caps;
12
13
import java.util.Arrays;
14
15
import org.apache.commons.lang.ArrayUtils;
16
import org.apache.commons.lang.StringUtils;
17
import org.eclipse.jubula.rc.common.CompSystemConstants;
18
import org.eclipse.jubula.rc.common.driver.ClickOptions;
19
import org.eclipse.jubula.rc.common.driver.DragAndDropHelper;
20
import org.eclipse.jubula.rc.common.exception.StepExecutionException;
21
import org.eclipse.jubula.rc.common.implclasses.IndexConverter;
22
import org.eclipse.jubula.rc.common.implclasses.ListSelectionVerifier;
23
import org.eclipse.jubula.rc.common.implclasses.MatchUtil;
24
import org.eclipse.jubula.rc.common.implclasses.Verifier;
25
import org.eclipse.jubula.rc.common.uiadapter.interfaces.IListAdapter;
26
import org.eclipse.jubula.tools.constants.StringConstants;
27
import org.eclipse.jubula.tools.constants.TestDataConstants;
28
import org.eclipse.jubula.tools.objects.event.EventFactory;
29
import org.eclipse.jubula.tools.objects.event.TestErrorEvent;
30
import org.eclipse.jubula.tools.utils.StringParsing;
31
32
/**
33
 * 
34
 * @author BREDEX GmbH
35
 *
36
 */
37
public abstract class AbstractListCAPs extends AbstractTextVerifiable {
38
39
    /** The default separator for enumerations of list values. */
40
    public static final char INDEX_LIST_SEP_CHAR = 
41
        TestDataConstants.VALUE_CHAR_DEFAULT; 
42
    //FIXME this should be in an upper class or Util
43
    /** The default separator of a list of values */
44
    public static final char VALUE_SEPARATOR = 
45
        TestDataConstants.VALUE_CHAR_DEFAULT;
46
    
47
    /**
48
     * Splits the enumeration of values.
49
     * @param values The values to split
50
     * @param separator The separator, may be <code>null</code>
51
     * @return The array of values
52
     */
53
    private String[] split(String values, String separator) {
54
        String[] list = StringParsing.splitToArray(values, ((separator == null)
55
            || (separator.length() == 0) ? INDEX_LIST_SEP_CHAR
56
                : separator.charAt(0)),
57
            TestDataConstants.ESCAPE_CHAR_DEFAULT);
58
        list = StringUtils.stripAll(list);
59
        return list;
60
    }
61
    
62
    /**
63
     * @return The array of selected indices
64
     * @throws StepExecutionException If there are no indices selected
65
     */
66
    private int[] getCheckedSelectedIndices() throws StepExecutionException {
67
        int[] selected = getListAdapter().getSelectedIndices();
68
        if (selected.length == 0) {
69
            throw new StepExecutionException("No list element selected", //$NON-NLS-1$
70
                EventFactory.createActionError(TestErrorEvent.NO_SELECTION));
71
        }
72
        return selected;
73
    }
74
75
    /**
76
     * 
77
     * @return the List Adapter
78
     */
79
    private IListAdapter getListAdapter() {
80
        return ((IListAdapter) getComponent());
81
    }
82
    
83
    /**
84
     * Verifies if the passed index is selected.
85
     * 
86
     * @param index The index to verify
87
     * @param expectSelected Whether the index should be selected.
88
     */
89
    public void gdVerifySelectedIndex(String index, boolean expectSelected) {
90
        int[] selected = getCheckedSelectedIndices();
91
        int implIndex = IndexConverter.toImplementationIndex(
92
                Integer.parseInt(index));
93
94
        boolean isSelected = ArrayUtils.contains(selected, implIndex);
95
        if (expectSelected != isSelected) {
96
            throw new StepExecutionException(
97
                    "Selection check failed for index: " + index,  //$NON-NLS-1$
98
                    EventFactory.createVerifyFailed(
99
                            String.valueOf(expectSelected), 
100
                            String.valueOf(isSelected)));
101
        }
102
    }
103
    
104
    /**
105
     * Verifies if the passed value or enumeration of values is selected. By
106
     * default, the enumeration separator is <code>,</code>
107
     * @param valueList The value or list of values to verify
108
     */
109
    public void gdVerifySelectedValue(String valueList) {
110
        gdVerifySelectedValue(valueList, MatchUtil.DEFAULT_OPERATOR, true);
111
    }
112
    
113
    /**
114
     * Verifies if the passed value is selected.
115
     * 
116
     * @param value The value to verify
117
     * @param operator The operator to use when comparing the 
118
     *                 expected and actual values.
119
     *  @param isSelected if the value should be selected or not.
120
     */
121
    public void gdVerifySelectedValue(String value, String operator,
122
            boolean isSelected) {
123
124
        final String[] current = getListAdapter().getSelectedValues();
125
        final ListSelectionVerifier listSelVerifier =
126
            new ListSelectionVerifier();
127
        for (int i = 0; i < current.length; i++) {
128
            listSelVerifier.addItem(i, current[i], true);
129
        }
130
        listSelVerifier.verifySelection(value, operator, isSelected);
131
    }
132
    
133
    /**
134
     * Verifies if all selected elements of a list match a text.
135
     * @param text The text to verify
136
     * @param operator The operator used to verify
137
     */
138
    public void gdVerifyText(String text, String operator) {
139
        String[] selected = getListAdapter().getSelectedValues();
140
        final int selCount = selected.length;
141
        if (selCount < 1) {
142
            throw new StepExecutionException("No selection", //$NON-NLS-1$
143
                EventFactory.createActionError(TestErrorEvent.NO_SELECTION));
144
        }
145
        for (int i = 0; i < selCount; i++) {
146
            Verifier.match(selected[i], text, operator);
147
        }
148
    }
149
    
150
    /**
151
     * Selects the passed index or enumeration of indices. The enumeration must
152
     * be separated by <code>,</code>, e.g. <code>1, 3,6</code>.
153
     * @param indexList The index or indices to select
154
     * @param extendSelection Whether this selection extends a previous 
155
     *                        selection.
156
     * @param button what mouse button should be used
157
     */
158
    public void gdSelectIndex(String indexList, final String extendSelection,
159
            int button) {
160
        final boolean isExtendSelection = extendSelection
161
                .equals(CompSystemConstants.EXTEND_SELECTION_YES);
162
        selectIndices(IndexConverter
163
                .toImplementationIndices(parseIndices(indexList)), ClickOptions
164
                .create().setClickCount(1).setMouseButton(button),
165
                isExtendSelection);
166
    }
167
    
168
    /**
169
     * Selects the passed value or enumeration of values. By default, the
170
     * enumeration separator is <code>,</code>.
171
     * @param valueList The value or list of values to select
172
     * @param operator If regular expressions are used
173
     * @param searchType Determines where the search begins ("relative" or "absolute")
174
     * @param extendSelection Whether this selection extends a previous 
175
     *                          selection. If <code>true</code>, the first 
176
     *                          element will be selected with CONTROL as a 
177
     *                          modifier.
178
     * @param button what mouse button should be used
179
     */
180
    public void gdSelectValue(String valueList, String operator, 
181
            String searchType, final String extendSelection, int button) {
182
        final boolean isExtendSelection = 
183
            extendSelection.equals(CompSystemConstants.EXTEND_SELECTION_YES);
184
        selectValue(valueList, String.valueOf(VALUE_SEPARATOR), operator, 
185
            searchType, ClickOptions.create()
186
                .setClickCount(1)
187
                .setMouseButton(button), isExtendSelection); 
188
    }
189
    
190
    /**
191
     * Selects the passed value or enumeration of values. By default, the
192
     * enumeration separator is <code>,</code>, but may be changed by
193
     * <code>separator</code>.
194
     * @param valueList The value or list of values to select
195
     * @param separator The separator, optional
196
     * @param operator If regular expressions are used
197
     * @param searchType Determines where the search begins ("relative" or "absolute")
198
     * @param clickCount the amount of clicks to use
199
     * @param extendSelection Whether this selection extends a previous 
200
     *                        selection.
201
     */
202
    public void gdSelectValue(String valueList, String separator,
203
            String operator, final String searchType, int clickCount, 
204
            final String extendSelection) {
205
        final boolean isExtendSelection = 
206
            extendSelection.equals(CompSystemConstants.EXTEND_SELECTION_YES);
207
        selectValue(valueList, separator, operator, searchType, ClickOptions
208
                .create().setClickCount(clickCount), isExtendSelection);
209
    }
210
    
211
    /**
212
     * Verifies if the list contains an element that renderes <code>value</code>.
213
     * @param value The text to verify
214
     */
215
    public void gdVerifyContainsValue(String value) {
216
        Verifier.equals(true, containsValue(value));
217
    }
218
219
    /**
220
     * Verifies if the list contains an element that renderes <code>value</code>.
221
     * @param value The text to verify
222
     * @param operator The operator used to verify
223
     * @param exists if the wanted value should exist or not.
224
     */
225
    public void gdVerifyContainsValue(String value, String operator,
226
            boolean exists) {
227
228
        Verifier.equals(exists, containsValue(value, operator));
229
    }
230
    
231
    /**
232
     * Action to read the value of the current selected item of the JList
233
     * to store it in a variable in the Client
234
     * @param variable the name of the variable
235
     * @return the text value.
236
     */
237
    public String gdReadValue(String variable) {
238
        String[] selected = getListAdapter().getSelectedValues();
239
        if (selected.length > 0) {
240
            return selected[0];
241
        }
242
        throw new StepExecutionException("No list item selected", //$NON-NLS-1$
243
            EventFactory.createActionError(TestErrorEvent.NO_SELECTION));
244
    }
245
    
246
    /**
247
     * Drags the passed value.
248
     *
249
     * @param mouseButton the mouseButton.
250
     * @param modifier the modifier.
251
     * @param value The value to drag
252
     * @param operator If regular expressions are used
253
     * @param searchType Determines where the search begins ("relative" or "absolute")
254
     */
255
    public void gdDragValue(int mouseButton, String modifier, String value,
256
            String operator, final String searchType) {
257
258
        DragAndDropHelper dndHelper = DragAndDropHelper.getInstance();
259
        dndHelper.setModifier(modifier);
260
        dndHelper.setMouseButton(mouseButton);
261
262
        Integer [] indices = getListAdapter().findIndicesOfValues(
263
            new String [] {value}, operator, searchType);
264
        selectIndices(ArrayUtils.toPrimitive(indices), 
265
                ClickOptions.create().setClickCount(0), false);
266
267
        pressOrReleaseModifiers(modifier, true);
268
        getRobot().mousePress(null, null, mouseButton);
269
    }
270
271
    /**
272
     * Drops on the passed value.
273
     *
274
     * @param value The value on which to drop
275
     * @param operator If regular expressions are used
276
     * @param searchType Determines where the search begins ("relative" or "absolute")
277
     * @param delayBeforeDrop the amount of time (in milliseconds) to wait
278
     *                        between moving the mouse to the drop point and
279
     *                        releasing the mouse button
280
     */
281
    public void gdDropValue(String value, String operator,
282
        final String searchType, int delayBeforeDrop) {
283
284
        DragAndDropHelper dndHelper = DragAndDropHelper.getInstance();
285
        try {
286
            Integer [] indices = getListAdapter().findIndicesOfValues(
287
                new String [] {value}, operator, searchType);
288
            selectIndices(ArrayUtils.toPrimitive(indices), 
289
                    ClickOptions.create().setClickCount(0), false);
290
            waitBeforeDrop(delayBeforeDrop);
291
        } finally {
292
            getRobot().mouseRelease(null, null, dndHelper.getMouseButton());
293
            pressOrReleaseModifiers(dndHelper.getModifier(), false);
294
        }
295
    }
296
297
    /**
298
     * Drags the passed index.
299
     *
300
     * @param mouseButton the mouseButton.
301
     * @param modifier the modifier.
302
     * @param index The index to drag
303
     */
304
    public void gdDragIndex(final int mouseButton, final String modifier,
305
            int index) {
306
307
        DragAndDropHelper dndHelper = DragAndDropHelper.getInstance();
308
        dndHelper.setModifier(modifier);
309
        dndHelper.setMouseButton(mouseButton);
310
311
        selectIndices(
312
                new int [] {IndexConverter.toImplementationIndex(index)}, 
313
                ClickOptions.create().setClickCount(0), false);
314
315
        pressOrReleaseModifiers(modifier, true);
316
        getRobot().mousePress(null, null, mouseButton);
317
    }
318
319
    /**
320
     * Drops onto the passed index.
321
     *
322
     * @param index The index on which to drop
323
     * @param delayBeforeDrop the amount of time (in milliseconds) to wait
324
     *                        between moving the mouse to the drop point and
325
     *                        releasing the mouse button
326
     */
327
    public void gdDropIndex(final int index, int delayBeforeDrop) {
328
329
        DragAndDropHelper dndHelper = DragAndDropHelper.getInstance();
330
331
        try {
332
            selectIndices(
333
                    new int [] {IndexConverter.toImplementationIndex(index)}, 
334
                    ClickOptions.create().setClickCount(0), false);
335
            waitBeforeDrop(delayBeforeDrop);
336
        } finally {
337
            getRobot().mouseRelease(null, null, dndHelper.getMouseButton());
338
            pressOrReleaseModifiers(dndHelper.getModifier(), false);
339
        }
340
    }
341
342
    /**
343
     * @param value The value
344
     * @return <code>true</code> if the list contains an element that is rendered with <code>value</code>
345
     */
346
    public boolean containsValue(String value) {
347
        Integer[] indices = getListAdapter().findIndicesOfValues(
348
                new String[] { value },
349
                MatchUtil.EQUALS, CompSystemConstants.SEARCH_TYPE_ABSOLUTE);
350
        return indices.length > 0;
351
    }
352
    
353
    /**
354
     * @param value The value
355
     * @param operator The operator used to verify
356
     * @return <code>true</code> if the list contains an element that is rendered with <code>value</code>
357
     */
358
    public boolean containsValue(String value, String operator) {
359
        Integer[] indices = null;
360
        if (operator.equals(MatchUtil.NOT_EQUALS)) {
361
            indices = getListAdapter().findIndicesOfValues(
362
                    new String[] { value },
363
                MatchUtil.EQUALS, CompSystemConstants.SEARCH_TYPE_ABSOLUTE);
364
            return indices.length == 0;
365
        } 
366
        indices = getListAdapter().findIndicesOfValues(new String[] { value },
367
            operator, CompSystemConstants.SEARCH_TYPE_ABSOLUTE);
368
        return indices.length > 0;
369
    }
370
    
371
    /**
372
     * Selects the passed value or enumeration of values. By default, the
373
     * enumeration separator is <code>,</code>, but may be changed by
374
     * <code>separator</code>.
375
     * @param valueList The value or list of values to select
376
     * @param separator The separator, optional
377
     * @param operator If regular expressions are used
378
     * @param searchType Determines where the search begins ("relative" or "absolute")
379
     * @param co the click options to use
380
     * @param isExtendSelection Whether this selection extends a previous 
381
     *                        selection.
382
     */
383
    private void selectValue(String valueList, String separator,
384
            String operator, final String searchType, ClickOptions co, 
385
            final boolean isExtendSelection) {
386
387
        String[] values = null;
388
        if (StringConstants.EMPTY.equals(valueList)) {
389
            values = new String[1];
390
            values[0] = StringConstants.EMPTY;
391
        } else {
392
            values = split(valueList, separator);
393
        }
394
        Integer[] indices = getListAdapter().findIndicesOfValues(values,
395
                operator, searchType);
396
        Arrays.sort(indices);
397
        if (!operator.equals(MatchUtil.NOT_EQUALS) 
398
                && (indices.length < values.length)) {
399
            throw new StepExecutionException("One or more values not found of set: " //$NON-NLS-1$
400
                + Arrays.asList(values).toString(),
401
                EventFactory.createActionError(TestErrorEvent.NOT_FOUND));
402
        }
403
        selectIndices(ArrayUtils.toPrimitive(indices), co, isExtendSelection);
404
    }
405
    
406
    /**
407
     * Parses the enumeration of indices.
408
     * @param indexList The enumeration of indices
409
     * @return The array of parsed indices
410
     */
411
    private int[] parseIndices(String indexList) {
412
        String[] list = StringParsing.splitToArray(indexList,
413
                INDEX_LIST_SEP_CHAR, TestDataConstants.ESCAPE_CHAR_DEFAULT);
414
        int[] indices = new int[list.length];
415
        for (int i = 0; i < list.length; i++) {
416
            indices[i] = IndexConverter.intValue(list[i]);
417
        }
418
        return indices;
419
    }
420
    
421
    /**
422
     * @param indices The indices to select
423
     * @param co the click options to use
424
     * @param isExtendSelection Whether this selection extends a previous 
425
     *                          selection. If <code>true</code>, the first 
426
     *                          element will be selected with CONTROL as a 
427
     *                          modifier.
428
     */
429
    private void selectIndices(int[] indices, ClickOptions co, 
430
            boolean isExtendSelection) {
431
        Object list = getListAdapter().getRealComponent();
432
        if (indices.length > 0) {
433
            try {
434
                if (isExtendSelection) {
435
                    getRobot().keyPress(list,
436
                            getSystemDefaultModifier());
437
                }
438
439
                // first selection
440
                getListAdapter().clickOnIndex(
441
                        new Integer(indices[0]), co);
442
            } finally {
443
                if (isExtendSelection) {
444
                    getRobot().keyRelease(list,
445
                            getSystemDefaultModifier());
446
                }
447
            }
448
        }
449
        try {
450
            getRobot().keyPress(list,
451
                    getSystemDefaultModifier());
452
            // following selections
453
            for (int i = 1; i < indices.length; i++) {
454
                getListAdapter().clickOnIndex(
455
                        new Integer(indices[i]), co);
456
            }
457
        } finally {
458
            getRobot().keyRelease(list,
459
                    getSystemDefaultModifier());
460
        }
461
    }
462
    
463
    /**
464
     * {@inheritDoc}
465
     */
466
    public String[] getTextArrayFromComponent() {
467
        return null;
468
    }
469
    
470
    /**
471
     * 
472
     * @return -
473
     */
474
    protected abstract int getSystemDefaultModifier();
475
    
476
}
(-)a/org.eclipse.jubula.rc.common/src/org/eclipse/jubula/rc/common/caps/AbstractTableCAPs.java (-115 / +13 lines)
Lines 11-22 Link Here
11
package org.eclipse.jubula.rc.common.caps;
11
package org.eclipse.jubula.rc.common.caps;
12
12
13
import java.awt.Rectangle;
13
import java.awt.Rectangle;
14
import java.util.StringTokenizer;
15
16
import org.eclipse.jubula.rc.common.CompSystemConstants;
14
import org.eclipse.jubula.rc.common.CompSystemConstants;
17
import org.eclipse.jubula.rc.common.driver.ClickOptions;
15
import org.eclipse.jubula.rc.common.driver.ClickOptions;
18
import org.eclipse.jubula.rc.common.driver.DragAndDropHelper;
16
import org.eclipse.jubula.rc.common.driver.DragAndDropHelper;
19
import org.eclipse.jubula.rc.common.driver.IRobot;
20
import org.eclipse.jubula.rc.common.exception.StepExecutionException;
17
import org.eclipse.jubula.rc.common.exception.StepExecutionException;
21
import org.eclipse.jubula.rc.common.implclasses.IndexConverter;
18
import org.eclipse.jubula.rc.common.implclasses.IndexConverter;
22
import org.eclipse.jubula.rc.common.implclasses.MatchUtil;
19
import org.eclipse.jubula.rc.common.implclasses.MatchUtil;
Lines 24-34 import org.eclipse.jubula.rc.common.implclasses.Verifier; Link Here
24
import org.eclipse.jubula.rc.common.implclasses.table.Cell;
21
import org.eclipse.jubula.rc.common.implclasses.table.Cell;
25
import org.eclipse.jubula.rc.common.logger.AutServerLogger;
22
import org.eclipse.jubula.rc.common.logger.AutServerLogger;
26
import org.eclipse.jubula.rc.common.uiadapter.interfaces.ITableAdapter;
23
import org.eclipse.jubula.rc.common.uiadapter.interfaces.ITableAdapter;
27
import org.eclipse.jubula.rc.common.util.KeyStrokeUtil;
28
import org.eclipse.jubula.tools.constants.InputConstants;
24
import org.eclipse.jubula.tools.constants.InputConstants;
29
import org.eclipse.jubula.tools.objects.event.EventFactory;
25
import org.eclipse.jubula.tools.objects.event.EventFactory;
30
import org.eclipse.jubula.tools.objects.event.TestErrorEvent;
26
import org.eclipse.jubula.tools.objects.event.TestErrorEvent;
31
import org.eclipse.jubula.tools.utils.TimeUtil;
32
27
33
/**
28
/**
34
 * General implementation for tables.
29
 * General implementation for tables.
Lines 564-580 public abstract class AbstractTableCAPs extends AbstractTextInputSupport { Link Here
564
                co, extendSelection);
559
                co, extendSelection);
565
        
560
        
566
    }
561
    }
567
    
562
//FIXME    
568
    /**
563
//    /**
569
     * Action to read the value of the current selected cell of the JTable 
564
//     * Action to read the value of the current selected cell of the JTable 
570
     * to store it in a variable in the Client
565
//     * to store it in a variable in the Client
571
     * @param variable the name of the variable
566
//     * @param variable the name of the variable
572
     * @return the text value.
567
//     * @return the text value.
573
     */
568
//     */
574
    public String gdReadValue(String variable) {
569
//    public String gdReadValue(String variable) {
575
        final Cell selectedCell = getTableAdapter().getSelectedCell();
570
//        final Cell selectedCell = getTableAdapter().getSelectedCell();
576
        return getCellText(selectedCell.getRow(), selectedCell.getCol());
571
//        return getCellText(selectedCell.getRow(), selectedCell.getCol());
577
    }
572
//    }
578
    
573
    
579
    /**
574
    /**
580
     * Action to read the value of the passed cell of the JTable
575
     * Action to read the value of the passed cell of the JTable
Lines 956-990 public abstract class AbstractTableCAPs extends AbstractTextInputSupport { Link Here
956
        return getTableAdapter().getCellText(row, column);
951
        return getTableAdapter().getCellText(row, column);
957
952
958
    }
953
    }
959
    
954
        
960
    /**
961
     * Presses or releases the given modifier.
962
     * @param modifier the modifier.
963
     * @param press if true, the modifier will be pressed.
964
     * if false, the modifier will be released.
965
     */
966
    protected void pressOrReleaseModifiers(String modifier, boolean press) {
967
        final IRobot robot = getRobot();
968
        final StringTokenizer modTok = new StringTokenizer(
969
                KeyStrokeUtil.getModifierString(modifier), " "); //$NON-NLS-1$
970
        while (modTok.hasMoreTokens()) {
971
            final String mod = modTok.nextToken();
972
            final int keyCode = getKeyCode(mod);
973
            if (press) {
974
                robot.keyPress(null, keyCode);
975
            } else {
976
                robot.keyRelease(null, keyCode);
977
            }
978
        }
979
    }
980
    
981
    /**
982
     * Gets the key code for a specific modifier
983
     * @param mod the modifier
984
     * @return the integer key code value
985
     */
986
    protected abstract int getKeyCode(String mod);
987
    
988
    /**
955
    /**
989
     * Checks whether <code>0 <= value < count</code>. 
956
     * Checks whether <code>0 <= value < count</code>. 
990
     * @param value The value to check.
957
     * @param value The value to check.
Lines 1081-1096 public abstract class AbstractTableCAPs extends AbstractTextInputSupport { Link Here
1081
        return true;
1048
        return true;
1082
    }
1049
    }
1083
    
1050
    
1084
    /**
1051
1085
     * Waits the given amount of time. Logs a drop-related error if interrupted.
1086
     *
1087
     * @param delayBeforeDrop the amount of time (in milliseconds) to wait
1088
     *                        between moving the mouse to the drop point and
1089
     *                        releasing the mouse button
1090
     */
1091
    static void waitBeforeDrop(int delayBeforeDrop) {
1092
        TimeUtil.delay(delayBeforeDrop);
1093
    }
1094
    
1052
    
1095
    /**
1053
    /**
1096
     * Sets the specific editor to an replace mode. Means that the next key
1054
     * Sets the specific editor to an replace mode. Means that the next key
Lines 1132-1196 public abstract class AbstractTableCAPs extends AbstractTextInputSupport { Link Here
1132
     */
1090
     */
1133
    protected abstract boolean isMouseOnHeader();
1091
    protected abstract boolean isMouseOnHeader();
1134
1092
1135
    /**
1136
     * Selects the passed row of the JTable. This is actually a selection of the
1137
     * cell <code>(row, 0)</code>.
1138
     *
1139
     * @param row
1140
     *            The row
1141
     * @param extendSelection Should this selection be part of a multiple selection
1142
     * @throws StepExecutionException
1143
     *             If the row is invalid
1144
     * @deprecated the same as gdSelectCell
1145
     * Will be removed!
1146
     */
1147
    public void gdSelectRow(int row, String extendSelection)
1148
        throws StepExecutionException {
1149
        // FIXME this is only here for testing purpose (to get all CaA tests running)
1150
        gdSelectCell(String.valueOf(row), MatchUtil.DEFAULT_OPERATOR, "1", //$NON-NLS-1$
1151
                MatchUtil.DEFAULT_OPERATOR, 
1152
                ClickOptions.create().setClickCount(1), extendSelection);
1153
    }
1154
    
1155
    /**
1156
     * Finds the first column which contains the value <code>value</code>
1157
     * in the given row and selects the cell.
1158
     * 
1159
     * @param row the row
1160
     * @param value the value
1161
     * @param clickCount the mouse clicks.
1162
     * @param regex search using regex
1163
     * @param extendSelection Should this selection be part of a multiple selection
1164
     * @param searchType Determines where the search begins ("relative" or "absolute")
1165
     * @deprecated Will be removed with gdSelectCellByColValue with String parameter
1166
     * for Row/Column
1167
     */
1168
    public void gdSelectCellByColValue(int row, final String value, 
1169
        final String regex, int clickCount, final String extendSelection, 
1170
        final String searchType) {
1171
        // FIXME this is only here for testing purpose (to get all CaA tests running)
1172
        gdSelectCellByColValue(String.valueOf(row), MatchUtil.DEFAULT_OPERATOR,
1173
                value, regex, clickCount, extendSelection, searchType, 1);
1174
1093
1175
    }
1176
    
1177
    /**
1178
     * Finds the first row which contains the value <code>value</code>
1179
     * in column <code>col</code> and selects this row.
1180
     * @param col the column
1181
     * @param value the value
1182
     * @param clickCount the number of clicks.
1183
     * @param regexOp the regex operator
1184
     * @param extendSelection Should this selection be part of a multiple selection
1185
     * @param searchType Determines where the search begins ("relative" or "absolute")
1186
     * @deprecated Will be removed with gdSelectRowByValue with String parameter
1187
     * for Row/Column
1188
     */
1189
    public void gdSelectRowByValue(int col, final String value,
1190
        int clickCount, final String regexOp, final String extendSelection, 
1191
        final String searchType) {
1192
        // FIXME this is only here for testing purpose (to get all CaA tests running)
1193
        gdSelectRowByValue(String.valueOf(col), MatchUtil.DEFAULT_OPERATOR,
1194
                value, regexOp, clickCount, extendSelection, searchType, 1);
1195
    }
1196
}
1094
}
(-)a/org.eclipse.jubula.rc.common/src/org/eclipse/jubula/rc/common/caps/AbstractTextVerifiable.java (-5 / +10 lines)
Lines 11-16 Link Here
11
package org.eclipse.jubula.rc.common.caps;
11
package org.eclipse.jubula.rc.common.caps;
12
12
13
import org.eclipse.jubula.rc.common.exception.StepExecutionException;
13
import org.eclipse.jubula.rc.common.exception.StepExecutionException;
14
import org.eclipse.jubula.rc.common.implclasses.Verifier;
15
import org.eclipse.jubula.rc.common.uiadapter.interfaces.ITextVerifiable;
14
16
15
/**
17
/**
16
 * This class represents the general implementation for components
18
 * This class represents the general implementation for components
Lines 27-34 public abstract class AbstractTextVerifiable extends AbstractWidgetCAPs { Link Here
27
     * @param variable the name of the variable
29
     * @param variable the name of the variable
28
     * @return the text value.
30
     * @return the text value.
29
     */
31
     */
30
    public abstract String gdReadValue(String variable);
32
    public String gdReadValue(String variable) {
31
    // FIXME this is only a pattern because only Tables uses this at the moment
33
        return ((ITextVerifiable)getComponent()).getText();
34
    }
32
35
33
    /**
36
    /**
34
     * Verifies the rendered text inside the currently component.<br>
37
     * Verifies the rendered text inside the currently component.<br>
Lines 37-43 public abstract class AbstractTextVerifiable extends AbstractWidgetCAPs { Link Here
37
     * @param operator The operation used to verify
40
     * @param operator The operation used to verify
38
     * @throws StepExecutionException If the rendered text cannot be extracted.
41
     * @throws StepExecutionException If the rendered text cannot be extracted.
39
     */
42
     */
40
    public abstract void gdVerifyText(String text, String operator)
43
    public void gdVerifyText(String text, String operator)
41
        throws StepExecutionException;
44
        throws StepExecutionException {
42
    // FIXME this is only a pattern because only Tables uses this at the moment
45
        Verifier.match(((ITextVerifiable)getComponent()).getText(), text,
46
                                    operator);
47
    }
43
}
48
}
(-)a/org.eclipse.jubula.rc.common/src/org/eclipse/jubula/rc/common/caps/AbstractUICAPs.java (-3 / +8 lines)
Lines 27-39 import org.eclipse.jubula.rc.common.uiadapter.interfaces.IComponentAdapter; Link Here
27
 */
27
 */
28
public abstract class AbstractUICAPs implements IBaseImplementationClass {
28
public abstract class AbstractUICAPs implements IBaseImplementationClass {
29
29
30
    
31
    
32
    /** constants for communication */
30
    /** constants for communication */
33
    protected static final String POS_UNIT_PIXEL = "Pixel"; //$NON-NLS-1$
31
    protected static final String POS_UNIT_PIXEL = "Pixel"; //$NON-NLS-1$
34
    
32
    
35
    /** constants for communication */
33
    /** constants for communication */
36
    protected static final String POS_UNI_PERCENT = "Percent"; //$NON-NLS-1$
34
    protected static final String POS_UNI_PERCENT = "Percent"; //$NON-NLS-1$
35
    
36
    /** */
37
    private IRobotFactory m_robotFactory;    
38
37
    /**    */
39
    /**    */
38
    private IComponentAdapter m_component;
40
    private IComponentAdapter m_component;
39
41
Lines 50-56 public abstract class AbstractUICAPs implements IBaseImplementationClass { Link Here
50
     * Gets the Robot factory. The factory is created once per instance.
52
     * Gets the Robot factory. The factory is created once per instance.
51
     * @return The Robot factory.
53
     * @return The Robot factory.
52
     */
54
     */
53
    protected abstract IRobotFactory getRobotFactory();
55
    protected IRobotFactory getRobotFactory() {
56
        m_robotFactory = m_component.getRobotFactory();
57
        return m_robotFactory;
58
    }
54
    
59
    
55
    /**
60
    /**
56
     * {@inheritDoc}
61
     * {@inheritDoc}
(-)a/org.eclipse.jubula.rc.common/src/org/eclipse/jubula/rc/common/caps/AbstractWidgetCAPs.java (+45 lines)
Lines 10-21 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.jubula.rc.common.caps;
11
package org.eclipse.jubula.rc.common.caps;
12
12
13
import java.util.StringTokenizer;
14
13
import org.eclipse.jubula.rc.common.CompSystemConstants;
15
import org.eclipse.jubula.rc.common.CompSystemConstants;
14
import org.eclipse.jubula.rc.common.driver.ClickOptions;
16
import org.eclipse.jubula.rc.common.driver.ClickOptions;
17
import org.eclipse.jubula.rc.common.driver.IRobot;
15
import org.eclipse.jubula.rc.common.driver.ClickOptions.ClickModifier;
18
import org.eclipse.jubula.rc.common.driver.ClickOptions.ClickModifier;
16
import org.eclipse.jubula.rc.common.exception.StepExecutionException;
19
import org.eclipse.jubula.rc.common.exception.StepExecutionException;
17
import org.eclipse.jubula.rc.common.implclasses.Verifier;
20
import org.eclipse.jubula.rc.common.implclasses.Verifier;
18
import org.eclipse.jubula.rc.common.uiadapter.interfaces.IWidgetAdapter;
21
import org.eclipse.jubula.rc.common.uiadapter.interfaces.IWidgetAdapter;
22
import org.eclipse.jubula.rc.common.util.KeyStrokeUtil;
23
import org.eclipse.jubula.tools.utils.TimeUtil;
19
/**
24
/**
20
 * Implementation of basic functions for a lot of graphics components
25
 * Implementation of basic functions for a lot of graphics components
21
 * except for context menus and menus. 
26
 * except for context menus and menus. 
Lines 482-486 public abstract class AbstractWidgetCAPs extends AbstractUICAPs { Link Here
482
        getWidgetAdapter().showToolTip(text, textSize,
487
        getWidgetAdapter().showToolTip(text, textSize,
483
                timePerWord, windowWidth);
488
                timePerWord, windowWidth);
484
    }
489
    }
490
    
491
    /**
492
     * Presses or releases the given modifier.
493
     * @param modifier the modifier.
494
     * @param press if true, the modifier will be pressed.
495
     * if false, the modifier will be released.
496
     */
497
    protected void pressOrReleaseModifiers(String modifier, boolean press) {
498
        final IRobot robot = getRobot();
499
        final StringTokenizer modTok = new StringTokenizer(
500
                KeyStrokeUtil.getModifierString(modifier), " "); //$NON-NLS-1$
501
        while (modTok.hasMoreTokens()) {
502
            final String mod = modTok.nextToken();
503
            final int keyCode = getKeyCode(mod);
504
            if (press) {
505
                robot.keyPress(null, keyCode);
506
            } else {
507
                robot.keyRelease(null, keyCode);
508
            }
509
        }
510
    }
511
    
512
    /**
513
     * Gets the key code for a specific modifier
514
     * @param mod the modifier
515
     * @return the integer key code value
516
     */
517
    protected int getKeyCode(String mod) {
518
        return getWidgetAdapter().getKeyCode(mod);
519
    }
485
520
521
    /**
522
     * Waits the given amount of time. Logs a drop-related error if interrupted.
523
     *
524
     * @param delayBeforeDrop the amount of time (in milliseconds) to wait
525
     *                        between moving the mouse to the drop point and
526
     *                        releasing the mouse button
527
     */
528
    public static void waitBeforeDrop(int delayBeforeDrop) {
529
        TimeUtil.delay(delayBeforeDrop);
530
    }
486
}
531
}
(-)a/org.eclipse.jubula.rc.common/src/org/eclipse/jubula/rc/common/uiadapter/interfaces/IButtonAdapter.java (-8 / +1 lines)
Lines 18-24 package org.eclipse.jubula.rc.common.uiadapter.interfaces; Link Here
18
 * @author BREDEX GmbH
18
 * @author BREDEX GmbH
19
 */
19
 */
20
20
21
public interface IButtonAdapter extends IWidgetAdapter {
21
public interface IButtonAdapter extends ITextVerifiable {
22
    /**
22
    /**
23
     * Gets the text from the button
23
     * Gets the text from the button
24
     * @return the text which is saved in the component
24
     * @return the text which is saved in the component
Lines 30-41 public interface IButtonAdapter extends IWidgetAdapter { Link Here
30
     * @return <code>true</code> if the component is selected
30
     * @return <code>true</code> if the component is selected
31
     */
31
     */
32
    public boolean isSelected();
32
    public boolean isSelected();
33
    /**
34
     * Action to read the value of a Button to store it in a variable
35
     * in the Client
36
     * @param variable the name of the variable
37
     * @return the text value.
38
     */
39
    public String  readValue(String variable);
40
   
33
   
41
}
34
}
(-)a/org.eclipse.jubula.rc.common/src/org/eclipse/jubula/rc/common/uiadapter/interfaces/IComponentAdapter.java (+9 lines)
Lines 9-14 Link Here
9
 *     BREDEX GmbH - initial API and implementation 
9
 *     BREDEX GmbH - initial API and implementation 
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.jubula.rc.common.uiadapter.interfaces;
11
package org.eclipse.jubula.rc.common.uiadapter.interfaces;
12
13
import org.eclipse.jubula.rc.common.driver.IRobotFactory;
14
12
/**
15
/**
13
 * This is the main interface for classes which will hold or be the
16
 * This is the main interface for classes which will hold or be the
14
 * component that implement the methods we need for this
17
 * component that implement the methods we need for this
Lines 22-26 public interface IComponentAdapter { Link Here
22
     * @return toolkit specific component
25
     * @return toolkit specific component
23
     */
26
     */
24
    public Object getRealComponent();
27
    public Object getRealComponent();
28
29
    /**
30
     * Gets the toolkit specific RobotFactory
31
     * @return the RobotFactory
32
     */
33
    public IRobotFactory getRobotFactory();
25
   
34
   
26
}
35
}
(-)a/org.eclipse.jubula.rc.common/src/org/eclipse/jubula/rc/common/uiadapter/interfaces/IListAdapter.java (+52 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2012 BREDEX GmbH.
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
 *     BREDEX GmbH - initial API and implementation 
10
 *******************************************************************************/
11
package org.eclipse.jubula.rc.common.uiadapter.interfaces;
12
13
import org.eclipse.jubula.rc.common.driver.ClickOptions;
14
15
/**
16
 * 
17
 * @author BREDEX GmbH
18
 *
19
 */
20
public interface IListAdapter extends ITextVerifiable {
21
    /**
22
     * 
23
     * @return The array of selected indices
24
     */
25
    public int[] getSelectedIndices();
26
27
    /**
28
     * Clicks on the index of the passed list.
29
     * @param i The index to click
30
     * @param co the click options to use for selecting an index item
31
     */
32
    public void clickOnIndex(Integer i, ClickOptions co);
33
    
34
    /**
35
     * @return The array of selected values as the renderer shows them
36
     */
37
    public String[] getSelectedValues();
38
    
39
    /**
40
     * Finds the indices of the list elements that are rendered with the passed values.
41
     * @param values The values
42
     * @param operator operator to use
43
     * @param searchType 
44
     *            Determines where the search begins ("relative" or "absolute")
45
     * @return The array of indices. It's length is equal to the length of the
46
     *         values array, but may contains <code>null</code> elements for
47
     *         all values that are not found in the list
48
     */
49
    public Integer[] findIndicesOfValues(final String[] values,
50
        final String operator, final String searchType);
51
52
}
(-)a/org.eclipse.jubula.rc.common/src/org/eclipse/jubula/rc/common/uiadapter/interfaces/ITableAdapter.java (-1 / +1 lines)
Lines 20-26 import org.eclipse.jubula.rc.common.implclasses.table.Cell; Link Here
20
 * 
20
 * 
21
 * @author BREDEX GmbH
21
 * @author BREDEX GmbH
22
 */
22
 */
23
public interface ITableAdapter extends IWidgetAdapter {
23
public interface ITableAdapter extends ITextVerifiable {
24
    
24
    
25
    
25
    
26
    /**
26
    /**
(-)a/org.eclipse.jubula.rc.common/src/org/eclipse/jubula/rc/common/uiadapter/interfaces/ITextVerifiable.java (+15 lines)
Added Link Here
1
package org.eclipse.jubula.rc.common.uiadapter.interfaces;
2
/**
3
 * 
4
 * @author BREDEX GmbH
5
 *
6
 */
7
public interface ITextVerifiable extends IWidgetAdapter {
8
9
    /**
10
     * Gets the value of the component, or if there are more
11
     * than the first selected.
12
     * @return the value of the component
13
     */
14
    public String getText();
15
}
(-)a/org.eclipse.jubula.rc.common/src/org/eclipse/jubula/rc/common/uiadapter/interfaces/IWidgetAdapter.java (+7 lines)
Lines 106-110 public interface IWidgetAdapter extends IComponentAdapter { Link Here
106
     */
106
     */
107
    public void gdDrop(int xPos, String xUnits, int yPos, String yUnits,
107
    public void gdDrop(int xPos, String xUnits, int yPos, String yUnits,
108
            int delayBeforeDrop);
108
            int delayBeforeDrop);
109
    
110
    /**
111
     * Gets the key code for a specific modifier
112
     * @param mod the modifier
113
     * @return the integer key code value
114
     */
115
    public int getKeyCode(String mod);
109
116
110
}
117
}
(-)a/org.eclipse.jubula.rc.swing/src/org/eclipse/jubula/rc/swing/swing/caps/AbstractButtonCAPs.java (-15 lines)
Lines 11-19 Link Here
11
package org.eclipse.jubula.rc.swing.swing.caps;
11
package org.eclipse.jubula.rc.swing.swing.caps;
12
12
13
13
14
import org.eclipse.jubula.rc.common.driver.IRobotFactory;
15
import org.eclipse.jubula.rc.common.uiadapter.interfaces.IButtonAdapter;
14
import org.eclipse.jubula.rc.common.uiadapter.interfaces.IButtonAdapter;
16
import org.eclipse.jubula.rc.swing.driver.RobotFactoryConfig;
17
15
18
/**
16
/**
19
 * The implementation class for <code>AbstractButton</code> and subclasses. Note
17
 * The implementation class for <code>AbstractButton</code> and subclasses. Note
Lines 27-35 import org.eclipse.jubula.rc.swing.driver.RobotFactoryConfig; Link Here
27
public class AbstractButtonCAPs 
25
public class AbstractButtonCAPs 
28
    extends org.eclipse.jubula.rc.common.caps.AbstractButtonCAPs {
26
    extends org.eclipse.jubula.rc.common.caps.AbstractButtonCAPs {
29
27
30
    /** Robot Factory*/
31
    private IRobotFactory m_robotFactory;
32
33
    /**
28
    /**
34
     * Clicks the button <code>count</code> times.
29
     * Clicks the button <code>count</code> times.
35
     * 
30
     * 
Lines 47-60 public class AbstractButtonCAPs Link Here
47
        return new String[] { returnvalue.getText() };
42
        return new String[] { returnvalue.getText() };
48
    }
43
    }
49
44
50
    /** 
51
     * {@inheritDoc}
52
     */
53
    protected IRobotFactory getRobotFactory() {
54
        if (m_robotFactory == null) {
55
            m_robotFactory = new RobotFactoryConfig().getRobotFactory();
56
        }
57
        return m_robotFactory;
58
    }
59
60
}
45
}
(-)a/org.eclipse.jubula.rc.swing/src/org/eclipse/jubula/rc/swing/swing/caps/JListCAPs.java (+29 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2012 BREDEX GmbH.
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
 *     BREDEX GmbH - initial API and implementation 
10
 *******************************************************************************/
11
package org.eclipse.jubula.rc.swing.swing.caps;
12
13
import org.eclipse.jubula.rc.common.caps.AbstractListCAPs;
14
import org.eclipse.jubula.rc.swing.utils.SwingUtils;
15
/**
16
 * 
17
 * @author BREDEX GmbH
18
 *
19
 */
20
public class JListCAPs extends AbstractListCAPs {
21
        
22
    /**
23
     * {@inheritDoc}
24
     */
25
    protected int getSystemDefaultModifier() {
26
        return SwingUtils.getSystemDefaultModifier();
27
    }
28
    
29
}
(-)a/org.eclipse.jubula.rc.swing/src/org/eclipse/jubula/rc/swing/swing/caps/JMenuBarCAPs.java (-18 / +2 lines)
Lines 26-37 import javax.swing.JPopupMenu; Link Here
26
import javax.swing.MenuElement;
26
import javax.swing.MenuElement;
27
27
28
import org.eclipse.jubula.rc.common.caps.AbstractMenuCAPs;
28
import org.eclipse.jubula.rc.common.caps.AbstractMenuCAPs;
29
import org.eclipse.jubula.rc.common.driver.IRobotFactory;
30
import org.eclipse.jubula.rc.common.implclasses.IBaseImplementationClass;
31
import org.eclipse.jubula.rc.common.uiadapter.interfaces.IComponentAdapter;
29
import org.eclipse.jubula.rc.common.uiadapter.interfaces.IComponentAdapter;
32
import org.eclipse.jubula.rc.common.uiadapter.interfaces.IMenuAdapter;
30
import org.eclipse.jubula.rc.common.uiadapter.interfaces.IMenuAdapter;
33
import org.eclipse.jubula.rc.common.uiadapter.interfaces.IMenuItemAdapter;
31
import org.eclipse.jubula.rc.common.uiadapter.interfaces.IMenuItemAdapter;
34
import org.eclipse.jubula.rc.swing.driver.RobotFactoryConfig;
35
import org.eclipse.jubula.rc.swing.swing.implclasses.WindowHelper;
32
import org.eclipse.jubula.rc.swing.swing.implclasses.WindowHelper;
36
import org.eclipse.jubula.rc.swing.swing.uiadapter.JMenuItemAdapter;
33
import org.eclipse.jubula.rc.swing.swing.uiadapter.JMenuItemAdapter;
37
34
Lines 40-60 import org.eclipse.jubula.rc.swing.swing.uiadapter.JMenuItemAdapter; Link Here
40
 * 
37
 * 
41
 * @author BREDEX GmbH
38
 * @author BREDEX GmbH
42
 */
39
 */
43
public class JMenuBarCAPs extends AbstractMenuCAPs 
40
public class JMenuBarCAPs extends AbstractMenuCAPs {
44
    implements IBaseImplementationClass {
41
            
45
    
46
    /** The robot factory.  */
47
    private IRobotFactory m_robotFactory;
48
    /**
49
     * {@inheritDoc}
50
     */
51
    protected IRobotFactory getRobotFactory() {
52
        if (m_robotFactory == null) {
53
            m_robotFactory = new RobotFactoryConfig().getRobotFactory();
54
        }
55
        return m_robotFactory;
56
    }
57
        
58
    /**
42
    /**
59
     * {@inheritDoc}
43
     * {@inheritDoc}
60
     */
44
     */
(-)a/org.eclipse.jubula.rc.swing/src/org/eclipse/jubula/rc/swing/swing/caps/JTableCAPs.java (-23 lines)
Lines 23-35 import javax.swing.table.TableColumnModel; Link Here
23
import org.eclipse.jubula.rc.common.caps.AbstractTableCAPs;
23
import org.eclipse.jubula.rc.common.caps.AbstractTableCAPs;
24
import org.eclipse.jubula.rc.common.driver.ClickOptions;
24
import org.eclipse.jubula.rc.common.driver.ClickOptions;
25
import org.eclipse.jubula.rc.common.driver.IEventThreadQueuer;
25
import org.eclipse.jubula.rc.common.driver.IEventThreadQueuer;
26
import org.eclipse.jubula.rc.common.driver.IRobotFactory;
27
import org.eclipse.jubula.rc.common.driver.IRunnable;
26
import org.eclipse.jubula.rc.common.driver.IRunnable;
28
import org.eclipse.jubula.rc.common.exception.StepExecutionException;
27
import org.eclipse.jubula.rc.common.exception.StepExecutionException;
29
import org.eclipse.jubula.rc.common.implclasses.table.Cell;
28
import org.eclipse.jubula.rc.common.implclasses.table.Cell;
30
import org.eclipse.jubula.rc.common.logger.AutServerLogger;
29
import org.eclipse.jubula.rc.common.logger.AutServerLogger;
31
import org.eclipse.jubula.rc.swing.driver.RobotFactoryConfig;
32
import org.eclipse.jubula.rc.swing.swing.driver.KeyCodeConverter;
33
import org.eclipse.jubula.rc.swing.utils.SwingUtils;
30
import org.eclipse.jubula.rc.swing.utils.SwingUtils;
34
/**
31
/**
35
 * Toolkit specific commands for the <code>JTable</code>
32
 * Toolkit specific commands for the <code>JTable</code>
Lines 42-50 public class JTableCAPs extends AbstractTableCAPs { Link Here
42
    private static AutServerLogger log = new AutServerLogger(
39
    private static AutServerLogger log = new AutServerLogger(
43
            JTableCAPs.class);
40
            JTableCAPs.class);
44
41
45
    /** the RobotFactory from the AUT */
46
    private IRobotFactory m_robotFactory;
47
    
48
    /**
42
    /**
49
     * @return the log
43
     * @return the log
50
     */
44
     */
Lines 52-66 public class JTableCAPs extends AbstractTableCAPs { Link Here
52
        return log;
46
        return log;
53
    }    
47
    }    
54
48
55
    /**
56
     * {@inheritDoc}
57
     */
58
    protected IRobotFactory getRobotFactory() {
59
        if (m_robotFactory == null) {
60
            m_robotFactory = new RobotFactoryConfig().getRobotFactory();
61
        }
62
        return m_robotFactory;
63
    }
64
    
49
    
65
    /**
50
    /**
66
     * 
51
     * 
Lines 202-213 public class JTableCAPs extends AbstractTableCAPs { Link Here
202
                });
187
                });
203
    }
188
    }
204
189
205
206
    /**
207
     * {@inheritDoc}
208
     */
209
    protected int getKeyCode(String key) {
210
        return KeyCodeConverter.getKeyCode(key);
211
    }
212
213
}
190
}
(-)a/org.eclipse.jubula.rc.swing/src/org/eclipse/jubula/rc/swing/swing/caps/JTreeCAPs.java (-38 / +1 lines)
Lines 18-30 import org.eclipse.jubula.rc.common.CompSystemConstants; Link Here
18
import org.eclipse.jubula.rc.common.caps.AbstractTreeCAPs;
18
import org.eclipse.jubula.rc.common.caps.AbstractTreeCAPs;
19
import org.eclipse.jubula.rc.common.driver.DragAndDropHelper;
19
import org.eclipse.jubula.rc.common.driver.DragAndDropHelper;
20
import org.eclipse.jubula.rc.common.driver.IEventThreadQueuer;
20
import org.eclipse.jubula.rc.common.driver.IEventThreadQueuer;
21
import org.eclipse.jubula.rc.common.driver.IRobotFactory;
22
import org.eclipse.jubula.rc.common.driver.IRunnable;
21
import org.eclipse.jubula.rc.common.driver.IRunnable;
23
import org.eclipse.jubula.rc.common.exception.StepExecutionException;
22
import org.eclipse.jubula.rc.common.exception.StepExecutionException;
24
import org.eclipse.jubula.rc.swing.driver.RobotFactoryConfig;
25
import org.eclipse.jubula.tools.objects.event.EventFactory;
23
import org.eclipse.jubula.tools.objects.event.EventFactory;
26
import org.eclipse.jubula.tools.objects.event.TestErrorEvent;
24
import org.eclipse.jubula.tools.objects.event.TestErrorEvent;
27
import org.eclipse.jubula.tools.utils.TimeUtil;
28
/**
25
/**
29
 * Toolkit specific commands for the <code>JTree</code>
26
 * Toolkit specific commands for the <code>JTree</code>
30
 * 
27
 * 
Lines 32-52 import org.eclipse.jubula.tools.utils.TimeUtil; Link Here
32
 */
29
 */
33
public class JTreeCAPs extends AbstractTreeCAPs {
30
public class JTreeCAPs extends AbstractTreeCAPs {
34
31
35
    /** Robot Factory*/
32
   
36
    private IRobotFactory m_robotFactory;
37
38
    
39
    /**
40
     * Waits the given amount of time. Logs a drop-related error if interrupted.
41
     *
42
     * @param delayBeforeDrop the amount of time (in milliseconds) to wait
43
     *                        between moving the mouse to the drop point and
44
     *                        releasing the mouse button
45
     */
46
    static void waitBeforeDrop(int delayBeforeDrop) {
47
        TimeUtil.delay(delayBeforeDrop);
48
    }
49
    
50
    /**
33
    /**
51
     * {@inheritDoc}
34
     * {@inheritDoc}
52
     */
35
     */
Lines 164-189 public class JTreeCAPs extends AbstractTreeCAPs { Link Here
164
    private JTree getTreeComponent() {
147
    private JTree getTreeComponent() {
165
        return (JTree) getComponent().getRealComponent();
148
        return (JTree) getComponent().getRealComponent();
166
    }
149
    }
167
168
    /** 
169
     * {@inheritDoc}
170
     */
171
    protected IRobotFactory getRobotFactory() {
172
        if (m_robotFactory == null) {
173
            m_robotFactory = new RobotFactoryConfig().getRobotFactory();
174
        }
175
        return m_robotFactory;
176
    }
177
    
178
    /**
179
     * Presses or releases the given modifier.
180
     * @param modifier the modifier.
181
     * @param press if true, the modifier will be pressed.
182
     * if false, the modifier will be released.
183
     */
184
    protected void pressOrReleaseModifiers(String modifier, boolean press) {
185
        CapUtil.pressOrReleaseModifiers(modifier, press);
186
    }
187
    
150
    
188
    /**
151
    /**
189
     * @return The event thread queuer.
152
     * @return The event thread queuer.
(-)a/org.eclipse.jubula.rc.swing/src/org/eclipse/jubula/rc/swing/swing/uiadapter/AbstractComponentAdapter.java (+28 lines)
Added Link Here
1
package org.eclipse.jubula.rc.swing.swing.uiadapter;
2
3
import org.eclipse.jubula.rc.common.driver.IRobotFactory;
4
import org.eclipse.jubula.rc.common.uiadapter.interfaces.IComponentAdapter;
5
import org.eclipse.jubula.rc.swing.driver.RobotFactoryConfig;
6
/**
7
 * 
8
 * @author BREDEX GmbH
9
 *
10
 */
11
public abstract class AbstractComponentAdapter implements IComponentAdapter {
12
13
    /** the RobotFactory from the AUT */
14
    private IRobotFactory m_robotFactory;
15
    
16
    /**
17
     * Gets the Robot factory. The factory is created once per instance.
18
     *
19
     * @return The Robot factory.
20
     */
21
    public IRobotFactory getRobotFactory() {
22
        if (m_robotFactory == null) {
23
            m_robotFactory = new RobotFactoryConfig().getRobotFactory();
24
        }
25
        return m_robotFactory;
26
    }
27
28
}
(-)a/org.eclipse.jubula.rc.swing/src/org/eclipse/jubula/rc/swing/swing/uiadapter/JListAdapter.java (+243 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2012 BREDEX GmbH.
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
 *     BREDEX GmbH - initial API and implementation 
10
 *******************************************************************************/
11
package org.eclipse.jubula.rc.swing.swing.uiadapter;
12
13
import java.awt.Component;
14
import java.awt.Dimension;
15
import java.awt.Rectangle;
16
import java.util.HashSet;
17
import java.util.Set;
18
19
import javax.swing.JList;
20
import javax.swing.ListCellRenderer;
21
import javax.swing.ListModel;
22
23
import org.eclipse.jubula.rc.common.CompSystemConstants;
24
import org.eclipse.jubula.rc.common.driver.ClickOptions;
25
import org.eclipse.jubula.rc.common.driver.IRunnable;
26
import org.eclipse.jubula.rc.common.exception.StepExecutionException;
27
import org.eclipse.jubula.rc.common.implclasses.MatchUtil;
28
import org.eclipse.jubula.rc.common.uiadapter.interfaces.IListAdapter;
29
import org.eclipse.jubula.rc.swing.swing.caps.CapUtil;
30
import org.eclipse.jubula.rc.swing.swing.implclasses.JComboBoxImplClass;
31
import org.eclipse.jubula.tools.objects.event.EventFactory;
32
import org.eclipse.jubula.tools.objects.event.TestErrorEvent;
33
/**
34
 * 
35
 * @author BREDEX GmbH
36
 *
37
 */
38
public class JListAdapter extends WidgetAdapter implements IListAdapter {
39
    /** */
40
    private JList m_list;
41
    
42
    /**
43
     * 
44
     * @param objectToAdapt 
45
     */
46
    public JListAdapter(Object objectToAdapt) {
47
        super(objectToAdapt);
48
        m_list = (JList) objectToAdapt;
49
    }
50
    
51
    /**
52
     * {@inheritDoc}
53
     */
54
    public String getText() {
55
        String[] selected = getSelectedValues();
56
        if (selected.length > 0) {
57
            return selected[0];
58
        }
59
        throw new StepExecutionException("No list item selected", //$NON-NLS-1$
60
            EventFactory.createActionError(TestErrorEvent.NO_SELECTION));
61
    }
62
63
    /**
64
     * {@inheritDoc}
65
     */
66
    public int[] getSelectedIndices() {
67
        return (int[])getEventThreadQueuer().invokeAndWait(
68
            "getSelectedIndices", new IRunnable() { //$NON-NLS-1$
69
                public Object run() {
70
                    return m_list.getSelectedIndices();
71
                }
72
            });
73
    }
74
75
    /**
76
     * Clicks on the index of the passed list.
77
     *
78
     * @param i The index to click
79
     * @param co the click options to use
80
     * @param maxWidth the maximal width which is used to select the item
81
     */
82
    public void clickOnIndex(final Integer i,
83
            ClickOptions co, double maxWidth) {
84
        final int index = i.intValue();
85
        ListModel model = m_list.getModel();
86
        if ((model == null) || (index >= model.getSize())
87
            || (index < 0)) {
88
            throw new StepExecutionException("List index '" + i //$NON-NLS-1$
89
                + "' is out of range", //$NON-NLS-1$
90
                EventFactory.createActionError(TestErrorEvent.INVALID_INDEX));
91
        }
92
        // Call of JList.ensureIndexIsVisible() is not required,
93
        // because the Robot scrolls the click rectangle to visible.
94
        Rectangle r = (Rectangle) getRobotFactory().getEventThreadQueuer()
95
                .invokeAndWait("getCellBounds", new IRunnable() { //$NON-NLS-1$
96
97
                    public Object run() throws StepExecutionException {
98
                        return m_list.getCellBounds(index, index);
99
                    }
100
                });        
101
        
102
        if (r == null) {
103
            throw new StepExecutionException(
104
                "List index '" + i + "' is not visible", //$NON-NLS-1$ //$NON-NLS-2$
105
                EventFactory.createActionError(TestErrorEvent.NOT_VISIBLE));
106
        }
107
        
108
        // if possible adjust height and width for items
109
        ListCellRenderer lcr = m_list.getCellRenderer();
110
        if (lcr != null) {
111
            Component listItem = lcr.getListCellRendererComponent(m_list, model
112
                    .getElementAt(index), index, false, false);
113
            Dimension preferredSize = listItem.getPreferredSize();
114
            r.setSize(preferredSize);
115
        }
116
        
117
        if (maxWidth != JComboBoxImplClass.NO_MAX_WIDTH
118
                && r.getWidth() > maxWidth) {
119
            Dimension d = new Dimension();
120
            d.setSize(maxWidth, r.getHeight());
121
            r.setSize(d);
122
        }
123
124
        getRobot().click(m_list, r,
125
                co.setClickType(ClickOptions.ClickType.RELEASED));
126
    }
127
128
    /**
129
     * {@inheritDoc}
130
     */
131
    public String[] getSelectedValues() {
132
        final int[] indices = getSelectedIndices();
133
134
        return (String[])getEventThreadQueuer().invokeAndWait(
135
            "getSelectedValues", new IRunnable() { //$NON-NLS-1$
136
                public Object run() {
137
                    Object[] values = m_list.getSelectedValues();
138
                    String[] selected = new String[values.length];
139
                    ListCellRenderer renderer = m_list.getCellRenderer();
140
                    for (int i = 0; i < values.length; i++) {
141
                        Object value = values[i];
142
                        Component c = renderer.getListCellRendererComponent(
143
                            m_list, value, indices[i], true, false);
144
                        selected[i] = CapUtil.getRenderedText(c);
145
                    }
146
                    return selected;
147
                }
148
            });
149
    }
150
    /**
151
     * {@inheritDoc}
152
     */
153
    public Integer[] findIndicesOfValues(
154
            final String[] values, final String  operator,
155
            final String searchType) {
156
157
        final Set indexSet = new HashSet();
158
        getEventThreadQueuer().invokeAndWait("findIndices", //$NON-NLS-1$
159
            new IRunnable() {
160
                public Object run() {
161
                    ListCellRenderer renderer = m_list.getCellRenderer();
162
                    ListModel model = m_list.getModel();
163
                    for (int i = getStartingIndex(searchType);
164
                            i < model.getSize(); ++i) {
165
                        Object obj = model.getElementAt(i);
166
                        m_list.ensureIndexIsVisible(i);
167
                        Component comp = renderer
168
                                .getListCellRendererComponent(
169
                            m_list, obj, i, false, false);
170
                        String str = CapUtil.getRenderedText(comp);
171
                        if (MatchUtil.getInstance().
172
                            match(str, values, operator)) {
173
                            indexSet.add(new Integer(i));
174
                        }
175
                    }
176
                    return null; // return value is not used
177
                }
178
            });
179
180
        Integer[] indices = new Integer[indexSet.size()];
181
        indexSet.toArray(indices);
182
        return indices;
183
    }
184
    
185
    /**
186
     * Finds the indices of the list elements that are rendered with the passed
187
     * values.
188
     *
189
     * @param values The values
190
     * @param operator operator to use
191
     * @return The array of indices. It's length is equal to the length of the
192
     *         values array, but may contains <code>null</code> elements for
193
     *         all values that are not found in the list
194
     */
195
    public Integer[] findIndicesOfValues(
196
        final String[] values, final String  operator) {
197
198
        return findIndicesOfValues(values, operator, 
199
                CompSystemConstants.SEARCH_TYPE_ABSOLUTE);
200
    }
201
    
202
    /**
203
     * {@inheritDoc}
204
     */
205
    public boolean containsValue(String value, String operator) {
206
        Integer[] indices = null;
207
        if (operator.equals(MatchUtil.NOT_EQUALS)) {
208
            indices = findIndicesOfValues(new String[] { value },
209
                MatchUtil.EQUALS);
210
            return indices.length == 0;
211
        }
212
        indices = findIndicesOfValues(new String[] { value },
213
            operator);
214
        return indices.length > 0;
215
    }
216
    
217
    /**
218
     * Clicks on the index of the passed list.
219
     *
220
     * @param i
221
     *            The index to click
222
     * @param co the click options to use
223
     */
224
    public void clickOnIndex(final Integer i, ClickOptions co) {
225
        clickOnIndex(i, co, JComboBoxImplClass.NO_MAX_WIDTH);
226
    }
227
228
    /**
229
     * @param searchType Determines where the search begins ("relative" or "absolute")
230
     * @return The index from which to begin a search, based on the search type
231
     *         and (if appropriate) the currently selected cell.
232
     */
233
    private int getStartingIndex(final String searchType) {
234
        int startingIndex = 0;
235
        if (searchType.equalsIgnoreCase(
236
                CompSystemConstants.SEARCH_TYPE_RELATIVE)) {
237
            int [] selectedIndices = getSelectedIndices();
238
            // Start from the last selected item
239
            startingIndex = selectedIndices[selectedIndices.length - 1] + 1;
240
        }
241
        return startingIndex;
242
    }
243
}
(-)a/org.eclipse.jubula.rc.swing/src/org/eclipse/jubula/rc/swing/swing/uiadapter/JMenuAdapter.java (-1 / +2 lines)
Lines 28-34 import org.eclipse.jubula.rc.common.uiadapter.interfaces.IMenuItemAdapter; Link Here
28
 * @author BREDEX GmbH
28
 * @author BREDEX GmbH
29
 *
29
 *
30
 */
30
 */
31
public class JMenuAdapter implements IMenuAdapter {
31
public class JMenuAdapter extends AbstractComponentAdapter
32
    implements IMenuAdapter {
32
    /** The JMenu from the AUT */
33
    /** The JMenu from the AUT */
33
    private JMenu m_menu;
34
    private JMenu m_menu;
34
    
35
    
(-)a/org.eclipse.jubula.rc.swing/src/org/eclipse/jubula/rc/swing/swing/uiadapter/JMenuBarAdapter.java (-1 / +2 lines)
Lines 28-34 import org.eclipse.jubula.rc.common.uiadapter.interfaces.IMenuItemAdapter; Link Here
28
 * @author BREDEX GmbH
28
 * @author BREDEX GmbH
29
 *
29
 *
30
 */
30
 */
31
public class JMenuBarAdapter implements IMenuAdapter {
31
public class JMenuBarAdapter extends AbstractComponentAdapter
32
    implements IMenuAdapter {
32
    /** The JMenuBar */
33
    /** The JMenuBar */
33
    private JMenuBar m_menuBar;
34
    private JMenuBar m_menuBar;
34
    
35
    
(-)a/org.eclipse.jubula.rc.swing/src/org/eclipse/jubula/rc/swing/swing/uiadapter/JMenuItemAdapter.java (-17 / +2 lines)
Lines 16-29 import javax.swing.JMenuItem; Link Here
16
import org.eclipse.jubula.rc.common.driver.ClickOptions;
16
import org.eclipse.jubula.rc.common.driver.ClickOptions;
17
import org.eclipse.jubula.rc.common.driver.IEventThreadQueuer;
17
import org.eclipse.jubula.rc.common.driver.IEventThreadQueuer;
18
import org.eclipse.jubula.rc.common.driver.IRobot;
18
import org.eclipse.jubula.rc.common.driver.IRobot;
19
import org.eclipse.jubula.rc.common.driver.IRobotFactory;
20
import org.eclipse.jubula.rc.common.driver.IRunnable;
19
import org.eclipse.jubula.rc.common.driver.IRunnable;
21
import org.eclipse.jubula.rc.common.driver.RobotTiming;
20
import org.eclipse.jubula.rc.common.driver.RobotTiming;
22
import org.eclipse.jubula.rc.common.exception.RobotException;
21
import org.eclipse.jubula.rc.common.exception.RobotException;
23
import org.eclipse.jubula.rc.common.exception.StepExecutionException;
22
import org.eclipse.jubula.rc.common.exception.StepExecutionException;
24
import org.eclipse.jubula.rc.common.uiadapter.interfaces.IMenuAdapter;
23
import org.eclipse.jubula.rc.common.uiadapter.interfaces.IMenuAdapter;
25
import org.eclipse.jubula.rc.common.uiadapter.interfaces.IMenuItemAdapter;
24
import org.eclipse.jubula.rc.common.uiadapter.interfaces.IMenuItemAdapter;
26
import org.eclipse.jubula.rc.swing.driver.RobotFactoryConfig;
27
import org.eclipse.jubula.tools.objects.event.EventFactory;
25
import org.eclipse.jubula.tools.objects.event.EventFactory;
28
import org.eclipse.jubula.tools.objects.event.TestErrorEvent;
26
import org.eclipse.jubula.tools.objects.event.TestErrorEvent;
29
27
Lines 32-46 import org.eclipse.jubula.tools.objects.event.TestErrorEvent; Link Here
32
 * @author BREDEX GmbH
30
 * @author BREDEX GmbH
33
 * 
31
 * 
34
 */
32
 */
35
public class JMenuItemAdapter 
33
public class JMenuItemAdapter extends AbstractComponentAdapter
36
    implements IMenuItemAdapter {
34
    implements IMenuItemAdapter {
37
35
38
    /** the JMenuItem from the AUT    */
36
    /** the JMenuItem from the AUT    */
39
    private JMenuItem m_menuItem;
37
    private JMenuItem m_menuItem;
40
38
41
    /** the RobotFactory from the AUT */
42
    private IRobotFactory m_robotFactory;
43
  
44
    /**
39
    /**
45
     * 
40
     * 
46
     * @param objectToAdapt 
41
     * @param objectToAdapt 
Lines 48-64 public class JMenuItemAdapter Link Here
48
    public JMenuItemAdapter(Object objectToAdapt) {
43
    public JMenuItemAdapter(Object objectToAdapt) {
49
        m_menuItem = (JMenuItem) objectToAdapt;        
44
        m_menuItem = (JMenuItem) objectToAdapt;        
50
    }
45
    }
51
    /**
46
52
     * Gets the Robot factory. The factory is created once per instance.
53
     *
54
     * @return The Robot factory.
55
     */
56
    protected IRobotFactory getRobotFactory() {
57
        if (m_robotFactory == null) {
58
            m_robotFactory = new RobotFactoryConfig().getRobotFactory();
59
        }
60
        return m_robotFactory;
61
    }
62
    /**
47
    /**
63
     * Gets the IEventThreadQueuer.
48
     * Gets the IEventThreadQueuer.
64
     *
49
     *
(-)a/org.eclipse.jubula.rc.swing/src/org/eclipse/jubula/rc/swing/swing/uiadapter/JPopupMenuAdapter.java (-1 / +2 lines)
Lines 27-33 import org.eclipse.jubula.rc.common.uiadapter.interfaces.IMenuItemAdapter; Link Here
27
 * @author BREDEX GmbH
27
 * @author BREDEX GmbH
28
 *
28
 *
29
 */
29
 */
30
public class JPopupMenuAdapter implements IMenuAdapter {
30
public class JPopupMenuAdapter extends AbstractComponentAdapter
31
    implements IMenuAdapter {
31
    /** */
32
    /** */
32
    private JPopupMenu m_contextMenu;
33
    private JPopupMenu m_contextMenu;
33
    
34
    
(-)a/org.eclipse.jubula.rc.swing/src/org/eclipse/jubula/rc/swing/swing/uiadapter/JTableAdapter.java (+8 lines)
Lines 374-377 public class JTableAdapter extends WidgetAdapter implements ITableAdapter { Link Here
374
        getRobot().scrollToVisible(m_table, bounds);
374
        getRobot().scrollToVisible(m_table, bounds);
375
        return bounds;
375
        return bounds;
376
    }
376
    }
377
378
    /**
379
     * {@inheritDoc}
380
     */
381
    public String getText() {
382
        final Cell selectedCell = getSelectedCell();
383
        return getCellText(selectedCell.getRow(), selectedCell.getCol());
384
    }
377
}
385
}
(-)a/org.eclipse.jubula.rc.swing/src/org/eclipse/jubula/rc/swing/swing/uiadapter/WidgetAdapter.java (-16 / +11 lines)
Lines 21-37 import org.eclipse.jubula.rc.common.driver.ClickOptions; Link Here
21
import org.eclipse.jubula.rc.common.driver.DragAndDropHelper;
21
import org.eclipse.jubula.rc.common.driver.DragAndDropHelper;
22
import org.eclipse.jubula.rc.common.driver.IEventThreadQueuer;
22
import org.eclipse.jubula.rc.common.driver.IEventThreadQueuer;
23
import org.eclipse.jubula.rc.common.driver.IRobot;
23
import org.eclipse.jubula.rc.common.driver.IRobot;
24
import org.eclipse.jubula.rc.common.driver.IRobotFactory;
25
import org.eclipse.jubula.rc.common.driver.IRunnable;
24
import org.eclipse.jubula.rc.common.driver.IRunnable;
26
import org.eclipse.jubula.rc.common.driver.RobotTiming;
25
import org.eclipse.jubula.rc.common.driver.RobotTiming;
27
import org.eclipse.jubula.rc.common.exception.RobotException;
26
import org.eclipse.jubula.rc.common.exception.RobotException;
28
import org.eclipse.jubula.rc.common.exception.StepExecutionException;
27
import org.eclipse.jubula.rc.common.exception.StepExecutionException;
29
import org.eclipse.jubula.rc.common.listener.EventLock;
28
import org.eclipse.jubula.rc.common.listener.EventLock;
30
import org.eclipse.jubula.rc.common.uiadapter.interfaces.IWidgetAdapter;
29
import org.eclipse.jubula.rc.common.uiadapter.interfaces.IWidgetAdapter;
31
import org.eclipse.jubula.rc.swing.driver.RobotFactoryConfig;
32
import org.eclipse.jubula.rc.swing.swing.caps.CapUtil;
30
import org.eclipse.jubula.rc.swing.swing.caps.CapUtil;
33
import org.eclipse.jubula.rc.swing.swing.caps.JMenuBarCAPs;
31
import org.eclipse.jubula.rc.swing.swing.caps.JMenuBarCAPs;
34
import org.eclipse.jubula.rc.swing.swing.caps.CapUtil.PopupShownCondition;
32
import org.eclipse.jubula.rc.swing.swing.caps.CapUtil.PopupShownCondition;
33
import org.eclipse.jubula.rc.swing.swing.driver.KeyCodeConverter;
35
import org.eclipse.jubula.rc.swing.swing.implclasses.EventListener;
34
import org.eclipse.jubula.rc.swing.swing.implclasses.EventListener;
36
import org.eclipse.jubula.tools.constants.TimeoutConstants;
35
import org.eclipse.jubula.tools.constants.TimeoutConstants;
37
import org.eclipse.jubula.tools.i18n.I18n;
36
import org.eclipse.jubula.tools.i18n.I18n;
Lines 45-59 import org.eclipse.jubula.tools.utils.TimeUtil; Link Here
45
 * 
44
 * 
46
 * @author BREDEX GmbH 
45
 * @author BREDEX GmbH 
47
 */
46
 */
48
public abstract class WidgetAdapter implements IWidgetAdapter {
47
public abstract class WidgetAdapter extends AbstractComponentAdapter
48
    implements IWidgetAdapter {
49
      
49
      
50
    /** constants for communication */
50
    /** constants for communication */
51
    protected static final String POS_UNIT_PIXEL = "Pixel"; //$NON-NLS-1$
51
    protected static final String POS_UNIT_PIXEL = "Pixel"; //$NON-NLS-1$
52
    /** constants for communication */
52
    /** constants for communication */
53
    protected static final String POS_UNI_PERCENT = "Percent"; //$NON-NLS-1$
53
    protected static final String POS_UNI_PERCENT = "Percent"; //$NON-NLS-1$
54
    
54
    
55
    /** the RobotFactory from the AUT */
55
56
    private IRobotFactory m_robotFactory;
57
    
56
    
58
57
59
     
58
     
Lines 76-92 public abstract class WidgetAdapter implements IWidgetAdapter { Link Here
76
    }
75
    }
77
    
76
    
78
    /**
77
    /**
79
     * Gets the Robot factory. The factory is created once per instance.
80
     *
81
     * @return The Robot factory.
82
     */
83
    protected IRobotFactory getRobotFactory() {
84
        if (m_robotFactory == null) {
85
            m_robotFactory = new RobotFactoryConfig().getRobotFactory();
86
        }
87
        return m_robotFactory;
88
    }
89
    /**
90
     * Gets the IEventThreadQueuer.
78
     * Gets the IEventThreadQueuer.
91
     *
79
     *
92
     * @return The Robot
80
     * @return The Robot
Lines 331-334 public abstract class WidgetAdapter implements IWidgetAdapter { Link Here
331
                xPos, xUnits.equalsIgnoreCase(POS_UNIT_PIXEL),
319
                xPos, xUnits.equalsIgnoreCase(POS_UNIT_PIXEL),
332
                yPos, yUnits.equalsIgnoreCase(POS_UNIT_PIXEL));
320
                yPos, yUnits.equalsIgnoreCase(POS_UNIT_PIXEL));
333
    }
321
    }
322
    
323
    /**
324
     * {@inheritDoc}
325
     */
326
    public int getKeyCode(String mod) {
327
        return KeyCodeConverter.getKeyCode(mod);
328
    }
334
}
329
}
(-)a/org.eclipse.jubula.rc.swing/src/org/eclipse/jubula/rc/swing/swing/uiadapter/factory/SwingAdapterFactory.java (-1 / +7 lines)
Lines 13-18 package org.eclipse.jubula.rc.swing.swing.uiadapter.factory; Link Here
13
13
14
import javax.swing.JButton;
14
import javax.swing.JButton;
15
import javax.swing.JCheckBox;
15
import javax.swing.JCheckBox;
16
import javax.swing.JList;
16
import javax.swing.JMenuBar;
17
import javax.swing.JMenuBar;
17
import javax.swing.JMenuItem;
18
import javax.swing.JMenuItem;
18
import javax.swing.JPopupMenu;
19
import javax.swing.JPopupMenu;
Lines 23-28 import javax.swing.JTree; Link Here
23
import org.eclipse.jubula.rc.common.uiadapter.factory.IUIAdapterFactory;
24
import org.eclipse.jubula.rc.common.uiadapter.factory.IUIAdapterFactory;
24
import org.eclipse.jubula.rc.common.uiadapter.interfaces.IComponentAdapter;
25
import org.eclipse.jubula.rc.common.uiadapter.interfaces.IComponentAdapter;
25
import org.eclipse.jubula.rc.swing.swing.uiadapter.AbstractButtonAdapter;
26
import org.eclipse.jubula.rc.swing.swing.uiadapter.AbstractButtonAdapter;
27
import org.eclipse.jubula.rc.swing.swing.uiadapter.JListAdapter;
26
import org.eclipse.jubula.rc.swing.swing.uiadapter.JMenuBarAdapter;
28
import org.eclipse.jubula.rc.swing.swing.uiadapter.JMenuBarAdapter;
27
import org.eclipse.jubula.rc.swing.swing.uiadapter.JMenuItemAdapter;
29
import org.eclipse.jubula.rc.swing.swing.uiadapter.JMenuItemAdapter;
28
import org.eclipse.jubula.rc.swing.swing.uiadapter.JPopupMenuAdapter;
30
import org.eclipse.jubula.rc.swing.swing.uiadapter.JPopupMenuAdapter;
Lines 45-51 public class SwingAdapterFactory implements IUIAdapterFactory { Link Here
45
    private static final Class[] SUPPORTEDCLASSES = new Class[] { 
47
    private static final Class[] SUPPORTEDCLASSES = new Class[] { 
46
        JButton.class, JCheckBox.class, JRadioButton.class,
48
        JButton.class, JCheckBox.class, JRadioButton.class,
47
        JMenuBar.class, JMenuItem.class, JTree.class , 
49
        JMenuBar.class, JMenuItem.class, JTree.class , 
48
        JCheckBox.class, JRadioButton.class, JTable.class, JPopupMenu.class};
50
        JCheckBox.class, JRadioButton.class, JTable.class, JPopupMenu.class,
51
        JList.class};
49
    
52
    
50
    /**
53
    /**
51
     * {@inheritDoc}
54
     * {@inheritDoc}
Lines 81-86 public class SwingAdapterFactory implements IUIAdapterFactory { Link Here
81
        } else if (objectToAdapt instanceof JTable) {
84
        } else if (objectToAdapt instanceof JTable) {
82
            returnvalue = new JTableAdapter(objectToAdapt);
85
            returnvalue = new JTableAdapter(objectToAdapt);
83
            
86
            
87
        } else if (objectToAdapt instanceof JList) {
88
            returnvalue = new JListAdapter(objectToAdapt);
89
            
84
        } else if (objectToAdapt instanceof JPopupMenu) {
90
        } else if (objectToAdapt instanceof JPopupMenu) {
85
            returnvalue = new JPopupMenuAdapter(objectToAdapt);
91
            returnvalue = new JPopupMenuAdapter(objectToAdapt);
86
        
92
        
(-)a/org.eclipse.jubula.rc.swt/src/org/eclipse/jubula/rc/swt/caps/ButtonCAPs.java (-18 / +1 lines)
Lines 12-20 package org.eclipse.jubula.rc.swt.caps; Link Here
12
12
13
13
14
import org.eclipse.jubula.rc.common.caps.AbstractButtonCAPs;
14
import org.eclipse.jubula.rc.common.caps.AbstractButtonCAPs;
15
import org.eclipse.jubula.rc.common.driver.IRobotFactory;
16
import org.eclipse.jubula.rc.common.uiadapter.interfaces.IButtonAdapter;
15
import org.eclipse.jubula.rc.common.uiadapter.interfaces.IButtonAdapter;
17
import org.eclipse.jubula.rc.swt.driver.RobotFactoryConfig;
18
import org.eclipse.jubula.rc.swt.utils.SwtUtils;
16
import org.eclipse.jubula.rc.swt.utils.SwtUtils;
19
17
20
18
Lines 24-33 import org.eclipse.jubula.rc.swt.utils.SwtUtils; Link Here
24
 * @author BREDEX GmbH
22
 * @author BREDEX GmbH
25
 */
23
 */
26
public class ButtonCAPs extends AbstractButtonCAPs {
24
public class ButtonCAPs extends AbstractButtonCAPs {
27
    
25
28
    /** The robot factory. */
29
    private IRobotFactory m_robotFactory;
30
    
31
    /**
26
    /**
32
     * {@inheritDoc}
27
     * {@inheritDoc}
33
     */
28
     */
Lines 37-52 public class ButtonCAPs extends AbstractButtonCAPs { Link Here
37
                        ((IButtonAdapter)getComponent()).getText())};
32
                        ((IButtonAdapter)getComponent()).getText())};
38
    }
33
    }
39
    
34
    
40
    /**
41
     * Gets the Robot factory. The factory is created once per instance.
42
     * @return The Robot factory.
43
     */
44
    protected IRobotFactory getRobotFactory() {
45
        if (m_robotFactory == null) {
46
            m_robotFactory = new RobotFactoryConfig().getRobotFactory();
47
        }
48
        return m_robotFactory;
49
    }
50
51
52
}
35
}
(-)a/org.eclipse.jubula.rc.swt/src/org/eclipse/jubula/rc/swt/caps/CAPUtil.java (-12 lines)
Lines 20-26 import org.eclipse.jubula.rc.common.util.KeyStrokeUtil; Link Here
20
import org.eclipse.jubula.rc.swt.driver.KeyCodeConverter;
20
import org.eclipse.jubula.rc.swt.driver.KeyCodeConverter;
21
import org.eclipse.jubula.rc.swt.driver.SwtRobot;
21
import org.eclipse.jubula.rc.swt.driver.SwtRobot;
22
import org.eclipse.jubula.tools.utils.EnvironmentUtils;
22
import org.eclipse.jubula.tools.utils.EnvironmentUtils;
23
import org.eclipse.jubula.tools.utils.TimeUtil;
24
import org.eclipse.swt.widgets.Display;
23
import org.eclipse.swt.widgets.Display;
25
/**
24
/**
26
 * Util class for some swt specific commands.
25
 * Util class for some swt specific commands.
Lines 46-62 public class CAPUtil { Link Here
46
    }
45
    }
47
    
46
    
48
    /**
47
    /**
49
     * Waits the given amount of time. Logs a drop-related error if interrupted.
50
     * 
51
     * @param delayBeforeDrop the amount of time (in milliseconds) to wait
52
     *                        between moving the mouse to the drop point and
53
     *                        releasing the mouse button                       
54
     */
55
    public static void waitBeforeDrop(int delayBeforeDrop) {
56
        TimeUtil.delay(delayBeforeDrop);
57
    }
58
    
59
    /**
60
     * Move the mouse pointer from its current position to a few points in
48
     * Move the mouse pointer from its current position to a few points in
61
     * its proximity. This is used to initiate a drag operation.
49
     * its proximity. This is used to initiate a drag operation.
62
     * 
50
     * 
(-)a/org.eclipse.jubula.rc.swt/src/org/eclipse/jubula/rc/swt/caps/ListCAPs.java (+30 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2012 BREDEX GmbH.
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
 *     BREDEX GmbH - initial API and implementation 
10
 *******************************************************************************/
11
package org.eclipse.jubula.rc.swt.caps;
12
13
import org.eclipse.jubula.rc.common.caps.AbstractListCAPs;
14
import org.eclipse.jubula.rc.swt.utils.SwtUtils;
15
/**
16
 * 
17
 * @author BREDEX GmbH
18
 *
19
 */
20
public class ListCAPs extends AbstractListCAPs {
21
22
23
    /**
24
     * {@inheritDoc}
25
     */
26
    protected int getSystemDefaultModifier() {
27
        return SwtUtils.getSystemDefaultModifier();
28
    }
29
30
}
(-)a/org.eclipse.jubula.rc.swt/src/org/eclipse/jubula/rc/swt/caps/MenuCAPs.java (-25 / +2 lines)
Lines 13-22 package org.eclipse.jubula.rc.swt.caps; Link Here
13
import org.apache.commons.lang.Validate;
13
import org.apache.commons.lang.Validate;
14
import org.eclipse.jubula.rc.common.caps.AbstractMenuCAPs;
14
import org.eclipse.jubula.rc.common.caps.AbstractMenuCAPs;
15
import org.eclipse.jubula.rc.common.driver.IEventThreadQueuer;
15
import org.eclipse.jubula.rc.common.driver.IEventThreadQueuer;
16
import org.eclipse.jubula.rc.common.driver.IRobot;
17
import org.eclipse.jubula.rc.common.driver.IRobotFactory;
18
import org.eclipse.jubula.rc.common.driver.IRunnable;
16
import org.eclipse.jubula.rc.common.driver.IRunnable;
19
import org.eclipse.jubula.rc.common.exception.RobotException;
20
import org.eclipse.jubula.rc.common.exception.StepExecutionException;
17
import org.eclipse.jubula.rc.common.exception.StepExecutionException;
21
import org.eclipse.jubula.rc.common.implclasses.IBaseImplementationClass;
18
import org.eclipse.jubula.rc.common.implclasses.IBaseImplementationClass;
22
import org.eclipse.jubula.rc.common.implclasses.MenuUtilBase;
19
import org.eclipse.jubula.rc.common.implclasses.MenuUtilBase;
Lines 24-30 import org.eclipse.jubula.rc.common.uiadapter.interfaces.IComponentAdapter; Link Here
24
import org.eclipse.jubula.rc.common.uiadapter.interfaces.IMenuAdapter;
21
import org.eclipse.jubula.rc.common.uiadapter.interfaces.IMenuAdapter;
25
import org.eclipse.jubula.rc.common.uiadapter.interfaces.IMenuItemAdapter;
22
import org.eclipse.jubula.rc.common.uiadapter.interfaces.IMenuItemAdapter;
26
import org.eclipse.jubula.rc.swt.driver.EventThreadQueuerSwtImpl;
23
import org.eclipse.jubula.rc.swt.driver.EventThreadQueuerSwtImpl;
27
import org.eclipse.jubula.rc.swt.driver.RobotFactoryConfig;
28
import org.eclipse.jubula.rc.swt.driver.RobotSwtImpl;
24
import org.eclipse.jubula.rc.swt.driver.RobotSwtImpl;
29
import org.eclipse.jubula.rc.swt.uiadapter.MenuItemAdapter;
25
import org.eclipse.jubula.rc.swt.uiadapter.MenuItemAdapter;
30
import org.eclipse.jubula.tools.i18n.I18n;
26
import org.eclipse.jubula.tools.i18n.I18n;
Lines 43-63 import org.eclipse.swt.widgets.Shell; Link Here
43
 */
39
 */
44
public class MenuCAPs extends AbstractMenuCAPs 
40
public class MenuCAPs extends AbstractMenuCAPs 
45
    implements IBaseImplementationClass {
41
    implements IBaseImplementationClass {
46
    /** the RobotFactory from the AUT */
42
47
    private IRobotFactory m_robotFactory;
48
    
43
    
49
    /** Test variable for contextMenus*/
44
    /** Test variable for contextMenus*/
50
    private boolean m_isCM = false;
45
    private boolean m_isCM = false;
51
    /**
46
52
     * Gets the IEventThreadQueuer.
53
     * 
54
     * @return The Robot
55
     * @throws RobotException
56
     *             If the Robot cannot be created.
57
     */
58
    protected IRobot getRobot() throws RobotException {
59
        return getRobotFactory().getRobot();
60
    }
61
47
62
    /**
48
    /**
63
     * @return The event thread queuer.
49
     * @return The event thread queuer.
Lines 97-111 public class MenuCAPs extends AbstractMenuCAPs Link Here
97
    public String[] getTextArrayFromComponent() {
83
    public String[] getTextArrayFromComponent() {
98
        return null;
84
        return null;
99
    }
85
    }
100
    /**
101
     * {@inheritDoc}
102
     */
103
    protected IRobotFactory getRobotFactory() {
104
        if (m_robotFactory == null) {
105
            m_robotFactory = new RobotFactoryConfig().getRobotFactory();
106
        }
107
        return m_robotFactory;
108
    }
109
    
86
    
110
    /**
87
    /**
111
     * Tries to select a menu item in a menu defined by a Text-Path
88
     * Tries to select a menu item in a menu defined by a Text-Path
(-)a/org.eclipse.jubula.rc.swt/src/org/eclipse/jubula/rc/swt/caps/TableCAPs.java (-26 / +3 lines)
Lines 18-31 import org.eclipse.jubula.rc.common.caps.AbstractTableCAPs; Link Here
18
import org.eclipse.jubula.rc.common.driver.ClickOptions;
18
import org.eclipse.jubula.rc.common.driver.ClickOptions;
19
import org.eclipse.jubula.rc.common.driver.IEventThreadQueuer;
19
import org.eclipse.jubula.rc.common.driver.IEventThreadQueuer;
20
import org.eclipse.jubula.rc.common.driver.IRobot;
20
import org.eclipse.jubula.rc.common.driver.IRobot;
21
import org.eclipse.jubula.rc.common.driver.IRobotFactory;
22
import org.eclipse.jubula.rc.common.driver.IRunnable;
21
import org.eclipse.jubula.rc.common.driver.IRunnable;
23
import org.eclipse.jubula.rc.common.exception.StepExecutionException;
22
import org.eclipse.jubula.rc.common.exception.StepExecutionException;
24
import org.eclipse.jubula.rc.common.implclasses.table.Cell;
23
import org.eclipse.jubula.rc.common.implclasses.table.Cell;
25
import org.eclipse.jubula.rc.common.uiadapter.interfaces.ITableAdapter;
24
import org.eclipse.jubula.rc.common.uiadapter.interfaces.ITableAdapter;
26
import org.eclipse.jubula.rc.swt.driver.DragAndDropHelperSwt;
25
import org.eclipse.jubula.rc.swt.driver.DragAndDropHelperSwt;
27
import org.eclipse.jubula.rc.swt.driver.KeyCodeConverter;
28
import org.eclipse.jubula.rc.swt.driver.RobotFactoryConfig;
29
import org.eclipse.jubula.rc.swt.uiadapter.TableAdapter;
26
import org.eclipse.jubula.rc.swt.uiadapter.TableAdapter;
30
import org.eclipse.jubula.rc.swt.utils.SwtUtils;
27
import org.eclipse.jubula.rc.swt.utils.SwtUtils;
31
import org.eclipse.jubula.tools.constants.InputConstants;
28
import org.eclipse.jubula.tools.constants.InputConstants;
Lines 48-55 import org.eclipse.swt.widgets.Widget; Link Here
48
 */
45
 */
49
public class TableCAPs extends AbstractTableCAPs {
46
public class TableCAPs extends AbstractTableCAPs {
50
    
47
    
51
    /**  */
52
    private IRobotFactory m_robotFactory;
53
48
54
    /**
49
    /**
55
     *  Gets the real table component
50
     *  Gets the real table component
Lines 75-87 public class TableCAPs extends AbstractTableCAPs { Link Here
75
        componentTextArray = getTextArrayFromItemArray(itemArray);         
70
        componentTextArray = getTextArrayFromItemArray(itemArray);         
76
        return componentTextArray;
71
        return componentTextArray;
77
    }
72
    }
78
79
    /**
80
     * {@inheritDoc}
81
     */
82
    protected int getKeyCode(String mod) {
83
        return KeyCodeConverter.getKeyCode(mod);
84
    }
85
    
73
    
86
    /**
74
    /**
87
     * {@inheritDoc}
75
     * {@inheritDoc}
Lines 287-303 public class TableCAPs extends AbstractTableCAPs { Link Here
287
        
275
        
288
        return isOnHeader.booleanValue();
276
        return isOnHeader.booleanValue();
289
    }
277
    }
290
291
    /**
292
     * {@inheritDoc}
293
     */
294
    protected IRobotFactory getRobotFactory() {
295
        if (m_robotFactory == null) {
296
            m_robotFactory = new RobotFactoryConfig().getRobotFactory();
297
        }
298
        return m_robotFactory;
299
    }
300
301
    
278
    
302
    /**
279
    /**
303
     * Returns an array of representation strings that corresponds to the given
280
     * Returns an array of representation strings that corresponds to the given
Lines 573-579 public class TableCAPs extends AbstractTableCAPs { Link Here
573
                }            
550
                }            
574
            });
551
            });
575
552
576
            CAPUtil.waitBeforeDrop(delayBeforeDrop);
553
            waitBeforeDrop(delayBeforeDrop);
577
            
554
            
578
        } finally {
555
        } finally {
579
            robot.mouseRelease(dndHelper.getDragComponent(), null, 
556
            robot.mouseRelease(dndHelper.getDragComponent(), null, 
Lines 650-656 public class TableCAPs extends AbstractTableCAPs { Link Here
650
                }            
627
                }            
651
            });
628
            });
652
            
629
            
653
            CAPUtil.waitBeforeDrop(delayBeforeDrop);
630
            waitBeforeDrop(delayBeforeDrop);
654
            
631
            
655
        } finally {
632
        } finally {
656
            robot.mouseRelease(dndHelper.getDragComponent(), null, 
633
            robot.mouseRelease(dndHelper.getDragComponent(), null, 
Lines 726-732 public class TableCAPs extends AbstractTableCAPs { Link Here
726
                }            
703
                }            
727
            });
704
            });
728
705
729
            CAPUtil.waitBeforeDrop(delayBeforeDrop);
706
            waitBeforeDrop(delayBeforeDrop);
730
        
707
        
731
        } finally {
708
        } finally {
732
            robot.mouseRelease(dndHelper.getDragComponent(), null, 
709
            robot.mouseRelease(dndHelper.getDragComponent(), null, 
(-)a/org.eclipse.jubula.rc.swt/src/org/eclipse/jubula/rc/swt/caps/TreeCAPs.java (-29 / +3 lines)
Lines 13-27 package org.eclipse.jubula.rc.swt.caps; Link Here
13
import java.util.StringTokenizer;
13
import java.util.StringTokenizer;
14
14
15
import org.apache.commons.lang.Validate;
15
import org.apache.commons.lang.Validate;
16
import org.eclipse.jubula.rc.common.AUTServer;
17
import org.eclipse.jubula.rc.common.CompSystemConstants;
16
import org.eclipse.jubula.rc.common.CompSystemConstants;
18
import org.eclipse.jubula.rc.common.caps.AbstractTreeCAPs;
17
import org.eclipse.jubula.rc.common.caps.AbstractTreeCAPs;
19
import org.eclipse.jubula.rc.common.driver.ClickOptions;
18
import org.eclipse.jubula.rc.common.driver.ClickOptions;
20
import org.eclipse.jubula.rc.common.driver.IEventThreadQueuer;
19
import org.eclipse.jubula.rc.common.driver.IEventThreadQueuer;
21
import org.eclipse.jubula.rc.common.driver.IRobot;
20
import org.eclipse.jubula.rc.common.driver.IRobot;
22
import org.eclipse.jubula.rc.common.driver.IRobotFactory;
23
import org.eclipse.jubula.rc.common.driver.IRunnable;
21
import org.eclipse.jubula.rc.common.driver.IRunnable;
24
import org.eclipse.jubula.rc.common.exception.RobotException;
25
import org.eclipse.jubula.rc.common.exception.StepExecutionException;
22
import org.eclipse.jubula.rc.common.exception.StepExecutionException;
26
import org.eclipse.jubula.rc.common.implclasses.IndexConverter;
23
import org.eclipse.jubula.rc.common.implclasses.IndexConverter;
27
import org.eclipse.jubula.rc.common.implclasses.MatchUtil;
24
import org.eclipse.jubula.rc.common.implclasses.MatchUtil;
Lines 42-48 import org.eclipse.jubula.rc.common.implclasses.tree.TreeNodeOperationConstraint Link Here
42
import org.eclipse.jubula.rc.common.util.KeyStrokeUtil;
39
import org.eclipse.jubula.rc.common.util.KeyStrokeUtil;
43
import org.eclipse.jubula.rc.swt.driver.DragAndDropHelperSwt;
40
import org.eclipse.jubula.rc.swt.driver.DragAndDropHelperSwt;
44
import org.eclipse.jubula.rc.swt.driver.KeyCodeConverter;
41
import org.eclipse.jubula.rc.swt.driver.KeyCodeConverter;
45
import org.eclipse.jubula.rc.swt.driver.RobotFactoryConfig;
46
import org.eclipse.jubula.rc.swt.implclasses.TableTreeOperationContext;
42
import org.eclipse.jubula.rc.swt.implclasses.TableTreeOperationContext;
47
import org.eclipse.jubula.rc.swt.implclasses.TreeOperationContext;
43
import org.eclipse.jubula.rc.swt.implclasses.TreeOperationContext;
48
import org.eclipse.jubula.rc.swt.implclasses.tree.ToggleCheckboxOperation;
44
import org.eclipse.jubula.rc.swt.implclasses.tree.ToggleCheckboxOperation;
Lines 133-161 public class TreeCAPs extends AbstractTreeCAPs { Link Here
133
            return m_itemAtPoint;
129
            return m_itemAtPoint;
134
        }
130
        }
135
    }
131
    }
136
    
132
        
137
    /** The robot factory. */
138
    private IRobotFactory m_robotFactory;
139
    
140
    /**
141
     * Gets the Robot factory. The factory is created once per instance.
142
     * @return The Robot factory.
143
     */
144
    protected IRobotFactory getRobotFactory() {
145
        if (m_robotFactory == null) {
146
            m_robotFactory = new RobotFactoryConfig().getRobotFactory();
147
        }
148
        return m_robotFactory;
149
    }
150
    /**
151
     * Gets the Robot. 
152
     * @return The Robot
153
     * @throws RobotException If the Robot cannot be created.
154
     */
155
    protected IRobot getRobot() throws RobotException {
156
        return AUTServer.getInstance().getRobot();
157
    }
158
    
159
    /**
133
    /**
160
     * @return The event thread queuer.
134
     * @return The event thread queuer.
161
     */
135
     */
Lines 260-266 public class TreeCAPs extends AbstractTreeCAPs { Link Here
260
                    CompSystemConstants.EXTEND_SELECTION_NO);
234
                    CompSystemConstants.EXTEND_SELECTION_NO);
261
235
262
            SwtUtils.waitForDisplayIdle(getTree().getDisplay());
236
            SwtUtils.waitForDisplayIdle(getTree().getDisplay());
263
            CAPUtil.waitBeforeDrop(delayBeforeDrop);
237
            waitBeforeDrop(delayBeforeDrop);
264
            
238
            
265
        } finally {
239
        } finally {
266
            robot.mouseRelease(null, null, dndHelper.getMouseButton());
240
            robot.mouseRelease(null, null, dndHelper.getMouseButton());
Lines 331-337 public class TreeCAPs extends AbstractTreeCAPs { Link Here
331
                    CompSystemConstants.EXTEND_SELECTION_NO);
305
                    CompSystemConstants.EXTEND_SELECTION_NO);
332
306
333
            SwtUtils.waitForDisplayIdle(getTree().getDisplay());
307
            SwtUtils.waitForDisplayIdle(getTree().getDisplay());
334
            CAPUtil.waitBeforeDrop(delayBeforeDrop);
308
            waitBeforeDrop(delayBeforeDrop);
335
        } finally {
309
        } finally {
336
            robot.mouseRelease(null, null, dndHelper.getMouseButton());
310
            robot.mouseRelease(null, null, dndHelper.getMouseButton());
337
            pressOrReleaseModifiers(dndHelper.getModifier(),
311
            pressOrReleaseModifiers(dndHelper.getModifier(),
(-)a/org.eclipse.jubula.rc.swt/src/org/eclipse/jubula/rc/swt/uiadapter/AbstractComponentAdapter.java (+29 lines)
Added Link Here
1
package org.eclipse.jubula.rc.swt.uiadapter;
2
3
import org.eclipse.jubula.rc.common.driver.IRobotFactory;
4
import org.eclipse.jubula.rc.common.uiadapter.interfaces.IComponentAdapter;
5
import org.eclipse.jubula.rc.swt.driver.RobotFactoryConfig;
6
/**
7
 * 
8
 * @author BREDEX GmBH
9
 *
10
 */
11
public abstract class AbstractComponentAdapter implements IComponentAdapter {
12
13
    /** the RobotFactory from the AUT */
14
    private IRobotFactory m_robotFactory;
15
     
16
17
    /**
18
     * Gets the Robot factory. The factory is created once per instance.
19
     *
20
     * @return The Robot factory.
21
     */
22
    public IRobotFactory getRobotFactory() {
23
        if (m_robotFactory == null) {
24
            m_robotFactory = new RobotFactoryConfig().getRobotFactory();
25
        }
26
        return m_robotFactory;
27
    }
28
29
}
(-)a/org.eclipse.jubula.rc.swt/src/org/eclipse/jubula/rc/swt/uiadapter/ListAdapter.java (+208 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2012 BREDEX GmbH.
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
 *     BREDEX GmbH - initial API and implementation 
10
 *******************************************************************************/
11
package org.eclipse.jubula.rc.swt.uiadapter;
12
13
import java.util.ArrayList;
14
15
import org.eclipse.jubula.rc.common.CompSystemConstants;
16
import org.eclipse.jubula.rc.common.driver.ClickOptions;
17
import org.eclipse.jubula.rc.common.driver.IRunnable;
18
import org.eclipse.jubula.rc.common.exception.StepExecutionException;
19
import org.eclipse.jubula.rc.common.implclasses.MatchUtil;
20
import org.eclipse.jubula.rc.common.uiadapter.interfaces.IListAdapter;
21
import org.eclipse.jubula.rc.swt.utils.SwtUtils;
22
import org.eclipse.jubula.tools.objects.event.EventFactory;
23
import org.eclipse.jubula.tools.objects.event.TestErrorEvent;
24
import org.eclipse.swt.graphics.Rectangle;
25
import org.eclipse.swt.widgets.List;
26
/**
27
 * 
28
 * @author BREDEX GmbH
29
 *
30
 */
31
public class ListAdapter extends WidgetAdapter implements IListAdapter {
32
33
    /**  */
34
    private List m_list;
35
    /**
36
     * 
37
     * @param objectToAdapt -
38
     */
39
    public ListAdapter(Object objectToAdapt) {
40
        super(objectToAdapt);
41
        m_list = (List) objectToAdapt;
42
    }
43
44
    /**
45
     * {@inheritDoc}
46
     */
47
    public String getText() {
48
        String[] selected = getSelectedValues();
49
        if (selected.length > 0) {
50
            return selected[0];
51
        }
52
        throw new StepExecutionException("No list item selected", //$NON-NLS-1$
53
            EventFactory.createActionError(TestErrorEvent.NO_SELECTION));
54
    }
55
    
56
    /**
57
     * {@inheritDoc}
58
     */
59
    public int[] getSelectedIndices() {
60
        return (int[])getEventThreadQueuer().invokeAndWait(
61
                "getSelectedIndices", new IRunnable() { //$NON-NLS-1$
62
                    public Object run() {
63
                        return m_list.getSelectionIndices();
64
                    }
65
                });
66
    }
67
    /**
68
     * {@inheritDoc}
69
     */
70
    public void clickOnIndex(Integer i, ClickOptions co) {
71
        final int iVal = i.intValue();
72
        scrollIndexToVisible(iVal);
73
        
74
        final Rectangle clickConstraints = 
75
            (Rectangle)getEventThreadQueuer().invokeAndWait(
76
                "setClickConstraints",  //$NON-NLS-1$
77
                new IRunnable() {
78
79
                    public Object run() throws StepExecutionException {
80
                        Rectangle constraints = new Rectangle(0, 0, 0, 0);
81
                        int displayedItemCount = getDisplayedItemCount();
82
                        int numberBelowTop = 0;
83
                        if (displayedItemCount >= m_list.getItemCount()) {
84
                            numberBelowTop = iVal;
85
                        } else {
86
                            numberBelowTop = Math.max(0, iVal 
87
                                - m_list.getItemCount() + displayedItemCount);
88
                        }
89
                        
90
                        // Set the constraints based on the numberBelowTop
91
                        constraints.height = m_list.getItemHeight();
92
                        constraints.width = m_list.getBounds().width;
93
                        constraints.y += (numberBelowTop * constraints.height);
94
                        // explicitly use list relative bounds here - as e.g. on
95
                        // Mac OS systems list.getClientArea() is not relative
96
                        // see bug 353905
97
                        Rectangle actualListBounds =
98
                            new Rectangle(0, 0, m_list.getClientArea().width, 
99
                                    m_list.getClientArea().height);
100
                        return constraints.intersection(actualListBounds);
101
                    }
102
                });
103
        
104
        // Note that we set scrollToVisible false because we have already done
105
        // the scrolling.
106
        getRobot().click(m_list, clickConstraints, 
107
                co.setScrollToVisible(false));
108
109
    }
110
    /**
111
     * {@inheritDoc}
112
     */
113
    public String[] getSelectedValues() {
114
        return (String[])getEventThreadQueuer().invokeAndWait(
115
                "getSelectedValues", new IRunnable() { //$NON-NLS-1$
116
                    public Object run() {
117
                        return m_list.getSelection();
118
                    }
119
                });
120
    }
121
    /**
122
     * {@inheritDoc}
123
     */
124
    public Integer[] findIndicesOfValues(final String[] values,
125
            final String operator, final String searchType) {
126
        final java.util.List indexList = (java.util.List)
127
                getEventThreadQueuer().invokeAndWait("findIndices", //$NON-NLS-1$
128
                    new IRunnable() {
129
                        public Object run() {
130
                            final int valuesLength = values.length;
131
                            final java.util.List idxList = new ArrayList(
132
                                values.length);
133
                            final int listItemCount = m_list.getItemCount();
134
                            final MatchUtil matchUtil = MatchUtil.getInstance();
135
                            for (int i = 0; i < valuesLength; i++) {
136
                                final String value = values[i];
137
                                for (int j = getStartingIndex(searchType); 
138
                                    j < listItemCount; j++) {
139
                                    
140
                                    final String listItem = m_list.getItem(j);
141
                                    if (matchUtil.match(listItem, value, 
142
                                        operator)) {
143
                                        
144
                                        idxList.add(new Integer(j));
145
                                    }
146
                                }
147
                            }
148
                            return idxList;
149
                        }
150
                    });
151
        Integer[] indices = new Integer[indexList.size()];
152
        indexList.toArray(indices);
153
        return indices;
154
    }
155
156
    /**
157
     * @return  the number of items displayed in the list.
158
     */
159
    private int getDisplayedItemCount() {
160
        return ((Integer)getEventThreadQueuer().invokeAndWait(
161
                "getDisplayedItemCount",  //$NON-NLS-1$
162
                new IRunnable() {
163
164
                public Object run() throws StepExecutionException {
165
                    int listHeight = SwtUtils.getWidgetBounds(m_list).height;
166
                    int itemHeight = m_list.getItemHeight();
167
                    
168
                    return new Integer(listHeight / itemHeight);
169
                }
170
            
171
            })).intValue();
172
    }
173
    
174
    /**
175
     * @param index The index to make visible
176
     */
177
    private void scrollIndexToVisible(final int index) {
178
        getEventThreadQueuer().invokeAndWait(
179
            "scrollIndexToVisible",  //$NON-NLS-1$
180
            new IRunnable() {
181
182
                public Object run() throws StepExecutionException {
183
           
184
                    m_list.setTopIndex(index);
185
186
                    return null;
187
                }
188
            
189
            });
190
    }
191
    /**
192
     * @param searchType Determines where the search begins ("relative" or "absolute")
193
     * @return The index from which to begin a search, based on the search type
194
     *         and (if appropriate) the currently selected cell.
195
     */
196
    private int getStartingIndex(final String searchType) {
197
        int startingIndex = 0;
198
        if (searchType.equalsIgnoreCase(
199
                CompSystemConstants.SEARCH_TYPE_RELATIVE)) {
200
            int [] selectedIndices = getSelectedIndices();
201
            // Start from the last selected item, if any item(s) are selected
202
            if (selectedIndices.length > 0) {
203
                startingIndex = selectedIndices[selectedIndices.length - 1] + 1;
204
            }
205
        }
206
        return startingIndex;
207
    }
208
}
(-)a/org.eclipse.jubula.rc.swt/src/org/eclipse/jubula/rc/swt/uiadapter/MenuAdapter.java (-17 / +2 lines)
Lines 12-23 package org.eclipse.jubula.rc.swt.uiadapter; Link Here
12
12
13
import org.eclipse.jubula.rc.common.driver.IEventThreadQueuer;
13
import org.eclipse.jubula.rc.common.driver.IEventThreadQueuer;
14
import org.eclipse.jubula.rc.common.driver.IRobot;
14
import org.eclipse.jubula.rc.common.driver.IRobot;
15
import org.eclipse.jubula.rc.common.driver.IRobotFactory;
16
import org.eclipse.jubula.rc.common.driver.IRunnable;
15
import org.eclipse.jubula.rc.common.driver.IRunnable;
17
import org.eclipse.jubula.rc.common.exception.RobotException;
16
import org.eclipse.jubula.rc.common.exception.RobotException;
18
import org.eclipse.jubula.rc.common.uiadapter.interfaces.IMenuAdapter;
17
import org.eclipse.jubula.rc.common.uiadapter.interfaces.IMenuAdapter;
19
import org.eclipse.jubula.rc.common.uiadapter.interfaces.IMenuItemAdapter;
18
import org.eclipse.jubula.rc.common.uiadapter.interfaces.IMenuItemAdapter;
20
import org.eclipse.jubula.rc.swt.driver.RobotFactoryConfig;
21
import org.eclipse.swt.widgets.Menu;
19
import org.eclipse.swt.widgets.Menu;
22
import org.eclipse.swt.widgets.MenuItem;
20
import org.eclipse.swt.widgets.MenuItem;
23
21
Lines 26-37 import org.eclipse.swt.widgets.MenuItem; Link Here
26
 * 
24
 * 
27
 * @author BREDEX GmbH
25
 * @author BREDEX GmbH
28
 */
26
 */
29
public class MenuAdapter implements IMenuAdapter {
27
public class MenuAdapter extends AbstractComponentAdapter
28
    implements IMenuAdapter {
30
    /** the Menu from the AUT */
29
    /** the Menu from the AUT */
31
    private Menu m_menu;
30
    private Menu m_menu;
32
    
31
    
33
    /** the RobotFactory from the AUT */
34
    private IRobotFactory m_robotFactory;
35
32
36
    /**
33
    /**
37
     * 
34
     * 
Lines 42-59 public class MenuAdapter implements IMenuAdapter { Link Here
42
    }
39
    }
43
40
44
    /**
41
    /**
45
     * Gets the Robot factory. The factory is created once per instance.
46
     * 
47
     * @return The Robot factory.
48
     */
49
    protected IRobotFactory getRobotFactory() {
50
        if (m_robotFactory == null) {
51
            m_robotFactory = new RobotFactoryConfig().getRobotFactory();
52
        }
53
        return m_robotFactory;
54
    }
55
56
    /**
57
     * Gets the IEventThreadQueuer.
42
     * Gets the IEventThreadQueuer.
58
     * 
43
     * 
59
     * @return The Robot
44
     * @return The Robot
(-)a/org.eclipse.jubula.rc.swt/src/org/eclipse/jubula/rc/swt/uiadapter/MenuItemAdapter.java (-18 / +2 lines)
Lines 16-22 import org.eclipse.jubula.rc.common.driver.IEventThreadQueuer; Link Here
16
import org.eclipse.jubula.rc.common.driver.IRobot;
16
import org.eclipse.jubula.rc.common.driver.IRobot;
17
import org.eclipse.jubula.rc.common.driver.IRobotEventConfirmer;
17
import org.eclipse.jubula.rc.common.driver.IRobotEventConfirmer;
18
import org.eclipse.jubula.rc.common.driver.IRobotEventInterceptor;
18
import org.eclipse.jubula.rc.common.driver.IRobotEventInterceptor;
19
import org.eclipse.jubula.rc.common.driver.IRobotFactory;
20
import org.eclipse.jubula.rc.common.driver.IRunnable;
19
import org.eclipse.jubula.rc.common.driver.IRunnable;
21
import org.eclipse.jubula.rc.common.driver.InterceptorOptions;
20
import org.eclipse.jubula.rc.common.driver.InterceptorOptions;
22
import org.eclipse.jubula.rc.common.exception.RobotException;
21
import org.eclipse.jubula.rc.common.exception.RobotException;
Lines 25-31 import org.eclipse.jubula.rc.common.listener.EventLock; Link Here
25
import org.eclipse.jubula.rc.common.uiadapter.interfaces.IMenuAdapter;
24
import org.eclipse.jubula.rc.common.uiadapter.interfaces.IMenuAdapter;
26
import org.eclipse.jubula.rc.common.uiadapter.interfaces.IMenuItemAdapter;
25
import org.eclipse.jubula.rc.common.uiadapter.interfaces.IMenuItemAdapter;
27
import org.eclipse.jubula.rc.swt.driver.EventThreadQueuerSwtImpl;
26
import org.eclipse.jubula.rc.swt.driver.EventThreadQueuerSwtImpl;
28
import org.eclipse.jubula.rc.swt.driver.RobotFactoryConfig;
29
import org.eclipse.jubula.rc.swt.driver.RobotFactorySwtImpl;
27
import org.eclipse.jubula.rc.swt.driver.RobotFactorySwtImpl;
30
import org.eclipse.jubula.rc.swt.driver.SelectionSwtEventMatcher;
28
import org.eclipse.jubula.rc.swt.driver.SelectionSwtEventMatcher;
31
import org.eclipse.jubula.rc.swt.driver.ShowSwtEventMatcher;
29
import org.eclipse.jubula.rc.swt.driver.ShowSwtEventMatcher;
Lines 47-61 import org.eclipse.swt.widgets.MenuItem; Link Here
47
 * 
45
 * 
48
 *  @author BREDEX GmbH
46
 *  @author BREDEX GmbH
49
 */
47
 */
50
public class MenuItemAdapter implements IMenuItemAdapter {
48
public class MenuItemAdapter extends AbstractComponentAdapter
49
    implements IMenuItemAdapter {
51
50
52
    /** the MenuItem from the AUT*/
51
    /** the MenuItem from the AUT*/
53
    private MenuItem m_menuItem;
52
    private MenuItem m_menuItem;
54
    
53
    
55
54
56
    /** the RobotFactory from the AUT */
57
    private IRobotFactory m_robotFactory;
58
59
    /**
55
    /**
60
     * 
56
     * 
61
     * @param component graphics component which will be adapted
57
     * @param component graphics component which will be adapted
Lines 66-83 public class MenuItemAdapter implements IMenuItemAdapter { Link Here
66
    }
62
    }
67
    
63
    
68
    /**
64
    /**
69
     * Gets the Robot factory. The factory is created once per instance.
70
     * 
71
     * @return The Robot factory.
72
     */
73
    protected IRobotFactory getRobotFactory() {
74
        if (m_robotFactory == null) {
75
            m_robotFactory = new RobotFactoryConfig().getRobotFactory();
76
        }
77
        return m_robotFactory;
78
    }
79
80
    /**
81
     * Gets the IEventThreadQueuer.
65
     * Gets the IEventThreadQueuer.
82
     * 
66
     * 
83
     * @return The Robot
67
     * @return The Robot
(-)a/org.eclipse.jubula.rc.swt/src/org/eclipse/jubula/rc/swt/uiadapter/TableAdapter.java (+8 lines)
Lines 523-526 public class TableAdapter extends WidgetAdapter implements ITableAdapter { Link Here
523
        
523
        
524
        return SwtUtils.getCursorControl();
524
        return SwtUtils.getCursorControl();
525
    }
525
    }
526
527
    /**
528
     * {@inheritDoc}
529
     */
530
    public String getText() {
531
        final Cell selectedCell = getSelectedCell();
532
        return getCellText(selectedCell.getRow(), selectedCell.getCol());
533
    }
526
}
534
}
(-)a/org.eclipse.jubula.rc.swt/src/org/eclipse/jubula/rc/swt/uiadapter/WidgetAdapter.java (-19 / +14 lines)
Lines 11-31 Link Here
11
package org.eclipse.jubula.rc.swt.uiadapter;
11
package org.eclipse.jubula.rc.swt.uiadapter;
12
12
13
import org.eclipse.jubula.rc.common.caps.AbstractMenuCAPs;
13
import org.eclipse.jubula.rc.common.caps.AbstractMenuCAPs;
14
import org.eclipse.jubula.rc.common.caps.AbstractWidgetCAPs;
14
import org.eclipse.jubula.rc.common.driver.ClickOptions;
15
import org.eclipse.jubula.rc.common.driver.ClickOptions;
15
import org.eclipse.jubula.rc.common.driver.IEventThreadQueuer;
16
import org.eclipse.jubula.rc.common.driver.IEventThreadQueuer;
16
import org.eclipse.jubula.rc.common.driver.IRobot;
17
import org.eclipse.jubula.rc.common.driver.IRobot;
17
import org.eclipse.jubula.rc.common.driver.IRobotFactory;
18
import org.eclipse.jubula.rc.common.driver.IRunnable;
18
import org.eclipse.jubula.rc.common.driver.IRunnable;
19
import org.eclipse.jubula.rc.common.driver.RobotTiming;
19
import org.eclipse.jubula.rc.common.driver.RobotTiming;
20
import org.eclipse.jubula.rc.common.exception.RobotException;
20
import org.eclipse.jubula.rc.common.exception.RobotException;
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.listener.EventLock;
22
import org.eclipse.jubula.rc.common.listener.EventLock;
23
import org.eclipse.jubula.rc.common.uiadapter.interfaces.IWidgetAdapter;
23
import org.eclipse.jubula.rc.common.uiadapter.interfaces.IWidgetAdapter;
24
import org.eclipse.jubula.rc.swt.driver.KeyCodeConverter;
24
import org.eclipse.jubula.rc.swt.caps.CAPUtil;
25
import org.eclipse.jubula.rc.swt.caps.CAPUtil;
25
import org.eclipse.jubula.rc.swt.caps.MenuCAPs;
26
import org.eclipse.jubula.rc.swt.caps.MenuCAPs;
26
import org.eclipse.jubula.rc.swt.driver.DragAndDropHelperSwt;
27
import org.eclipse.jubula.rc.swt.driver.DragAndDropHelperSwt;
27
import org.eclipse.jubula.rc.swt.driver.EventThreadQueuerSwtImpl;
28
import org.eclipse.jubula.rc.swt.driver.EventThreadQueuerSwtImpl;
28
import org.eclipse.jubula.rc.swt.driver.RobotFactoryConfig;
29
import org.eclipse.jubula.rc.swt.implclasses.EventListener;
29
import org.eclipse.jubula.rc.swt.implclasses.EventListener;
30
import org.eclipse.jubula.rc.swt.implclasses.SimulatedTooltip;
30
import org.eclipse.jubula.rc.swt.implclasses.SimulatedTooltip;
31
import org.eclipse.jubula.rc.swt.utils.SwtUtils;
31
import org.eclipse.jubula.rc.swt.utils.SwtUtils;
Lines 45-61 import org.eclipse.swt.widgets.Widget; Link Here
45
 * 
45
 * 
46
 *  @author BREDEX GmbH
46
 *  @author BREDEX GmbH
47
 */
47
 */
48
public abstract class WidgetAdapter implements IWidgetAdapter {
48
public abstract class WidgetAdapter extends AbstractComponentAdapter
49
    implements IWidgetAdapter {
49
    
50
    
50
    /** constants for communication */
51
    /** constants for communication */
51
    protected static final String POS_UNIT_PIXEL = "Pixel"; //$NON-NLS-1$
52
    protected static final String POS_UNIT_PIXEL = "Pixel"; //$NON-NLS-1$
52
    /** constants for communication */
53
    /** constants for communication */
53
    protected static final String POS_UNI_PERCENT = "Percent"; //$NON-NLS-1$
54
    protected static final String POS_UNI_PERCENT = "Percent"; //$NON-NLS-1$
54
55
55
56
 
56
    /** the RobotFactory from the AUT */
57
    private IRobotFactory m_robotFactory;
58
     
59
    /**   */
57
    /**   */
60
    private Control m_component;
58
    private Control m_component;
61
    
59
    
Lines 109-125 public abstract class WidgetAdapter implements IWidgetAdapter { Link Here
109
        return m_component;
107
        return m_component;
110
    }
108
    }
111
    
109
    
112
    /**
110
113
     * Gets the Robot factory. The factory is created once per instance.
114
     *
115
     * @return The Robot factory.
116
     */
117
    protected IRobotFactory getRobotFactory() {
118
        if (m_robotFactory == null) {
119
            m_robotFactory = new RobotFactoryConfig().getRobotFactory();
120
        }
121
        return m_robotFactory;
122
    }
123
    /**
111
    /**
124
     * Gets the Robot
112
     * Gets the Robot
125
     *
113
     *
Lines 396-402 public abstract class WidgetAdapter implements IWidgetAdapter { Link Here
396
                }            
384
                }            
397
            });
385
            });
398
            
386
            
399
            CAPUtil.waitBeforeDrop(delayBeforeDrop);
387
            AbstractWidgetCAPs.waitBeforeDrop(delayBeforeDrop);
400
        } finally {
388
        } finally {
401
            getRobot().mouseRelease(null, null, mouseButton);
389
            getRobot().mouseRelease(null, null, mouseButton);
402
            CAPUtil.pressOrReleaseModifiers(modifier, false);
390
            CAPUtil.pressOrReleaseModifiers(modifier, false);
Lines 424-427 public abstract class WidgetAdapter implements IWidgetAdapter { Link Here
424
                        button), xPos, xUnits.equalsIgnoreCase(POS_UNIT_PIXEL),
412
                        button), xPos, xUnits.equalsIgnoreCase(POS_UNIT_PIXEL),
425
                yPos, yUnits.equalsIgnoreCase(POS_UNIT_PIXEL));
413
                yPos, yUnits.equalsIgnoreCase(POS_UNIT_PIXEL));
426
    }
414
    }
415
    
416
    /**
417
     * {@inheritDoc}
418
     */
419
    public int getKeyCode(String mod) {
420
        return KeyCodeConverter.getKeyCode(mod);
421
    }
427
}
422
}
(-)a/org.eclipse.jubula.rc.swt/src/org/eclipse/jubula/rc/swt/uiadapter/factory/SWTAdapterFactory.java (-1 / +5 lines)
Lines 13-23 package org.eclipse.jubula.rc.swt.uiadapter.factory; Link Here
13
import org.eclipse.jubula.rc.common.uiadapter.factory.IUIAdapterFactory;
13
import org.eclipse.jubula.rc.common.uiadapter.factory.IUIAdapterFactory;
14
import org.eclipse.jubula.rc.common.uiadapter.interfaces.IComponentAdapter;
14
import org.eclipse.jubula.rc.common.uiadapter.interfaces.IComponentAdapter;
15
import org.eclipse.jubula.rc.swt.uiadapter.ButtonAdapter;
15
import org.eclipse.jubula.rc.swt.uiadapter.ButtonAdapter;
16
import org.eclipse.jubula.rc.swt.uiadapter.ListAdapter;
16
import org.eclipse.jubula.rc.swt.uiadapter.MenuAdapter;
17
import org.eclipse.jubula.rc.swt.uiadapter.MenuAdapter;
17
import org.eclipse.jubula.rc.swt.uiadapter.MenuItemAdapter;
18
import org.eclipse.jubula.rc.swt.uiadapter.MenuItemAdapter;
18
import org.eclipse.jubula.rc.swt.uiadapter.TableAdapter;
19
import org.eclipse.jubula.rc.swt.uiadapter.TableAdapter;
19
import org.eclipse.jubula.rc.swt.uiadapter.TreeAdapter;
20
import org.eclipse.jubula.rc.swt.uiadapter.TreeAdapter;
20
import org.eclipse.swt.widgets.Button;
21
import org.eclipse.swt.widgets.Button;
22
import org.eclipse.swt.widgets.List;
21
import org.eclipse.swt.widgets.Menu;
23
import org.eclipse.swt.widgets.Menu;
22
import org.eclipse.swt.widgets.MenuItem;
24
import org.eclipse.swt.widgets.MenuItem;
23
import org.eclipse.swt.widgets.Table;
25
import org.eclipse.swt.widgets.Table;
Lines 33-39 public class SWTAdapterFactory implements IUIAdapterFactory { Link Here
33
    /** */
35
    /** */
34
    private static final Class[] SUPPORTEDCLASSES = 
36
    private static final Class[] SUPPORTEDCLASSES = 
35
            new Class[]{Button.class, Menu.class, MenuItem.class, Tree.class,
37
            new Class[]{Button.class, Menu.class, MenuItem.class, Tree.class,
36
                Table.class};
38
                Table.class, List.class};
37
    
39
    
38
    
40
    
39
    /**
41
    /**
Lines 58-63 public class SWTAdapterFactory implements IUIAdapterFactory { Link Here
58
            returnvalue = new TreeAdapter(objectToAdapt);
60
            returnvalue = new TreeAdapter(objectToAdapt);
59
        } else if (objectToAdapt instanceof Table) {
61
        } else if (objectToAdapt instanceof Table) {
60
            returnvalue = new TableAdapter(objectToAdapt);
62
            returnvalue = new TableAdapter(objectToAdapt);
63
        } else if (objectToAdapt instanceof List) {
64
            returnvalue = new ListAdapter(objectToAdapt);
61
        }
65
        }
62
        
66
        
63
        
67
        
(-)a/org.eclipse.jubula.toolkit.provider.swing/resources/xml/ComponentConfiguration.xml (-1 / +1 lines)
Lines 48-54 Link Here
48
	
48
	
49
	<toolkitComponent type="javax.swing.JList" visible="false">
49
	<toolkitComponent type="javax.swing.JList" visible="false">
50
		<realizes>guidancer.concrete.List</realizes>
50
		<realizes>guidancer.concrete.List</realizes>
51
		<testerClass>org.eclipse.jubula.rc.swing.swing.implclasses.JListImplClass</testerClass>
51
		<testerClass>org.eclipse.jubula.rc.swing.swing.caps.JListCAPs</testerClass>
52
		<componentClass name="javax.swing.JList" />
52
		<componentClass name="javax.swing.JList" />
53
	</toolkitComponent>
53
	</toolkitComponent>
54
	
54
	
(-)a/org.eclipse.jubula.toolkit.provider.swt/resources/xml/ComponentConfiguration.xml (-2 / +1 lines)
Lines 221-227 Link Here
221
	
221
	
222
	<toolkitComponent type="org.eclipse.swt.widgets.List" visible="false">
222
	<toolkitComponent type="org.eclipse.swt.widgets.List" visible="false">
223
		<realizes>guidancer.concrete.List</realizes>
223
		<realizes>guidancer.concrete.List</realizes>
224
		<testerClass>org.eclipse.jubula.rc.swt.implclasses.ListImplClass</testerClass>
224
		<testerClass>org.eclipse.jubula.rc.swt.caps.ListCAPs</testerClass>
225
		<componentClass name="org.eclipse.swt.widgets.List" />
225
		<componentClass name="org.eclipse.swt.widgets.List" />
226
	</toolkitComponent>
226
	</toolkitComponent>
227
	
227
	
228
- 

Return to bug 394179