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 234140 Details for
Bug 414550
(SWT) Tree: check selection of checkbox on selected node: ExecutionError "0"
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]
Fix for the bug
0003-Fix-Tree_checkCheckboxSelectionStateOnSelectedItem (text/plain), 16.50 KB, created by
Jan Philipp Wiegmann
on 2013-08-07 05:13:54 EDT
(
hide
)
Description:
Fix for the bug
Filename:
MIME Type:
Creator:
Jan Philipp Wiegmann
Created:
2013-08-07 05:13:54 EDT
Size:
16.50 KB
patch
obsolete
>From 674d7d314e9210606363ad45830c9d696435a8a6 Mon Sep 17 00:00:00 2001 >From: Jan Wiegmann <Jan.Wiegmann@bredex.de> >Date: Tue, 6 Aug 2013 16:35:55 +0200 >Subject: [PATCH] Fix for ExecutionError 0 in Selection-based Tree-Action > >--- > .../rc/common/tester/AbstractTreeTester.java | 5 -- > .../jubula/rc/common/tester/ListTester.java | 17 ++----- > .../jubula/rc/common/util/ArrayValidator.java | 58 ++++++++++++++++++++++ > .../rc/swing/tester/adapter/JListAdapter.java | 7 +-- > .../rc/swing/tester/adapter/JTableAdapter.java | 2 +- > .../rc/swing/tester/util/TreeOperationContext.java | 8 +-- > .../eclipse/jubula/rc/swt/tester/TreeTester.java | 7 ++- > .../jubula/rc/swt/tester/adapter/ListAdapter.java | 9 +--- > .../rc/swt/tester/tree/TreeOperationContext.java | 19 ++----- > 9 files changed, 77 insertions(+), 55 deletions(-) > create mode 100644 org.eclipse.jubula.rc.common/src/org/eclipse/jubula/rc/common/util/ArrayValidator.java > >diff --git a/org.eclipse.jubula.rc.common/src/org/eclipse/jubula/rc/common/tester/AbstractTreeTester.java b/org.eclipse.jubula.rc.common/src/org/eclipse/jubula/rc/common/tester/AbstractTreeTester.java >index 407ca00..a5e3316 100644 >--- a/org.eclipse.jubula.rc.common/src/org/eclipse/jubula/rc/common/tester/AbstractTreeTester.java >+++ b/org.eclipse.jubula.rc.common/src/org/eclipse/jubula/rc/common/tester/AbstractTreeTester.java >@@ -555,11 +555,6 @@ public abstract class AbstractTreeTester extends WidgetTester { > AbstractTreeOperationContext context = getTreeAdapter().getContext(); > Object selectedNode = > getSelectedNode(context); >- if (selectedNode == null) { >- throw new StepExecutionException("No tree item selected", //$NON-NLS-1$ >- EventFactory.createActionError(TestErrorEvent.NO_SELECTION)); >- } >- > return context.getRenderedText(selectedNode); > } > >diff --git a/org.eclipse.jubula.rc.common/src/org/eclipse/jubula/rc/common/tester/ListTester.java b/org.eclipse.jubula.rc.common/src/org/eclipse/jubula/rc/common/tester/ListTester.java >index 576a23a..81a0bb4 100644 >--- a/org.eclipse.jubula.rc.common/src/org/eclipse/jubula/rc/common/tester/ListTester.java >+++ b/org.eclipse.jubula.rc.common/src/org/eclipse/jubula/rc/common/tester/ListTester.java >@@ -20,6 +20,7 @@ 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.tester.adapter.interfaces.IListComponent; >+import org.eclipse.jubula.rc.common.util.ArrayValidator; > import org.eclipse.jubula.rc.common.util.IndexConverter; > import org.eclipse.jubula.rc.common.util.ListSelectionVerifier; > import org.eclipse.jubula.rc.common.util.MatchUtil; >@@ -58,10 +59,7 @@ public class ListTester extends AbstractTextVerifiableTester { > */ > 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)); >- } >+ ArrayValidator.validateSelectionArray(selected); > return selected; > } > >@@ -131,10 +129,7 @@ public class ListTester extends AbstractTextVerifiableTester { > public void rcVerifyText(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)); >- } >+ ArrayValidator.validateSelectionArray(selected); > for (int i = 0; i < selCount; i++) { > Verifier.match(selected[i], text, operator); > } >@@ -211,11 +206,7 @@ public class ListTester extends AbstractTextVerifiableTester { > */ > public String rcReadValue(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)); >+ return (String) ArrayValidator.validateSelectionArray(selected); > } > > /** >diff --git a/org.eclipse.jubula.rc.common/src/org/eclipse/jubula/rc/common/util/ArrayValidator.java b/org.eclipse.jubula.rc.common/src/org/eclipse/jubula/rc/common/util/ArrayValidator.java >new file mode 100644 >index 0000000..2fe1cc2 >--- /dev/null >+++ b/org.eclipse.jubula.rc.common/src/org/eclipse/jubula/rc/common/util/ArrayValidator.java >@@ -0,0 +1,58 @@ >+package org.eclipse.jubula.rc.common.util; >+ >+import org.eclipse.jubula.rc.common.exception.StepExecutionException; >+import org.eclipse.jubula.tools.objects.event.EventFactory; >+import org.eclipse.jubula.tools.objects.event.TestErrorEvent; >+ >+/** >+ * Utility methods to check whether an array is valid or not. >+ * >+ * @author BREDEX GmbH >+ * @created Aug 06, 2013 >+ * >+ */ >+public class ArrayValidator { >+ >+ /** >+ * private constructor >+ */ >+ private ArrayValidator() { >+ //do nothing >+ } >+ >+ /** >+ * Checks if there is any selection on the widget >+ * >+ * @param array an array of Objects to be validated >+ * @throws StepExecutionException thrown if >+ * @return The first selected Item >+ */ >+ public static Object validateSelectionArray(Object[] array) >+ throws StepExecutionException { >+ >+ if (array == null || array.length == 0) { >+ throw new StepExecutionException("No selection found", //$NON-NLS-1$ >+ EventFactory.createActionError( >+ TestErrorEvent.NO_SELECTION)); >+ } >+ return array[0]; >+ } >+ >+ /** >+ * Checks if there is any selection on the widget >+ * >+ * @param array an array of Objects to be validated >+ * @throws StepExecutionException thrown if >+ * @return The first selected Item >+ */ >+ public static int validateSelectionArray(int[] array) >+ throws StepExecutionException { >+ >+ if (array == null || array.length == 0) { >+ throw new StepExecutionException("No selection found", //$NON-NLS-1$ >+ EventFactory.createActionError( >+ TestErrorEvent.NO_SELECTION)); >+ } >+ return array[0]; >+ } >+} >diff --git a/org.eclipse.jubula.rc.swing/src/org/eclipse/jubula/rc/swing/tester/adapter/JListAdapter.java b/org.eclipse.jubula.rc.swing/src/org/eclipse/jubula/rc/swing/tester/adapter/JListAdapter.java >index 1932d76..a9f8dc4 100644 >--- a/org.eclipse.jubula.rc.swing/src/org/eclipse/jubula/rc/swing/tester/adapter/JListAdapter.java >+++ b/org.eclipse.jubula.rc.swing/src/org/eclipse/jubula/rc/swing/tester/adapter/JListAdapter.java >@@ -21,6 +21,7 @@ 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.tester.adapter.interfaces.IListComponent; >+import org.eclipse.jubula.rc.common.util.ArrayValidator; > import org.eclipse.jubula.rc.common.util.MatchUtil; > import org.eclipse.jubula.rc.swing.tester.util.TesterUtil; > import org.eclipse.jubula.tools.objects.event.EventFactory; >@@ -48,11 +49,7 @@ public class JListAdapter extends JComponentAdapter implements IListComponent { > */ > 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)); >+ return (String) ArrayValidator.validateSelectionArray(selected); > } > > /** >diff --git a/org.eclipse.jubula.rc.swing/src/org/eclipse/jubula/rc/swing/tester/adapter/JTableAdapter.java b/org.eclipse.jubula.rc.swing/src/org/eclipse/jubula/rc/swing/tester/adapter/JTableAdapter.java >index 6989350..832e429 100644 >--- a/org.eclipse.jubula.rc.swing/src/org/eclipse/jubula/rc/swing/tester/adapter/JTableAdapter.java >+++ b/org.eclipse.jubula.rc.swing/src/org/eclipse/jubula/rc/swing/tester/adapter/JTableAdapter.java >@@ -266,7 +266,7 @@ public class JTableAdapter extends JComponentAdapter > .Property > .DESCRIPTION_KEY)))) { > // set "invalid index" to "no selection" -> better description! >- throw new StepExecutionException("No selection", //$NON-NLS-1$ >+ throw new StepExecutionException("No selection found", //$NON-NLS-1$ > EventFactory.createActionError( > TestErrorEvent.NO_SELECTION)); > } >diff --git a/org.eclipse.jubula.rc.swing/src/org/eclipse/jubula/rc/swing/tester/util/TreeOperationContext.java b/org.eclipse.jubula.rc.swing/src/org/eclipse/jubula/rc/swing/tester/util/TreeOperationContext.java >index 203e308..766f321 100644 >--- a/org.eclipse.jubula.rc.swing/src/org/eclipse/jubula/rc/swing/tester/util/TreeOperationContext.java >+++ b/org.eclipse.jubula.rc.swing/src/org/eclipse/jubula/rc/swing/tester/util/TreeOperationContext.java >@@ -31,9 +31,8 @@ import org.eclipse.jubula.rc.common.driver.IRunnable; > import org.eclipse.jubula.rc.common.exception.StepExecutionException; > import org.eclipse.jubula.rc.common.implclasses.tree.AbstractTreeOperationContext; > import org.eclipse.jubula.rc.common.logger.AutServerLogger; >+import org.eclipse.jubula.rc.common.util.ArrayValidator; > import org.eclipse.jubula.rc.swing.driver.EventThreadQueuerAwtImpl; >-import org.eclipse.jubula.tools.objects.event.EventFactory; >-import org.eclipse.jubula.tools.objects.event.TestErrorEvent; > > > /** >@@ -512,10 +511,7 @@ public class TreeOperationContext extends AbstractTreeOperationContext { > */ > private TreePath[] getCheckedSelectedPaths() { > TreePath[] paths = (TreePath[])getSelectionPaths(); >- if (paths == null) { >- throw new StepExecutionException("No tree node(s) selected", //$NON-NLS-1$ >- EventFactory.createActionError(TestErrorEvent.NO_SELECTION)); >- } >+ ArrayValidator.validateSelectionArray(paths); > return paths; > } > /** >diff --git a/org.eclipse.jubula.rc.swt/src/org/eclipse/jubula/rc/swt/tester/TreeTester.java b/org.eclipse.jubula.rc.swt/src/org/eclipse/jubula/rc/swt/tester/TreeTester.java >index cbdccc1..420ea5a 100644 >--- a/org.eclipse.jubula.rc.swt/src/org/eclipse/jubula/rc/swt/tester/TreeTester.java >+++ b/org.eclipse.jubula.rc.swt/src/org/eclipse/jubula/rc/swt/tester/TreeTester.java >@@ -32,6 +32,7 @@ import org.eclipse.jubula.rc.common.implclasses.tree.StandardDepthFirstTraverser > import org.eclipse.jubula.rc.common.implclasses.tree.TreeNodeOperation; > import org.eclipse.jubula.rc.common.implclasses.tree.TreeNodeOperationConstraint; > import org.eclipse.jubula.rc.common.tester.AbstractTreeTester; >+import org.eclipse.jubula.rc.common.tester.adapter.interfaces.ITreeComponent; > import org.eclipse.jubula.rc.common.util.IndexConverter; > import org.eclipse.jubula.rc.common.util.KeyStrokeUtil; > import org.eclipse.jubula.rc.common.util.MatchUtil; >@@ -785,8 +786,10 @@ public class TreeTester extends AbstractTreeTester { > throws StepExecutionException { > Boolean checkSelected = ((Boolean)getEventThreadQueuer().invokeAndWait( > "rcVerifyTreeCheckbox", new IRunnable() { //$NON-NLS-1$ >- public Object run() { >- TreeItem node = getTree().getSelection()[0]; >+ public Object run() { >+ AbstractTreeOperationContext context = >+ ((ITreeComponent)getComponent()).getContext(); >+ TreeItem node = (TreeItem) getSelectedNode(context); > return new Boolean(node.getChecked()); > } > })); >diff --git a/org.eclipse.jubula.rc.swt/src/org/eclipse/jubula/rc/swt/tester/adapter/ListAdapter.java b/org.eclipse.jubula.rc.swt/src/org/eclipse/jubula/rc/swt/tester/adapter/ListAdapter.java >index 7e94ada..c5edca9 100644 >--- a/org.eclipse.jubula.rc.swt/src/org/eclipse/jubula/rc/swt/tester/adapter/ListAdapter.java >+++ b/org.eclipse.jubula.rc.swt/src/org/eclipse/jubula/rc/swt/tester/adapter/ListAdapter.java >@@ -14,9 +14,8 @@ 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.tester.adapter.interfaces.IListComponent; >+import org.eclipse.jubula.rc.common.util.ArrayValidator; > 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; > /** >@@ -39,11 +38,7 @@ public class ListAdapter extends ControlAdapter implements IListComponent { > */ > 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)); >+ return (String) ArrayValidator.validateSelectionArray(selected); > } > > /** >diff --git a/org.eclipse.jubula.rc.swt/src/org/eclipse/jubula/rc/swt/tester/tree/TreeOperationContext.java b/org.eclipse.jubula.rc.swt/src/org/eclipse/jubula/rc/swt/tester/tree/TreeOperationContext.java >index b32df7b..3f620ea 100644 >--- a/org.eclipse.jubula.rc.swt/src/org/eclipse/jubula/rc/swt/tester/tree/TreeOperationContext.java >+++ b/org.eclipse.jubula.rc.swt/src/org/eclipse/jubula/rc/swt/tester/tree/TreeOperationContext.java >@@ -21,13 +21,12 @@ import org.eclipse.jubula.rc.common.driver.IRunnable; > import org.eclipse.jubula.rc.common.exception.StepExecutionException; > import org.eclipse.jubula.rc.common.implclasses.tree.AbstractTreeOperationContext; > import org.eclipse.jubula.rc.common.logger.AutServerLogger; >+import org.eclipse.jubula.rc.common.util.ArrayValidator; > import org.eclipse.jubula.rc.common.util.Verifier; > import org.eclipse.jubula.rc.swt.tester.CAPUtil; > import org.eclipse.jubula.rc.swt.utils.SwtPointUtil; > import org.eclipse.jubula.rc.swt.utils.SwtUtils; > import org.eclipse.jubula.tools.constants.SwtAUTHierarchyConstants; >-import org.eclipse.jubula.tools.objects.event.EventFactory; >-import org.eclipse.jubula.tools.objects.event.TestErrorEvent; > import org.eclipse.swt.SWT; > import org.eclipse.swt.widgets.Control; > import org.eclipse.swt.widgets.Event; >@@ -454,13 +453,7 @@ public class TreeOperationContext extends AbstractTreeOperationContext { > public Object run() { > TreeItem [] selectedItems = > ((Tree)getTree()).getSelection(); >- if (selectedItems == null || selectedItems.length == 0) { >- throw new StepExecutionException( >- "No tree node(s) selected", //$NON-NLS-1$ >- EventFactory.createActionError( >- TestErrorEvent.NO_SELECTION)); >- } >- return selectedItems[0]; >+ return ArrayValidator.validateSelectionArray(selectedItems); > } > > }); >@@ -476,13 +469,7 @@ public class TreeOperationContext extends AbstractTreeOperationContext { > public Object run() { > TreeItem [] selectedItems = > ((Tree)getTree()).getSelection(); >- if (selectedItems == null || selectedItems.length == 0) { >- throw new StepExecutionException( >- "No tree node(s) selected", //$NON-NLS-1$ >- EventFactory.createActionError( >- TestErrorEvent.NO_SELECTION)); >- } >- return selectedItems; >+ return ArrayValidator.validateSelectionArray(selectedItems); > } > > }); >-- >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
Flags:
markus.tiede
:
iplog+
Actions:
View
|
Diff
Attachments on
bug 414550
: 234140