Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.swtbot.generator/src/org/eclipse/swtbot/generator/framework/rules/simple/RadioButtonClickedRule.java')
-rw-r--r--org.eclipse.swtbot.generator/src/org/eclipse/swtbot/generator/framework/rules/simple/RadioButtonClickedRule.java53
1 files changed, 53 insertions, 0 deletions
diff --git a/org.eclipse.swtbot.generator/src/org/eclipse/swtbot/generator/framework/rules/simple/RadioButtonClickedRule.java b/org.eclipse.swtbot.generator/src/org/eclipse/swtbot/generator/framework/rules/simple/RadioButtonClickedRule.java
new file mode 100644
index 00000000..dafb8682
--- /dev/null
+++ b/org.eclipse.swtbot.generator/src/org/eclipse/swtbot/generator/framework/rules/simple/RadioButtonClickedRule.java
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Red Hat Inc..
+ * 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:
+ * Mickael Istria (Red Hat) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swtbot.generator.framework.rules.simple;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swtbot.generator.framework.GenerationSimpleRule;
+import org.eclipse.swtbot.generator.framework.WidgetUtils;
+
+public class RadioButtonClickedRule extends GenerationSimpleRule {
+
+ private String buttonText;
+ private int index;
+
+ @Override
+ public boolean appliesTo(Event event) {
+ return event.widget instanceof Button &&
+ (((Button)event.widget).getStyle() & SWT.CHECK) != 0
+ && event.type == SWT.Selection;
+ }
+
+ @Override
+ public void initializeForEvent(Event event) {
+ this.buttonText = ((Button)event.widget).getText().replace("&", "");
+ if (this.buttonText == null) {
+ this.index = WidgetUtils.getIndex((Button)event.widget);
+ }
+ }
+
+ @Override
+ public String getWidgetAccessor() {
+ if (this.buttonText != null) {
+ return "bot.checkBox(\"" + this.buttonText + "\")";
+ } else {
+ return "bot.checkBox(" + this.index + ")";
+ }
+ }
+
+ @Override
+ public String getAction() {
+ return ".click()";
+ }
+
+} \ No newline at end of file

Back to the top