Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 223948 Details for
Bug 394179
Enhancement: Refactoring and generalization of the RC Swing and SWT
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Changed List patch
List.patch (text/plain), 111.83 KB, created by
Marvin Mueller
on 2012-11-26 07:02:54 EST
(
hide
)
Description:
Changed List patch
Filename:
MIME Type:
Creator:
Marvin Mueller
Created:
2012-11-26 07:02:54 EST
Size:
111.83 KB
patch
obsolete
>From c7d319babd336e48f4933043def7fd5b9b8b6c14 Mon Sep 17 00:00:00 2001 >From: Marvin Mueller <marvin.mueller@bredex.de> >Date: Fri, 16 Nov 2012 14:15:15 +0100 >Subject: [PATCH 2/3] Sprint Task - Generalize List and also refactoring > bigger parts > >There is a bigger change in the whole structure because the use of the >RobotFactory is generalized. >Also the TextVerifiable is know implemented in a real implementation and not only as dummy implementation. >--- > .../jubula/rc/common/caps/AbstractButtonCAPs.java | 33 +- > .../jubula/rc/common/caps/AbstractListCAPs.java | 476 +++++++++++++++++++++ > .../jubula/rc/common/caps/AbstractTableCAPs.java | 128 +----- > .../rc/common/caps/AbstractTextVerifiable.java | 15 +- > .../jubula/rc/common/caps/AbstractUICAPs.java | 11 +- > .../jubula/rc/common/caps/AbstractWidgetCAPs.java | 45 ++ > .../uiadapter/interfaces/IButtonAdapter.java | 9 +- > .../uiadapter/interfaces/IComponentAdapter.java | 9 + > .../common/uiadapter/interfaces/IListAdapter.java | 52 +++ > .../common/uiadapter/interfaces/ITableAdapter.java | 2 +- > .../uiadapter/interfaces/ITextVerifiable.java | 15 + > .../uiadapter/interfaces/IWidgetAdapter.java | 7 + > .../rc/swing/swing/caps/AbstractButtonCAPs.java | 15 - > .../jubula/rc/swing/swing/caps/JListCAPs.java | 29 ++ > .../jubula/rc/swing/swing/caps/JMenuBarCAPs.java | 20 +- > .../jubula/rc/swing/swing/caps/JTableCAPs.java | 23 - > .../jubula/rc/swing/swing/caps/JTreeCAPs.java | 39 +- > .../swing/uiadapter/AbstractComponentAdapter.java | 28 ++ > .../rc/swing/swing/uiadapter/JListAdapter.java | 243 +++++++++++ > .../rc/swing/swing/uiadapter/JMenuAdapter.java | 3 +- > .../rc/swing/swing/uiadapter/JMenuBarAdapter.java | 3 +- > .../rc/swing/swing/uiadapter/JMenuItemAdapter.java | 19 +- > .../swing/swing/uiadapter/JPopupMenuAdapter.java | 3 +- > .../rc/swing/swing/uiadapter/JTableAdapter.java | 8 + > .../rc/swing/swing/uiadapter/WidgetAdapter.java | 27 +- > .../uiadapter/factory/SwingAdapterFactory.java | 8 +- > .../org/eclipse/jubula/rc/swt/caps/ButtonCAPs.java | 19 +- > .../org/eclipse/jubula/rc/swt/caps/CAPUtil.java | 12 - > .../org/eclipse/jubula/rc/swt/caps/ListCAPs.java | 30 ++ > .../org/eclipse/jubula/rc/swt/caps/MenuCAPs.java | 27 +- > .../org/eclipse/jubula/rc/swt/caps/TableCAPs.java | 29 +- > .../org/eclipse/jubula/rc/swt/caps/TreeCAPs.java | 32 +- > .../rc/swt/uiadapter/AbstractComponentAdapter.java | 29 ++ > .../jubula/rc/swt/uiadapter/ListAdapter.java | 208 +++++++++ > .../jubula/rc/swt/uiadapter/MenuAdapter.java | 19 +- > .../jubula/rc/swt/uiadapter/MenuItemAdapter.java | 20 +- > .../jubula/rc/swt/uiadapter/TableAdapter.java | 8 + > .../jubula/rc/swt/uiadapter/WidgetAdapter.java | 33 +- > .../swt/uiadapter/factory/SWTAdapterFactory.java | 6 +- > .../resources/xml/ComponentConfiguration.xml | 2 +- > .../resources/xml/ComponentConfiguration.xml | 2 +- > 41 files changed, 1285 insertions(+), 461 deletions(-) > create mode 100644 org.eclipse.jubula.rc.common/src/org/eclipse/jubula/rc/common/caps/AbstractListCAPs.java > create mode 100644 org.eclipse.jubula.rc.common/src/org/eclipse/jubula/rc/common/uiadapter/interfaces/IListAdapter.java > create mode 100644 org.eclipse.jubula.rc.common/src/org/eclipse/jubula/rc/common/uiadapter/interfaces/ITextVerifiable.java > create mode 100644 org.eclipse.jubula.rc.swing/src/org/eclipse/jubula/rc/swing/swing/caps/JListCAPs.java > create mode 100644 org.eclipse.jubula.rc.swing/src/org/eclipse/jubula/rc/swing/swing/uiadapter/AbstractComponentAdapter.java > create mode 100644 org.eclipse.jubula.rc.swing/src/org/eclipse/jubula/rc/swing/swing/uiadapter/JListAdapter.java > create mode 100644 org.eclipse.jubula.rc.swt/src/org/eclipse/jubula/rc/swt/caps/ListCAPs.java > create mode 100644 org.eclipse.jubula.rc.swt/src/org/eclipse/jubula/rc/swt/uiadapter/AbstractComponentAdapter.java > create mode 100644 org.eclipse.jubula.rc.swt/src/org/eclipse/jubula/rc/swt/uiadapter/ListAdapter.java > >diff --git a/org.eclipse.jubula.rc.common/src/org/eclipse/jubula/rc/common/caps/AbstractButtonCAPs.java b/org.eclipse.jubula.rc.common/src/org/eclipse/jubula/rc/common/caps/AbstractButtonCAPs.java >index 2486836..ab32139 100644 >--- a/org.eclipse.jubula.rc.common/src/org/eclipse/jubula/rc/common/caps/AbstractButtonCAPs.java >+++ b/org.eclipse.jubula.rc.common/src/org/eclipse/jubula/rc/common/caps/AbstractButtonCAPs.java >@@ -22,19 +22,9 @@ import org.eclipse.jubula.rc.common.uiadapter.interfaces.IButtonAdapter; > * @author BREDEX GmbH > * > */ >-public abstract class AbstractButtonCAPs extends AbstractWidgetCAPs { >+public abstract class AbstractButtonCAPs extends AbstractTextVerifiable { > > /** >- * Action to read the value of a JButton to store it in a variable in the >- * Client >- * >- * @param variable the name of the variable >- * @return the text value. >- */ >- public String gdReadValue(String variable) { >- return ((IButtonAdapter) this.getComponent()).getText(); >- } >- /** > * > * @return the IButtonAdapter for the component. > */ >@@ -51,17 +41,7 @@ public abstract class AbstractButtonCAPs extends AbstractWidgetCAPs { > > Verifier.equals(selected, getButtonAdapter().isSelected()); > } >- >- /** >- * Verifies the passed text. >- * >- * @param text The text to verify >- * @param operator The RegEx operator used to verify >- */ >- public void gdVerifyText(String text, String operator) { >- verifyText(text, operator); >- } >- >+ > /** > * Verifies the passed text. > * >@@ -70,14 +50,5 @@ public abstract class AbstractButtonCAPs extends AbstractWidgetCAPs { > public void gdVerifyText(String text) { > gdVerifyText(text, MatchUtil.DEFAULT_OPERATOR); > } >- /** >- * Verifies the passed text. >- * @param text The text to verify >- * @param operator The operator used to verify >- */ >- public void verifyText(String text, String operator) { >- String value = getButtonAdapter().getText(); >- Verifier.match(value, text, operator); >- } > > } >diff --git a/org.eclipse.jubula.rc.common/src/org/eclipse/jubula/rc/common/caps/AbstractListCAPs.java b/org.eclipse.jubula.rc.common/src/org/eclipse/jubula/rc/common/caps/AbstractListCAPs.java >new file mode 100644 >index 0000000..66f2b8c >--- /dev/null >+++ b/org.eclipse.jubula.rc.common/src/org/eclipse/jubula/rc/common/caps/AbstractListCAPs.java >@@ -0,0 +1,476 @@ >+/******************************************************************************* >+ * Copyright (c) 2012 BREDEX GmbH. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * BREDEX GmbH - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.jubula.rc.common.caps; >+ >+import java.util.Arrays; >+ >+import org.apache.commons.lang.ArrayUtils; >+import org.apache.commons.lang.StringUtils; >+import org.eclipse.jubula.rc.common.CompSystemConstants; >+import org.eclipse.jubula.rc.common.driver.ClickOptions; >+import org.eclipse.jubula.rc.common.driver.DragAndDropHelper; >+import org.eclipse.jubula.rc.common.exception.StepExecutionException; >+import org.eclipse.jubula.rc.common.implclasses.IndexConverter; >+import org.eclipse.jubula.rc.common.implclasses.ListSelectionVerifier; >+import org.eclipse.jubula.rc.common.implclasses.MatchUtil; >+import org.eclipse.jubula.rc.common.implclasses.Verifier; >+import org.eclipse.jubula.rc.common.uiadapter.interfaces.IListAdapter; >+import org.eclipse.jubula.tools.constants.StringConstants; >+import org.eclipse.jubula.tools.constants.TestDataConstants; >+import org.eclipse.jubula.tools.objects.event.EventFactory; >+import org.eclipse.jubula.tools.objects.event.TestErrorEvent; >+import org.eclipse.jubula.tools.utils.StringParsing; >+ >+/** >+ * >+ * @author BREDEX GmbH >+ * >+ */ >+public abstract class AbstractListCAPs extends AbstractTextVerifiable { >+ >+ /** The default separator for enumerations of list values. */ >+ public static final char INDEX_LIST_SEP_CHAR = >+ TestDataConstants.VALUE_CHAR_DEFAULT; >+ //FIXME this should be in an upper class or Util >+ /** The default separator of a list of values */ >+ public static final char VALUE_SEPARATOR = >+ TestDataConstants.VALUE_CHAR_DEFAULT; >+ >+ /** >+ * Splits the enumeration of values. >+ * @param values The values to split >+ * @param separator The separator, may be <code>null</code> >+ * @return The array of values >+ */ >+ private String[] split(String values, String separator) { >+ String[] list = StringParsing.splitToArray(values, ((separator == null) >+ || (separator.length() == 0) ? INDEX_LIST_SEP_CHAR >+ : separator.charAt(0)), >+ TestDataConstants.ESCAPE_CHAR_DEFAULT); >+ list = StringUtils.stripAll(list); >+ return list; >+ } >+ >+ /** >+ * @return The array of selected indices >+ * @throws StepExecutionException If there are no indices selected >+ */ >+ private int[] getCheckedSelectedIndices() throws StepExecutionException { >+ int[] selected = getListAdapter().getSelectedIndices(); >+ if (selected.length == 0) { >+ throw new StepExecutionException("No list element selected", //$NON-NLS-1$ >+ EventFactory.createActionError(TestErrorEvent.NO_SELECTION)); >+ } >+ return selected; >+ } >+ >+ /** >+ * >+ * @return the List Adapter >+ */ >+ private IListAdapter getListAdapter() { >+ return ((IListAdapter) getComponent()); >+ } >+ >+ /** >+ * Verifies if the passed index is selected. >+ * >+ * @param index The index to verify >+ * @param expectSelected Whether the index should be selected. >+ */ >+ public void gdVerifySelectedIndex(String index, boolean expectSelected) { >+ int[] selected = getCheckedSelectedIndices(); >+ int implIndex = IndexConverter.toImplementationIndex( >+ Integer.parseInt(index)); >+ >+ boolean isSelected = ArrayUtils.contains(selected, implIndex); >+ if (expectSelected != isSelected) { >+ throw new StepExecutionException( >+ "Selection check failed for index: " + index, //$NON-NLS-1$ >+ EventFactory.createVerifyFailed( >+ String.valueOf(expectSelected), >+ String.valueOf(isSelected))); >+ } >+ } >+ >+ /** >+ * Verifies if the passed value or enumeration of values is selected. By >+ * default, the enumeration separator is <code>,</code> >+ * @param valueList The value or list of values to verify >+ */ >+ public void gdVerifySelectedValue(String valueList) { >+ gdVerifySelectedValue(valueList, MatchUtil.DEFAULT_OPERATOR, true); >+ } >+ >+ /** >+ * Verifies if the passed value is selected. >+ * >+ * @param value The value to verify >+ * @param operator The operator to use when comparing the >+ * expected and actual values. >+ * @param isSelected if the value should be selected or not. >+ */ >+ public void gdVerifySelectedValue(String value, String operator, >+ boolean isSelected) { >+ >+ final String[] current = getListAdapter().getSelectedValues(); >+ final ListSelectionVerifier listSelVerifier = >+ new ListSelectionVerifier(); >+ for (int i = 0; i < current.length; i++) { >+ listSelVerifier.addItem(i, current[i], true); >+ } >+ listSelVerifier.verifySelection(value, operator, isSelected); >+ } >+ >+ /** >+ * Verifies if all selected elements of a list match a text. >+ * @param text The text to verify >+ * @param operator The operator used to verify >+ */ >+ public void gdVerifyText(String text, String operator) { >+ String[] selected = getListAdapter().getSelectedValues(); >+ final int selCount = selected.length; >+ if (selCount < 1) { >+ throw new StepExecutionException("No selection", //$NON-NLS-1$ >+ EventFactory.createActionError(TestErrorEvent.NO_SELECTION)); >+ } >+ for (int i = 0; i < selCount; i++) { >+ Verifier.match(selected[i], text, operator); >+ } >+ } >+ >+ /** >+ * Selects the passed index or enumeration of indices. The enumeration must >+ * be separated by <code>,</code>, e.g. <code>1, 3,6</code>. >+ * @param indexList The index or indices to select >+ * @param extendSelection Whether this selection extends a previous >+ * selection. >+ * @param button what mouse button should be used >+ */ >+ public void gdSelectIndex(String indexList, final String extendSelection, >+ int button) { >+ final boolean isExtendSelection = extendSelection >+ .equals(CompSystemConstants.EXTEND_SELECTION_YES); >+ selectIndices(IndexConverter >+ .toImplementationIndices(parseIndices(indexList)), ClickOptions >+ .create().setClickCount(1).setMouseButton(button), >+ isExtendSelection); >+ } >+ >+ /** >+ * Selects the passed value or enumeration of values. By default, the >+ * enumeration separator is <code>,</code>. >+ * @param valueList The value or list of values to select >+ * @param operator If regular expressions are used >+ * @param searchType Determines where the search begins ("relative" or "absolute") >+ * @param extendSelection Whether this selection extends a previous >+ * selection. If <code>true</code>, the first >+ * element will be selected with CONTROL as a >+ * modifier. >+ * @param button what mouse button should be used >+ */ >+ public void gdSelectValue(String valueList, String operator, >+ String searchType, final String extendSelection, int button) { >+ final boolean isExtendSelection = >+ extendSelection.equals(CompSystemConstants.EXTEND_SELECTION_YES); >+ selectValue(valueList, String.valueOf(VALUE_SEPARATOR), operator, >+ searchType, ClickOptions.create() >+ .setClickCount(1) >+ .setMouseButton(button), isExtendSelection); >+ } >+ >+ /** >+ * Selects the passed value or enumeration of values. By default, the >+ * enumeration separator is <code>,</code>, but may be changed by >+ * <code>separator</code>. >+ * @param valueList The value or list of values to select >+ * @param separator The separator, optional >+ * @param operator If regular expressions are used >+ * @param searchType Determines where the search begins ("relative" or "absolute") >+ * @param clickCount the amount of clicks to use >+ * @param extendSelection Whether this selection extends a previous >+ * selection. >+ */ >+ public void gdSelectValue(String valueList, String separator, >+ String operator, final String searchType, int clickCount, >+ final String extendSelection) { >+ final boolean isExtendSelection = >+ extendSelection.equals(CompSystemConstants.EXTEND_SELECTION_YES); >+ selectValue(valueList, separator, operator, searchType, ClickOptions >+ .create().setClickCount(clickCount), isExtendSelection); >+ } >+ >+ /** >+ * Verifies if the list contains an element that renderes <code>value</code>. >+ * @param value The text to verify >+ */ >+ public void gdVerifyContainsValue(String value) { >+ Verifier.equals(true, containsValue(value)); >+ } >+ >+ /** >+ * Verifies if the list contains an element that renderes <code>value</code>. >+ * @param value The text to verify >+ * @param operator The operator used to verify >+ * @param exists if the wanted value should exist or not. >+ */ >+ public void gdVerifyContainsValue(String value, String operator, >+ boolean exists) { >+ >+ Verifier.equals(exists, containsValue(value, operator)); >+ } >+ >+ /** >+ * Action to read the value of the current selected item of the JList >+ * to store it in a variable in the Client >+ * @param variable the name of the variable >+ * @return the text value. >+ */ >+ public String gdReadValue(String variable) { >+ String[] selected = getListAdapter().getSelectedValues(); >+ if (selected.length > 0) { >+ return selected[0]; >+ } >+ throw new StepExecutionException("No list item selected", //$NON-NLS-1$ >+ EventFactory.createActionError(TestErrorEvent.NO_SELECTION)); >+ } >+ >+ /** >+ * Drags the passed value. >+ * >+ * @param mouseButton the mouseButton. >+ * @param modifier the modifier. >+ * @param value The value to drag >+ * @param operator If regular expressions are used >+ * @param searchType Determines where the search begins ("relative" or "absolute") >+ */ >+ public void gdDragValue(int mouseButton, String modifier, String value, >+ String operator, final String searchType) { >+ >+ DragAndDropHelper dndHelper = DragAndDropHelper.getInstance(); >+ dndHelper.setModifier(modifier); >+ dndHelper.setMouseButton(mouseButton); >+ >+ Integer [] indices = getListAdapter().findIndicesOfValues( >+ new String [] {value}, operator, searchType); >+ selectIndices(ArrayUtils.toPrimitive(indices), >+ ClickOptions.create().setClickCount(0), false); >+ >+ pressOrReleaseModifiers(modifier, true); >+ getRobot().mousePress(null, null, mouseButton); >+ } >+ >+ /** >+ * Drops on the passed value. >+ * >+ * @param value The value on which to drop >+ * @param operator If regular expressions are used >+ * @param searchType Determines where the search begins ("relative" or "absolute") >+ * @param delayBeforeDrop the amount of time (in milliseconds) to wait >+ * between moving the mouse to the drop point and >+ * releasing the mouse button >+ */ >+ public void gdDropValue(String value, String operator, >+ final String searchType, int delayBeforeDrop) { >+ >+ DragAndDropHelper dndHelper = DragAndDropHelper.getInstance(); >+ try { >+ Integer [] indices = getListAdapter().findIndicesOfValues( >+ new String [] {value}, operator, searchType); >+ selectIndices(ArrayUtils.toPrimitive(indices), >+ ClickOptions.create().setClickCount(0), false); >+ waitBeforeDrop(delayBeforeDrop); >+ } finally { >+ getRobot().mouseRelease(null, null, dndHelper.getMouseButton()); >+ pressOrReleaseModifiers(dndHelper.getModifier(), false); >+ } >+ } >+ >+ /** >+ * Drags the passed index. >+ * >+ * @param mouseButton the mouseButton. >+ * @param modifier the modifier. >+ * @param index The index to drag >+ */ >+ public void gdDragIndex(final int mouseButton, final String modifier, >+ int index) { >+ >+ DragAndDropHelper dndHelper = DragAndDropHelper.getInstance(); >+ dndHelper.setModifier(modifier); >+ dndHelper.setMouseButton(mouseButton); >+ >+ selectIndices( >+ new int [] {IndexConverter.toImplementationIndex(index)}, >+ ClickOptions.create().setClickCount(0), false); >+ >+ pressOrReleaseModifiers(modifier, true); >+ getRobot().mousePress(null, null, mouseButton); >+ } >+ >+ /** >+ * Drops onto the passed index. >+ * >+ * @param index The index on which to drop >+ * @param delayBeforeDrop the amount of time (in milliseconds) to wait >+ * between moving the mouse to the drop point and >+ * releasing the mouse button >+ */ >+ public void gdDropIndex(final int index, int delayBeforeDrop) { >+ >+ DragAndDropHelper dndHelper = DragAndDropHelper.getInstance(); >+ >+ try { >+ selectIndices( >+ new int [] {IndexConverter.toImplementationIndex(index)}, >+ ClickOptions.create().setClickCount(0), false); >+ waitBeforeDrop(delayBeforeDrop); >+ } finally { >+ getRobot().mouseRelease(null, null, dndHelper.getMouseButton()); >+ pressOrReleaseModifiers(dndHelper.getModifier(), false); >+ } >+ } >+ >+ /** >+ * @param value The value >+ * @return <code>true</code> if the list contains an element that is rendered with <code>value</code> >+ */ >+ public boolean containsValue(String value) { >+ Integer[] indices = getListAdapter().findIndicesOfValues( >+ new String[] { value }, >+ MatchUtil.EQUALS, CompSystemConstants.SEARCH_TYPE_ABSOLUTE); >+ return indices.length > 0; >+ } >+ >+ /** >+ * @param value The value >+ * @param operator The operator used to verify >+ * @return <code>true</code> if the list contains an element that is rendered with <code>value</code> >+ */ >+ public boolean containsValue(String value, String operator) { >+ Integer[] indices = null; >+ if (operator.equals(MatchUtil.NOT_EQUALS)) { >+ indices = getListAdapter().findIndicesOfValues( >+ new String[] { value }, >+ MatchUtil.EQUALS, CompSystemConstants.SEARCH_TYPE_ABSOLUTE); >+ return indices.length == 0; >+ } >+ indices = getListAdapter().findIndicesOfValues(new String[] { value }, >+ operator, CompSystemConstants.SEARCH_TYPE_ABSOLUTE); >+ return indices.length > 0; >+ } >+ >+ /** >+ * Selects the passed value or enumeration of values. By default, the >+ * enumeration separator is <code>,</code>, but may be changed by >+ * <code>separator</code>. >+ * @param valueList The value or list of values to select >+ * @param separator The separator, optional >+ * @param operator If regular expressions are used >+ * @param searchType Determines where the search begins ("relative" or "absolute") >+ * @param co the click options to use >+ * @param isExtendSelection Whether this selection extends a previous >+ * selection. >+ */ >+ private void selectValue(String valueList, String separator, >+ String operator, final String searchType, ClickOptions co, >+ final boolean isExtendSelection) { >+ >+ String[] values = null; >+ if (StringConstants.EMPTY.equals(valueList)) { >+ values = new String[1]; >+ values[0] = StringConstants.EMPTY; >+ } else { >+ values = split(valueList, separator); >+ } >+ Integer[] indices = getListAdapter().findIndicesOfValues(values, >+ operator, searchType); >+ Arrays.sort(indices); >+ if (!operator.equals(MatchUtil.NOT_EQUALS) >+ && (indices.length < values.length)) { >+ throw new StepExecutionException("One or more values not found of set: " //$NON-NLS-1$ >+ + Arrays.asList(values).toString(), >+ EventFactory.createActionError(TestErrorEvent.NOT_FOUND)); >+ } >+ selectIndices(ArrayUtils.toPrimitive(indices), co, isExtendSelection); >+ } >+ >+ /** >+ * Parses the enumeration of indices. >+ * @param indexList The enumeration of indices >+ * @return The array of parsed indices >+ */ >+ private int[] parseIndices(String indexList) { >+ String[] list = StringParsing.splitToArray(indexList, >+ INDEX_LIST_SEP_CHAR, TestDataConstants.ESCAPE_CHAR_DEFAULT); >+ int[] indices = new int[list.length]; >+ for (int i = 0; i < list.length; i++) { >+ indices[i] = IndexConverter.intValue(list[i]); >+ } >+ return indices; >+ } >+ >+ /** >+ * @param indices The indices to select >+ * @param co the click options to use >+ * @param isExtendSelection Whether this selection extends a previous >+ * selection. If <code>true</code>, the first >+ * element will be selected with CONTROL as a >+ * modifier. >+ */ >+ private void selectIndices(int[] indices, ClickOptions co, >+ boolean isExtendSelection) { >+ Object list = getListAdapter().getRealComponent(); >+ if (indices.length > 0) { >+ try { >+ if (isExtendSelection) { >+ getRobot().keyPress(list, >+ getSystemDefaultModifier()); >+ } >+ >+ // first selection >+ getListAdapter().clickOnIndex( >+ new Integer(indices[0]), co); >+ } finally { >+ if (isExtendSelection) { >+ getRobot().keyRelease(list, >+ getSystemDefaultModifier()); >+ } >+ } >+ } >+ try { >+ getRobot().keyPress(list, >+ getSystemDefaultModifier()); >+ // following selections >+ for (int i = 1; i < indices.length; i++) { >+ getListAdapter().clickOnIndex( >+ new Integer(indices[i]), co); >+ } >+ } finally { >+ getRobot().keyRelease(list, >+ getSystemDefaultModifier()); >+ } >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public String[] getTextArrayFromComponent() { >+ return null; >+ } >+ >+ /** >+ * >+ * @return - >+ */ >+ protected abstract int getSystemDefaultModifier(); >+ >+} >diff --git a/org.eclipse.jubula.rc.common/src/org/eclipse/jubula/rc/common/caps/AbstractTableCAPs.java b/org.eclipse.jubula.rc.common/src/org/eclipse/jubula/rc/common/caps/AbstractTableCAPs.java >index 08e40b4..b6411d9 100644 >--- a/org.eclipse.jubula.rc.common/src/org/eclipse/jubula/rc/common/caps/AbstractTableCAPs.java >+++ b/org.eclipse.jubula.rc.common/src/org/eclipse/jubula/rc/common/caps/AbstractTableCAPs.java >@@ -11,12 +11,9 @@ > package org.eclipse.jubula.rc.common.caps; > > import java.awt.Rectangle; >-import java.util.StringTokenizer; >- > import org.eclipse.jubula.rc.common.CompSystemConstants; > import org.eclipse.jubula.rc.common.driver.ClickOptions; > import org.eclipse.jubula.rc.common.driver.DragAndDropHelper; >-import org.eclipse.jubula.rc.common.driver.IRobot; > import org.eclipse.jubula.rc.common.exception.StepExecutionException; > import org.eclipse.jubula.rc.common.implclasses.IndexConverter; > import org.eclipse.jubula.rc.common.implclasses.MatchUtil; >@@ -24,11 +21,9 @@ import org.eclipse.jubula.rc.common.implclasses.Verifier; > import org.eclipse.jubula.rc.common.implclasses.table.Cell; > import org.eclipse.jubula.rc.common.logger.AutServerLogger; > import org.eclipse.jubula.rc.common.uiadapter.interfaces.ITableAdapter; >-import org.eclipse.jubula.rc.common.util.KeyStrokeUtil; > import org.eclipse.jubula.tools.constants.InputConstants; > import org.eclipse.jubula.tools.objects.event.EventFactory; > import org.eclipse.jubula.tools.objects.event.TestErrorEvent; >-import org.eclipse.jubula.tools.utils.TimeUtil; > > /** > * General implementation for tables. >@@ -564,17 +559,17 @@ public abstract class AbstractTableCAPs extends AbstractTextInputSupport { > co, extendSelection); > > } >- >- /** >- * Action to read the value of the current selected cell of the JTable >- * to store it in a variable in the Client >- * @param variable the name of the variable >- * @return the text value. >- */ >- public String gdReadValue(String variable) { >- final Cell selectedCell = getTableAdapter().getSelectedCell(); >- return getCellText(selectedCell.getRow(), selectedCell.getCol()); >- } >+//FIXME >+// /** >+// * Action to read the value of the current selected cell of the JTable >+// * to store it in a variable in the Client >+// * @param variable the name of the variable >+// * @return the text value. >+// */ >+// public String gdReadValue(String variable) { >+// final Cell selectedCell = getTableAdapter().getSelectedCell(); >+// return getCellText(selectedCell.getRow(), selectedCell.getCol()); >+// } > > /** > * Action to read the value of the passed cell of the JTable >@@ -956,35 +951,7 @@ public abstract class AbstractTableCAPs extends AbstractTextInputSupport { > return getTableAdapter().getCellText(row, column); > > } >- >- /** >- * Presses or releases the given modifier. >- * @param modifier the modifier. >- * @param press if true, the modifier will be pressed. >- * if false, the modifier will be released. >- */ >- protected void pressOrReleaseModifiers(String modifier, boolean press) { >- final IRobot robot = getRobot(); >- final StringTokenizer modTok = new StringTokenizer( >- KeyStrokeUtil.getModifierString(modifier), " "); //$NON-NLS-1$ >- while (modTok.hasMoreTokens()) { >- final String mod = modTok.nextToken(); >- final int keyCode = getKeyCode(mod); >- if (press) { >- robot.keyPress(null, keyCode); >- } else { >- robot.keyRelease(null, keyCode); >- } >- } >- } >- >- /** >- * Gets the key code for a specific modifier >- * @param mod the modifier >- * @return the integer key code value >- */ >- protected abstract int getKeyCode(String mod); >- >+ > /** > * Checks whether <code>0 <= value < count</code>. > * @param value The value to check. >@@ -1081,16 +1048,7 @@ public abstract class AbstractTableCAPs extends AbstractTextInputSupport { > return true; > } > >- /** >- * Waits the given amount of time. Logs a drop-related error if interrupted. >- * >- * @param delayBeforeDrop the amount of time (in milliseconds) to wait >- * between moving the mouse to the drop point and >- * releasing the mouse button >- */ >- static void waitBeforeDrop(int delayBeforeDrop) { >- TimeUtil.delay(delayBeforeDrop); >- } >+ > > /** > * Sets the specific editor to an replace mode. Means that the next key >@@ -1132,65 +1090,5 @@ public abstract class AbstractTableCAPs extends AbstractTextInputSupport { > */ > protected abstract boolean isMouseOnHeader(); > >- /** >- * Selects the passed row of the JTable. This is actually a selection of the >- * cell <code>(row, 0)</code>. >- * >- * @param row >- * The row >- * @param extendSelection Should this selection be part of a multiple selection >- * @throws StepExecutionException >- * If the row is invalid >- * @deprecated the same as gdSelectCell >- * Will be removed! >- */ >- public void gdSelectRow(int row, String extendSelection) >- throws StepExecutionException { >- // FIXME this is only here for testing purpose (to get all CaA tests running) >- gdSelectCell(String.valueOf(row), MatchUtil.DEFAULT_OPERATOR, "1", //$NON-NLS-1$ >- MatchUtil.DEFAULT_OPERATOR, >- ClickOptions.create().setClickCount(1), extendSelection); >- } >- >- /** >- * Finds the first column which contains the value <code>value</code> >- * in the given row and selects the cell. >- * >- * @param row the row >- * @param value the value >- * @param clickCount the mouse clicks. >- * @param regex search using regex >- * @param extendSelection Should this selection be part of a multiple selection >- * @param searchType Determines where the search begins ("relative" or "absolute") >- * @deprecated Will be removed with gdSelectCellByColValue with String parameter >- * for Row/Column >- */ >- public void gdSelectCellByColValue(int row, final String value, >- final String regex, int clickCount, final String extendSelection, >- final String searchType) { >- // FIXME this is only here for testing purpose (to get all CaA tests running) >- gdSelectCellByColValue(String.valueOf(row), MatchUtil.DEFAULT_OPERATOR, >- value, regex, clickCount, extendSelection, searchType, 1); > >- } >- >- /** >- * Finds the first row which contains the value <code>value</code> >- * in column <code>col</code> and selects this row. >- * @param col the column >- * @param value the value >- * @param clickCount the number of clicks. >- * @param regexOp the regex operator >- * @param extendSelection Should this selection be part of a multiple selection >- * @param searchType Determines where the search begins ("relative" or "absolute") >- * @deprecated Will be removed with gdSelectRowByValue with String parameter >- * for Row/Column >- */ >- public void gdSelectRowByValue(int col, final String value, >- int clickCount, final String regexOp, final String extendSelection, >- final String searchType) { >- // FIXME this is only here for testing purpose (to get all CaA tests running) >- gdSelectRowByValue(String.valueOf(col), MatchUtil.DEFAULT_OPERATOR, >- value, regexOp, clickCount, extendSelection, searchType, 1); >- } > } >\ No newline at end of file >diff --git a/org.eclipse.jubula.rc.common/src/org/eclipse/jubula/rc/common/caps/AbstractTextVerifiable.java b/org.eclipse.jubula.rc.common/src/org/eclipse/jubula/rc/common/caps/AbstractTextVerifiable.java >index bac865d..0dc6e35 100644 >--- a/org.eclipse.jubula.rc.common/src/org/eclipse/jubula/rc/common/caps/AbstractTextVerifiable.java >+++ b/org.eclipse.jubula.rc.common/src/org/eclipse/jubula/rc/common/caps/AbstractTextVerifiable.java >@@ -11,6 +11,8 @@ > package org.eclipse.jubula.rc.common.caps; > > import org.eclipse.jubula.rc.common.exception.StepExecutionException; >+import org.eclipse.jubula.rc.common.implclasses.Verifier; >+import org.eclipse.jubula.rc.common.uiadapter.interfaces.ITextVerifiable; > > /** > * This class represents the general implementation for components >@@ -27,8 +29,9 @@ public abstract class AbstractTextVerifiable extends AbstractWidgetCAPs { > * @param variable the name of the variable > * @return the text value. > */ >- public abstract String gdReadValue(String variable); >- // FIXME this is only a pattern because only Tables uses this at the moment >+ public String gdReadValue(String variable) { >+ return ((ITextVerifiable)getComponent()).getText(); >+ } > > /** > * Verifies the rendered text inside the currently component.<br> >@@ -37,7 +40,9 @@ public abstract class AbstractTextVerifiable extends AbstractWidgetCAPs { > * @param operator The operation used to verify > * @throws StepExecutionException If the rendered text cannot be extracted. > */ >- public abstract void gdVerifyText(String text, String operator) >- throws StepExecutionException; >- // FIXME this is only a pattern because only Tables uses this at the moment >+ public void gdVerifyText(String text, String operator) >+ throws StepExecutionException { >+ Verifier.match(((ITextVerifiable)getComponent()).getText(), text, >+ operator); >+ } > } >diff --git a/org.eclipse.jubula.rc.common/src/org/eclipse/jubula/rc/common/caps/AbstractUICAPs.java b/org.eclipse.jubula.rc.common/src/org/eclipse/jubula/rc/common/caps/AbstractUICAPs.java >index f1aa6a5..6680c38 100644 >--- a/org.eclipse.jubula.rc.common/src/org/eclipse/jubula/rc/common/caps/AbstractUICAPs.java >+++ b/org.eclipse.jubula.rc.common/src/org/eclipse/jubula/rc/common/caps/AbstractUICAPs.java >@@ -27,13 +27,15 @@ import org.eclipse.jubula.rc.common.uiadapter.interfaces.IComponentAdapter; > */ > public abstract class AbstractUICAPs implements IBaseImplementationClass { > >- >- > /** constants for communication */ > protected static final String POS_UNIT_PIXEL = "Pixel"; //$NON-NLS-1$ > > /** constants for communication */ > protected static final String POS_UNI_PERCENT = "Percent"; //$NON-NLS-1$ >+ >+ /** */ >+ private IRobotFactory m_robotFactory; >+ > /** */ > private IComponentAdapter m_component; > >@@ -50,7 +52,10 @@ public abstract class AbstractUICAPs implements IBaseImplementationClass { > * Gets the Robot factory. The factory is created once per instance. > * @return The Robot factory. > */ >- protected abstract IRobotFactory getRobotFactory(); >+ protected IRobotFactory getRobotFactory() { >+ m_robotFactory = m_component.getRobotFactory(); >+ return m_robotFactory; >+ } > > /** > * {@inheritDoc} >diff --git a/org.eclipse.jubula.rc.common/src/org/eclipse/jubula/rc/common/caps/AbstractWidgetCAPs.java b/org.eclipse.jubula.rc.common/src/org/eclipse/jubula/rc/common/caps/AbstractWidgetCAPs.java >index b6c9ea4..888eb8b 100644 >--- a/org.eclipse.jubula.rc.common/src/org/eclipse/jubula/rc/common/caps/AbstractWidgetCAPs.java >+++ b/org.eclipse.jubula.rc.common/src/org/eclipse/jubula/rc/common/caps/AbstractWidgetCAPs.java >@@ -10,12 +10,17 @@ > *******************************************************************************/ > package org.eclipse.jubula.rc.common.caps; > >+import java.util.StringTokenizer; >+ > import org.eclipse.jubula.rc.common.CompSystemConstants; > import org.eclipse.jubula.rc.common.driver.ClickOptions; >+import org.eclipse.jubula.rc.common.driver.IRobot; > import org.eclipse.jubula.rc.common.driver.ClickOptions.ClickModifier; > import org.eclipse.jubula.rc.common.exception.StepExecutionException; > import org.eclipse.jubula.rc.common.implclasses.Verifier; > import org.eclipse.jubula.rc.common.uiadapter.interfaces.IWidgetAdapter; >+import org.eclipse.jubula.rc.common.util.KeyStrokeUtil; >+import org.eclipse.jubula.tools.utils.TimeUtil; > /** > * Implementation of basic functions for a lot of graphics components > * except for context menus and menus. >@@ -482,5 +487,45 @@ public abstract class AbstractWidgetCAPs extends AbstractUICAPs { > getWidgetAdapter().showToolTip(text, textSize, > timePerWord, windowWidth); > } >+ >+ /** >+ * Presses or releases the given modifier. >+ * @param modifier the modifier. >+ * @param press if true, the modifier will be pressed. >+ * if false, the modifier will be released. >+ */ >+ protected void pressOrReleaseModifiers(String modifier, boolean press) { >+ final IRobot robot = getRobot(); >+ final StringTokenizer modTok = new StringTokenizer( >+ KeyStrokeUtil.getModifierString(modifier), " "); //$NON-NLS-1$ >+ while (modTok.hasMoreTokens()) { >+ final String mod = modTok.nextToken(); >+ final int keyCode = getKeyCode(mod); >+ if (press) { >+ robot.keyPress(null, keyCode); >+ } else { >+ robot.keyRelease(null, keyCode); >+ } >+ } >+ } >+ >+ /** >+ * Gets the key code for a specific modifier >+ * @param mod the modifier >+ * @return the integer key code value >+ */ >+ protected int getKeyCode(String mod) { >+ return getWidgetAdapter().getKeyCode(mod); >+ } > >+ /** >+ * Waits the given amount of time. Logs a drop-related error if interrupted. >+ * >+ * @param delayBeforeDrop the amount of time (in milliseconds) to wait >+ * between moving the mouse to the drop point and >+ * releasing the mouse button >+ */ >+ public static void waitBeforeDrop(int delayBeforeDrop) { >+ TimeUtil.delay(delayBeforeDrop); >+ } > } >diff --git a/org.eclipse.jubula.rc.common/src/org/eclipse/jubula/rc/common/uiadapter/interfaces/IButtonAdapter.java b/org.eclipse.jubula.rc.common/src/org/eclipse/jubula/rc/common/uiadapter/interfaces/IButtonAdapter.java >index 3bd260c..cd4bfe6 100644 >--- a/org.eclipse.jubula.rc.common/src/org/eclipse/jubula/rc/common/uiadapter/interfaces/IButtonAdapter.java >+++ b/org.eclipse.jubula.rc.common/src/org/eclipse/jubula/rc/common/uiadapter/interfaces/IButtonAdapter.java >@@ -18,7 +18,7 @@ package org.eclipse.jubula.rc.common.uiadapter.interfaces; > * @author BREDEX GmbH > */ > >-public interface IButtonAdapter extends IWidgetAdapter { >+public interface IButtonAdapter extends ITextVerifiable { > /** > * Gets the text from the button > * @return the text which is saved in the component >@@ -30,12 +30,5 @@ public interface IButtonAdapter extends IWidgetAdapter { > * @return <code>true</code> if the component is selected > */ > public boolean isSelected(); >- /** >- * Action to read the value of a Button to store it in a variable >- * in the Client >- * @param variable the name of the variable >- * @return the text value. >- */ >- public String readValue(String variable); > > } >\ No newline at end of file >diff --git a/org.eclipse.jubula.rc.common/src/org/eclipse/jubula/rc/common/uiadapter/interfaces/IComponentAdapter.java b/org.eclipse.jubula.rc.common/src/org/eclipse/jubula/rc/common/uiadapter/interfaces/IComponentAdapter.java >index 5d2e200..b558099 100644 >--- a/org.eclipse.jubula.rc.common/src/org/eclipse/jubula/rc/common/uiadapter/interfaces/IComponentAdapter.java >+++ b/org.eclipse.jubula.rc.common/src/org/eclipse/jubula/rc/common/uiadapter/interfaces/IComponentAdapter.java >@@ -9,6 +9,9 @@ > * BREDEX GmbH - initial API and implementation > *******************************************************************************/ > package org.eclipse.jubula.rc.common.uiadapter.interfaces; >+ >+import org.eclipse.jubula.rc.common.driver.IRobotFactory; >+ > /** > * This is the main interface for classes which will hold or be the > * component that implement the methods we need for this >@@ -22,5 +25,11 @@ public interface IComponentAdapter { > * @return toolkit specific component > */ > public Object getRealComponent(); >+ >+ /** >+ * Gets the toolkit specific RobotFactory >+ * @return the RobotFactory >+ */ >+ public IRobotFactory getRobotFactory(); > > } >\ No newline at end of file >diff --git a/org.eclipse.jubula.rc.common/src/org/eclipse/jubula/rc/common/uiadapter/interfaces/IListAdapter.java b/org.eclipse.jubula.rc.common/src/org/eclipse/jubula/rc/common/uiadapter/interfaces/IListAdapter.java >new file mode 100644 >index 0000000..97d30ca >--- /dev/null >+++ b/org.eclipse.jubula.rc.common/src/org/eclipse/jubula/rc/common/uiadapter/interfaces/IListAdapter.java >@@ -0,0 +1,52 @@ >+/******************************************************************************* >+ * Copyright (c) 2012 BREDEX GmbH. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * BREDEX GmbH - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.jubula.rc.common.uiadapter.interfaces; >+ >+import org.eclipse.jubula.rc.common.driver.ClickOptions; >+ >+/** >+ * >+ * @author BREDEX GmbH >+ * >+ */ >+public interface IListAdapter extends ITextVerifiable { >+ /** >+ * >+ * @return The array of selected indices >+ */ >+ public int[] getSelectedIndices(); >+ >+ /** >+ * Clicks on the index of the passed list. >+ * @param i The index to click >+ * @param co the click options to use for selecting an index item >+ */ >+ public void clickOnIndex(Integer i, ClickOptions co); >+ >+ /** >+ * @return The array of selected values as the renderer shows them >+ */ >+ public String[] getSelectedValues(); >+ >+ /** >+ * Finds the indices of the list elements that are rendered with the passed values. >+ * @param values The values >+ * @param operator operator to use >+ * @param searchType >+ * Determines where the search begins ("relative" or "absolute") >+ * @return The array of indices. It's length is equal to the length of the >+ * values array, but may contains <code>null</code> elements for >+ * all values that are not found in the list >+ */ >+ public Integer[] findIndicesOfValues(final String[] values, >+ final String operator, final String searchType); >+ >+} >diff --git a/org.eclipse.jubula.rc.common/src/org/eclipse/jubula/rc/common/uiadapter/interfaces/ITableAdapter.java b/org.eclipse.jubula.rc.common/src/org/eclipse/jubula/rc/common/uiadapter/interfaces/ITableAdapter.java >index b645cd5..ab0e657 100644 >--- a/org.eclipse.jubula.rc.common/src/org/eclipse/jubula/rc/common/uiadapter/interfaces/ITableAdapter.java >+++ b/org.eclipse.jubula.rc.common/src/org/eclipse/jubula/rc/common/uiadapter/interfaces/ITableAdapter.java >@@ -20,7 +20,7 @@ import org.eclipse.jubula.rc.common.implclasses.table.Cell; > * > * @author BREDEX GmbH > */ >-public interface ITableAdapter extends IWidgetAdapter { >+public interface ITableAdapter extends ITextVerifiable { > > > /** >diff --git a/org.eclipse.jubula.rc.common/src/org/eclipse/jubula/rc/common/uiadapter/interfaces/ITextVerifiable.java b/org.eclipse.jubula.rc.common/src/org/eclipse/jubula/rc/common/uiadapter/interfaces/ITextVerifiable.java >new file mode 100644 >index 0000000..84d98dc >--- /dev/null >+++ b/org.eclipse.jubula.rc.common/src/org/eclipse/jubula/rc/common/uiadapter/interfaces/ITextVerifiable.java >@@ -0,0 +1,15 @@ >+package org.eclipse.jubula.rc.common.uiadapter.interfaces; >+/** >+ * >+ * @author BREDEX GmbH >+ * >+ */ >+public interface ITextVerifiable extends IWidgetAdapter { >+ >+ /** >+ * Gets the value of the component, or if there are more >+ * than the first selected. >+ * @return the value of the component >+ */ >+ public String getText(); >+} >diff --git a/org.eclipse.jubula.rc.common/src/org/eclipse/jubula/rc/common/uiadapter/interfaces/IWidgetAdapter.java b/org.eclipse.jubula.rc.common/src/org/eclipse/jubula/rc/common/uiadapter/interfaces/IWidgetAdapter.java >index c77f426..04b3605 100644 >--- a/org.eclipse.jubula.rc.common/src/org/eclipse/jubula/rc/common/uiadapter/interfaces/IWidgetAdapter.java >+++ b/org.eclipse.jubula.rc.common/src/org/eclipse/jubula/rc/common/uiadapter/interfaces/IWidgetAdapter.java >@@ -106,5 +106,12 @@ public interface IWidgetAdapter extends IComponentAdapter { > */ > public void gdDrop(int xPos, String xUnits, int yPos, String yUnits, > int delayBeforeDrop); >+ >+ /** >+ * Gets the key code for a specific modifier >+ * @param mod the modifier >+ * @return the integer key code value >+ */ >+ public int getKeyCode(String mod); > > } >\ No newline at end of file >diff --git a/org.eclipse.jubula.rc.swing/src/org/eclipse/jubula/rc/swing/swing/caps/AbstractButtonCAPs.java b/org.eclipse.jubula.rc.swing/src/org/eclipse/jubula/rc/swing/swing/caps/AbstractButtonCAPs.java >index b60f776..1ff29f7 100644 >--- a/org.eclipse.jubula.rc.swing/src/org/eclipse/jubula/rc/swing/swing/caps/AbstractButtonCAPs.java >+++ b/org.eclipse.jubula.rc.swing/src/org/eclipse/jubula/rc/swing/swing/caps/AbstractButtonCAPs.java >@@ -11,9 +11,7 @@ > package org.eclipse.jubula.rc.swing.swing.caps; > > >-import org.eclipse.jubula.rc.common.driver.IRobotFactory; > import org.eclipse.jubula.rc.common.uiadapter.interfaces.IButtonAdapter; >-import org.eclipse.jubula.rc.swing.driver.RobotFactoryConfig; > > /** > * The implementation class for <code>AbstractButton</code> and subclasses. Note >@@ -27,9 +25,6 @@ import org.eclipse.jubula.rc.swing.driver.RobotFactoryConfig; > public class AbstractButtonCAPs > extends org.eclipse.jubula.rc.common.caps.AbstractButtonCAPs { > >- /** Robot Factory*/ >- private IRobotFactory m_robotFactory; >- > /** > * Clicks the button <code>count</code> times. > * >@@ -47,14 +42,4 @@ public class AbstractButtonCAPs > return new String[] { returnvalue.getText() }; > } > >- /** >- * {@inheritDoc} >- */ >- protected IRobotFactory getRobotFactory() { >- if (m_robotFactory == null) { >- m_robotFactory = new RobotFactoryConfig().getRobotFactory(); >- } >- return m_robotFactory; >- } >- > } >\ No newline at end of file >diff --git a/org.eclipse.jubula.rc.swing/src/org/eclipse/jubula/rc/swing/swing/caps/JListCAPs.java b/org.eclipse.jubula.rc.swing/src/org/eclipse/jubula/rc/swing/swing/caps/JListCAPs.java >new file mode 100644 >index 0000000..c8453eb >--- /dev/null >+++ b/org.eclipse.jubula.rc.swing/src/org/eclipse/jubula/rc/swing/swing/caps/JListCAPs.java >@@ -0,0 +1,29 @@ >+/******************************************************************************* >+ * Copyright (c) 2012 BREDEX GmbH. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * BREDEX GmbH - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.jubula.rc.swing.swing.caps; >+ >+import org.eclipse.jubula.rc.common.caps.AbstractListCAPs; >+import org.eclipse.jubula.rc.swing.utils.SwingUtils; >+/** >+ * >+ * @author BREDEX GmbH >+ * >+ */ >+public class JListCAPs extends AbstractListCAPs { >+ >+ /** >+ * {@inheritDoc} >+ */ >+ protected int getSystemDefaultModifier() { >+ return SwingUtils.getSystemDefaultModifier(); >+ } >+ >+} >diff --git a/org.eclipse.jubula.rc.swing/src/org/eclipse/jubula/rc/swing/swing/caps/JMenuBarCAPs.java b/org.eclipse.jubula.rc.swing/src/org/eclipse/jubula/rc/swing/swing/caps/JMenuBarCAPs.java >index a2aa007..aa1d921 100644 >--- a/org.eclipse.jubula.rc.swing/src/org/eclipse/jubula/rc/swing/swing/caps/JMenuBarCAPs.java >+++ b/org.eclipse.jubula.rc.swing/src/org/eclipse/jubula/rc/swing/swing/caps/JMenuBarCAPs.java >@@ -26,12 +26,9 @@ import javax.swing.JPopupMenu; > import javax.swing.MenuElement; > > import org.eclipse.jubula.rc.common.caps.AbstractMenuCAPs; >-import org.eclipse.jubula.rc.common.driver.IRobotFactory; >-import org.eclipse.jubula.rc.common.implclasses.IBaseImplementationClass; > import org.eclipse.jubula.rc.common.uiadapter.interfaces.IComponentAdapter; > import org.eclipse.jubula.rc.common.uiadapter.interfaces.IMenuAdapter; > import org.eclipse.jubula.rc.common.uiadapter.interfaces.IMenuItemAdapter; >-import org.eclipse.jubula.rc.swing.driver.RobotFactoryConfig; > import org.eclipse.jubula.rc.swing.swing.implclasses.WindowHelper; > import org.eclipse.jubula.rc.swing.swing.uiadapter.JMenuItemAdapter; > >@@ -40,21 +37,8 @@ import org.eclipse.jubula.rc.swing.swing.uiadapter.JMenuItemAdapter; > * > * @author BREDEX GmbH > */ >-public class JMenuBarCAPs extends AbstractMenuCAPs >- implements IBaseImplementationClass { >- >- /** The robot factory. */ >- private IRobotFactory m_robotFactory; >- /** >- * {@inheritDoc} >- */ >- protected IRobotFactory getRobotFactory() { >- if (m_robotFactory == null) { >- m_robotFactory = new RobotFactoryConfig().getRobotFactory(); >- } >- return m_robotFactory; >- } >- >+public class JMenuBarCAPs extends AbstractMenuCAPs { >+ > /** > * {@inheritDoc} > */ >diff --git a/org.eclipse.jubula.rc.swing/src/org/eclipse/jubula/rc/swing/swing/caps/JTableCAPs.java b/org.eclipse.jubula.rc.swing/src/org/eclipse/jubula/rc/swing/swing/caps/JTableCAPs.java >index c26754f..a20d36e 100644 >--- a/org.eclipse.jubula.rc.swing/src/org/eclipse/jubula/rc/swing/swing/caps/JTableCAPs.java >+++ b/org.eclipse.jubula.rc.swing/src/org/eclipse/jubula/rc/swing/swing/caps/JTableCAPs.java >@@ -23,13 +23,10 @@ import javax.swing.table.TableColumnModel; > import org.eclipse.jubula.rc.common.caps.AbstractTableCAPs; > import org.eclipse.jubula.rc.common.driver.ClickOptions; > import org.eclipse.jubula.rc.common.driver.IEventThreadQueuer; >-import org.eclipse.jubula.rc.common.driver.IRobotFactory; > import org.eclipse.jubula.rc.common.driver.IRunnable; > import org.eclipse.jubula.rc.common.exception.StepExecutionException; > import org.eclipse.jubula.rc.common.implclasses.table.Cell; > import org.eclipse.jubula.rc.common.logger.AutServerLogger; >-import org.eclipse.jubula.rc.swing.driver.RobotFactoryConfig; >-import org.eclipse.jubula.rc.swing.swing.driver.KeyCodeConverter; > import org.eclipse.jubula.rc.swing.utils.SwingUtils; > /** > * Toolkit specific commands for the <code>JTable</code> >@@ -42,9 +39,6 @@ public class JTableCAPs extends AbstractTableCAPs { > private static AutServerLogger log = new AutServerLogger( > JTableCAPs.class); > >- /** the RobotFactory from the AUT */ >- private IRobotFactory m_robotFactory; >- > /** > * @return the log > */ >@@ -52,15 +46,6 @@ public class JTableCAPs extends AbstractTableCAPs { > return log; > } > >- /** >- * {@inheritDoc} >- */ >- protected IRobotFactory getRobotFactory() { >- if (m_robotFactory == null) { >- m_robotFactory = new RobotFactoryConfig().getRobotFactory(); >- } >- return m_robotFactory; >- } > > /** > * >@@ -202,12 +187,4 @@ public class JTableCAPs extends AbstractTableCAPs { > }); > } > >- >- /** >- * {@inheritDoc} >- */ >- protected int getKeyCode(String key) { >- return KeyCodeConverter.getKeyCode(key); >- } >- > } >diff --git a/org.eclipse.jubula.rc.swing/src/org/eclipse/jubula/rc/swing/swing/caps/JTreeCAPs.java b/org.eclipse.jubula.rc.swing/src/org/eclipse/jubula/rc/swing/swing/caps/JTreeCAPs.java >index 4061446..2c7cd0a 100644 >--- a/org.eclipse.jubula.rc.swing/src/org/eclipse/jubula/rc/swing/swing/caps/JTreeCAPs.java >+++ b/org.eclipse.jubula.rc.swing/src/org/eclipse/jubula/rc/swing/swing/caps/JTreeCAPs.java >@@ -18,13 +18,10 @@ import org.eclipse.jubula.rc.common.CompSystemConstants; > import org.eclipse.jubula.rc.common.caps.AbstractTreeCAPs; > import org.eclipse.jubula.rc.common.driver.DragAndDropHelper; > import org.eclipse.jubula.rc.common.driver.IEventThreadQueuer; >-import org.eclipse.jubula.rc.common.driver.IRobotFactory; > import org.eclipse.jubula.rc.common.driver.IRunnable; > import org.eclipse.jubula.rc.common.exception.StepExecutionException; >-import org.eclipse.jubula.rc.swing.driver.RobotFactoryConfig; > import org.eclipse.jubula.tools.objects.event.EventFactory; > import org.eclipse.jubula.tools.objects.event.TestErrorEvent; >-import org.eclipse.jubula.tools.utils.TimeUtil; > /** > * Toolkit specific commands for the <code>JTree</code> > * >@@ -32,21 +29,7 @@ import org.eclipse.jubula.tools.utils.TimeUtil; > */ > public class JTreeCAPs extends AbstractTreeCAPs { > >- /** Robot Factory*/ >- private IRobotFactory m_robotFactory; >- >- >- /** >- * Waits the given amount of time. Logs a drop-related error if interrupted. >- * >- * @param delayBeforeDrop the amount of time (in milliseconds) to wait >- * between moving the mouse to the drop point and >- * releasing the mouse button >- */ >- static void waitBeforeDrop(int delayBeforeDrop) { >- TimeUtil.delay(delayBeforeDrop); >- } >- >+ > /** > * {@inheritDoc} > */ >@@ -164,26 +147,6 @@ public class JTreeCAPs extends AbstractTreeCAPs { > private JTree getTreeComponent() { > return (JTree) getComponent().getRealComponent(); > } >- >- /** >- * {@inheritDoc} >- */ >- protected IRobotFactory getRobotFactory() { >- if (m_robotFactory == null) { >- m_robotFactory = new RobotFactoryConfig().getRobotFactory(); >- } >- return m_robotFactory; >- } >- >- /** >- * Presses or releases the given modifier. >- * @param modifier the modifier. >- * @param press if true, the modifier will be pressed. >- * if false, the modifier will be released. >- */ >- protected void pressOrReleaseModifiers(String modifier, boolean press) { >- CapUtil.pressOrReleaseModifiers(modifier, press); >- } > > /** > * @return The event thread queuer. >diff --git a/org.eclipse.jubula.rc.swing/src/org/eclipse/jubula/rc/swing/swing/uiadapter/AbstractComponentAdapter.java b/org.eclipse.jubula.rc.swing/src/org/eclipse/jubula/rc/swing/swing/uiadapter/AbstractComponentAdapter.java >new file mode 100644 >index 0000000..eb4aff7 >--- /dev/null >+++ b/org.eclipse.jubula.rc.swing/src/org/eclipse/jubula/rc/swing/swing/uiadapter/AbstractComponentAdapter.java >@@ -0,0 +1,28 @@ >+package org.eclipse.jubula.rc.swing.swing.uiadapter; >+ >+import org.eclipse.jubula.rc.common.driver.IRobotFactory; >+import org.eclipse.jubula.rc.common.uiadapter.interfaces.IComponentAdapter; >+import org.eclipse.jubula.rc.swing.driver.RobotFactoryConfig; >+/** >+ * >+ * @author BREDEX GmbH >+ * >+ */ >+public abstract class AbstractComponentAdapter implements IComponentAdapter { >+ >+ /** the RobotFactory from the AUT */ >+ private IRobotFactory m_robotFactory; >+ >+ /** >+ * Gets the Robot factory. The factory is created once per instance. >+ * >+ * @return The Robot factory. >+ */ >+ public IRobotFactory getRobotFactory() { >+ if (m_robotFactory == null) { >+ m_robotFactory = new RobotFactoryConfig().getRobotFactory(); >+ } >+ return m_robotFactory; >+ } >+ >+} >diff --git a/org.eclipse.jubula.rc.swing/src/org/eclipse/jubula/rc/swing/swing/uiadapter/JListAdapter.java b/org.eclipse.jubula.rc.swing/src/org/eclipse/jubula/rc/swing/swing/uiadapter/JListAdapter.java >new file mode 100644 >index 0000000..48a66c8 >--- /dev/null >+++ b/org.eclipse.jubula.rc.swing/src/org/eclipse/jubula/rc/swing/swing/uiadapter/JListAdapter.java >@@ -0,0 +1,243 @@ >+/******************************************************************************* >+ * Copyright (c) 2012 BREDEX GmbH. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * BREDEX GmbH - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.jubula.rc.swing.swing.uiadapter; >+ >+import java.awt.Component; >+import java.awt.Dimension; >+import java.awt.Rectangle; >+import java.util.HashSet; >+import java.util.Set; >+ >+import javax.swing.JList; >+import javax.swing.ListCellRenderer; >+import javax.swing.ListModel; >+ >+import org.eclipse.jubula.rc.common.CompSystemConstants; >+import org.eclipse.jubula.rc.common.driver.ClickOptions; >+import org.eclipse.jubula.rc.common.driver.IRunnable; >+import org.eclipse.jubula.rc.common.exception.StepExecutionException; >+import org.eclipse.jubula.rc.common.implclasses.MatchUtil; >+import org.eclipse.jubula.rc.common.uiadapter.interfaces.IListAdapter; >+import org.eclipse.jubula.rc.swing.swing.caps.CapUtil; >+import org.eclipse.jubula.rc.swing.swing.implclasses.JComboBoxImplClass; >+import org.eclipse.jubula.tools.objects.event.EventFactory; >+import org.eclipse.jubula.tools.objects.event.TestErrorEvent; >+/** >+ * >+ * @author BREDEX GmbH >+ * >+ */ >+public class JListAdapter extends WidgetAdapter implements IListAdapter { >+ /** */ >+ private JList m_list; >+ >+ /** >+ * >+ * @param objectToAdapt >+ */ >+ public JListAdapter(Object objectToAdapt) { >+ super(objectToAdapt); >+ m_list = (JList) objectToAdapt; >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public String getText() { >+ String[] selected = getSelectedValues(); >+ if (selected.length > 0) { >+ return selected[0]; >+ } >+ throw new StepExecutionException("No list item selected", //$NON-NLS-1$ >+ EventFactory.createActionError(TestErrorEvent.NO_SELECTION)); >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public int[] getSelectedIndices() { >+ return (int[])getEventThreadQueuer().invokeAndWait( >+ "getSelectedIndices", new IRunnable() { //$NON-NLS-1$ >+ public Object run() { >+ return m_list.getSelectedIndices(); >+ } >+ }); >+ } >+ >+ /** >+ * Clicks on the index of the passed list. >+ * >+ * @param i The index to click >+ * @param co the click options to use >+ * @param maxWidth the maximal width which is used to select the item >+ */ >+ public void clickOnIndex(final Integer i, >+ ClickOptions co, double maxWidth) { >+ final int index = i.intValue(); >+ ListModel model = m_list.getModel(); >+ if ((model == null) || (index >= model.getSize()) >+ || (index < 0)) { >+ throw new StepExecutionException("List index '" + i //$NON-NLS-1$ >+ + "' is out of range", //$NON-NLS-1$ >+ EventFactory.createActionError(TestErrorEvent.INVALID_INDEX)); >+ } >+ // Call of JList.ensureIndexIsVisible() is not required, >+ // because the Robot scrolls the click rectangle to visible. >+ Rectangle r = (Rectangle) getRobotFactory().getEventThreadQueuer() >+ .invokeAndWait("getCellBounds", new IRunnable() { //$NON-NLS-1$ >+ >+ public Object run() throws StepExecutionException { >+ return m_list.getCellBounds(index, index); >+ } >+ }); >+ >+ if (r == null) { >+ throw new StepExecutionException( >+ "List index '" + i + "' is not visible", //$NON-NLS-1$ //$NON-NLS-2$ >+ EventFactory.createActionError(TestErrorEvent.NOT_VISIBLE)); >+ } >+ >+ // if possible adjust height and width for items >+ ListCellRenderer lcr = m_list.getCellRenderer(); >+ if (lcr != null) { >+ Component listItem = lcr.getListCellRendererComponent(m_list, model >+ .getElementAt(index), index, false, false); >+ Dimension preferredSize = listItem.getPreferredSize(); >+ r.setSize(preferredSize); >+ } >+ >+ if (maxWidth != JComboBoxImplClass.NO_MAX_WIDTH >+ && r.getWidth() > maxWidth) { >+ Dimension d = new Dimension(); >+ d.setSize(maxWidth, r.getHeight()); >+ r.setSize(d); >+ } >+ >+ getRobot().click(m_list, r, >+ co.setClickType(ClickOptions.ClickType.RELEASED)); >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public String[] getSelectedValues() { >+ final int[] indices = getSelectedIndices(); >+ >+ return (String[])getEventThreadQueuer().invokeAndWait( >+ "getSelectedValues", new IRunnable() { //$NON-NLS-1$ >+ public Object run() { >+ Object[] values = m_list.getSelectedValues(); >+ String[] selected = new String[values.length]; >+ ListCellRenderer renderer = m_list.getCellRenderer(); >+ for (int i = 0; i < values.length; i++) { >+ Object value = values[i]; >+ Component c = renderer.getListCellRendererComponent( >+ m_list, value, indices[i], true, false); >+ selected[i] = CapUtil.getRenderedText(c); >+ } >+ return selected; >+ } >+ }); >+ } >+ /** >+ * {@inheritDoc} >+ */ >+ public Integer[] findIndicesOfValues( >+ final String[] values, final String operator, >+ final String searchType) { >+ >+ final Set indexSet = new HashSet(); >+ getEventThreadQueuer().invokeAndWait("findIndices", //$NON-NLS-1$ >+ new IRunnable() { >+ public Object run() { >+ ListCellRenderer renderer = m_list.getCellRenderer(); >+ ListModel model = m_list.getModel(); >+ for (int i = getStartingIndex(searchType); >+ i < model.getSize(); ++i) { >+ Object obj = model.getElementAt(i); >+ m_list.ensureIndexIsVisible(i); >+ Component comp = renderer >+ .getListCellRendererComponent( >+ m_list, obj, i, false, false); >+ String str = CapUtil.getRenderedText(comp); >+ if (MatchUtil.getInstance(). >+ match(str, values, operator)) { >+ indexSet.add(new Integer(i)); >+ } >+ } >+ return null; // return value is not used >+ } >+ }); >+ >+ Integer[] indices = new Integer[indexSet.size()]; >+ indexSet.toArray(indices); >+ return indices; >+ } >+ >+ /** >+ * Finds the indices of the list elements that are rendered with the passed >+ * values. >+ * >+ * @param values The values >+ * @param operator operator to use >+ * @return The array of indices. It's length is equal to the length of the >+ * values array, but may contains <code>null</code> elements for >+ * all values that are not found in the list >+ */ >+ public Integer[] findIndicesOfValues( >+ final String[] values, final String operator) { >+ >+ return findIndicesOfValues(values, operator, >+ CompSystemConstants.SEARCH_TYPE_ABSOLUTE); >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public boolean containsValue(String value, String operator) { >+ Integer[] indices = null; >+ if (operator.equals(MatchUtil.NOT_EQUALS)) { >+ indices = findIndicesOfValues(new String[] { value }, >+ MatchUtil.EQUALS); >+ return indices.length == 0; >+ } >+ indices = findIndicesOfValues(new String[] { value }, >+ operator); >+ return indices.length > 0; >+ } >+ >+ /** >+ * Clicks on the index of the passed list. >+ * >+ * @param i >+ * The index to click >+ * @param co the click options to use >+ */ >+ public void clickOnIndex(final Integer i, ClickOptions co) { >+ clickOnIndex(i, co, JComboBoxImplClass.NO_MAX_WIDTH); >+ } >+ >+ /** >+ * @param searchType Determines where the search begins ("relative" or "absolute") >+ * @return The index from which to begin a search, based on the search type >+ * and (if appropriate) the currently selected cell. >+ */ >+ private int getStartingIndex(final String searchType) { >+ int startingIndex = 0; >+ if (searchType.equalsIgnoreCase( >+ CompSystemConstants.SEARCH_TYPE_RELATIVE)) { >+ int [] selectedIndices = getSelectedIndices(); >+ // Start from the last selected item >+ startingIndex = selectedIndices[selectedIndices.length - 1] + 1; >+ } >+ return startingIndex; >+ } >+} >diff --git a/org.eclipse.jubula.rc.swing/src/org/eclipse/jubula/rc/swing/swing/uiadapter/JMenuAdapter.java b/org.eclipse.jubula.rc.swing/src/org/eclipse/jubula/rc/swing/swing/uiadapter/JMenuAdapter.java >index 0b3e3b9..1cb35e5 100644 >--- a/org.eclipse.jubula.rc.swing/src/org/eclipse/jubula/rc/swing/swing/uiadapter/JMenuAdapter.java >+++ b/org.eclipse.jubula.rc.swing/src/org/eclipse/jubula/rc/swing/swing/uiadapter/JMenuAdapter.java >@@ -28,7 +28,8 @@ import org.eclipse.jubula.rc.common.uiadapter.interfaces.IMenuItemAdapter; > * @author BREDEX GmbH > * > */ >-public class JMenuAdapter implements IMenuAdapter { >+public class JMenuAdapter extends AbstractComponentAdapter >+ implements IMenuAdapter { > /** The JMenu from the AUT */ > private JMenu m_menu; > >diff --git a/org.eclipse.jubula.rc.swing/src/org/eclipse/jubula/rc/swing/swing/uiadapter/JMenuBarAdapter.java b/org.eclipse.jubula.rc.swing/src/org/eclipse/jubula/rc/swing/swing/uiadapter/JMenuBarAdapter.java >index 5bfb7e4..ba1d33f 100644 >--- a/org.eclipse.jubula.rc.swing/src/org/eclipse/jubula/rc/swing/swing/uiadapter/JMenuBarAdapter.java >+++ b/org.eclipse.jubula.rc.swing/src/org/eclipse/jubula/rc/swing/swing/uiadapter/JMenuBarAdapter.java >@@ -28,7 +28,8 @@ import org.eclipse.jubula.rc.common.uiadapter.interfaces.IMenuItemAdapter; > * @author BREDEX GmbH > * > */ >-public class JMenuBarAdapter implements IMenuAdapter { >+public class JMenuBarAdapter extends AbstractComponentAdapter >+ implements IMenuAdapter { > /** The JMenuBar */ > private JMenuBar m_menuBar; > >diff --git a/org.eclipse.jubula.rc.swing/src/org/eclipse/jubula/rc/swing/swing/uiadapter/JMenuItemAdapter.java b/org.eclipse.jubula.rc.swing/src/org/eclipse/jubula/rc/swing/swing/uiadapter/JMenuItemAdapter.java >index 3ca11f6..dc1ec79 100644 >--- a/org.eclipse.jubula.rc.swing/src/org/eclipse/jubula/rc/swing/swing/uiadapter/JMenuItemAdapter.java >+++ b/org.eclipse.jubula.rc.swing/src/org/eclipse/jubula/rc/swing/swing/uiadapter/JMenuItemAdapter.java >@@ -16,14 +16,12 @@ import javax.swing.JMenuItem; > import org.eclipse.jubula.rc.common.driver.ClickOptions; > import org.eclipse.jubula.rc.common.driver.IEventThreadQueuer; > import org.eclipse.jubula.rc.common.driver.IRobot; >-import org.eclipse.jubula.rc.common.driver.IRobotFactory; > import org.eclipse.jubula.rc.common.driver.IRunnable; > import org.eclipse.jubula.rc.common.driver.RobotTiming; > import org.eclipse.jubula.rc.common.exception.RobotException; > import org.eclipse.jubula.rc.common.exception.StepExecutionException; > import org.eclipse.jubula.rc.common.uiadapter.interfaces.IMenuAdapter; > import org.eclipse.jubula.rc.common.uiadapter.interfaces.IMenuItemAdapter; >-import org.eclipse.jubula.rc.swing.driver.RobotFactoryConfig; > import org.eclipse.jubula.tools.objects.event.EventFactory; > import org.eclipse.jubula.tools.objects.event.TestErrorEvent; > >@@ -32,15 +30,12 @@ import org.eclipse.jubula.tools.objects.event.TestErrorEvent; > * @author BREDEX GmbH > * > */ >-public class JMenuItemAdapter >+public class JMenuItemAdapter extends AbstractComponentAdapter > implements IMenuItemAdapter { > > /** the JMenuItem from the AUT */ > private JMenuItem m_menuItem; > >- /** the RobotFactory from the AUT */ >- private IRobotFactory m_robotFactory; >- > /** > * > * @param objectToAdapt >@@ -48,17 +43,7 @@ public class JMenuItemAdapter > public JMenuItemAdapter(Object objectToAdapt) { > m_menuItem = (JMenuItem) objectToAdapt; > } >- /** >- * Gets the Robot factory. The factory is created once per instance. >- * >- * @return The Robot factory. >- */ >- protected IRobotFactory getRobotFactory() { >- if (m_robotFactory == null) { >- m_robotFactory = new RobotFactoryConfig().getRobotFactory(); >- } >- return m_robotFactory; >- } >+ > /** > * Gets the IEventThreadQueuer. > * >diff --git a/org.eclipse.jubula.rc.swing/src/org/eclipse/jubula/rc/swing/swing/uiadapter/JPopupMenuAdapter.java b/org.eclipse.jubula.rc.swing/src/org/eclipse/jubula/rc/swing/swing/uiadapter/JPopupMenuAdapter.java >index d5ef952..5a5075c 100644 >--- a/org.eclipse.jubula.rc.swing/src/org/eclipse/jubula/rc/swing/swing/uiadapter/JPopupMenuAdapter.java >+++ b/org.eclipse.jubula.rc.swing/src/org/eclipse/jubula/rc/swing/swing/uiadapter/JPopupMenuAdapter.java >@@ -27,7 +27,8 @@ import org.eclipse.jubula.rc.common.uiadapter.interfaces.IMenuItemAdapter; > * @author BREDEX GmbH > * > */ >-public class JPopupMenuAdapter implements IMenuAdapter { >+public class JPopupMenuAdapter extends AbstractComponentAdapter >+ implements IMenuAdapter { > /** */ > private JPopupMenu m_contextMenu; > >diff --git a/org.eclipse.jubula.rc.swing/src/org/eclipse/jubula/rc/swing/swing/uiadapter/JTableAdapter.java b/org.eclipse.jubula.rc.swing/src/org/eclipse/jubula/rc/swing/swing/uiadapter/JTableAdapter.java >index ba11276..50b5461 100644 >--- a/org.eclipse.jubula.rc.swing/src/org/eclipse/jubula/rc/swing/swing/uiadapter/JTableAdapter.java >+++ b/org.eclipse.jubula.rc.swing/src/org/eclipse/jubula/rc/swing/swing/uiadapter/JTableAdapter.java >@@ -374,4 +374,12 @@ public class JTableAdapter extends WidgetAdapter implements ITableAdapter { > getRobot().scrollToVisible(m_table, bounds); > return bounds; > } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public String getText() { >+ final Cell selectedCell = getSelectedCell(); >+ return getCellText(selectedCell.getRow(), selectedCell.getCol()); >+ } > } >diff --git a/org.eclipse.jubula.rc.swing/src/org/eclipse/jubula/rc/swing/swing/uiadapter/WidgetAdapter.java b/org.eclipse.jubula.rc.swing/src/org/eclipse/jubula/rc/swing/swing/uiadapter/WidgetAdapter.java >index 190f1ad..c91b5dc 100644 >--- a/org.eclipse.jubula.rc.swing/src/org/eclipse/jubula/rc/swing/swing/uiadapter/WidgetAdapter.java >+++ b/org.eclipse.jubula.rc.swing/src/org/eclipse/jubula/rc/swing/swing/uiadapter/WidgetAdapter.java >@@ -21,17 +21,16 @@ import org.eclipse.jubula.rc.common.driver.ClickOptions; > import org.eclipse.jubula.rc.common.driver.DragAndDropHelper; > import org.eclipse.jubula.rc.common.driver.IEventThreadQueuer; > import org.eclipse.jubula.rc.common.driver.IRobot; >-import org.eclipse.jubula.rc.common.driver.IRobotFactory; > import org.eclipse.jubula.rc.common.driver.IRunnable; > import org.eclipse.jubula.rc.common.driver.RobotTiming; > import org.eclipse.jubula.rc.common.exception.RobotException; > import org.eclipse.jubula.rc.common.exception.StepExecutionException; > import org.eclipse.jubula.rc.common.listener.EventLock; > import org.eclipse.jubula.rc.common.uiadapter.interfaces.IWidgetAdapter; >-import org.eclipse.jubula.rc.swing.driver.RobotFactoryConfig; > import org.eclipse.jubula.rc.swing.swing.caps.CapUtil; > import org.eclipse.jubula.rc.swing.swing.caps.JMenuBarCAPs; > import org.eclipse.jubula.rc.swing.swing.caps.CapUtil.PopupShownCondition; >+import org.eclipse.jubula.rc.swing.swing.driver.KeyCodeConverter; > import org.eclipse.jubula.rc.swing.swing.implclasses.EventListener; > import org.eclipse.jubula.tools.constants.TimeoutConstants; > import org.eclipse.jubula.tools.i18n.I18n; >@@ -45,15 +44,15 @@ import org.eclipse.jubula.tools.utils.TimeUtil; > * > * @author BREDEX GmbH > */ >-public abstract class WidgetAdapter implements IWidgetAdapter { >+public abstract class WidgetAdapter extends AbstractComponentAdapter >+ implements IWidgetAdapter { > > /** constants for communication */ > protected static final String POS_UNIT_PIXEL = "Pixel"; //$NON-NLS-1$ > /** constants for communication */ > protected static final String POS_UNI_PERCENT = "Percent"; //$NON-NLS-1$ > >- /** the RobotFactory from the AUT */ >- private IRobotFactory m_robotFactory; >+ > > > >@@ -76,17 +75,6 @@ public abstract class WidgetAdapter implements IWidgetAdapter { > } > > /** >- * Gets the Robot factory. The factory is created once per instance. >- * >- * @return The Robot factory. >- */ >- protected IRobotFactory getRobotFactory() { >- if (m_robotFactory == null) { >- m_robotFactory = new RobotFactoryConfig().getRobotFactory(); >- } >- return m_robotFactory; >- } >- /** > * Gets the IEventThreadQueuer. > * > * @return The Robot >@@ -331,4 +319,11 @@ public abstract class WidgetAdapter implements IWidgetAdapter { > xPos, xUnits.equalsIgnoreCase(POS_UNIT_PIXEL), > yPos, yUnits.equalsIgnoreCase(POS_UNIT_PIXEL)); > } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public int getKeyCode(String mod) { >+ return KeyCodeConverter.getKeyCode(mod); >+ } > } >diff --git a/org.eclipse.jubula.rc.swing/src/org/eclipse/jubula/rc/swing/swing/uiadapter/factory/SwingAdapterFactory.java b/org.eclipse.jubula.rc.swing/src/org/eclipse/jubula/rc/swing/swing/uiadapter/factory/SwingAdapterFactory.java >index e043a5b..8584168 100644 >--- a/org.eclipse.jubula.rc.swing/src/org/eclipse/jubula/rc/swing/swing/uiadapter/factory/SwingAdapterFactory.java >+++ b/org.eclipse.jubula.rc.swing/src/org/eclipse/jubula/rc/swing/swing/uiadapter/factory/SwingAdapterFactory.java >@@ -13,6 +13,7 @@ package org.eclipse.jubula.rc.swing.swing.uiadapter.factory; > > import javax.swing.JButton; > import javax.swing.JCheckBox; >+import javax.swing.JList; > import javax.swing.JMenuBar; > import javax.swing.JMenuItem; > import javax.swing.JPopupMenu; >@@ -23,6 +24,7 @@ import javax.swing.JTree; > import org.eclipse.jubula.rc.common.uiadapter.factory.IUIAdapterFactory; > import org.eclipse.jubula.rc.common.uiadapter.interfaces.IComponentAdapter; > import org.eclipse.jubula.rc.swing.swing.uiadapter.AbstractButtonAdapter; >+import org.eclipse.jubula.rc.swing.swing.uiadapter.JListAdapter; > import org.eclipse.jubula.rc.swing.swing.uiadapter.JMenuBarAdapter; > import org.eclipse.jubula.rc.swing.swing.uiadapter.JMenuItemAdapter; > import org.eclipse.jubula.rc.swing.swing.uiadapter.JPopupMenuAdapter; >@@ -45,7 +47,8 @@ public class SwingAdapterFactory implements IUIAdapterFactory { > private static final Class[] SUPPORTEDCLASSES = new Class[] { > JButton.class, JCheckBox.class, JRadioButton.class, > JMenuBar.class, JMenuItem.class, JTree.class , >- JCheckBox.class, JRadioButton.class, JTable.class, JPopupMenu.class}; >+ JCheckBox.class, JRadioButton.class, JTable.class, JPopupMenu.class, >+ JList.class}; > > /** > * {@inheritDoc} >@@ -81,6 +84,9 @@ public class SwingAdapterFactory implements IUIAdapterFactory { > } else if (objectToAdapt instanceof JTable) { > returnvalue = new JTableAdapter(objectToAdapt); > >+ } else if (objectToAdapt instanceof JList) { >+ returnvalue = new JListAdapter(objectToAdapt); >+ > } else if (objectToAdapt instanceof JPopupMenu) { > returnvalue = new JPopupMenuAdapter(objectToAdapt); > >diff --git a/org.eclipse.jubula.rc.swt/src/org/eclipse/jubula/rc/swt/caps/ButtonCAPs.java b/org.eclipse.jubula.rc.swt/src/org/eclipse/jubula/rc/swt/caps/ButtonCAPs.java >index a24ca6d..d7ffdbd 100644 >--- a/org.eclipse.jubula.rc.swt/src/org/eclipse/jubula/rc/swt/caps/ButtonCAPs.java >+++ b/org.eclipse.jubula.rc.swt/src/org/eclipse/jubula/rc/swt/caps/ButtonCAPs.java >@@ -12,9 +12,7 @@ package org.eclipse.jubula.rc.swt.caps; > > > import org.eclipse.jubula.rc.common.caps.AbstractButtonCAPs; >-import org.eclipse.jubula.rc.common.driver.IRobotFactory; > import org.eclipse.jubula.rc.common.uiadapter.interfaces.IButtonAdapter; >-import org.eclipse.jubula.rc.swt.driver.RobotFactoryConfig; > import org.eclipse.jubula.rc.swt.utils.SwtUtils; > > >@@ -24,10 +22,7 @@ import org.eclipse.jubula.rc.swt.utils.SwtUtils; > * @author BREDEX GmbH > */ > public class ButtonCAPs extends AbstractButtonCAPs { >- >- /** The robot factory. */ >- private IRobotFactory m_robotFactory; >- >+ > /** > * {@inheritDoc} > */ >@@ -37,16 +32,4 @@ public class ButtonCAPs extends AbstractButtonCAPs { > ((IButtonAdapter)getComponent()).getText())}; > } > >- /** >- * Gets the Robot factory. The factory is created once per instance. >- * @return The Robot factory. >- */ >- protected IRobotFactory getRobotFactory() { >- if (m_robotFactory == null) { >- m_robotFactory = new RobotFactoryConfig().getRobotFactory(); >- } >- return m_robotFactory; >- } >- >- > } >\ No newline at end of file >diff --git a/org.eclipse.jubula.rc.swt/src/org/eclipse/jubula/rc/swt/caps/CAPUtil.java b/org.eclipse.jubula.rc.swt/src/org/eclipse/jubula/rc/swt/caps/CAPUtil.java >index b1d0361..c8d1f61 100644 >--- a/org.eclipse.jubula.rc.swt/src/org/eclipse/jubula/rc/swt/caps/CAPUtil.java >+++ b/org.eclipse.jubula.rc.swt/src/org/eclipse/jubula/rc/swt/caps/CAPUtil.java >@@ -20,7 +20,6 @@ import org.eclipse.jubula.rc.common.util.KeyStrokeUtil; > import org.eclipse.jubula.rc.swt.driver.KeyCodeConverter; > import org.eclipse.jubula.rc.swt.driver.SwtRobot; > import org.eclipse.jubula.tools.utils.EnvironmentUtils; >-import org.eclipse.jubula.tools.utils.TimeUtil; > import org.eclipse.swt.widgets.Display; > /** > * Util class for some swt specific commands. >@@ -46,17 +45,6 @@ public class CAPUtil { > } > > /** >- * Waits the given amount of time. Logs a drop-related error if interrupted. >- * >- * @param delayBeforeDrop the amount of time (in milliseconds) to wait >- * between moving the mouse to the drop point and >- * releasing the mouse button >- */ >- public static void waitBeforeDrop(int delayBeforeDrop) { >- TimeUtil.delay(delayBeforeDrop); >- } >- >- /** > * Move the mouse pointer from its current position to a few points in > * its proximity. This is used to initiate a drag operation. > * >diff --git a/org.eclipse.jubula.rc.swt/src/org/eclipse/jubula/rc/swt/caps/ListCAPs.java b/org.eclipse.jubula.rc.swt/src/org/eclipse/jubula/rc/swt/caps/ListCAPs.java >new file mode 100644 >index 0000000..c6075b5 >--- /dev/null >+++ b/org.eclipse.jubula.rc.swt/src/org/eclipse/jubula/rc/swt/caps/ListCAPs.java >@@ -0,0 +1,30 @@ >+/******************************************************************************* >+ * Copyright (c) 2012 BREDEX GmbH. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * BREDEX GmbH - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.jubula.rc.swt.caps; >+ >+import org.eclipse.jubula.rc.common.caps.AbstractListCAPs; >+import org.eclipse.jubula.rc.swt.utils.SwtUtils; >+/** >+ * >+ * @author BREDEX GmbH >+ * >+ */ >+public class ListCAPs extends AbstractListCAPs { >+ >+ >+ /** >+ * {@inheritDoc} >+ */ >+ protected int getSystemDefaultModifier() { >+ return SwtUtils.getSystemDefaultModifier(); >+ } >+ >+} >diff --git a/org.eclipse.jubula.rc.swt/src/org/eclipse/jubula/rc/swt/caps/MenuCAPs.java b/org.eclipse.jubula.rc.swt/src/org/eclipse/jubula/rc/swt/caps/MenuCAPs.java >index 77d5271..32e82c8 100644 >--- a/org.eclipse.jubula.rc.swt/src/org/eclipse/jubula/rc/swt/caps/MenuCAPs.java >+++ b/org.eclipse.jubula.rc.swt/src/org/eclipse/jubula/rc/swt/caps/MenuCAPs.java >@@ -13,10 +13,7 @@ package org.eclipse.jubula.rc.swt.caps; > import org.apache.commons.lang.Validate; > import org.eclipse.jubula.rc.common.caps.AbstractMenuCAPs; > import org.eclipse.jubula.rc.common.driver.IEventThreadQueuer; >-import org.eclipse.jubula.rc.common.driver.IRobot; >-import org.eclipse.jubula.rc.common.driver.IRobotFactory; > import org.eclipse.jubula.rc.common.driver.IRunnable; >-import org.eclipse.jubula.rc.common.exception.RobotException; > import org.eclipse.jubula.rc.common.exception.StepExecutionException; > import org.eclipse.jubula.rc.common.implclasses.IBaseImplementationClass; > import org.eclipse.jubula.rc.common.implclasses.MenuUtilBase; >@@ -24,7 +21,6 @@ import org.eclipse.jubula.rc.common.uiadapter.interfaces.IComponentAdapter; > import org.eclipse.jubula.rc.common.uiadapter.interfaces.IMenuAdapter; > import org.eclipse.jubula.rc.common.uiadapter.interfaces.IMenuItemAdapter; > import org.eclipse.jubula.rc.swt.driver.EventThreadQueuerSwtImpl; >-import org.eclipse.jubula.rc.swt.driver.RobotFactoryConfig; > import org.eclipse.jubula.rc.swt.driver.RobotSwtImpl; > import org.eclipse.jubula.rc.swt.uiadapter.MenuItemAdapter; > import org.eclipse.jubula.tools.i18n.I18n; >@@ -43,21 +39,11 @@ import org.eclipse.swt.widgets.Shell; > */ > public class MenuCAPs extends AbstractMenuCAPs > implements IBaseImplementationClass { >- /** the RobotFactory from the AUT */ >- private IRobotFactory m_robotFactory; >+ > > /** Test variable for contextMenus*/ > private boolean m_isCM = false; >- /** >- * Gets the IEventThreadQueuer. >- * >- * @return The Robot >- * @throws RobotException >- * If the Robot cannot be created. >- */ >- protected IRobot getRobot() throws RobotException { >- return getRobotFactory().getRobot(); >- } >+ > > /** > * @return The event thread queuer. >@@ -97,15 +83,6 @@ public class MenuCAPs extends AbstractMenuCAPs > public String[] getTextArrayFromComponent() { > return null; > } >- /** >- * {@inheritDoc} >- */ >- protected IRobotFactory getRobotFactory() { >- if (m_robotFactory == null) { >- m_robotFactory = new RobotFactoryConfig().getRobotFactory(); >- } >- return m_robotFactory; >- } > > /** > * Tries to select a menu item in a menu defined by a Text-Path >diff --git a/org.eclipse.jubula.rc.swt/src/org/eclipse/jubula/rc/swt/caps/TableCAPs.java b/org.eclipse.jubula.rc.swt/src/org/eclipse/jubula/rc/swt/caps/TableCAPs.java >index bbb668f..23d8876 100644 >--- a/org.eclipse.jubula.rc.swt/src/org/eclipse/jubula/rc/swt/caps/TableCAPs.java >+++ b/org.eclipse.jubula.rc.swt/src/org/eclipse/jubula/rc/swt/caps/TableCAPs.java >@@ -18,14 +18,11 @@ import org.eclipse.jubula.rc.common.caps.AbstractTableCAPs; > import org.eclipse.jubula.rc.common.driver.ClickOptions; > import org.eclipse.jubula.rc.common.driver.IEventThreadQueuer; > import org.eclipse.jubula.rc.common.driver.IRobot; >-import org.eclipse.jubula.rc.common.driver.IRobotFactory; > import org.eclipse.jubula.rc.common.driver.IRunnable; > import org.eclipse.jubula.rc.common.exception.StepExecutionException; > import org.eclipse.jubula.rc.common.implclasses.table.Cell; > import org.eclipse.jubula.rc.common.uiadapter.interfaces.ITableAdapter; > import org.eclipse.jubula.rc.swt.driver.DragAndDropHelperSwt; >-import org.eclipse.jubula.rc.swt.driver.KeyCodeConverter; >-import org.eclipse.jubula.rc.swt.driver.RobotFactoryConfig; > import org.eclipse.jubula.rc.swt.uiadapter.TableAdapter; > import org.eclipse.jubula.rc.swt.utils.SwtUtils; > import org.eclipse.jubula.tools.constants.InputConstants; >@@ -48,8 +45,6 @@ import org.eclipse.swt.widgets.Widget; > */ > public class TableCAPs extends AbstractTableCAPs { > >- /** */ >- private IRobotFactory m_robotFactory; > > /** > * Gets the real table component >@@ -75,13 +70,6 @@ public class TableCAPs extends AbstractTableCAPs { > componentTextArray = getTextArrayFromItemArray(itemArray); > return componentTextArray; > } >- >- /** >- * {@inheritDoc} >- */ >- protected int getKeyCode(String mod) { >- return KeyCodeConverter.getKeyCode(mod); >- } > > /** > * {@inheritDoc} >@@ -287,17 +275,6 @@ public class TableCAPs extends AbstractTableCAPs { > > return isOnHeader.booleanValue(); > } >- >- /** >- * {@inheritDoc} >- */ >- protected IRobotFactory getRobotFactory() { >- if (m_robotFactory == null) { >- m_robotFactory = new RobotFactoryConfig().getRobotFactory(); >- } >- return m_robotFactory; >- } >- > > /** > * Returns an array of representation strings that corresponds to the given >@@ -573,7 +550,7 @@ public class TableCAPs extends AbstractTableCAPs { > } > }); > >- CAPUtil.waitBeforeDrop(delayBeforeDrop); >+ waitBeforeDrop(delayBeforeDrop); > > } finally { > robot.mouseRelease(dndHelper.getDragComponent(), null, >@@ -650,7 +627,7 @@ public class TableCAPs extends AbstractTableCAPs { > } > }); > >- CAPUtil.waitBeforeDrop(delayBeforeDrop); >+ waitBeforeDrop(delayBeforeDrop); > > } finally { > robot.mouseRelease(dndHelper.getDragComponent(), null, >@@ -726,7 +703,7 @@ public class TableCAPs extends AbstractTableCAPs { > } > }); > >- CAPUtil.waitBeforeDrop(delayBeforeDrop); >+ waitBeforeDrop(delayBeforeDrop); > > } finally { > robot.mouseRelease(dndHelper.getDragComponent(), null, >diff --git a/org.eclipse.jubula.rc.swt/src/org/eclipse/jubula/rc/swt/caps/TreeCAPs.java b/org.eclipse.jubula.rc.swt/src/org/eclipse/jubula/rc/swt/caps/TreeCAPs.java >index fe9ad1a..c9c535e 100644 >--- a/org.eclipse.jubula.rc.swt/src/org/eclipse/jubula/rc/swt/caps/TreeCAPs.java >+++ b/org.eclipse.jubula.rc.swt/src/org/eclipse/jubula/rc/swt/caps/TreeCAPs.java >@@ -13,15 +13,12 @@ package org.eclipse.jubula.rc.swt.caps; > import java.util.StringTokenizer; > > import org.apache.commons.lang.Validate; >-import org.eclipse.jubula.rc.common.AUTServer; > import org.eclipse.jubula.rc.common.CompSystemConstants; > import org.eclipse.jubula.rc.common.caps.AbstractTreeCAPs; > import org.eclipse.jubula.rc.common.driver.ClickOptions; > import org.eclipse.jubula.rc.common.driver.IEventThreadQueuer; > import org.eclipse.jubula.rc.common.driver.IRobot; >-import org.eclipse.jubula.rc.common.driver.IRobotFactory; > import org.eclipse.jubula.rc.common.driver.IRunnable; >-import org.eclipse.jubula.rc.common.exception.RobotException; > import org.eclipse.jubula.rc.common.exception.StepExecutionException; > import org.eclipse.jubula.rc.common.implclasses.IndexConverter; > import org.eclipse.jubula.rc.common.implclasses.MatchUtil; >@@ -42,7 +39,6 @@ import org.eclipse.jubula.rc.common.implclasses.tree.TreeNodeOperationConstraint > import org.eclipse.jubula.rc.common.util.KeyStrokeUtil; > import org.eclipse.jubula.rc.swt.driver.DragAndDropHelperSwt; > import org.eclipse.jubula.rc.swt.driver.KeyCodeConverter; >-import org.eclipse.jubula.rc.swt.driver.RobotFactoryConfig; > import org.eclipse.jubula.rc.swt.implclasses.TableTreeOperationContext; > import org.eclipse.jubula.rc.swt.implclasses.TreeOperationContext; > import org.eclipse.jubula.rc.swt.implclasses.tree.ToggleCheckboxOperation; >@@ -133,29 +129,7 @@ public class TreeCAPs extends AbstractTreeCAPs { > return m_itemAtPoint; > } > } >- >- /** The robot factory. */ >- private IRobotFactory m_robotFactory; >- >- /** >- * Gets the Robot factory. The factory is created once per instance. >- * @return The Robot factory. >- */ >- protected IRobotFactory getRobotFactory() { >- if (m_robotFactory == null) { >- m_robotFactory = new RobotFactoryConfig().getRobotFactory(); >- } >- return m_robotFactory; >- } >- /** >- * Gets the Robot. >- * @return The Robot >- * @throws RobotException If the Robot cannot be created. >- */ >- protected IRobot getRobot() throws RobotException { >- return AUTServer.getInstance().getRobot(); >- } >- >+ > /** > * @return The event thread queuer. > */ >@@ -260,7 +234,7 @@ public class TreeCAPs extends AbstractTreeCAPs { > CompSystemConstants.EXTEND_SELECTION_NO); > > SwtUtils.waitForDisplayIdle(getTree().getDisplay()); >- CAPUtil.waitBeforeDrop(delayBeforeDrop); >+ waitBeforeDrop(delayBeforeDrop); > > } finally { > robot.mouseRelease(null, null, dndHelper.getMouseButton()); >@@ -331,7 +305,7 @@ public class TreeCAPs extends AbstractTreeCAPs { > CompSystemConstants.EXTEND_SELECTION_NO); > > SwtUtils.waitForDisplayIdle(getTree().getDisplay()); >- CAPUtil.waitBeforeDrop(delayBeforeDrop); >+ waitBeforeDrop(delayBeforeDrop); > } finally { > robot.mouseRelease(null, null, dndHelper.getMouseButton()); > pressOrReleaseModifiers(dndHelper.getModifier(), >diff --git a/org.eclipse.jubula.rc.swt/src/org/eclipse/jubula/rc/swt/uiadapter/AbstractComponentAdapter.java b/org.eclipse.jubula.rc.swt/src/org/eclipse/jubula/rc/swt/uiadapter/AbstractComponentAdapter.java >new file mode 100644 >index 0000000..1fce295 >--- /dev/null >+++ b/org.eclipse.jubula.rc.swt/src/org/eclipse/jubula/rc/swt/uiadapter/AbstractComponentAdapter.java >@@ -0,0 +1,29 @@ >+package org.eclipse.jubula.rc.swt.uiadapter; >+ >+import org.eclipse.jubula.rc.common.driver.IRobotFactory; >+import org.eclipse.jubula.rc.common.uiadapter.interfaces.IComponentAdapter; >+import org.eclipse.jubula.rc.swt.driver.RobotFactoryConfig; >+/** >+ * >+ * @author BREDEX GmBH >+ * >+ */ >+public abstract class AbstractComponentAdapter implements IComponentAdapter { >+ >+ /** the RobotFactory from the AUT */ >+ private IRobotFactory m_robotFactory; >+ >+ >+ /** >+ * Gets the Robot factory. The factory is created once per instance. >+ * >+ * @return The Robot factory. >+ */ >+ public IRobotFactory getRobotFactory() { >+ if (m_robotFactory == null) { >+ m_robotFactory = new RobotFactoryConfig().getRobotFactory(); >+ } >+ return m_robotFactory; >+ } >+ >+} >diff --git a/org.eclipse.jubula.rc.swt/src/org/eclipse/jubula/rc/swt/uiadapter/ListAdapter.java b/org.eclipse.jubula.rc.swt/src/org/eclipse/jubula/rc/swt/uiadapter/ListAdapter.java >new file mode 100644 >index 0000000..2f3deaf >--- /dev/null >+++ b/org.eclipse.jubula.rc.swt/src/org/eclipse/jubula/rc/swt/uiadapter/ListAdapter.java >@@ -0,0 +1,208 @@ >+/******************************************************************************* >+ * Copyright (c) 2012 BREDEX GmbH. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * BREDEX GmbH - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.jubula.rc.swt.uiadapter; >+ >+import java.util.ArrayList; >+ >+import org.eclipse.jubula.rc.common.CompSystemConstants; >+import org.eclipse.jubula.rc.common.driver.ClickOptions; >+import org.eclipse.jubula.rc.common.driver.IRunnable; >+import org.eclipse.jubula.rc.common.exception.StepExecutionException; >+import org.eclipse.jubula.rc.common.implclasses.MatchUtil; >+import org.eclipse.jubula.rc.common.uiadapter.interfaces.IListAdapter; >+import org.eclipse.jubula.rc.swt.utils.SwtUtils; >+import org.eclipse.jubula.tools.objects.event.EventFactory; >+import org.eclipse.jubula.tools.objects.event.TestErrorEvent; >+import org.eclipse.swt.graphics.Rectangle; >+import org.eclipse.swt.widgets.List; >+/** >+ * >+ * @author BREDEX GmbH >+ * >+ */ >+public class ListAdapter extends WidgetAdapter implements IListAdapter { >+ >+ /** */ >+ private List m_list; >+ /** >+ * >+ * @param objectToAdapt - >+ */ >+ public ListAdapter(Object objectToAdapt) { >+ super(objectToAdapt); >+ m_list = (List) objectToAdapt; >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public String getText() { >+ String[] selected = getSelectedValues(); >+ if (selected.length > 0) { >+ return selected[0]; >+ } >+ throw new StepExecutionException("No list item selected", //$NON-NLS-1$ >+ EventFactory.createActionError(TestErrorEvent.NO_SELECTION)); >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public int[] getSelectedIndices() { >+ return (int[])getEventThreadQueuer().invokeAndWait( >+ "getSelectedIndices", new IRunnable() { //$NON-NLS-1$ >+ public Object run() { >+ return m_list.getSelectionIndices(); >+ } >+ }); >+ } >+ /** >+ * {@inheritDoc} >+ */ >+ public void clickOnIndex(Integer i, ClickOptions co) { >+ final int iVal = i.intValue(); >+ scrollIndexToVisible(iVal); >+ >+ final Rectangle clickConstraints = >+ (Rectangle)getEventThreadQueuer().invokeAndWait( >+ "setClickConstraints", //$NON-NLS-1$ >+ new IRunnable() { >+ >+ public Object run() throws StepExecutionException { >+ Rectangle constraints = new Rectangle(0, 0, 0, 0); >+ int displayedItemCount = getDisplayedItemCount(); >+ int numberBelowTop = 0; >+ if (displayedItemCount >= m_list.getItemCount()) { >+ numberBelowTop = iVal; >+ } else { >+ numberBelowTop = Math.max(0, iVal >+ - m_list.getItemCount() + displayedItemCount); >+ } >+ >+ // Set the constraints based on the numberBelowTop >+ constraints.height = m_list.getItemHeight(); >+ constraints.width = m_list.getBounds().width; >+ constraints.y += (numberBelowTop * constraints.height); >+ // explicitly use list relative bounds here - as e.g. on >+ // Mac OS systems list.getClientArea() is not relative >+ // see bug 353905 >+ Rectangle actualListBounds = >+ new Rectangle(0, 0, m_list.getClientArea().width, >+ m_list.getClientArea().height); >+ return constraints.intersection(actualListBounds); >+ } >+ }); >+ >+ // Note that we set scrollToVisible false because we have already done >+ // the scrolling. >+ getRobot().click(m_list, clickConstraints, >+ co.setScrollToVisible(false)); >+ >+ } >+ /** >+ * {@inheritDoc} >+ */ >+ public String[] getSelectedValues() { >+ return (String[])getEventThreadQueuer().invokeAndWait( >+ "getSelectedValues", new IRunnable() { //$NON-NLS-1$ >+ public Object run() { >+ return m_list.getSelection(); >+ } >+ }); >+ } >+ /** >+ * {@inheritDoc} >+ */ >+ public Integer[] findIndicesOfValues(final String[] values, >+ final String operator, final String searchType) { >+ final java.util.List indexList = (java.util.List) >+ getEventThreadQueuer().invokeAndWait("findIndices", //$NON-NLS-1$ >+ new IRunnable() { >+ public Object run() { >+ final int valuesLength = values.length; >+ final java.util.List idxList = new ArrayList( >+ values.length); >+ final int listItemCount = m_list.getItemCount(); >+ final MatchUtil matchUtil = MatchUtil.getInstance(); >+ for (int i = 0; i < valuesLength; i++) { >+ final String value = values[i]; >+ for (int j = getStartingIndex(searchType); >+ j < listItemCount; j++) { >+ >+ final String listItem = m_list.getItem(j); >+ if (matchUtil.match(listItem, value, >+ operator)) { >+ >+ idxList.add(new Integer(j)); >+ } >+ } >+ } >+ return idxList; >+ } >+ }); >+ Integer[] indices = new Integer[indexList.size()]; >+ indexList.toArray(indices); >+ return indices; >+ } >+ >+ /** >+ * @return the number of items displayed in the list. >+ */ >+ private int getDisplayedItemCount() { >+ return ((Integer)getEventThreadQueuer().invokeAndWait( >+ "getDisplayedItemCount", //$NON-NLS-1$ >+ new IRunnable() { >+ >+ public Object run() throws StepExecutionException { >+ int listHeight = SwtUtils.getWidgetBounds(m_list).height; >+ int itemHeight = m_list.getItemHeight(); >+ >+ return new Integer(listHeight / itemHeight); >+ } >+ >+ })).intValue(); >+ } >+ >+ /** >+ * @param index The index to make visible >+ */ >+ private void scrollIndexToVisible(final int index) { >+ getEventThreadQueuer().invokeAndWait( >+ "scrollIndexToVisible", //$NON-NLS-1$ >+ new IRunnable() { >+ >+ public Object run() throws StepExecutionException { >+ >+ m_list.setTopIndex(index); >+ >+ return null; >+ } >+ >+ }); >+ } >+ /** >+ * @param searchType Determines where the search begins ("relative" or "absolute") >+ * @return The index from which to begin a search, based on the search type >+ * and (if appropriate) the currently selected cell. >+ */ >+ private int getStartingIndex(final String searchType) { >+ int startingIndex = 0; >+ if (searchType.equalsIgnoreCase( >+ CompSystemConstants.SEARCH_TYPE_RELATIVE)) { >+ int [] selectedIndices = getSelectedIndices(); >+ // Start from the last selected item, if any item(s) are selected >+ if (selectedIndices.length > 0) { >+ startingIndex = selectedIndices[selectedIndices.length - 1] + 1; >+ } >+ } >+ return startingIndex; >+ } >+} >diff --git a/org.eclipse.jubula.rc.swt/src/org/eclipse/jubula/rc/swt/uiadapter/MenuAdapter.java b/org.eclipse.jubula.rc.swt/src/org/eclipse/jubula/rc/swt/uiadapter/MenuAdapter.java >index c5daae2..7cecbb1 100644 >--- a/org.eclipse.jubula.rc.swt/src/org/eclipse/jubula/rc/swt/uiadapter/MenuAdapter.java >+++ b/org.eclipse.jubula.rc.swt/src/org/eclipse/jubula/rc/swt/uiadapter/MenuAdapter.java >@@ -12,12 +12,10 @@ package org.eclipse.jubula.rc.swt.uiadapter; > > import org.eclipse.jubula.rc.common.driver.IEventThreadQueuer; > import org.eclipse.jubula.rc.common.driver.IRobot; >-import org.eclipse.jubula.rc.common.driver.IRobotFactory; > import org.eclipse.jubula.rc.common.driver.IRunnable; > import org.eclipse.jubula.rc.common.exception.RobotException; > import org.eclipse.jubula.rc.common.uiadapter.interfaces.IMenuAdapter; > import org.eclipse.jubula.rc.common.uiadapter.interfaces.IMenuItemAdapter; >-import org.eclipse.jubula.rc.swt.driver.RobotFactoryConfig; > import org.eclipse.swt.widgets.Menu; > import org.eclipse.swt.widgets.MenuItem; > >@@ -26,12 +24,11 @@ import org.eclipse.swt.widgets.MenuItem; > * > * @author BREDEX GmbH > */ >-public class MenuAdapter implements IMenuAdapter { >+public class MenuAdapter extends AbstractComponentAdapter >+ implements IMenuAdapter { > /** the Menu from the AUT */ > private Menu m_menu; > >- /** the RobotFactory from the AUT */ >- private IRobotFactory m_robotFactory; > > /** > * >@@ -42,18 +39,6 @@ public class MenuAdapter implements IMenuAdapter { > } > > /** >- * Gets the Robot factory. The factory is created once per instance. >- * >- * @return The Robot factory. >- */ >- protected IRobotFactory getRobotFactory() { >- if (m_robotFactory == null) { >- m_robotFactory = new RobotFactoryConfig().getRobotFactory(); >- } >- return m_robotFactory; >- } >- >- /** > * Gets the IEventThreadQueuer. > * > * @return The Robot >diff --git a/org.eclipse.jubula.rc.swt/src/org/eclipse/jubula/rc/swt/uiadapter/MenuItemAdapter.java b/org.eclipse.jubula.rc.swt/src/org/eclipse/jubula/rc/swt/uiadapter/MenuItemAdapter.java >index d9bc73e..bbc1fdf 100644 >--- a/org.eclipse.jubula.rc.swt/src/org/eclipse/jubula/rc/swt/uiadapter/MenuItemAdapter.java >+++ b/org.eclipse.jubula.rc.swt/src/org/eclipse/jubula/rc/swt/uiadapter/MenuItemAdapter.java >@@ -16,7 +16,6 @@ import org.eclipse.jubula.rc.common.driver.IEventThreadQueuer; > import org.eclipse.jubula.rc.common.driver.IRobot; > import org.eclipse.jubula.rc.common.driver.IRobotEventConfirmer; > import org.eclipse.jubula.rc.common.driver.IRobotEventInterceptor; >-import org.eclipse.jubula.rc.common.driver.IRobotFactory; > import org.eclipse.jubula.rc.common.driver.IRunnable; > import org.eclipse.jubula.rc.common.driver.InterceptorOptions; > import org.eclipse.jubula.rc.common.exception.RobotException; >@@ -25,7 +24,6 @@ import org.eclipse.jubula.rc.common.listener.EventLock; > import org.eclipse.jubula.rc.common.uiadapter.interfaces.IMenuAdapter; > import org.eclipse.jubula.rc.common.uiadapter.interfaces.IMenuItemAdapter; > import org.eclipse.jubula.rc.swt.driver.EventThreadQueuerSwtImpl; >-import org.eclipse.jubula.rc.swt.driver.RobotFactoryConfig; > import org.eclipse.jubula.rc.swt.driver.RobotFactorySwtImpl; > import org.eclipse.jubula.rc.swt.driver.SelectionSwtEventMatcher; > import org.eclipse.jubula.rc.swt.driver.ShowSwtEventMatcher; >@@ -47,15 +45,13 @@ import org.eclipse.swt.widgets.MenuItem; > * > * @author BREDEX GmbH > */ >-public class MenuItemAdapter implements IMenuItemAdapter { >+public class MenuItemAdapter extends AbstractComponentAdapter >+ implements IMenuItemAdapter { > > /** the MenuItem from the AUT*/ > private MenuItem m_menuItem; > > >- /** the RobotFactory from the AUT */ >- private IRobotFactory m_robotFactory; >- > /** > * > * @param component graphics component which will be adapted >@@ -66,18 +62,6 @@ public class MenuItemAdapter implements IMenuItemAdapter { > } > > /** >- * Gets the Robot factory. The factory is created once per instance. >- * >- * @return The Robot factory. >- */ >- protected IRobotFactory getRobotFactory() { >- if (m_robotFactory == null) { >- m_robotFactory = new RobotFactoryConfig().getRobotFactory(); >- } >- return m_robotFactory; >- } >- >- /** > * Gets the IEventThreadQueuer. > * > * @return The Robot >diff --git a/org.eclipse.jubula.rc.swt/src/org/eclipse/jubula/rc/swt/uiadapter/TableAdapter.java b/org.eclipse.jubula.rc.swt/src/org/eclipse/jubula/rc/swt/uiadapter/TableAdapter.java >index 0db01aa..a15db03 100644 >--- a/org.eclipse.jubula.rc.swt/src/org/eclipse/jubula/rc/swt/uiadapter/TableAdapter.java >+++ b/org.eclipse.jubula.rc.swt/src/org/eclipse/jubula/rc/swt/uiadapter/TableAdapter.java >@@ -523,4 +523,12 @@ public class TableAdapter extends WidgetAdapter implements ITableAdapter { > > return SwtUtils.getCursorControl(); > } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public String getText() { >+ final Cell selectedCell = getSelectedCell(); >+ return getCellText(selectedCell.getRow(), selectedCell.getCol()); >+ } > } >diff --git a/org.eclipse.jubula.rc.swt/src/org/eclipse/jubula/rc/swt/uiadapter/WidgetAdapter.java b/org.eclipse.jubula.rc.swt/src/org/eclipse/jubula/rc/swt/uiadapter/WidgetAdapter.java >index 6e52073..da7a13a 100644 >--- a/org.eclipse.jubula.rc.swt/src/org/eclipse/jubula/rc/swt/uiadapter/WidgetAdapter.java >+++ b/org.eclipse.jubula.rc.swt/src/org/eclipse/jubula/rc/swt/uiadapter/WidgetAdapter.java >@@ -11,21 +11,21 @@ > package org.eclipse.jubula.rc.swt.uiadapter; > > import org.eclipse.jubula.rc.common.caps.AbstractMenuCAPs; >+import org.eclipse.jubula.rc.common.caps.AbstractWidgetCAPs; > import org.eclipse.jubula.rc.common.driver.ClickOptions; > import org.eclipse.jubula.rc.common.driver.IEventThreadQueuer; > import org.eclipse.jubula.rc.common.driver.IRobot; >-import org.eclipse.jubula.rc.common.driver.IRobotFactory; > import org.eclipse.jubula.rc.common.driver.IRunnable; > import org.eclipse.jubula.rc.common.driver.RobotTiming; > import org.eclipse.jubula.rc.common.exception.RobotException; > import org.eclipse.jubula.rc.common.exception.StepExecutionException; > import org.eclipse.jubula.rc.common.listener.EventLock; > import org.eclipse.jubula.rc.common.uiadapter.interfaces.IWidgetAdapter; >+import org.eclipse.jubula.rc.swt.driver.KeyCodeConverter; > import org.eclipse.jubula.rc.swt.caps.CAPUtil; > import org.eclipse.jubula.rc.swt.caps.MenuCAPs; > import org.eclipse.jubula.rc.swt.driver.DragAndDropHelperSwt; > import org.eclipse.jubula.rc.swt.driver.EventThreadQueuerSwtImpl; >-import org.eclipse.jubula.rc.swt.driver.RobotFactoryConfig; > import org.eclipse.jubula.rc.swt.implclasses.EventListener; > import org.eclipse.jubula.rc.swt.implclasses.SimulatedTooltip; > import org.eclipse.jubula.rc.swt.utils.SwtUtils; >@@ -45,17 +45,15 @@ import org.eclipse.swt.widgets.Widget; > * > * @author BREDEX GmbH > */ >-public abstract class WidgetAdapter implements IWidgetAdapter { >+public abstract class WidgetAdapter extends AbstractComponentAdapter >+ implements IWidgetAdapter { > > /** constants for communication */ > protected static final String POS_UNIT_PIXEL = "Pixel"; //$NON-NLS-1$ > /** constants for communication */ > protected static final String POS_UNI_PERCENT = "Percent"; //$NON-NLS-1$ > >- >- /** the RobotFactory from the AUT */ >- private IRobotFactory m_robotFactory; >- >+ > /** */ > private Control m_component; > >@@ -109,17 +107,7 @@ public abstract class WidgetAdapter implements IWidgetAdapter { > return m_component; > } > >- /** >- * Gets the Robot factory. The factory is created once per instance. >- * >- * @return The Robot factory. >- */ >- protected IRobotFactory getRobotFactory() { >- if (m_robotFactory == null) { >- m_robotFactory = new RobotFactoryConfig().getRobotFactory(); >- } >- return m_robotFactory; >- } >+ > /** > * Gets the Robot > * >@@ -396,7 +384,7 @@ public abstract class WidgetAdapter implements IWidgetAdapter { > } > }); > >- CAPUtil.waitBeforeDrop(delayBeforeDrop); >+ AbstractWidgetCAPs.waitBeforeDrop(delayBeforeDrop); > } finally { > getRobot().mouseRelease(null, null, mouseButton); > CAPUtil.pressOrReleaseModifiers(modifier, false); >@@ -424,4 +412,11 @@ public abstract class WidgetAdapter implements IWidgetAdapter { > button), xPos, xUnits.equalsIgnoreCase(POS_UNIT_PIXEL), > yPos, yUnits.equalsIgnoreCase(POS_UNIT_PIXEL)); > } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public int getKeyCode(String mod) { >+ return KeyCodeConverter.getKeyCode(mod); >+ } > } >\ No newline at end of file >diff --git a/org.eclipse.jubula.rc.swt/src/org/eclipse/jubula/rc/swt/uiadapter/factory/SWTAdapterFactory.java b/org.eclipse.jubula.rc.swt/src/org/eclipse/jubula/rc/swt/uiadapter/factory/SWTAdapterFactory.java >index 4f9f53f..a1a4232 100644 >--- a/org.eclipse.jubula.rc.swt/src/org/eclipse/jubula/rc/swt/uiadapter/factory/SWTAdapterFactory.java >+++ b/org.eclipse.jubula.rc.swt/src/org/eclipse/jubula/rc/swt/uiadapter/factory/SWTAdapterFactory.java >@@ -13,11 +13,13 @@ package org.eclipse.jubula.rc.swt.uiadapter.factory; > import org.eclipse.jubula.rc.common.uiadapter.factory.IUIAdapterFactory; > import org.eclipse.jubula.rc.common.uiadapter.interfaces.IComponentAdapter; > import org.eclipse.jubula.rc.swt.uiadapter.ButtonAdapter; >+import org.eclipse.jubula.rc.swt.uiadapter.ListAdapter; > import org.eclipse.jubula.rc.swt.uiadapter.MenuAdapter; > import org.eclipse.jubula.rc.swt.uiadapter.MenuItemAdapter; > import org.eclipse.jubula.rc.swt.uiadapter.TableAdapter; > import org.eclipse.jubula.rc.swt.uiadapter.TreeAdapter; > import org.eclipse.swt.widgets.Button; >+import org.eclipse.swt.widgets.List; > import org.eclipse.swt.widgets.Menu; > import org.eclipse.swt.widgets.MenuItem; > import org.eclipse.swt.widgets.Table; >@@ -33,7 +35,7 @@ public class SWTAdapterFactory implements IUIAdapterFactory { > /** */ > private static final Class[] SUPPORTEDCLASSES = > new Class[]{Button.class, Menu.class, MenuItem.class, Tree.class, >- Table.class}; >+ Table.class, List.class}; > > > /** >@@ -58,6 +60,8 @@ public class SWTAdapterFactory implements IUIAdapterFactory { > returnvalue = new TreeAdapter(objectToAdapt); > } else if (objectToAdapt instanceof Table) { > returnvalue = new TableAdapter(objectToAdapt); >+ } else if (objectToAdapt instanceof List) { >+ returnvalue = new ListAdapter(objectToAdapt); > } > > >diff --git a/org.eclipse.jubula.toolkit.provider.swing/resources/xml/ComponentConfiguration.xml b/org.eclipse.jubula.toolkit.provider.swing/resources/xml/ComponentConfiguration.xml >index 3f49ff8..0d3963c 100644 >--- a/org.eclipse.jubula.toolkit.provider.swing/resources/xml/ComponentConfiguration.xml >+++ b/org.eclipse.jubula.toolkit.provider.swing/resources/xml/ComponentConfiguration.xml >@@ -48,7 +48,7 @@ > > <toolkitComponent type="javax.swing.JList" visible="false"> > <realizes>guidancer.concrete.List</realizes> >- <testerClass>org.eclipse.jubula.rc.swing.swing.implclasses.JListImplClass</testerClass> >+ <testerClass>org.eclipse.jubula.rc.swing.swing.caps.JListCAPs</testerClass> > <componentClass name="javax.swing.JList" /> > </toolkitComponent> > >diff --git a/org.eclipse.jubula.toolkit.provider.swt/resources/xml/ComponentConfiguration.xml b/org.eclipse.jubula.toolkit.provider.swt/resources/xml/ComponentConfiguration.xml >index b55dd5c..6544234 100644 >--- a/org.eclipse.jubula.toolkit.provider.swt/resources/xml/ComponentConfiguration.xml >+++ b/org.eclipse.jubula.toolkit.provider.swt/resources/xml/ComponentConfiguration.xml >@@ -221,7 +221,7 @@ > > <toolkitComponent type="org.eclipse.swt.widgets.List" visible="false"> > <realizes>guidancer.concrete.List</realizes> >- <testerClass>org.eclipse.jubula.rc.swt.implclasses.ListImplClass</testerClass> >+ <testerClass>org.eclipse.jubula.rc.swt.caps.ListCAPs</testerClass> > <componentClass name="org.eclipse.swt.widgets.List" /> > </toolkitComponent> > >-- >1.7.11 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 394179
:
223499
|
223848
|
223948
|
223950
|
224096
|
224662
|
225163