Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZeb Ford-Reitz2012-03-15 14:49:40 +0000
committerZeb Ford-Reitz2012-03-15 15:44:34 +0000
commit882da695a3f4425b3bde866bf83e6058cac3be4d (patch)
tree4397003e780af95796b18656d48f8ff8bea00679
parenta9bc6f29b4a6c204167003e8382c076d2c01c54d (diff)
downloadorg.eclipse.jubula.core-882da695a3f4425b3bde866bf83e6058cac3be4d.tar.gz
org.eclipse.jubula.core-882da695a3f4425b3bde866bf83e6058cac3be4d.tar.xz
org.eclipse.jubula.core-882da695a3f4425b3bde866bf83e6058cac3be4d.zip
Fixes https://bxapps.bredex.de/bugzilla/show_bug.cgi?id=201.
Addresses the fact that "command + a" (used to select the entire contents of a text field / combo box) sometimes results in "a" being entered into the text field on Mac. The workaround is to immediately fall back to programmatically selecting the contents of the text field / combo box on Mac.
-rw-r--r--org.eclipse.jubula.rc.swt/src/org/eclipse/jubula/rc/swt/implclasses/ComboBoxHelper.java22
-rw-r--r--org.eclipse.jubula.rc.swt/src/org/eclipse/jubula/rc/swt/implclasses/TextImplClass.java18
2 files changed, 34 insertions, 6 deletions
diff --git a/org.eclipse.jubula.rc.swt/src/org/eclipse/jubula/rc/swt/implclasses/ComboBoxHelper.java b/org.eclipse.jubula.rc.swt/src/org/eclipse/jubula/rc/swt/implclasses/ComboBoxHelper.java
index 6b4d4dbf9..a9f6508bc 100644
--- a/org.eclipse.jubula.rc.swt/src/org/eclipse/jubula/rc/swt/implclasses/ComboBoxHelper.java
+++ b/org.eclipse.jubula.rc.swt/src/org/eclipse/jubula/rc/swt/implclasses/ComboBoxHelper.java
@@ -9,6 +9,7 @@
* BREDEX GmbH - initial API and implementation and/or initial documentation
*******************************************************************************/
package org.eclipse.jubula.rc.swt.implclasses;
+import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.Validate;
import org.eclipse.jubula.rc.common.driver.ClickOptions;
import org.eclipse.jubula.rc.common.driver.IEventThreadQueuer;
@@ -19,7 +20,9 @@ import org.eclipse.jubula.rc.common.logger.AutServerLogger;
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.jubula.tools.utils.EnvironmentUtils;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Control;
@@ -200,7 +203,24 @@ public class ComboBoxHelper extends AbstractComboBoxHelper {
*/
public void selectAll() {
click(new Integer(1));
- m_robot.keyStroke(m_robot.getSystemModifierSpec() + " A"); //$NON-NLS-1$
+
+ // fix for https://bxapps.bredex.de/bugzilla/show_bug.cgi?id=201
+ // The keystroke "command + a" sometimes causes an "a" to be entered
+ // into the text field instead of selecting all text (or having no
+ // effect).
+ if (EnvironmentUtils.isMacOS()) {
+ m_eventThreadQueuer.invokeAndWait("combo.selectAll", //$NON-NLS-1$
+ new IRunnable() {
+ public Object run() {
+ Combo comboBox = (Combo)m_implClass.getComponent();
+ int textLength = StringUtils.length(comboBox.getText());
+ comboBox.setSelection(new Point(0, textLength));
+ return null;
+ }
+ });
+ } else {
+ m_robot.keyStroke(m_robot.getSystemModifierSpec() + " A"); //$NON-NLS-1$
+ }
}
/**
diff --git a/org.eclipse.jubula.rc.swt/src/org/eclipse/jubula/rc/swt/implclasses/TextImplClass.java b/org.eclipse.jubula.rc.swt/src/org/eclipse/jubula/rc/swt/implclasses/TextImplClass.java
index 240053b6f..36f7fb39a 100644
--- a/org.eclipse.jubula.rc.swt/src/org/eclipse/jubula/rc/swt/implclasses/TextImplClass.java
+++ b/org.eclipse.jubula.rc.swt/src/org/eclipse/jubula/rc/swt/implclasses/TextImplClass.java
@@ -19,6 +19,7 @@ import org.eclipse.jubula.rc.swt.interfaces.ITextImplClass;
import org.eclipse.jubula.tools.constants.StringConstants;
import org.eclipse.jubula.tools.objects.event.EventFactory;
import org.eclipse.jubula.tools.objects.event.TestErrorEvent;
+import org.eclipse.jubula.tools.utils.EnvironmentUtils;
import org.eclipse.jubula.tools.utils.TimeUtil;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Control;
@@ -131,12 +132,19 @@ public class TextImplClass extends AbstractControlImplClass
*/
protected void selectAll() {
final String totalText = getText();
- try {
- getRobot().keyStroke(getRobot().getSystemModifierSpec() + " A"); //$NON-NLS-1$
- } catch (StepExecutionException see) {
- /*This might happen under certain circumstances e.g. on MacOS X see
+
+ // fix for https://bxapps.bredex.de/bugzilla/show_bug.cgi?id=201
+ // The keystroke "command + a" sometimes causes an "a" to be entered
+ // into the text field instead of selecting all text (or having no
+ // effect).
+ if (!EnvironmentUtils.isMacOS()) {
+ try {
+ getRobot().keyStroke(getRobot().getSystemModifierSpec() + " A"); //$NON-NLS-1$
+ } catch (StepExecutionException see) {
+ /*This might happen under certain circumstances e.g. on MacOS X see
bug 342691 */
- log.warn(see);
+ log.warn(see);
+ }
}
if (!totalText.equals(getSelectionText())) {

Back to the top