|
Lines 1-1738
Link Here
|
| 1 |
/******************************************************************************* |
1 |
/******************************************************************************* |
| 2 |
* Copyright (c) 2005, 2008 IBM Corporation and others. |
2 |
* Copyright (c) 2005, 2008 IBM Corporation and others. |
| 3 |
* All rights reserved. This program and the accompanying materials |
3 |
* All rights reserved. This program and the accompanying materials |
| 4 |
* are made available under the terms of the Eclipse Public License v1.0 |
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
| 5 |
* which accompanies this distribution, and is available at |
5 |
* which accompanies this distribution, and is available at |
| 6 |
* http://www.eclipse.org/legal/epl-v10.html |
6 |
* http://www.eclipse.org/legal/epl-v10.html |
| 7 |
* $Id: AutoGUITestCasesForm.java,v 1.23 2008/04/10 01:28:58 paules Exp $ |
7 |
* $Id: AutoGUITestCasesForm.java,v 1.23 2008/04/10 01:28:58 paules Exp $ |
| 8 |
* |
8 |
* |
| 9 |
* Contributors: |
9 |
* Contributors: |
| 10 |
* IBM Corporation - initial API and implementation |
10 |
* IBM Corporation - initial API and implementation |
| 11 |
*******************************************************************************/ |
11 |
*******************************************************************************/ |
| 12 |
package org.eclipse.tptp.test.auto.gui.internal.editor; |
12 |
package org.eclipse.tptp.test.auto.gui.internal.editor; |
| 13 |
|
13 |
|
| 14 |
import java.util.ArrayList; |
14 |
import java.util.ArrayList; |
| 15 |
import java.util.Hashtable; |
15 |
import java.util.Hashtable; |
| 16 |
import java.util.Iterator; |
16 |
import java.util.Iterator; |
| 17 |
import java.util.LinkedList; |
17 |
import java.util.LinkedList; |
| 18 |
import java.util.List; |
18 |
import java.util.List; |
| 19 |
|
19 |
|
| 20 |
import org.eclipse.core.commands.ExecutionException; |
20 |
import org.eclipse.core.commands.ExecutionException; |
| 21 |
import org.eclipse.core.commands.operations.AbstractOperation; |
21 |
import org.eclipse.core.commands.operations.AbstractOperation; |
| 22 |
import org.eclipse.core.commands.operations.DefaultOperationHistory; |
22 |
import org.eclipse.core.commands.operations.DefaultOperationHistory; |
| 23 |
import org.eclipse.core.commands.operations.IOperationHistory; |
23 |
import org.eclipse.core.commands.operations.IOperationHistory; |
| 24 |
import org.eclipse.core.commands.operations.IUndoContext; |
24 |
import org.eclipse.core.commands.operations.IUndoContext; |
| 25 |
import org.eclipse.core.runtime.IAdaptable; |
25 |
import org.eclipse.core.runtime.IAdaptable; |
| 26 |
import org.eclipse.core.runtime.IProgressMonitor; |
26 |
import org.eclipse.core.runtime.IProgressMonitor; |
| 27 |
import org.eclipse.core.runtime.IStatus; |
27 |
import org.eclipse.core.runtime.IStatus; |
| 28 |
import org.eclipse.core.runtime.NullProgressMonitor; |
28 |
import org.eclipse.core.runtime.NullProgressMonitor; |
| 29 |
import org.eclipse.core.runtime.Status; |
29 |
import org.eclipse.core.runtime.Status; |
| 30 |
import org.eclipse.hyades.models.common.facades.behavioral.IProperty; |
30 |
import org.eclipse.hyades.models.common.facades.behavioral.IProperty; |
| 31 |
import org.eclipse.hyades.models.common.facades.behavioral.ITargetInvocation; |
31 |
import org.eclipse.hyades.models.common.facades.behavioral.ITargetInvocation; |
| 32 |
import org.eclipse.hyades.models.common.facades.behavioral.ITestCase; |
32 |
import org.eclipse.hyades.models.common.facades.behavioral.ITestCase; |
| 33 |
import org.eclipse.hyades.models.common.facades.behavioral.impl.HyadesFactory; |
33 |
import org.eclipse.hyades.models.common.facades.behavioral.impl.HyadesFactory; |
| 34 |
import org.eclipse.hyades.models.common.facades.behavioral.impl.HyadesUtil; |
34 |
import org.eclipse.hyades.models.common.facades.behavioral.impl.HyadesUtil; |
| 35 |
import org.eclipse.hyades.models.common.fragments.Common_Behavior_FragmentsPackage; |
35 |
import org.eclipse.hyades.models.common.fragments.Common_Behavior_FragmentsPackage; |
| 36 |
import org.eclipse.hyades.models.common.testprofile.Common_TestprofilePackage; |
36 |
import org.eclipse.hyades.models.common.testprofile.Common_TestprofilePackage; |
| 37 |
import org.eclipse.hyades.test.tools.ui.common.internal.editor.TestCasesEclipseForm; |
37 |
import org.eclipse.hyades.test.tools.ui.common.internal.editor.TestCasesEclipseForm; |
| 38 |
import org.eclipse.hyades.test.tools.ui.common.internal.util.FormUtil; |
38 |
import org.eclipse.hyades.test.tools.ui.common.internal.util.FormUtil; |
| 39 |
import org.eclipse.hyades.test.tools.ui.internal.resources.ToolsUiPluginResourceBundle; |
39 |
import org.eclipse.hyades.test.tools.ui.internal.resources.ToolsUiPluginResourceBundle; |
| 40 |
import org.eclipse.hyades.test.ui.TestUIImages; |
40 |
import org.eclipse.hyades.test.ui.TestUIImages; |
| 41 |
import org.eclipse.hyades.test.ui.UiPlugin; |
41 |
import org.eclipse.hyades.test.ui.UiPlugin; |
| 42 |
import org.eclipse.hyades.test.ui.internal.editor.form.util.EObjectTree; |
42 |
import org.eclipse.hyades.test.ui.internal.editor.form.util.EObjectTree; |
| 43 |
import org.eclipse.hyades.test.ui.internal.model.ui.MoveChildrenDownAction; |
43 |
import org.eclipse.hyades.test.ui.internal.model.ui.MoveChildrenDownAction; |
| 44 |
import org.eclipse.hyades.test.ui.internal.model.ui.MoveChildrenUpAction; |
44 |
import org.eclipse.hyades.test.ui.internal.model.ui.MoveChildrenUpAction; |
| 45 |
import org.eclipse.hyades.test.ui.internal.model.ui.RemoveChildrenAction; |
45 |
import org.eclipse.hyades.test.ui.internal.model.ui.RemoveChildrenAction; |
| 46 |
import org.eclipse.hyades.test.ui.internal.resources.UiPluginResourceBundle; |
46 |
import org.eclipse.hyades.test.ui.internal.resources.UiPluginResourceBundle; |
| 47 |
import org.eclipse.hyades.ui.editor.IEditorExtension; |
47 |
import org.eclipse.hyades.ui.editor.IEditorExtension; |
| 48 |
import org.eclipse.hyades.ui.internal.util.GridDataUtil; |
48 |
import org.eclipse.hyades.ui.internal.util.GridDataUtil; |
| 49 |
import org.eclipse.jface.action.Action; |
49 |
import org.eclipse.jface.action.Action; |
| 50 |
import org.eclipse.jface.action.IAction; |
50 |
import org.eclipse.jface.action.IAction; |
| 51 |
import org.eclipse.jface.action.IToolBarManager; |
51 |
import org.eclipse.jface.action.IToolBarManager; |
| 52 |
import org.eclipse.jface.action.MenuManager; |
52 |
import org.eclipse.jface.action.MenuManager; |
| 53 |
import org.eclipse.jface.action.Separator; |
53 |
import org.eclipse.jface.action.Separator; |
| 54 |
import org.eclipse.jface.text.Document; |
54 |
import org.eclipse.jface.text.Document; |
| 55 |
import org.eclipse.jface.text.IFindReplaceTarget; |
55 |
import org.eclipse.jface.text.IFindReplaceTarget; |
| 56 |
import org.eclipse.jface.text.source.AnnotationRulerColumn; |
56 |
import org.eclipse.jface.text.source.AnnotationRulerColumn; |
| 57 |
import org.eclipse.jface.text.source.CompositeRuler; |
57 |
import org.eclipse.jface.text.source.CompositeRuler; |
| 58 |
import org.eclipse.jface.text.source.LineNumberRulerColumn; |
58 |
import org.eclipse.jface.text.source.LineNumberRulerColumn; |
| 59 |
import org.eclipse.jface.text.source.SourceViewer; |
59 |
import org.eclipse.jface.text.source.SourceViewer; |
| 60 |
import org.eclipse.jface.text.source.SourceViewerConfiguration; |
60 |
import org.eclipse.jface.text.source.SourceViewerConfiguration; |
| 61 |
import org.eclipse.jface.viewers.ISelection; |
61 |
import org.eclipse.jface.viewers.ISelection; |
| 62 |
import org.eclipse.jface.viewers.ISelectionChangedListener; |
62 |
import org.eclipse.jface.viewers.ISelectionChangedListener; |
| 63 |
import org.eclipse.jface.viewers.SelectionChangedEvent; |
63 |
import org.eclipse.jface.viewers.SelectionChangedEvent; |
| 64 |
import org.eclipse.jface.viewers.StructuredSelection; |
64 |
import org.eclipse.jface.viewers.StructuredSelection; |
| 65 |
import org.eclipse.jface.viewers.TreeViewer; |
65 |
import org.eclipse.jface.viewers.TreeViewer; |
| 66 |
import org.eclipse.swt.SWT; |
66 |
import org.eclipse.swt.SWT; |
| 67 |
import org.eclipse.swt.custom.ExtendedModifyEvent; |
67 |
import org.eclipse.swt.custom.ExtendedModifyEvent; |
| 68 |
import org.eclipse.swt.custom.ExtendedModifyListener; |
68 |
import org.eclipse.swt.custom.ExtendedModifyListener; |
| 69 |
import org.eclipse.swt.custom.SashForm; |
69 |
import org.eclipse.swt.custom.SashForm; |
| 70 |
import org.eclipse.swt.custom.StyledText; |
70 |
import org.eclipse.swt.custom.StyledText; |
| 71 |
import org.eclipse.swt.events.FocusAdapter; |
71 |
import org.eclipse.swt.events.FocusAdapter; |
| 72 |
import org.eclipse.swt.events.FocusEvent; |
72 |
import org.eclipse.swt.events.FocusEvent; |
| 73 |
import org.eclipse.swt.events.ModifyEvent; |
73 |
import org.eclipse.swt.events.ModifyEvent; |
| 74 |
import org.eclipse.swt.events.ModifyListener; |
74 |
import org.eclipse.swt.events.ModifyListener; |
| 75 |
import org.eclipse.swt.graphics.Color; |
75 |
import org.eclipse.swt.graphics.Color; |
| 76 |
import org.eclipse.swt.graphics.Font; |
76 |
import org.eclipse.swt.graphics.Font; |
| 77 |
import org.eclipse.swt.graphics.Point; |
77 |
import org.eclipse.swt.graphics.Point; |
| 78 |
import org.eclipse.swt.graphics.RGB; |
78 |
import org.eclipse.swt.graphics.RGB; |
| 79 |
import org.eclipse.swt.layout.GridData; |
79 |
import org.eclipse.swt.layout.GridData; |
| 80 |
import org.eclipse.swt.layout.GridLayout; |
80 |
import org.eclipse.swt.layout.GridLayout; |
| 81 |
import org.eclipse.swt.widgets.Composite; |
81 |
import org.eclipse.swt.widgets.Composite; |
| 82 |
import org.eclipse.swt.widgets.Control; |
82 |
import org.eclipse.swt.widgets.Control; |
| 83 |
import org.eclipse.swt.widgets.Display; |
83 |
import org.eclipse.swt.widgets.Display; |
| 84 |
import org.eclipse.swt.widgets.Label; |
84 |
import org.eclipse.swt.widgets.Label; |
| 85 |
import org.eclipse.swt.widgets.Text; |
85 |
import org.eclipse.swt.widgets.Text; |
| 86 |
import org.eclipse.swt.widgets.TreeItem; |
86 |
import org.eclipse.swt.widgets.TreeItem; |
| 87 |
import org.eclipse.tptp.test.auto.gui.internal.AutoGUIImages; |
87 |
import org.eclipse.tptp.test.auto.gui.internal.AutoGUIImages; |
| 88 |
import org.eclipse.tptp.test.auto.gui.internal.AutoGUIMessages; |
88 |
import org.eclipse.tptp.test.auto.gui.internal.AutoGUIMessages; |
| 89 |
import org.eclipse.tptp.test.auto.gui.internal.GlobalConstants; |
89 |
import org.eclipse.tptp.test.auto.gui.internal.GlobalConstants; |
| 90 |
import org.eclipse.tptp.test.auto.gui.internal.GuiPlugin; |
90 |
import org.eclipse.tptp.test.auto.gui.internal.GuiPlugin; |
| 91 |
import org.eclipse.tptp.test.auto.gui.internal.actions.AutoGUIDelegatorAction; |
91 |
import org.eclipse.tptp.test.auto.gui.internal.actions.AutoGUIDelegatorAction; |
| 92 |
import org.eclipse.tptp.test.auto.gui.internal.actions.AutoGUIOrientationAction; |
92 |
import org.eclipse.tptp.test.auto.gui.internal.actions.AutoGUIOrientationAction; |
| 93 |
import org.eclipse.tptp.test.auto.gui.internal.actions.AutoGUIPlayAction; |
93 |
import org.eclipse.tptp.test.auto.gui.internal.actions.AutoGUIPlayAction; |
| 94 |
import org.eclipse.tptp.test.auto.gui.internal.actions.AutoGUIRecordAction; |
94 |
import org.eclipse.tptp.test.auto.gui.internal.actions.AutoGUIRecordAction; |
| 95 |
import org.eclipse.tptp.test.auto.gui.internal.actions.AutoGUIRefreshAction; |
95 |
import org.eclipse.tptp.test.auto.gui.internal.actions.AutoGUIRefreshAction; |
| 96 |
import org.eclipse.tptp.test.auto.gui.internal.actions.AutoGUITestCaseAction; |
96 |
import org.eclipse.tptp.test.auto.gui.internal.actions.AutoGUITestCaseAction; |
| 97 |
import org.eclipse.tptp.test.auto.gui.internal.actions.AutoGUIUpdateTestCaseAction; |
97 |
import org.eclipse.tptp.test.auto.gui.internal.actions.AutoGUIUpdateTestCaseAction; |
| 98 |
import org.eclipse.tptp.test.auto.gui.internal.core.IUIObject; |
98 |
import org.eclipse.tptp.test.auto.gui.internal.editor.AutoGUITestCaseTreeStructure.MacroUIInstruction; |
| 99 |
import org.eclipse.tptp.test.auto.gui.internal.editor.AutoGUITestCaseTreeStructure.MacroUIInstruction; |
99 |
import org.eclipse.tptp.test.auto.gui.internal.macroobject.mine.MacroObjectDescriptor; |
| 100 |
import org.eclipse.tptp.test.auto.gui.internal.macro.ObjectMineManager; |
100 |
import org.eclipse.tptp.test.auto.gui.internal.macroobject.mine.MacroObjectDescriptorMineManager; |
| 101 |
import org.eclipse.ui.IActionBars; |
101 |
import org.eclipse.ui.IActionBars; |
| 102 |
import org.eclipse.ui.actions.ActionFactory; |
102 |
import org.eclipse.ui.actions.ActionFactory; |
| 103 |
import org.eclipse.ui.forms.IManagedForm; |
103 |
import org.eclipse.ui.forms.IManagedForm; |
| 104 |
import org.eclipse.ui.forms.events.ExpansionEvent; |
104 |
import org.eclipse.ui.forms.events.ExpansionEvent; |
| 105 |
import org.eclipse.ui.forms.events.IExpansionListener; |
105 |
import org.eclipse.ui.forms.events.IExpansionListener; |
| 106 |
import org.eclipse.ui.forms.widgets.ScrolledForm; |
106 |
import org.eclipse.ui.forms.widgets.ScrolledForm; |
| 107 |
import org.eclipse.ui.forms.widgets.Section; |
107 |
import org.eclipse.ui.forms.widgets.Section; |
| 108 |
import org.eclipse.ui.texteditor.FindReplaceAction; |
108 |
import org.eclipse.ui.texteditor.FindReplaceAction; |
| 109 |
import org.eclipse.ui.texteditor.ITextEditorExtension2; |
109 |
import org.eclipse.ui.texteditor.ITextEditorExtension2; |
| 110 |
|
110 |
|
| 111 |
|
111 |
|
| 112 |
/** |
112 |
/** |
| 113 |
* This form provides the 'macro-examine' page that allows users to easily navigate through |
113 |
* This form provides the 'macro-examine' page that allows users to easily navigate through |
| 114 |
* a macro and make the appropriate adjustments. |
114 |
* a macro and make the appropriate adjustments. |
| 115 |
* |
115 |
* |
| 116 |
* |
116 |
* |
| 117 |
* @author Ali Mehregani |
117 |
* @author Ali Mehregani |
| 118 |
* @author Paul E. Slauenwhite |
118 |
* @author Paul E. Slauenwhite |
| 119 |
* @version April 7, 2008 |
119 |
* @version April 7, 2008 |
| 120 |
* @since August 19, 2006 |
120 |
* @since August 19, 2006 |
| 121 |
*/ |
121 |
*/ |
| 122 |
public class AutoGUITestCasesForm extends TestCasesEclipseForm implements ITextEditorExtension2 |
122 |
public class AutoGUITestCasesForm extends TestCasesEclipseForm implements ITextEditorExtension2 |
| 123 |
{ |
123 |
{ |
| 124 |
/* The maximum number of undo operations that can be performed */ |
124 |
/* The maximum number of undo operations that can be performed */ |
| 125 |
protected static final int UNDO_OPERATION_LIMIT = 200; |
125 |
protected static final int UNDO_OPERATION_LIMIT = 200; |
| 126 |
|
126 |
|
| 127 |
/* The toolkit used to create widgets */ |
127 |
/* The toolkit used to create widgets */ |
| 128 |
private AutoGUIToolkit autoGUIToolkit; |
128 |
private AutoGUIToolkit autoGUIToolkit; |
| 129 |
|
129 |
|
| 130 |
/* The form */ |
130 |
/* The form */ |
| 131 |
private ScrolledForm form; |
131 |
private ScrolledForm form; |
| 132 |
|
132 |
|
| 133 |
/* The sash form seperating the test cases from the macro text box */ |
133 |
/* The sash form seperating the test cases from the macro text box */ |
| 134 |
private SashForm sashForm; |
134 |
private SashForm sashForm; |
| 135 |
|
135 |
|
| 136 |
/* The logical representation of each macro */ |
136 |
/* The logical representation of each macro */ |
| 137 |
private AutoGUITestCaseTreeStructure logicalTreeRepresentaion; |
137 |
private AutoGUITestCaseTreeStructure logicalTreeRepresentaion; |
| 138 |
|
138 |
|
| 139 |
/* The style text used to display the raw macro */ |
139 |
/* The style text used to display the raw macro */ |
| 140 |
private StyledText rawRepresentation; |
140 |
private StyledText rawRepresentation; |
| 141 |
|
141 |
|
| 142 |
/* The styler used for the macro text box */ |
142 |
/* The styler used for the macro text box */ |
| 143 |
private AutoGUIXMLLineStyler xmlLineStyler; |
143 |
private AutoGUIXMLLineStyler xmlLineStyler; |
| 144 |
|
144 |
|
| 145 |
/* Disable the modify listener on the styled text showing the raw macro */ |
145 |
/* Disable the modify listener on the styled text showing the raw macro */ |
| 146 |
private boolean disableModifyListener; |
146 |
private boolean disableModifyListener; |
| 147 |
|
147 |
|
| 148 |
/* Allows for the retrieval of test case properties */ |
148 |
/* Allows for the retrieval of test case properties */ |
| 149 |
private GUITestCaseProperties testCasePropertyManager; |
149 |
private GUITestCaseProperties testCasePropertyManager; |
| 150 |
|
150 |
|
| 151 |
/* Stores the hierarchy of the last selection of the tree in order for it to be restored after operations that |
151 |
/* Stores the hierarchy of the last selection of the tree in order for it to be restored after operations that |
| 152 |
* will cause the tree content to be refreshed. The selection indices will be stored. If in case the desired item |
152 |
* will cause the tree content to be refreshed. The selection indices will be stored. If in case the desired item |
| 153 |
* is not found, then the next closest one should be returned */ |
153 |
* is not found, then the next closest one should be returned */ |
| 154 |
private LinkedList lastTreeHierarchySelected; |
154 |
private LinkedList lastTreeHierarchySelected; |
| 155 |
|
155 |
|
| 156 |
/* The listener for the logical tree representation of the macro */ |
156 |
/* The listener for the logical tree representation of the macro */ |
| 157 |
private LogicalRepresentationListener logicalRepresentationListener; |
157 |
private LogicalRepresentationListener logicalRepresentationListener; |
| 158 |
|
158 |
|
| 159 |
/* Keeps track of the operation history so that they can be undone and redone. */ |
159 |
/* Keeps track of the operation history so that they can be undone and redone. */ |
| 160 |
private IOperationHistory linearOperationHistory; |
160 |
private IOperationHistory linearOperationHistory; |
| 161 |
|
161 |
|
| 162 |
/* Keeps track of the context used for undoable operations |
162 |
/* Keeps track of the context used for undoable operations |
| 163 |
* KEY = test case id |
163 |
* KEY = test case id |
| 164 |
* VALUE = a context of type IUndoContext */ |
164 |
* VALUE = a context of type IUndoContext */ |
| 165 |
private Hashtable context; |
165 |
private Hashtable context; |
| 166 |
|
166 |
|
| 167 |
/* A flag that enables/disables the hisotry operation keeper */ |
167 |
/* A flag that enables/disables the hisotry operation keeper */ |
| 168 |
private boolean isOperationHistory; |
168 |
private boolean isOperationHistory; |
| 169 |
|
169 |
|
| 170 |
/* The actions */ |
170 |
/* The actions */ |
| 171 |
private IAction[] actions; |
171 |
private IAction[] actions; |
| 172 |
|
172 |
|
| 173 |
/* Action separator indices */ |
173 |
/* Action separator indices */ |
| 174 |
private int[] separators; |
174 |
private int[] separators; |
| 175 |
|
175 |
|
| 176 |
/* The starting point text box */ |
176 |
/* The starting point text box */ |
| 177 |
private Text startingPttxt; |
177 |
private Text startingPttxt; |
| 178 |
|
178 |
|
| 179 |
/* The object mine tree */ |
179 |
/* The object mine tree */ |
| 180 |
private AutoGUIObjectMineTreeStructure objectMineTree; |
180 |
private AutoGUIMacroObjectDescriptorMineTreeStructure objectMineTree; |
| 181 |
|
181 |
|
| 182 |
/* The object mine listener */ |
182 |
/* The object mine listener */ |
| 183 |
private ObjectMineTreeListener objectMineListener; |
183 |
private ObjectMineTreeListener objectMineListener; |
| 184 |
|
184 |
|
| 185 |
/* A expansion listener */ |
185 |
/* A expansion listener */ |
| 186 |
private ExpansionListener expansionListener; |
186 |
private ExpansionListener expansionListener; |
| 187 |
|
187 |
|
| 188 |
/* The macro modification listeners */ |
188 |
/* The macro modification listeners */ |
| 189 |
private ArrayList macroModificationListeners; |
189 |
private ArrayList macroModificationListeners; |
| 190 |
|
190 |
|
| 191 |
/* The active macro modify listener */ |
191 |
/* The active macro modify listener */ |
| 192 |
private IMacroModifyListener activeMacroModifyListener; |
192 |
private IMacroModifyListener activeMacroModifyListener; |
| 193 |
|
193 |
|
| 194 |
/* The root macro modify listener */ |
194 |
/* The root macro modify listener */ |
| 195 |
private RootMacroModifyListener rootMacroModifyListener; |
195 |
private RootMacroModifyListener rootMacroModifyListener; |
| 196 |
|
196 |
|
| 197 |
/* The find/replace action */ |
197 |
/* The find/replace action */ |
| 198 |
private FindReplaceAction findReplaceAction; |
198 |
private FindReplaceAction findReplaceAction; |
| 199 |
|
199 |
|
| 200 |
/* The find/replace target */ |
200 |
/* The find/replace target */ |
| 201 |
private MacroFindReplaceTarget macroFindReplaceTarget; |
201 |
private MacroFindReplaceTarget macroFindReplaceTarget; |
| 202 |
|
202 |
|
| 203 |
/* The undo action */ |
203 |
/* The undo action */ |
| 204 |
private UndoRedoAction undoAction; |
204 |
private UndoRedoAction undoAction; |
| 205 |
|
205 |
|
| 206 |
private UndoRedoAction redoAction; |
206 |
private UndoRedoAction redoAction; |
| 207 |
|
207 |
|
| 208 |
public AutoGUITestCasesForm(IEditorExtension editor, String id, String title) |
208 |
public AutoGUITestCasesForm(IEditorExtension editor, String id, String title) |
| 209 |
{ |
209 |
{ |
| 210 |
super(editor, AutoGUIMessages.TST_SUITE_AUTO_GENERAL_TITLE, id, title); |
210 |
super(editor, AutoGUIMessages.TST_SUITE_AUTO_GENERAL_TITLE, id, title); |
| 211 |
autoGUIToolkit = new AutoGUIToolkit (GuiPlugin.getDefault().getWorkbench().getDisplay()); |
211 |
autoGUIToolkit = new AutoGUIToolkit (GuiPlugin.getDefault().getWorkbench().getDisplay()); |
| 212 |
disableModifyListener = false; |
212 |
disableModifyListener = false; |
| 213 |
lastTreeHierarchySelected = new LinkedList(); |
213 |
lastTreeHierarchySelected = new LinkedList(); |
| 214 |
logicalTreeRepresentaion = new AutoGUITestCaseTreeStructure (editor, Common_TestprofilePackage.eINSTANCE.getTPFTestSuite_TestCases()); |
214 |
logicalTreeRepresentaion = new AutoGUITestCaseTreeStructure (editor, Common_TestprofilePackage.eINSTANCE.getTPFTestSuite_TestCases()); |
| 215 |
logicalRepresentationListener = new LogicalRepresentationListener(); |
215 |
logicalRepresentationListener = new LogicalRepresentationListener(); |
| 216 |
objectMineTree = new AutoGUIObjectMineTreeStructure(this, editor); |
216 |
objectMineTree = new AutoGUIMacroObjectDescriptorMineTreeStructure(this, editor); |
| 217 |
linearOperationHistory = new DefaultOperationHistory(); |
217 |
linearOperationHistory = new DefaultOperationHistory(); |
| 218 |
context = new Hashtable(); |
218 |
context = new Hashtable(); |
| 219 |
isOperationHistory = true; |
219 |
isOperationHistory = true; |
| 220 |
testCasePropertyManager = new GUITestCaseProperties(); |
220 |
testCasePropertyManager = new GUITestCaseProperties(); |
| 221 |
expansionListener = new ExpansionListener(); |
221 |
expansionListener = new ExpansionListener(); |
| 222 |
objectMineListener = new ObjectMineTreeListener(); |
222 |
objectMineListener = new ObjectMineTreeListener(); |
| 223 |
macroModificationListeners = new ArrayList(); |
223 |
macroModificationListeners = new ArrayList(); |
| 224 |
createActions(); |
224 |
createActions(); |
| 225 |
} |
225 |
} |
| 226 |
|
226 |
|
| 227 |
|
227 |
|
| 228 |
/** |
228 |
/** |
| 229 |
* Creates the toolbar actions |
229 |
* Creates the toolbar actions |
| 230 |
*/ |
230 |
*/ |
| 231 |
private void createActions() |
231 |
private void createActions() |
| 232 |
{ |
232 |
{ |
| 233 |
MoveChildrenUpAction moveUpAction = new MoveChildrenUpAction(); |
233 |
MoveChildrenUpAction moveUpAction = new MoveChildrenUpAction(); |
| 234 |
MoveChildrenDownAction moveDownAction = new MoveChildrenDownAction(); |
234 |
MoveChildrenDownAction moveDownAction = new MoveChildrenDownAction(); |
| 235 |
|
235 |
|
| 236 |
moveUpAction.setEStructuralFeature(Common_Behavior_FragmentsPackage.eINSTANCE.getBVRInteractionOperand_InteractionFragments()); |
236 |
moveUpAction.setEStructuralFeature(Common_Behavior_FragmentsPackage.eINSTANCE.getBVRInteractionOperand_InteractionFragments()); |
| 237 |
moveDownAction.setEStructuralFeature(Common_Behavior_FragmentsPackage.eINSTANCE.getBVRInteractionOperand_InteractionFragments()); |
237 |
moveDownAction.setEStructuralFeature(Common_Behavior_FragmentsPackage.eINSTANCE.getBVRInteractionOperand_InteractionFragments()); |
| 238 |
actions = new IAction[] |
238 |
actions = new IAction[] |
| 239 |
{ |
239 |
{ |
| 240 |
new AutoGUIRecordAction(this, ToolsUiPluginResourceBundle.W_TEST.toLowerCase()), |
240 |
new AutoGUIRecordAction(this, ToolsUiPluginResourceBundle.W_TEST.toLowerCase()), |
| 241 |
new AutoGUIPlayAction (this), |
241 |
new AutoGUIPlayAction (this), |
| 242 |
new AutoGUIDelegatorAction(this, AutoGUIMessages.TST_SUITE_AUTO_MACRO_DELETE, AutoGUIImages.getInstance().getImageDescriptor("e", AutoGUIImages.DELETE), AutoGUIImages.getInstance().getImageDescriptor("d", AutoGUIImages.DELETE), new RemoveChildrenAction(false)), |
242 |
new AutoGUIDelegatorAction(this, AutoGUIMessages.TST_SUITE_AUTO_MACRO_DELETE, AutoGUIImages.getInstance().getImageDescriptor("e", AutoGUIImages.DELETE), AutoGUIImages.getInstance().getImageDescriptor("d", AutoGUIImages.DELETE), new RemoveChildrenAction(false)), |
| 243 |
new AutoGUIUpdateTestCaseAction(this, AutoGUIMessages.TST_SUITE_AUTO_MACRO_UPDATE, AutoGUIImages.getInstance().getImageDescriptor("e", AutoGUIImages.UPDATE)), |
243 |
new AutoGUIUpdateTestCaseAction(this, AutoGUIMessages.TST_SUITE_AUTO_MACRO_UPDATE, AutoGUIImages.getInstance().getImageDescriptor("e", AutoGUIImages.UPDATE)), |
| 244 |
new AutoGUIRefreshAction(this, AutoGUIMessages.TST_SUITE_AUTO_MACRO_REFRESH, AutoGUIImages.getInstance().getImageDescriptor("c", AutoGUIImages.REFRESH)), |
244 |
new AutoGUIRefreshAction(this, AutoGUIMessages.TST_SUITE_AUTO_MACRO_REFRESH, AutoGUIImages.getInstance().getImageDescriptor("c", AutoGUIImages.REFRESH)), |
| 245 |
new AutoGUIDelegatorAction(this, AutoGUIMessages.TST_SUITE_AUTO_MACRO_UP, AutoGUIImages.getInstance().getImageDescriptor("e", AutoGUIImages.UP), AutoGUIImages.getInstance().getImageDescriptor("d", AutoGUIImages.UP), moveUpAction), |
245 |
new AutoGUIDelegatorAction(this, AutoGUIMessages.TST_SUITE_AUTO_MACRO_UP, AutoGUIImages.getInstance().getImageDescriptor("e", AutoGUIImages.UP), AutoGUIImages.getInstance().getImageDescriptor("d", AutoGUIImages.UP), moveUpAction), |
| 246 |
new AutoGUIDelegatorAction(this, AutoGUIMessages.TST_SUITE_AUTO_MACRO_DOWN, AutoGUIImages.getInstance().getImageDescriptor("e", AutoGUIImages.DOWN), AutoGUIImages.getInstance().getImageDescriptor("d", AutoGUIImages.DOWN ), moveDownAction), |
246 |
new AutoGUIDelegatorAction(this, AutoGUIMessages.TST_SUITE_AUTO_MACRO_DOWN, AutoGUIImages.getInstance().getImageDescriptor("e", AutoGUIImages.DOWN), AutoGUIImages.getInstance().getImageDescriptor("d", AutoGUIImages.DOWN ), moveDownAction), |
| 247 |
new AutoGUIOrientationAction(this, true, UiPluginResourceBundle.Editor_horizontal_orientation, TestUIImages.INSTANCE.getImageDescriptor("e", TestUIImages.IMG_HORIZONTAL)), |
247 |
new AutoGUIOrientationAction(this, true, UiPluginResourceBundle.Editor_horizontal_orientation, TestUIImages.INSTANCE.getImageDescriptor("e", TestUIImages.IMG_HORIZONTAL)), |
| 248 |
new AutoGUIOrientationAction(this, false, UiPluginResourceBundle.Editor_vertical_orientation, TestUIImages.INSTANCE.getImageDescriptor("e", TestUIImages.IMG_VERTICAL)), |
248 |
new AutoGUIOrientationAction(this, false, UiPluginResourceBundle.Editor_vertical_orientation, TestUIImages.INSTANCE.getImageDescriptor("e", TestUIImages.IMG_VERTICAL)), |
| 249 |
}; |
249 |
}; |
| 250 |
|
250 |
|
| 251 |
separators = new int[] {1, 6}; |
251 |
separators = new int[] {1, 6}; |
| 252 |
} |
252 |
} |
| 253 |
|
253 |
|
| 254 |
protected void createRightColumnControls(Composite parent) |
254 |
protected void createRightColumnControls(Composite parent) |
| 255 |
{ |
255 |
{ |
| 256 |
/* Doesn't need to be implemented */ |
256 |
/* Doesn't need to be implemented */ |
| 257 |
} |
257 |
} |
| 258 |
|
258 |
|
| 259 |
protected void createLeftColumnControls(Composite parent) |
259 |
protected void createLeftColumnControls(Composite parent) |
| 260 |
{ |
260 |
{ |
| 261 |
/* Doesn't need to be implemented */ |
261 |
/* Doesn't need to be implemented */ |
| 262 |
} |
262 |
} |
| 263 |
|
263 |
|
| 264 |
|
264 |
|
| 265 |
/** |
265 |
/** |
| 266 |
* This method is over-written to re-organize controls based on a different |
266 |
* This method is over-written to re-organize controls based on a different |
| 267 |
* layout than the one that the parent class provides. |
267 |
* layout than the one that the parent class provides. |
| 268 |
* |
268 |
* |
| 269 |
* This form is divided into two horizontal panes that can be resized. The |
269 |
* This form is divided into two horizontal panes that can be resized. The |
| 270 |
* upper pane provides a logical tree view of the macro whereas the lower |
270 |
* upper pane provides a logical tree view of the macro whereas the lower |
| 271 |
* pane provides the raw XML macro. |
271 |
* pane provides the raw XML macro. |
| 272 |
*/ |
272 |
*/ |
| 273 |
protected void createFormContent(IManagedForm managedForm) |
273 |
protected void createFormContent(IManagedForm managedForm) |
| 274 |
{ |
274 |
{ |
| 275 |
form = managedForm.getForm(); |
275 |
form = managedForm.getForm(); |
| 276 |
form.setText(getEditorTitle()); |
276 |
form.setText(getEditorTitle()); |
| 277 |
Composite parent = form.getBody(); |
277 |
Composite parent = form.getBody(); |
| 278 |
|
278 |
|
| 279 |
GridLayout gridLayout = new GridLayout(); |
279 |
GridLayout gridLayout = new GridLayout(); |
| 280 |
parent.setLayout(gridLayout); |
280 |
parent.setLayout(gridLayout); |
| 281 |
GridData gd = GridDataUtil.createFill(); |
281 |
GridData gd = GridDataUtil.createFill(); |
| 282 |
parent.setLayoutData(gd); |
282 |
parent.setLayoutData(gd); |
| 283 |
|
283 |
|
| 284 |
Control[] controls = createSashForm(parent, SWT.HORIZONTAL); |
284 |
Control[] controls = createSashForm(parent, SWT.HORIZONTAL); |
| 285 |
sashForm = (SashForm)controls[0]; |
285 |
sashForm = (SashForm)controls[0]; |
| 286 |
|
286 |
|
| 287 |
sashForm.setWeights(new int[] {3, 7}); |
287 |
sashForm.setWeights(new int[] {3, 7}); |
| 288 |
createLeftPane((Composite)controls[1]); |
288 |
createLeftPane((Composite)controls[1]); |
| 289 |
createRightPane((Composite)controls[2]); |
289 |
createRightPane((Composite)controls[2]); |
| 290 |
|
290 |
|
| 291 |
addActions(); |
291 |
addActions(); |
| 292 |
} |
292 |
} |
| 293 |
|
293 |
|
| 294 |
|
294 |
|
| 295 |
/** |
295 |
/** |
| 296 |
* Adds the actions to the toolbar of the test case |
296 |
* Adds the actions to the toolbar of the test case |
| 297 |
* page. |
297 |
* page. |
| 298 |
*/ |
298 |
*/ |
| 299 |
private void addActions() |
299 |
private void addActions() |
| 300 |
{ |
300 |
{ |
| 301 |
TreeViewer treeViewer = logicalTreeRepresentaion.getTreeViewer(); |
301 |
TreeViewer treeViewer = logicalTreeRepresentaion.getTreeViewer(); |
| 302 |
IToolBarManager toolbarManager = form.getToolBarManager(); |
302 |
IToolBarManager toolbarManager = form.getToolBarManager(); |
| 303 |
int currentSeparatorInx = separators[0]; |
303 |
int currentSeparatorInx = separators[0]; |
| 304 |
int inx = 0; |
304 |
int inx = 0; |
| 305 |
|
305 |
|
| 306 |
for (int i = 0; i < actions.length; i++) |
306 |
for (int i = 0; i < actions.length; i++) |
| 307 |
{ |
307 |
{ |
| 308 |
if (actions[i] instanceof AutoGUITestCaseAction) |
308 |
if (actions[i] instanceof AutoGUITestCaseAction) |
| 309 |
{ |
309 |
{ |
| 310 |
AutoGUITestCaseAction autoGuiAction = (AutoGUITestCaseAction)actions[i]; |
310 |
AutoGUITestCaseAction autoGuiAction = (AutoGUITestCaseAction)actions[i]; |
| 311 |
treeViewer.addSelectionChangedListener(autoGuiAction); |
311 |
treeViewer.addSelectionChangedListener(autoGuiAction); |
| 312 |
autoGuiAction.init(); |
312 |
autoGuiAction.init(); |
| 313 |
} |
313 |
} |
| 314 |
|
314 |
|
| 315 |
toolbarManager.add(actions[i]); |
315 |
toolbarManager.add(actions[i]); |
| 316 |
if (currentSeparatorInx != -1 && currentSeparatorInx == i) |
316 |
if (currentSeparatorInx != -1 && currentSeparatorInx == i) |
| 317 |
{ |
317 |
{ |
| 318 |
toolbarManager.add(new Separator()); |
318 |
toolbarManager.add(new Separator()); |
| 319 |
if (++inx >= separators.length) |
319 |
if (++inx >= separators.length) |
| 320 |
currentSeparatorInx = -1; |
320 |
currentSeparatorInx = -1; |
| 321 |
else |
321 |
else |
| 322 |
currentSeparatorInx = separators[inx]; |
322 |
currentSeparatorInx = separators[inx]; |
| 323 |
} |
323 |
} |
| 324 |
} |
324 |
} |
| 325 |
|
325 |
|
| 326 |
form.updateToolBar(); |
326 |
form.updateToolBar(); |
| 327 |
} |
327 |
} |
| 328 |
|
328 |
|
| 329 |
|
329 |
|
| 330 |
private void createLeftPane(Composite parent) |
330 |
private void createLeftPane(Composite parent) |
| 331 |
{ |
331 |
{ |
| 332 |
Control[] controls = createSashForm(parent, SWT.VERTICAL); |
332 |
Control[] controls = createSashForm(parent, SWT.VERTICAL); |
| 333 |
final SashForm sashForm = (SashForm)controls[0]; |
333 |
final SashForm sashForm = (SashForm)controls[0]; |
| 334 |
sashForm.setWeights(new int[] {5, 5}); |
334 |
sashForm.setWeights(new int[] {5, 5}); |
| 335 |
|
335 |
|
| 336 |
|
336 |
|
| 337 |
/* Create the test case section */ |
337 |
/* Create the test case section */ |
| 338 |
createTreeStructure ((Composite)controls[1], logicalTreeRepresentaion, AutoGUIMessages.TST_SUITE_AUTO_MACRO_TESTS, logicalRepresentationListener); |
338 |
createTreeStructure ((Composite)controls[1], logicalTreeRepresentaion, AutoGUIMessages.TST_SUITE_AUTO_MACRO_TESTS, logicalRepresentationListener); |
| 339 |
|
339 |
|
| 340 |
/* Set the properties of the section */ |
340 |
/* Set the properties of the section */ |
| 341 |
Section objectMineSection = createTreeStructure ((Composite)controls[2], objectMineTree, AutoGUIMessages.TST_SUITE_AUTO_MACRO_OBJ_MINE, objectMineListener); |
341 |
Section objectMineSection = createTreeStructure ((Composite)controls[2], objectMineTree, AutoGUIMessages.TST_SUITE_AUTO_MACRO_OBJ_MINE, objectMineListener); |
| 342 |
objectMineSection.addExpansionListener(new IExpansionListener(){ |
342 |
objectMineSection.addExpansionListener(new IExpansionListener(){ |
| 343 |
|
343 |
|
| 344 |
public void expansionStateChanged(ExpansionEvent e) |
344 |
public void expansionStateChanged(ExpansionEvent e) |
| 345 |
{ |
345 |
{ |
| 346 |
if (!e.getState()) |
346 |
if (!e.getState()) |
| 347 |
{ |
347 |
{ |
| 348 |
sashForm.setWeights(new int[] {95, 5}); |
348 |
sashForm.setWeights(new int[] {95, 5}); |
| 349 |
} |
349 |
} |
| 350 |
else |
350 |
else |
| 351 |
{ |
351 |
{ |
| 352 |
sashForm.setWeights(new int[] {5, 5}); |
352 |
sashForm.setWeights(new int[] {5, 5}); |
| 353 |
} |
353 |
} |
| 354 |
} |
354 |
} |
| 355 |
|
355 |
|
| 356 |
public void expansionStateChanging(ExpansionEvent e) |
356 |
public void expansionStateChanging(ExpansionEvent e) |
| 357 |
{ |
357 |
{ |
| 358 |
}}); |
358 |
}}); |
| 359 |
} |
359 |
} |
| 360 |
|
360 |
|
| 361 |
|
361 |
|
| 362 |
private Control[] createSashForm(Composite parent, int orientation) |
362 |
private Control[] createSashForm(Composite parent, int orientation) |
| 363 |
{ |
363 |
{ |
| 364 |
SashForm sashForm = autoGUIToolkit.createSashForm(parent, orientation); |
364 |
SashForm sashForm = autoGUIToolkit.createSashForm(parent, orientation); |
| 365 |
sashForm.setLayoutData (new GridData(SWT.FILL, SWT.FILL, true, true)); |
365 |
sashForm.setLayoutData (new GridData(SWT.FILL, SWT.FILL, true, true)); |
| 366 |
|
366 |
|
| 367 |
Composite firstChild = autoGUIToolkit.createComposite(sashForm); |
367 |
Composite firstChild = autoGUIToolkit.createComposite(sashForm); |
| 368 |
firstChild.setLayout(new GridLayout()); |
368 |
firstChild.setLayout(new GridLayout()); |
| 369 |
firstChild.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); |
369 |
firstChild.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); |
| 370 |
|
370 |
|
| 371 |
Composite secondChild = autoGUIToolkit.createComposite(sashForm); |
371 |
Composite secondChild = autoGUIToolkit.createComposite(sashForm); |
| 372 |
secondChild.setLayout(new GridLayout()); |
372 |
secondChild.setLayout(new GridLayout()); |
| 373 |
secondChild.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); |
373 |
secondChild.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); |
| 374 |
|
374 |
|
| 375 |
return new Control[] {sashForm, firstChild, secondChild}; |
375 |
return new Control[] {sashForm, firstChild, secondChild}; |
| 376 |
} |
376 |
} |
| 377 |
|
377 |
|
| 378 |
|
378 |
|
| 379 |
private Section createTreeStructure (Composite parent, EObjectTree treeStructure, String sectionName, IMacroModifyListener macroListener) |
379 |
private Section createTreeStructure (Composite parent, EObjectTree treeStructure, String sectionName, IMacroModifyListener macroListener) |
| 380 |
{ |
380 |
{ |
| 381 |
/* Create the section */ |
381 |
/* Create the section */ |
| 382 |
Section section = FormUtil.createSection(autoGUIToolkit, parent, form); |
382 |
Section section = FormUtil.createSection(autoGUIToolkit, parent, form); |
| 383 |
section.addExpansionListener(expansionListener); |
383 |
section.addExpansionListener(expansionListener); |
| 384 |
section.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); |
384 |
section.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); |
| 385 |
|
385 |
|
| 386 |
/* Create the client of the section */ |
386 |
/* Create the client of the section */ |
| 387 |
final Control sectionClient = treeStructure.createControls(section, autoGUIToolkit); |
387 |
final Control sectionClient = treeStructure.createControls(section, autoGUIToolkit); |
| 388 |
treeStructure.getViewerPart().getViewer().setInput(getTestSuite()); |
388 |
treeStructure.getViewerPart().getViewer().setInput(getTestSuite()); |
| 389 |
|
389 |
|
| 390 |
/* Register the appropriate listeners */ |
390 |
/* Register the appropriate listeners */ |
| 391 |
final TreeViewer treeViewer = treeStructure.getTreeViewer(); |
391 |
final TreeViewer treeViewer = treeStructure.getTreeViewer(); |
| 392 |
treeViewer.addSelectionChangedListener(macroListener); |
392 |
treeViewer.addSelectionChangedListener(macroListener); |
| 393 |
addMacroModifyListener(macroListener); |
393 |
addMacroModifyListener(macroListener); |
| 394 |
treeViewer.getTree().addFocusListener(new FocusAdapter(){ |
394 |
treeViewer.getTree().addFocusListener(new FocusAdapter(){ |
| 395 |
|
395 |
|
| 396 |
public void focusGained(FocusEvent e) |
396 |
public void focusGained(FocusEvent e) |
| 397 |
{ |
397 |
{ |
| 398 |
Object[] selectedObjects = null; |
398 |
Object[] selectedObjects = null; |
| 399 |
ISelection selection = treeViewer.getSelection(); |
399 |
ISelection selection = treeViewer.getSelection(); |
| 400 |
if (selection instanceof StructuredSelection) |
400 |
if (selection instanceof StructuredSelection) |
| 401 |
selectedObjects = ((StructuredSelection)selection).toArray(); |
401 |
selectedObjects = ((StructuredSelection)selection).toArray(); |
| 402 |
treeViewer.setSelection(new StructuredSelection(selectedObjects)); |
402 |
treeViewer.setSelection(new StructuredSelection(selectedObjects)); |
| 403 |
} |
403 |
} |
| 404 |
}); |
404 |
}); |
| 405 |
|
405 |
|
| 406 |
/* Set the properties of the section */ |
406 |
/* Set the properties of the section */ |
| 407 |
FormUtil.setSectionProperty (autoGUIToolkit, section, sectionClient, sectionName); |
407 |
FormUtil.setSectionProperty (autoGUIToolkit, section, sectionClient, sectionName); |
| 408 |
|
408 |
|
| 409 |
return section; |
409 |
return section; |
| 410 |
} |
410 |
} |
| 411 |
|
411 |
|
| 412 |
public void setActive(boolean active) |
412 |
public void setActive(boolean active) |
| 413 |
{ |
413 |
{ |
| 414 |
super.setActive(active); |
414 |
super.setActive(active); |
| 415 |
|
415 |
|
| 416 |
|
416 |
|
| 417 |
IActionBars actionBars = this.getEditor().getEditorSite().getActionBars(); |
417 |
IActionBars actionBars = this.getEditor().getEditorSite().getActionBars(); |
| 418 |
if (actionBars == null) |
418 |
if (actionBars == null) |
| 419 |
return; |
419 |
return; |
| 420 |
|
420 |
|
| 421 |
if (active) |
421 |
if (active) |
| 422 |
{ |
422 |
{ |
| 423 |
actionBars.setGlobalActionHandler(ActionFactory.FIND.getId(), findReplaceAction); |
423 |
actionBars.setGlobalActionHandler(ActionFactory.FIND.getId(), findReplaceAction); |
| 424 |
actionBars.setGlobalActionHandler(ActionFactory.UNDO.getId(), undoAction); |
424 |
actionBars.setGlobalActionHandler(ActionFactory.UNDO.getId(), undoAction); |
| 425 |
actionBars.setGlobalActionHandler(ActionFactory.REDO.getId(), redoAction); |
425 |
actionBars.setGlobalActionHandler(ActionFactory.REDO.getId(), redoAction); |
| 426 |
} |
426 |
} |
| 427 |
else |
427 |
else |
| 428 |
{ |
428 |
{ |
| 429 |
actionBars.setGlobalActionHandler(ActionFactory.FIND.getId(), null); |
429 |
actionBars.setGlobalActionHandler(ActionFactory.FIND.getId(), null); |
| 430 |
actionBars.setGlobalActionHandler(ActionFactory.UNDO.getId(), null); |
430 |
actionBars.setGlobalActionHandler(ActionFactory.UNDO.getId(), null); |
| 431 |
actionBars.setGlobalActionHandler(ActionFactory.REDO.getId(), null); |
431 |
actionBars.setGlobalActionHandler(ActionFactory.REDO.getId(), null); |
| 432 |
} |
432 |
} |
| 433 |
} |
433 |
} |
| 434 |
|
434 |
|
| 435 |
|
435 |
|
| 436 |
/** |
436 |
/** |
| 437 |
* Refreshes the test case tree and the object mine tree owned by |
437 |
* Refreshes the test case tree and the object mine tree owned by |
| 438 |
* this form. |
438 |
* this form. |
| 439 |
*/ |
439 |
*/ |
| 440 |
public void refresh() |
440 |
public void refresh() |
| 441 |
{ |
441 |
{ |
| 442 |
TreeViewer treeViewer = null; |
442 |
TreeViewer treeViewer = null; |
| 443 |
ISelection selection = null; |
443 |
ISelection selection = null; |
| 444 |
if (activeMacroModifyListener != null) |
444 |
if (activeMacroModifyListener != null) |
| 445 |
{ |
445 |
{ |
| 446 |
treeViewer = activeMacroModifyListener.getTreeStructure().getTreeViewer(); |
446 |
treeViewer = activeMacroModifyListener.getTreeStructure().getTreeViewer(); |
| 447 |
selection = treeViewer.getSelection(); |
447 |
selection = treeViewer.getSelection(); |
| 448 |
} |
448 |
} |
| 449 |
|
449 |
|
| 450 |
logicalTreeRepresentaion.refresh(); |
450 |
logicalTreeRepresentaion.refresh(); |
| 451 |
objectMineTree.refresh(); |
451 |
objectMineTree.refresh(); |
| 452 |
|
452 |
|
| 453 |
if (treeViewer != null) |
453 |
if (treeViewer != null) |
| 454 |
{ |
454 |
{ |
| 455 |
treeViewer.setSelection(selection); |
455 |
treeViewer.setSelection(selection); |
| 456 |
} |
456 |
} |
| 457 |
} |
457 |
} |
| 458 |
|
458 |
|
| 459 |
private void setMacroText(String macro) |
459 |
private void setMacroText(String macro) |
| 460 |
{ |
460 |
{ |
| 461 |
isOperationHistory = false; |
461 |
isOperationHistory = false; |
| 462 |
rawRepresentation.setText(macro); |
462 |
rawRepresentation.setText(macro); |
| 463 |
isOperationHistory = true; |
463 |
isOperationHistory = true; |
| 464 |
} |
464 |
} |
| 465 |
|
465 |
|
| 466 |
|
466 |
|
| 467 |
private void createRightPane(Composite parent) |
467 |
private void createRightPane(Composite parent) |
| 468 |
{ |
468 |
{ |
| 469 |
final SashForm sashForm = autoGUIToolkit.createSashForm(parent, SWT.VERTICAL); |
469 |
final SashForm sashForm = autoGUIToolkit.createSashForm(parent, SWT.VERTICAL); |
| 470 |
sashForm.setLayout(new GridLayout()); |
470 |
sashForm.setLayout(new GridLayout()); |
| 471 |
sashForm.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); |
471 |
sashForm.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); |
| 472 |
|
472 |
|
| 473 |
Composite macroComposite = autoGUIToolkit.createComposite(sashForm); |
473 |
Composite macroComposite = autoGUIToolkit.createComposite(sashForm); |
| 474 |
macroComposite.setLayout(new GridLayout()); |
474 |
macroComposite.setLayout(new GridLayout()); |
| 475 |
macroComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); |
475 |
macroComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); |
| 476 |
|
476 |
|
| 477 |
Section section = FormUtil.createSection(autoGUIToolkit, macroComposite, form); |
477 |
Section section = FormUtil.createSection(autoGUIToolkit, macroComposite, form); |
| 478 |
section.setLayout(new GridLayout()); |
478 |
section.setLayout(new GridLayout()); |
| 479 |
section.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); |
479 |
section.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); |
| 480 |
section.addExpansionListener(expansionListener); |
480 |
section.addExpansionListener(expansionListener); |
| 481 |
|
481 |
|
| 482 |
/* Create the client of the section */ |
482 |
/* Create the client of the section */ |
| 483 |
Composite sectionClient = autoGUIToolkit.createComposite(section); |
483 |
Composite sectionClient = autoGUIToolkit.createComposite(section); |
| 484 |
sectionClient.setLayout(new GridLayout()); |
484 |
sectionClient.setLayout(new GridLayout()); |
| 485 |
|
485 |
|
| 486 |
|
486 |
|
| 487 |
/* Create the left side ruler along with 2 columns: line number column and an annotation column */ |
487 |
/* Create the left side ruler along with 2 columns: line number column and an annotation column */ |
| 488 |
CompositeRuler compositeRuler = new CompositeRuler(); |
488 |
CompositeRuler compositeRuler = new CompositeRuler(); |
| 489 |
LineNumberRulerColumn lineNumberRuler = new LineNumberRulerColumn(); |
489 |
LineNumberRulerColumn lineNumberRuler = new LineNumberRulerColumn(); |
| 490 |
Font courierFont = new Font(Display.getDefault(), "Courier New", 10, SWT.NORMAL); |
490 |
Font courierFont = new Font(Display.getDefault(), "Courier New", 10, SWT.NORMAL); |
| 491 |
lineNumberRuler.setFont(courierFont); |
491 |
lineNumberRuler.setFont(courierFont); |
| 492 |
lineNumberRuler.setForeground(new Color(Display.getDefault(), new RGB(180,180,180))); |
492 |
lineNumberRuler.setForeground(new Color(Display.getDefault(), new RGB(180,180,180))); |
| 493 |
|
493 |
|
| 494 |
AnnotationRulerColumn annotationRulerColumn = new AnnotationRulerColumn(12); |
494 |
AnnotationRulerColumn annotationRulerColumn = new AnnotationRulerColumn(12); |
| 495 |
compositeRuler.addDecorator(0, lineNumberRuler); |
495 |
compositeRuler.addDecorator(0, lineNumberRuler); |
| 496 |
compositeRuler.addDecorator(1, annotationRulerColumn); |
496 |
compositeRuler.addDecorator(1, annotationRulerColumn); |
| 497 |
|
497 |
|
| 498 |
/* Create the source viewer that will be used to contain the macro text */ |
498 |
/* Create the source viewer that will be used to contain the macro text */ |
| 499 |
Composite sourceViewerComposite = autoGUIToolkit.createComposite(sectionClient, SWT.BORDER); |
499 |
Composite sourceViewerComposite = autoGUIToolkit.createComposite(sectionClient, SWT.BORDER); |
| 500 |
sourceViewerComposite.setLayout(new GridLayout()); |
500 |
sourceViewerComposite.setLayout(new GridLayout()); |
| 501 |
sourceViewerComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); |
501 |
sourceViewerComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); |
| 502 |
|
502 |
|
| 503 |
SourceViewer sourceViewer = new SourceViewer(sourceViewerComposite, compositeRuler, SWT.V_SCROLL | SWT.H_SCROLL | SWT.MULTI | SWT.BORDER | SWT.FULL_SELECTION); |
503 |
SourceViewer sourceViewer = new SourceViewer(sourceViewerComposite, compositeRuler, SWT.V_SCROLL | SWT.H_SCROLL | SWT.MULTI | SWT.BORDER | SWT.FULL_SELECTION); |
| 504 |
sourceViewer.configure(new SourceViewerConfiguration()); |
504 |
sourceViewer.configure(new SourceViewerConfiguration()); |
| 505 |
sourceViewer.setDocument(new Document()); |
505 |
sourceViewer.setDocument(new Document()); |
| 506 |
sourceViewer.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); |
506 |
sourceViewer.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); |
| 507 |
sourceViewer.showAnnotations(true); |
507 |
sourceViewer.showAnnotations(true); |
| 508 |
|
508 |
|
| 509 |
rawRepresentation = sourceViewer.getTextWidget(); |
509 |
rawRepresentation = sourceViewer.getTextWidget(); |
| 510 |
AutoGUIXMLLineStyler xmlLineStyler = new AutoGUIXMLLineStyler(); |
510 |
AutoGUIXMLLineStyler xmlLineStyler = new AutoGUIXMLLineStyler(); |
| 511 |
rawRepresentation.addLineStyleListener(xmlLineStyler); |
511 |
rawRepresentation.addLineStyleListener(xmlLineStyler); |
| 512 |
rawRepresentation.addExtendedModifyListener(new ExtendedModifyListener() |
512 |
rawRepresentation.addExtendedModifyListener(new ExtendedModifyListener() |
| 513 |
{ |
513 |
{ |
| 514 |
public void modifyText(ExtendedModifyEvent event) |
514 |
public void modifyText(ExtendedModifyEvent event) |
| 515 |
{ |
515 |
{ |
| 516 |
rawRepresentation.redrawRange(0, ((StyledText)event.widget).getText().length(), false); |
516 |
rawRepresentation.redrawRange(0, ((StyledText)event.widget).getText().length(), false); |
| 517 |
// added for defect 164345 |
517 |
// added for defect 164345 |
| 518 |
// Liz D. |
518 |
// Liz D. |
| 519 |
} |
519 |
} |
| 520 |
}); |
520 |
}); |
| 521 |
|
521 |
|
| 522 |
rawRepresentation.setFont(courierFont); |
522 |
rawRepresentation.setFont(courierFont); |
| 523 |
ITestCase testCase = logicalTreeRepresentaion.getSelectedTestCase(); |
523 |
ITestCase testCase = logicalTreeRepresentaion.getSelectedTestCase(); |
| 524 |
if (testCase == null) |
524 |
if (testCase == null) |
| 525 |
rawRepresentation.setEditable(false); |
525 |
rawRepresentation.setEditable(false); |
| 526 |
|
526 |
|
| 527 |
|
527 |
|
| 528 |
/* Create the general section */ |
528 |
/* Create the general section */ |
| 529 |
Composite descriptionComposite = autoGUIToolkit.createComposite(sashForm); |
529 |
Composite descriptionComposite = autoGUIToolkit.createComposite(sashForm); |
| 530 |
descriptionComposite.setLayout(new GridLayout()); |
530 |
descriptionComposite.setLayout(new GridLayout()); |
| 531 |
descriptionComposite.setLayoutData(new GridData(SWT.FILL, SWT.DEFAULT, true, false)); |
531 |
descriptionComposite.setLayoutData(new GridData(SWT.FILL, SWT.DEFAULT, true, false)); |
| 532 |
Section commonPropertySection = createCommonPropertySection (autoGUIToolkit, descriptionComposite); |
532 |
Section commonPropertySection = createCommonPropertySection (autoGUIToolkit, descriptionComposite); |
| 533 |
commonPropertySection.setLayout(new GridLayout()); |
533 |
commonPropertySection.setLayout(new GridLayout()); |
| 534 |
commonPropertySection.setLayoutData(new GridData(SWT.FILL, SWT.DEFAULT, true, false)); |
534 |
commonPropertySection.setLayoutData(new GridData(SWT.FILL, SWT.DEFAULT, true, false)); |
| 535 |
createStartingPointControls(commonPropertySection); |
535 |
createStartingPointControls(commonPropertySection); |
| 536 |
commonPropertySection.setLayoutData(new GridData(SWT.FILL, SWT.DEFAULT, true, false)); |
536 |
commonPropertySection.setLayoutData(new GridData(SWT.FILL, SWT.DEFAULT, true, false)); |
| 537 |
commonPropertySection.setExpanded(false); |
537 |
commonPropertySection.setExpanded(false); |
| 538 |
commonPropertySection.addExpansionListener(expansionListener); |
538 |
commonPropertySection.addExpansionListener(expansionListener); |
| 539 |
commonPropertySection.addExpansionListener(new IExpansionListener(){ |
539 |
commonPropertySection.addExpansionListener(new IExpansionListener(){ |
| 540 |
|
540 |
|
| 541 |
public void expansionStateChanged(ExpansionEvent e) |
541 |
public void expansionStateChanged(ExpansionEvent e) |
| 542 |
{ |
542 |
{ |
| 543 |
// TODO Auto-generated method stub |
543 |
// TODO Auto-generated method stub |
| 544 |
|
544 |
|
| 545 |
} |
545 |
} |
| 546 |
|
546 |
|
| 547 |
public void expansionStateChanging(ExpansionEvent e) |
547 |
public void expansionStateChanging(ExpansionEvent e) |
| 548 |
{ |
548 |
{ |
| 549 |
if (e.getState()) |
549 |
if (e.getState()) |
| 550 |
{ |
550 |
{ |
| 551 |
sashForm.setWeights(new int[]{5, 5}); |
551 |
sashForm.setWeights(new int[]{5, 5}); |
| 552 |
} |
552 |
} |
| 553 |
else |
553 |
else |
| 554 |
{ |
554 |
{ |
| 555 |
sashForm.setWeights(new int[]{95, 5}); |
555 |
sashForm.setWeights(new int[]{95, 5}); |
| 556 |
} |
556 |
} |
| 557 |
|
557 |
|
| 558 |
}}); |
558 |
}}); |
| 559 |
|
559 |
|
| 560 |
/* Set the properties of the section */ |
560 |
/* Set the properties of the section */ |
| 561 |
FormUtil.setSectionProperty (autoGUIToolkit, section, sectionClient, AutoGUIMessages.TST_SUITE_AUTO_MACRO_MACRO); |
561 |
FormUtil.setSectionProperty (autoGUIToolkit, section, sectionClient, AutoGUIMessages.TST_SUITE_AUTO_MACRO_MACRO); |
| 562 |
sashForm.setWeights(new int[]{95, 5}); |
562 |
sashForm.setWeights(new int[]{95, 5}); |
| 563 |
|
563 |
|
| 564 |
if (rootMacroModifyListener == null) |
564 |
if (rootMacroModifyListener == null) |
| 565 |
rootMacroModifyListener = new RootMacroModifyListener(); |
565 |
rootMacroModifyListener = new RootMacroModifyListener(); |
| 566 |
rawRepresentation.addExtendedModifyListener(rootMacroModifyListener); |
566 |
rawRepresentation.addExtendedModifyListener(rootMacroModifyListener); |
| 567 |
|
567 |
|
| 568 |
MenuManager menuManager = new MenuManager(); |
568 |
MenuManager menuManager = new MenuManager(); |
| 569 |
findReplaceAction = new FindReplaceAction(UiPlugin.getInstance().getResourceBundle(), "find_replace_action.", this); |
569 |
findReplaceAction = new FindReplaceAction(UiPlugin.getInstance().getResourceBundle(), "find_replace_action.", this); |
| 570 |
findReplaceAction.setText(AutoGUIMessages.TST_SUITE_AUTO_MACRO_FIND); |
570 |
findReplaceAction.setText(AutoGUIMessages.TST_SUITE_AUTO_MACRO_FIND); |
| 571 |
findReplaceAction.setImageDescriptor(AutoGUIImages.getInstance().getImageDescriptor("e", AutoGUIImages.FIND)); |
571 |
findReplaceAction.setImageDescriptor(AutoGUIImages.getInstance().getImageDescriptor("e", AutoGUIImages.FIND)); |
| 572 |
menuManager.add(findReplaceAction); |
572 |
menuManager.add(findReplaceAction); |
| 573 |
rawRepresentation.setMenu(menuManager.createContextMenu(rawRepresentation)); |
573 |
rawRepresentation.setMenu(menuManager.createContextMenu(rawRepresentation)); |
| 574 |
|
574 |
|
| 575 |
|
575 |
|
| 576 |
undoAction = new UndoRedoAction(true); |
576 |
undoAction = new UndoRedoAction(true); |
| 577 |
redoAction = new UndoRedoAction(false); |
577 |
redoAction = new UndoRedoAction(false); |
| 578 |
} |
578 |
} |
| 579 |
|
579 |
|
| 580 |
|
580 |
|
| 581 |
/** |
581 |
/** |
| 582 |
* Allows a macro modify listener to be registered with this test case page. |
582 |
* Allows a macro modify listener to be registered with this test case page. |
| 583 |
* Has no effects if the listener is already registered. |
583 |
* Has no effects if the listener is already registered. |
| 584 |
* |
584 |
* |
| 585 |
* @param macroListener The listener |
585 |
* @param macroListener The listener |
| 586 |
*/ |
586 |
*/ |
| 587 |
private void addMacroModifyListener(IMacroModifyListener macroListener) |
587 |
private void addMacroModifyListener(IMacroModifyListener macroListener) |
| 588 |
{ |
588 |
{ |
| 589 |
if (!macroModificationListeners.contains(macroListener)) |
589 |
if (!macroModificationListeners.contains(macroListener)) |
| 590 |
macroModificationListeners.add(macroListener); |
590 |
macroModificationListeners.add(macroListener); |
| 591 |
} |
591 |
} |
| 592 |
|
592 |
|
| 593 |
|
593 |
|
| 594 |
/** |
594 |
/** |
| 595 |
* Removes a macro modify listener. Has no effects if the listener is not |
595 |
* Removes a macro modify listener. Has no effects if the listener is not |
| 596 |
* registered. |
596 |
* registered. |
| 597 |
* |
597 |
* |
| 598 |
* @param macroListener The macro modify listener to remove |
598 |
* @param macroListener The macro modify listener to remove |
| 599 |
*/ |
599 |
*/ |
| 600 |
private void removeMacroModifyListener(IMacroModifyListener macroListener) |
600 |
private void removeMacroModifyListener(IMacroModifyListener macroListener) |
| 601 |
{ |
601 |
{ |
| 602 |
macroModificationListeners.remove(macroListener); |
602 |
macroModificationListeners.remove(macroListener); |
| 603 |
} |
603 |
} |
| 604 |
|
604 |
|
| 605 |
|
605 |
|
| 606 |
/** |
606 |
/** |
| 607 |
* Grants a macro modify listener activation. |
607 |
* Grants a macro modify listener activation. |
| 608 |
* |
608 |
* |
| 609 |
* @param macroModifyListener The macro modify listener requesting the activation |
609 |
* @param macroModifyListener The macro modify listener requesting the activation |
| 610 |
* @return true if request is granted; false otherwise. |
610 |
* @return true if request is granted; false otherwise. |
| 611 |
*/ |
611 |
*/ |
| 612 |
private boolean requestActivation(IMacroModifyListener macroModifyListener) |
612 |
private boolean requestActivation(IMacroModifyListener macroModifyListener) |
| 613 |
{ |
613 |
{ |
| 614 |
if (macroModifyListener == activeMacroModifyListener) |
614 |
if (macroModifyListener == activeMacroModifyListener) |
| 615 |
return true; |
615 |
return true; |
| 616 |
|
616 |
|
| 617 |
boolean grantStatus = false; |
617 |
boolean grantStatus = false; |
| 618 |
for (int i = 0, listenerCount = macroModificationListeners.size(); i < listenerCount; i++) |
618 |
for (int i = 0, listenerCount = macroModificationListeners.size(); i < listenerCount; i++) |
| 619 |
{ |
619 |
{ |
| 620 |
IMacroModifyListener currentListener = (IMacroModifyListener)macroModificationListeners.get(i); |
620 |
IMacroModifyListener currentListener = (IMacroModifyListener)macroModificationListeners.get(i); |
| 621 |
if (currentListener == macroModifyListener) |
621 |
if (currentListener == macroModifyListener) |
| 622 |
{ |
622 |
{ |
| 623 |
grantStatus = true; |
623 |
grantStatus = true; |
| 624 |
if (activeMacroModifyListener != null) |
624 |
if (activeMacroModifyListener != null) |
| 625 |
activeMacroModifyListener.deactivated(); |
625 |
activeMacroModifyListener.deactivated(); |
| 626 |
activeMacroModifyListener = currentListener; |
626 |
activeMacroModifyListener = currentListener; |
| 627 |
} |
627 |
} |
| 628 |
} |
628 |
} |
| 629 |
|
629 |
|
| 630 |
return grantStatus; |
630 |
return grantStatus; |
| 631 |
} |
631 |
} |
| 632 |
|
632 |
|
| 633 |
|
633 |
|
| 634 |
/** |
634 |
/** |
| 635 |
* Returns the currently active modify listener |
635 |
* Returns the currently active modify listener |
| 636 |
* |
636 |
* |
| 637 |
* @return The active modify listener |
637 |
* @return The active modify listener |
| 638 |
*/ |
638 |
*/ |
| 639 |
private IMacroModifyListener getActiveMacroListener() |
639 |
private IMacroModifyListener getActiveMacroListener() |
| 640 |
{ |
640 |
{ |
| 641 |
return activeMacroModifyListener; |
641 |
return activeMacroModifyListener; |
| 642 |
} |
642 |
} |
| 643 |
|
643 |
|
| 644 |
|
644 |
|
| 645 |
/** |
645 |
/** |
| 646 |
* Create the starting point text box |
646 |
* Create the starting point text box |
| 647 |
* |
647 |
* |
| 648 |
* @param commonPropertySection |
648 |
* @param commonPropertySection |
| 649 |
*/ |
649 |
*/ |
| 650 |
private void createStartingPointControls(Section commonPropertySection) |
650 |
private void createStartingPointControls(Section commonPropertySection) |
| 651 |
{ |
651 |
{ |
| 652 |
Composite composite = (Composite)commonPropertySection.getClient(); |
652 |
Composite composite = (Composite)commonPropertySection.getClient(); |
| 653 |
|
653 |
|
| 654 |
/* Create the starting point widgets */ |
654 |
/* Create the starting point widgets */ |
| 655 |
Label startingPtlbl = autoGUIToolkit.createLabel(composite, AutoGUIMessages.AUTO_GUI_DETAILS_STARTPT); |
655 |
Label startingPtlbl = autoGUIToolkit.createLabel(composite, AutoGUIMessages.AUTO_GUI_DETAILS_STARTPT); |
| 656 |
startingPtlbl.setLayoutData(new GridData(SWT.FILL, SWT.DEFAULT, true, false)); |
656 |
startingPtlbl.setLayoutData(new GridData(SWT.FILL, SWT.DEFAULT, true, false)); |
| 657 |
|
657 |
|
| 658 |
ITestCase testCase = logicalTreeRepresentaion.getSelectedTestCase(); |
658 |
ITestCase testCase = logicalTreeRepresentaion.getSelectedTestCase(); |
| 659 |
String startingPt = (testCase == null ? "" : getProperty(testCase, GUITestCaseProperties.STARTING_PT)); |
659 |
String startingPt = (testCase == null ? "" : getProperty(testCase, GUITestCaseProperties.STARTING_PT)); |
| 660 |
|
660 |
|
| 661 |
startingPttxt = autoGUIToolkit.createText (composite, startingPt, SWT.BORDER); |
661 |
startingPttxt = autoGUIToolkit.createText (composite, startingPt, SWT.BORDER); |
| 662 |
if (testCase == null) |
662 |
if (testCase == null) |
| 663 |
startingPttxt.setEditable(false); |
663 |
startingPttxt.setEditable(false); |
| 664 |
startingPttxt.setLayoutData(new GridData(SWT.FILL, SWT.DEFAULT, true, false)); |
664 |
startingPttxt.setLayoutData(new GridData(SWT.FILL, SWT.DEFAULT, true, false)); |
| 665 |
startingPttxt.addModifyListener(new ModifyListener(){ |
665 |
startingPttxt.addModifyListener(new ModifyListener(){ |
| 666 |
|
666 |
|
| 667 |
public void modifyText(ModifyEvent e) |
667 |
public void modifyText(ModifyEvent e) |
| 668 |
{ |
668 |
{ |
| 669 |
ITestCase input = logicalTreeRepresentaion.getSelectedTestCase(); |
669 |
ITestCase input = logicalTreeRepresentaion.getSelectedTestCase(); |
| 670 |
|
670 |
|
| 671 |
/* We need input to be set */ |
671 |
/* We need input to be set */ |
| 672 |
if (input == null) |
672 |
if (input == null) |
| 673 |
{ |
673 |
{ |
| 674 |
startingPttxt.setEditable(false); |
674 |
startingPttxt.setEditable(false); |
| 675 |
return; |
675 |
return; |
| 676 |
} |
676 |
} |
| 677 |
|
677 |
|
| 678 |
|
678 |
|
| 679 |
String oldfield = null, newfield = null; |
679 |
String oldfield = null, newfield = null; |
| 680 |
newfield = startingPttxt.getText(); |
680 |
newfield = startingPttxt.getText(); |
| 681 |
oldfield = getProperty(input, GUITestCaseProperties.STARTING_PT); |
681 |
oldfield = getProperty(input, GUITestCaseProperties.STARTING_PT); |
| 682 |
|
682 |
|
| 683 |
if (oldfield == null && (newfield == null || newfield.length() <= 0)) |
683 |
if (oldfield == null && (newfield == null || newfield.length() <= 0)) |
| 684 |
return; |
684 |
return; |
| 685 |
|
685 |
|
| 686 |
if ((oldfield == null && newfield != null && newfield.length() > 0) || (oldfield != null && !oldfield.equals(newfield))) |
686 |
if ((oldfield == null && newfield != null && newfield.length() > 0) || (oldfield != null && !oldfield.equals(newfield))) |
| 687 |
addProperty(input, GUITestCaseProperties.STARTING_PT, newfield); |
687 |
addProperty(input, GUITestCaseProperties.STARTING_PT, newfield); |
| 688 |
else |
688 |
else |
| 689 |
return; |
689 |
return; |
| 690 |
|
690 |
|
| 691 |
|
691 |
|
| 692 |
markEditorDirty(); |
692 |
markEditorDirty(); |
| 693 |
}}); |
693 |
}}); |
| 694 |
|
694 |
|
| 695 |
} |
695 |
} |
| 696 |
|
696 |
|
| 697 |
public StyledText getRawRepresentation() |
697 |
public StyledText getRawRepresentation() |
| 698 |
{ |
698 |
{ |
| 699 |
return rawRepresentation; |
699 |
return rawRepresentation; |
| 700 |
} |
700 |
} |
| 701 |
|
701 |
|
| 702 |
|
702 |
|
| 703 |
private IUndoContext getUndoContext() |
703 |
private IUndoContext getUndoContext() |
| 704 |
{ |
704 |
{ |
| 705 |
if (activeMacroModifyListener == null) |
705 |
if (activeMacroModifyListener == null) |
| 706 |
return null; |
706 |
return null; |
| 707 |
|
707 |
|
| 708 |
return activeMacroModifyListener.getUndoContext(); |
708 |
return activeMacroModifyListener.getUndoContext(); |
| 709 |
} |
709 |
} |
| 710 |
|
710 |
|
| 711 |
|
711 |
|
| 712 |
public void dispose() |
712 |
public void dispose() |
| 713 |
{ |
713 |
{ |
| 714 |
super.dispose(); |
714 |
super.dispose(); |
| 715 |
|
715 |
|
| 716 |
logicalRepresentationListener = null; |
716 |
logicalRepresentationListener = null; |
| 717 |
|
717 |
|
| 718 |
removeMacroModifyListener(logicalRepresentationListener); |
718 |
removeMacroModifyListener(logicalRepresentationListener); |
| 719 |
removeMacroModifyListener(objectMineListener); |
719 |
removeMacroModifyListener(objectMineListener); |
| 720 |
|
720 |
|
| 721 |
if (lastTreeHierarchySelected != null) |
721 |
if (lastTreeHierarchySelected != null) |
| 722 |
{ |
722 |
{ |
| 723 |
lastTreeHierarchySelected.clear(); |
723 |
lastTreeHierarchySelected.clear(); |
| 724 |
lastTreeHierarchySelected = null; |
724 |
lastTreeHierarchySelected = null; |
| 725 |
} |
725 |
} |
| 726 |
|
726 |
|
| 727 |
if (xmlLineStyler != null) |
727 |
if (xmlLineStyler != null) |
| 728 |
xmlLineStyler.dispose(); |
728 |
xmlLineStyler.dispose(); |
| 729 |
|
729 |
|
| 730 |
if (rawRepresentation != null) |
730 |
if (rawRepresentation != null) |
| 731 |
{ |
731 |
{ |
| 732 |
rawRepresentation.dispose(); |
732 |
rawRepresentation.dispose(); |
| 733 |
rawRepresentation = null; |
733 |
rawRepresentation = null; |
| 734 |
} |
734 |
} |
| 735 |
|
735 |
|
| 736 |
if (logicalTreeRepresentaion != null) |
736 |
if (logicalTreeRepresentaion != null) |
| 737 |
{ |
737 |
{ |
| 738 |
logicalTreeRepresentaion.dispose(); |
738 |
logicalTreeRepresentaion.dispose(); |
| 739 |
logicalTreeRepresentaion = null; |
739 |
logicalTreeRepresentaion = null; |
| 740 |
} |
740 |
} |
| 741 |
|
741 |
|
| 742 |
if (linearOperationHistory != null && context != null) |
742 |
if (linearOperationHistory != null && context != null) |
| 743 |
{ |
743 |
{ |
| 744 |
for (Iterator contextIterator = context.values().iterator(); contextIterator.hasNext();) |
744 |
for (Iterator contextIterator = context.values().iterator(); contextIterator.hasNext();) |
| 745 |
linearOperationHistory.dispose((IUndoContext)contextIterator.next(), true, true, true); |
745 |
linearOperationHistory.dispose((IUndoContext)contextIterator.next(), true, true, true); |
| 746 |
|
746 |
|
| 747 |
linearOperationHistory = null; |
747 |
linearOperationHistory = null; |
| 748 |
context = null; |
748 |
context = null; |
| 749 |
} |
749 |
} |
| 750 |
} |
750 |
} |
| 751 |
|
751 |
|
| 752 |
/** |
752 |
/** |
| 753 |
* Adds extended properties to test cases |
753 |
* Adds extended properties to test cases |
| 754 |
* |
754 |
* |
| 755 |
* @param testCase The test case |
755 |
* @param testCase The test case |
| 756 |
* @param field The field to be added - see constants in GUITestCaseProperties |
756 |
* @param field The field to be added - see constants in GUITestCaseProperties |
| 757 |
* @param value The value of the field |
757 |
* @param value The value of the field |
| 758 |
*/ |
758 |
*/ |
| 759 |
public void addProperty (ITestCase testCase, byte field, String value) |
759 |
public void addProperty (ITestCase testCase, byte field, String value) |
| 760 |
{ |
760 |
{ |
| 761 |
testCasePropertyManager.setTestCase(testCase); |
761 |
testCasePropertyManager.setTestCase(testCase); |
| 762 |
testCasePropertyManager.addProperty(field, value); |
762 |
testCasePropertyManager.addProperty(field, value); |
| 763 |
} |
763 |
} |
| 764 |
|
764 |
|
| 765 |
|
765 |
|
| 766 |
public String getProperty (ITestCase testCase, byte field) |
766 |
public String getProperty (ITestCase testCase, byte field) |
| 767 |
{ |
767 |
{ |
| 768 |
testCasePropertyManager.setTestCase(testCase); |
768 |
testCasePropertyManager.setTestCase(testCase); |
| 769 |
return testCasePropertyManager.getProperty(field); |
769 |
return testCasePropertyManager.getProperty(field); |
| 770 |
} |
770 |
} |
| 771 |
|
771 |
|
| 772 |
|
772 |
|
| 773 |
private void setMacroContent (String content) |
773 |
private void setMacroContent (String content) |
| 774 |
{ |
774 |
{ |
| 775 |
boolean isContentNull = content == null; |
775 |
boolean isContentNull = content == null; |
| 776 |
|
776 |
|
| 777 |
if (isContentNull) |
777 |
if (isContentNull) |
| 778 |
rootMacroModifyListener.setEnabled(false); |
778 |
rootMacroModifyListener.setEnabled(false); |
| 779 |
|
779 |
|
| 780 |
setMacroText(isContentNull ? "" : content); |
780 |
setMacroText(isContentNull ? "" : content); |
| 781 |
rootMacroModifyListener.setEnabled(true); |
781 |
rootMacroModifyListener.setEnabled(true); |
| 782 |
|
782 |
|
| 783 |
/* Make the macro text area non-editable if there are no selections in the active input */ |
783 |
/* Make the macro text area non-editable if there are no selections in the active input */ |
| 784 |
rawRepresentation.setEditable(!(isContentNull && activeMacroModifyListener.getSelection().isEmpty())); |
784 |
rawRepresentation.setEditable(!(isContentNull && activeMacroModifyListener.getSelection().isEmpty())); |
| 785 |
} |
785 |
} |
| 786 |
|
786 |
|
| 787 |
private void selectMacroFragment(List lineOffsetRelation, Integer[] lineRange) |
787 |
private void selectMacroFragment(List lineOffsetRelation, Integer[] lineRange) |
| 788 |
{ |
788 |
{ |
| 789 |
if (lineOffsetRelation == null) |
789 |
if (lineOffsetRelation == null) |
| 790 |
return; |
790 |
return; |
| 791 |
|
791 |
|
| 792 |
if (lineRange.length < 2) |
792 |
if (lineRange.length < 2) |
| 793 |
return; |
793 |
return; |
| 794 |
int startOffset = -1, endOffset = -1; |
794 |
int startOffset = -1, endOffset = -1; |
| 795 |
int lineStart = lineRange[0].intValue() - 1, lineEnd = lineRange[1].intValue(); |
795 |
int lineStart = lineRange[0].intValue() - 1, lineEnd = lineRange[1].intValue(); |
| 796 |
int parsedMacroLength = lineOffsetRelation.size(); |
796 |
int parsedMacroLength = lineOffsetRelation.size(); |
| 797 |
String textContent = rawRepresentation.getText(); |
797 |
String textContent = rawRepresentation.getText(); |
| 798 |
|
798 |
|
| 799 |
if (lineStart > 0 && lineStart < parsedMacroLength) |
799 |
if (lineStart > 0 && lineStart < parsedMacroLength) |
| 800 |
startOffset = ((int[])lineOffsetRelation.get(lineStart))[0]; |
800 |
startOffset = ((int[])lineOffsetRelation.get(lineStart))[0]; |
| 801 |
if (lineEnd > 0 && lineEnd < parsedMacroLength) |
801 |
if (lineEnd > 0 && lineEnd < parsedMacroLength) |
| 802 |
endOffset = ((int[])lineOffsetRelation.get(lineEnd))[0]; |
802 |
endOffset = ((int[])lineOffsetRelation.get(lineEnd))[0]; |
| 803 |
else if (lineEnd - 1 > 0 && lineEnd - 1 < parsedMacroLength) |
803 |
else if (lineEnd - 1 > 0 && lineEnd - 1 < parsedMacroLength) |
| 804 |
endOffset = textContent.length(); |
804 |
endOffset = textContent.length(); |
| 805 |
|
805 |
|
| 806 |
if (startOffset >= 0 && endOffset >= 0 && endOffset > startOffset && endOffset < textContent.length()) |
806 |
if (startOffset >= 0 && endOffset >= 0 && endOffset > startOffset && endOffset < textContent.length()) |
| 807 |
{ |
807 |
{ |
| 808 |
/* Make sure that the start/end offset are not in the middle of a line delimiter */ |
808 |
/* Make sure that the start/end offset are not in the middle of a line delimiter */ |
| 809 |
char startChar = textContent.charAt(startOffset); |
809 |
char startChar = textContent.charAt(startOffset); |
| 810 |
char endChar = textContent.charAt(endOffset); |
810 |
char endChar = textContent.charAt(endOffset); |
| 811 |
if (startChar != '\r' && startChar != '\n' && endChar != '\r' && endChar != '\n') |
811 |
if (startChar != '\r' && startChar != '\n' && endChar != '\r' && endChar != '\n') |
| 812 |
{ |
812 |
{ |
| 813 |
rawRepresentation.setSelection(startOffset, endOffset); |
813 |
rawRepresentation.setSelection(startOffset, endOffset); |
| 814 |
} |
814 |
} |
| 815 |
} |
815 |
} |
| 816 |
} |
816 |
} |
| 817 |
|
817 |
|
| 818 |
/** |
818 |
/** |
| 819 |
* The selection listener for the logical tree representation of the macro |
819 |
* The selection listener for the logical tree representation of the macro |
| 820 |
* |
820 |
* |
| 821 |
* @author Ali Mehregani |
821 |
* @author Ali Mehregani |
| 822 |
*/ |
822 |
*/ |
| 823 |
public class LogicalRepresentationListener implements IMacroModifyListener |
823 |
public class LogicalRepresentationListener implements IMacroModifyListener |
| 824 |
{ |
824 |
{ |
| 825 |
public void selectionChanged(SelectionChangedEvent event) |
825 |
public void selectionChanged(SelectionChangedEvent event) |
| 826 |
{ |
826 |
{ |
| 827 |
/* Give control to the test case tree modifier */ |
827 |
/* Give control to the test case tree modifier */ |
| 828 |
boolean activationRequest = requestActivation(logicalRepresentationListener); |
828 |
boolean activationRequest = requestActivation(logicalRepresentationListener); |
| 829 |
if (!activationRequest) |
829 |
if (!activationRequest) |
| 830 |
return; |
830 |
return; |
| 831 |
|
831 |
|
| 832 |
ITestCase currentTestCase = (ITestCase) rawRepresentation.getData(); |
832 |
ITestCase currentTestCase = (ITestCase) rawRepresentation.getData(); |
| 833 |
ITestCase selectedTestCase = logicalTreeRepresentaion.getSelectedTestCase(); |
833 |
ITestCase selectedTestCase = logicalTreeRepresentaion.getSelectedTestCase(); |
| 834 |
|
834 |
|
| 835 |
/* Update the test case */ |
835 |
/* Update the test case */ |
| 836 |
if (currentTestCase == null || currentTestCase != selectedTestCase) |
836 |
if (currentTestCase == null || currentTestCase != selectedTestCase) |
| 837 |
{ |
837 |
{ |
| 838 |
rawRepresentation.setData(selectedTestCase); |
838 |
rawRepresentation.setData(selectedTestCase); |
| 839 |
testCaseSelectionChanged (selectedTestCase); |
839 |
testCaseSelectionChanged (selectedTestCase); |
| 840 |
} |
840 |
} |
| 841 |
|
841 |
|
| 842 |
|
842 |
|
| 843 |
/* Was there a macro instruction selected? */ |
843 |
/* Was there a macro instruction selected? */ |
| 844 |
TreeItem[] selectedNodes = logicalTreeRepresentaion.getTreeViewer().getTree().getSelection(); |
844 |
TreeItem[] selectedNodes = logicalTreeRepresentaion.getTreeViewer().getTree().getSelection(); |
| 845 |
if (selectedNodes != null && selectedNodes.length == 1 && !(selectedNodes[0].getData() instanceof ITestCase)) |
845 |
if (selectedNodes != null && selectedNodes.length == 1 && !(selectedNodes[0].getData() instanceof ITestCase)) |
| 846 |
treeNodeSelectionChanged (selectedNodes[0]); |
846 |
treeNodeSelectionChanged (selectedNodes[0]); |
| 847 |
} |
847 |
} |
| 848 |
|
848 |
|
| 849 |
|
849 |
|
| 850 |
private void testCaseSelectionChanged(ITestCase selectedTestCase) |
850 |
private void testCaseSelectionChanged(ITestCase selectedTestCase) |
| 851 |
{ |
851 |
{ |
| 852 |
/* Update the name, description */ |
852 |
/* Update the name, description */ |
| 853 |
getCommonSection().setInput(selectedTestCase); |
853 |
getCommonSection().setInput(selectedTestCase); |
| 854 |
|
854 |
|
| 855 |
if (selectedTestCase == null) |
855 |
if (selectedTestCase == null) |
| 856 |
{ |
856 |
{ |
| 857 |
setMacroContent(null); |
857 |
setMacroContent(null); |
| 858 |
startingPttxt.setText(""); |
858 |
startingPttxt.setText(""); |
| 859 |
startingPttxt.setEditable(false); |
859 |
startingPttxt.setEditable(false); |
| 860 |
return; |
860 |
return; |
| 861 |
} |
861 |
} |
| 862 |
else |
862 |
else |
| 863 |
{ |
863 |
{ |
| 864 |
String startingPt = getProperty(selectedTestCase, GUITestCaseProperties.STARTING_PT); |
864 |
String startingPt = getProperty(selectedTestCase, GUITestCaseProperties.STARTING_PT); |
| 865 |
if (startingPt == null) |
865 |
if (startingPt == null) |
| 866 |
startingPt = ""; |
866 |
startingPt = ""; |
| 867 |
|
867 |
|
| 868 |
startingPttxt.setText(startingPt); |
868 |
startingPttxt.setText(startingPt); |
| 869 |
} |
869 |
} |
| 870 |
|
870 |
|
| 871 |
startingPttxt.setEditable(true); |
871 |
startingPttxt.setEditable(true); |
| 872 |
testCasePropertyManager.setTestCase(selectedTestCase); |
872 |
testCasePropertyManager.setTestCase(selectedTestCase); |
| 873 |
String macro = testCasePropertyManager.getProperty(GUITestCaseProperties.MACRO_FRAGMENT); |
873 |
String macro = testCasePropertyManager.getProperty(GUITestCaseProperties.MACRO_FRAGMENT); |
| 874 |
|
874 |
|
| 875 |
if (macro != null) |
875 |
if (macro != null) |
| 876 |
setMacroContent(macro); |
876 |
setMacroContent(macro); |
| 877 |
else |
877 |
else |
| 878 |
rawRepresentation.setData(null); |
878 |
rawRepresentation.setData(null); |
| 879 |
} |
879 |
} |
| 880 |
|
880 |
|
| 881 |
private void treeNodeSelectionChanged(TreeItem selectedTreeNode) |
881 |
private void treeNodeSelectionChanged(TreeItem selectedTreeNode) |
| 882 |
{ |
882 |
{ |
| 883 |
ITestCase selectedTestCase = logicalTreeRepresentaion.getSelectedTestCase(); |
883 |
ITestCase selectedTestCase = logicalTreeRepresentaion.getSelectedTestCase(); |
| 884 |
if (selectedTreeNode == null || selectedTestCase == null) |
884 |
if (selectedTreeNode == null || selectedTestCase == null) |
| 885 |
return; |
885 |
return; |
| 886 |
|
886 |
|
| 887 |
Object uiInstruction = selectedTreeNode.getData(); |
887 |
Object uiInstruction = selectedTreeNode.getData(); |
| 888 |
if (uiInstruction == null || !(uiInstruction instanceof MacroUIInstruction)) |
888 |
if (uiInstruction == null || !(uiInstruction instanceof MacroUIInstruction)) |
| 889 |
return; |
889 |
return; |
| 890 |
|
890 |
|
| 891 |
Integer[] lineRange = ((MacroUIInstruction) uiInstruction).getLineNumber(); |
891 |
Integer[] lineRange = ((MacroUIInstruction) uiInstruction).getLineNumber(); |
| 892 |
selectMacroFragment (logicalTreeRepresentaion.getLineOffsetRelation(), lineRange); |
892 |
selectMacroFragment (logicalTreeRepresentaion.getLineOffsetRelation(), lineRange); |
| 893 |
} |
893 |
} |
| 894 |
|
894 |
|
| 895 |
|
895 |
|
| 896 |
public void macroModified(ExtendedModifyEvent event) |
896 |
public void macroModified(ExtendedModifyEvent event) |
| 897 |
{ |
897 |
{ |
| 898 |
markEditorDirty(); |
898 |
markEditorDirty(); |
| 899 |
|
899 |
|
| 900 |
/* Update the offest that each tree item keeps track */ |
900 |
/* Update the offest that each tree item keeps track */ |
| 901 |
if (isOperationHistory) |
901 |
if (isOperationHistory) |
| 902 |
{ |
902 |
{ |
| 903 |
logicalTreeRepresentaion.updateOffsetRelation(AutoGUITestCasesForm.this, logicalTreeRepresentaion.getLineOffsetRelation(), event.length, event.replacedText.length()); |
903 |
logicalTreeRepresentaion.updateOffsetRelation(AutoGUITestCasesForm.this, logicalTreeRepresentaion.getLineOffsetRelation(), event.length, event.replacedText.length()); |
| 904 |
} |
904 |
} |
| 905 |
} |
905 |
} |
| 906 |
|
906 |
|
| 907 |
|
907 |
|
| 908 |
public void performUndoRedoOperation(int lengthOfReplacedText, int lengthOfNewText) |
908 |
public void performUndoRedoOperation(int lengthOfReplacedText, int lengthOfNewText) |
| 909 |
{ |
909 |
{ |
| 910 |
/* Update the offest that each tree item keeps track */ |
910 |
/* Update the offest that each tree item keeps track */ |
| 911 |
logicalTreeRepresentaion.updateOffsetRelation(AutoGUITestCasesForm.this, logicalTreeRepresentaion.getLineOffsetRelation(), lengthOfReplacedText, lengthOfNewText); |
911 |
logicalTreeRepresentaion.updateOffsetRelation(AutoGUITestCasesForm.this, logicalTreeRepresentaion.getLineOffsetRelation(), lengthOfReplacedText, lengthOfNewText); |
| 912 |
} |
912 |
} |
| 913 |
|
913 |
|
| 914 |
|
914 |
|
| 915 |
public void markEditorDirty() |
915 |
public void markEditorDirty() |
| 916 |
{ |
916 |
{ |
| 917 |
ITestCase selectedTestCase = logicalTreeRepresentaion.getSelectedTestCase(); |
917 |
ITestCase selectedTestCase = logicalTreeRepresentaion.getSelectedTestCase(); |
| 918 |
if (disableModifyListener || selectedTestCase == null) |
918 |
if (disableModifyListener || selectedTestCase == null) |
| 919 |
return; |
919 |
return; |
| 920 |
|
920 |
|
| 921 |
testCasePropertyManager.setTestCase(selectedTestCase); |
921 |
testCasePropertyManager.setTestCase(selectedTestCase); |
| 922 |
if (!updateTestProperty (testCasePropertyManager.getProperty(GUITestCaseProperties.MACRO_FRAGMENT), rawRepresentation.getText(), false)) |
922 |
if (!updateTestProperty (testCasePropertyManager.getProperty(GUITestCaseProperties.MACRO_FRAGMENT), rawRepresentation.getText(), false)) |
| 923 |
return; |
923 |
return; |
| 924 |
} |
924 |
} |
| 925 |
|
925 |
|
| 926 |
|
926 |
|
| 927 |
public ISelection getSelection() |
927 |
public ISelection getSelection() |
| 928 |
{ |
928 |
{ |
| 929 |
return logicalTreeRepresentaion.getStructuredSelection(); |
929 |
return logicalTreeRepresentaion.getStructuredSelection(); |
| 930 |
} |
930 |
} |
| 931 |
|
931 |
|
| 932 |
|
932 |
|
| 933 |
public void deactivated() |
933 |
public void deactivated() |
| 934 |
{ |
934 |
{ |
| 935 |
rawRepresentation.setData(null); |
935 |
rawRepresentation.setData(null); |
| 936 |
} |
936 |
} |
| 937 |
|
937 |
|
| 938 |
|
938 |
|
| 939 |
public IUndoContext getUndoContext() |
939 |
public IUndoContext getUndoContext() |
| 940 |
{ |
940 |
{ |
| 941 |
/* Do we already have the context cached? */ |
941 |
/* Do we already have the context cached? */ |
| 942 |
ITestCase testCase = (ITestCase)rawRepresentation.getData(); |
942 |
ITestCase testCase = (ITestCase)rawRepresentation.getData(); |
| 943 |
if (testCase == null) |
943 |
if (testCase == null) |
| 944 |
return null; |
944 |
return null; |
| 945 |
|
945 |
|
| 946 |
String testCaseId = testCase.getId(); |
946 |
String testCaseId = testCase.getId(); |
| 947 |
if (context.get(testCaseId) != null) |
947 |
if (context.get(testCaseId) != null) |
| 948 |
return (IUndoContext)context.get(testCaseId); |
948 |
return (IUndoContext)context.get(testCaseId); |
| 949 |
|
949 |
|
| 950 |
/* The context was not found. Create it and store it in cache */ |
950 |
/* The context was not found. Create it and store it in cache */ |
| 951 |
IUndoContext currentContext = new MacroUndoContext(testCaseId); |
951 |
IUndoContext currentContext = new MacroUndoContext(testCaseId); |
| 952 |
context.put(testCaseId, currentContext); |
952 |
context.put(testCaseId, currentContext); |
| 953 |
linearOperationHistory.setLimit(currentContext, UNDO_OPERATION_LIMIT); |
953 |
linearOperationHistory.setLimit(currentContext, UNDO_OPERATION_LIMIT); |
| 954 |
return currentContext; |
954 |
return currentContext; |
| 955 |
} |
955 |
} |
| 956 |
|
956 |
|
| 957 |
|
957 |
|
| 958 |
public AutoGUIAbstractTreeStructure getTreeStructure() |
958 |
public AutoGUIAbstractTreeStructure getTreeStructure() |
| 959 |
{ |
959 |
{ |
| 960 |
return logicalTreeRepresentaion; |
960 |
return logicalTreeRepresentaion; |
| 961 |
} |
961 |
} |
| 962 |
} |
962 |
} |
| 963 |
|
963 |
|
| 964 |
|
964 |
|
| 965 |
/** |
965 |
/** |
| 966 |
* The selection listener for the logical tree representation of the macro |
966 |
* The selection listener for the logical tree representation of the macro |
| 967 |
* |
967 |
* |
| 968 |
* @author Ali Mehregani |
968 |
* @author Ali Mehregani |
| 969 |
*/ |
969 |
*/ |
| 970 |
public class ObjectMineTreeListener implements IMacroModifyListener |
970 |
public class ObjectMineTreeListener implements IMacroModifyListener |
| 971 |
{ |
971 |
{ |
| 972 |
/** The undo context */ |
972 |
/** The undo context */ |
| 973 |
private IUndoContext undoContext; |
973 |
private IUndoContext undoContext; |
| 974 |
|
974 |
|
| 975 |
|
975 |
|
| 976 |
public ObjectMineTreeListener() |
976 |
public ObjectMineTreeListener() |
| 977 |
{ |
977 |
{ |
| 978 |
undoContext = new MacroUndoContext(MacroUndoContext.GLOBAL_CONTEXT_ID); |
978 |
undoContext = new MacroUndoContext(MacroUndoContext.GLOBAL_CONTEXT_ID); |
| 979 |
context.put(MacroUndoContext.GLOBAL_CONTEXT_ID, undoContext); |
979 |
context.put(MacroUndoContext.GLOBAL_CONTEXT_ID, undoContext); |
| 980 |
linearOperationHistory.setLimit(undoContext, UNDO_OPERATION_LIMIT); |
980 |
linearOperationHistory.setLimit(undoContext, UNDO_OPERATION_LIMIT); |
| 981 |
} |
981 |
} |
| 982 |
|
982 |
|
| 983 |
|
983 |
|
| 984 |
public void selectionChanged(SelectionChangedEvent event) |
984 |
public void selectionChanged(SelectionChangedEvent event) |
| 985 |
{ |
985 |
{ |
| 986 |
boolean requiresActivation = getActiveMacroListener() != this; |
986 |
boolean requiresActivation = getActiveMacroListener() != this; |
| 987 |
|
987 |
|
| 988 |
/* Give control to the test case tree modifier */ |
988 |
/* Give control to the test case tree modifier */ |
| 989 |
if (requiresActivation) |
989 |
if (requiresActivation) |
| 990 |
{ |
990 |
{ |
| 991 |
requiresActivation = true; |
991 |
requiresActivation = true; |
| 992 |
boolean activationRequest = requestActivation(objectMineListener); |
992 |
boolean activationRequest = requestActivation(objectMineListener); |
| 993 |
if (!activationRequest) |
993 |
if (!activationRequest) |
| 994 |
return; |
994 |
return; |
| 995 |
} |
995 |
} |
| 996 |
|
996 |
|
| 997 |
if (event.getSelection() == null || event.getSelection().isEmpty()) |
997 |
if (event.getSelection() == null || event.getSelection().isEmpty()) |
| 998 |
{ |
998 |
{ |
| 999 |
setMacroContent(null); |
999 |
setMacroContent(null); |
| 1000 |
return; |
1000 |
return; |
| 1001 |
} |
1001 |
} |
| 1002 |
|
1002 |
|
| 1003 |
/* Irregardless of any object selected we need to show the XML fragment correponding to the |
1003 |
/* Irregardless of any object selected we need to show the XML fragment correponding to the |
| 1004 |
* test suite's object mine in the macro text box. If an object is selected, then its corresponding |
1004 |
* test suite's object mine in the macro text box. If an object is selected, then its corresponding |
| 1005 |
* XML fragment should be selected. */ |
1005 |
* XML fragment should be selected. */ |
| 1006 |
String objectMineXML = HyadesUtil.getTestSuiteVariable(getTestSuite(), GlobalConstants.TEST_SUITE_PROPERTY_OBJECT_MINE); |
1006 |
String objectMineXML = HyadesUtil.getTestSuiteVariable(getTestSuite(), GlobalConstants.TEST_SUITE_PROPERTY_OBJECT_MINE); |
| 1007 |
objectMineXML = objectMineXML == null ? "" : objectMineXML; |
1007 |
objectMineXML = objectMineXML == null ? "" : objectMineXML; |
| 1008 |
setMacroContent(objectMineXML); |
1008 |
setMacroContent(objectMineXML); |
| 1009 |
|
1009 |
|
| 1010 |
|
1010 |
|
| 1011 |
ISelection selectedEntity = event.getSelection(); |
1011 |
ISelection selectedEntity = event.getSelection(); |
| 1012 |
if (!selectedEntity.isEmpty() && selectedEntity instanceof StructuredSelection) |
1012 |
if (!selectedEntity.isEmpty() && selectedEntity instanceof StructuredSelection) |
| 1013 |
{ |
1013 |
{ |
| 1014 |
Object[] selectedItems = ((StructuredSelection)selectedEntity).toArray(); |
1014 |
Object[] selectedItems = ((StructuredSelection)selectedEntity).toArray(); |
| 1015 |
Integer[] lineLevelDetail = null; |
1015 |
Integer[] lineLevelDetail = null; |
| 1016 |
if (selectedItems.length == 1 && selectedItems[0] instanceof IUIObject) |
1016 |
if (selectedItems.length == 1 && selectedItems[0] instanceof MacroObjectDescriptor) |
| 1017 |
lineLevelDetail = (Integer[])((IUIObject)selectedItems[0]).getData(); |
1017 |
lineLevelDetail = (Integer[])((MacroObjectDescriptor)selectedItems[0]).getData(); |
| 1018 |
|
1018 |
|
| 1019 |
/* Select the XML fragment if the line level information is available */ |
1019 |
/* Select the XML fragment if the line level information is available */ |
| 1020 |
if (lineLevelDetail != null) |
1020 |
if (lineLevelDetail != null) |
| 1021 |
{ |
1021 |
{ |
| 1022 |
selectMacroFragment (objectMineTree.getLineOffsetRelation(), lineLevelDetail); |
1022 |
selectMacroFragment (objectMineTree.getLineOffsetRelation(), lineLevelDetail); |
| 1023 |
} |
1023 |
} |
| 1024 |
} |
1024 |
} |
| 1025 |
} |
1025 |
} |
| 1026 |
|
1026 |
|
| 1027 |
|
1027 |
|
| 1028 |
|
1028 |
|
| 1029 |
public void macroModified(ExtendedModifyEvent event) |
1029 |
public void macroModified(ExtendedModifyEvent event) |
| 1030 |
{ |
1030 |
{ |
| 1031 |
/* Mark the editor dirty */ |
1031 |
/* Mark the editor dirty */ |
| 1032 |
if (disableModifyListener) |
1032 |
if (disableModifyListener) |
| 1033 |
return; |
1033 |
return; |
| 1034 |
|
1034 |
|
| 1035 |
if (!updateTestProperty (HyadesUtil.getTestSuiteVariable(getTestSuite(), GlobalConstants.TEST_SUITE_PROPERTY_OBJECT_MINE), rawRepresentation.getText(), true)) |
1035 |
if (!updateTestProperty (HyadesUtil.getTestSuiteVariable(getTestSuite(), GlobalConstants.TEST_SUITE_PROPERTY_OBJECT_MINE), rawRepresentation.getText(), true)) |
| 1036 |
return; |
1036 |
return; |
| 1037 |
|
1037 |
|
| 1038 |
/* Update the offest that each tree item keeps track */ |
1038 |
/* Update the offest that each tree item keeps track */ |
| 1039 |
ObjectMineManager.getInstance().markObjectMineDirty (getTestSuite()); |
1039 |
MacroObjectDescriptorMineManager.getInstance().markObjectMineDirty (getTestSuite()); |
| 1040 |
if (isOperationHistory) |
1040 |
if (isOperationHistory) |
| 1041 |
{ |
1041 |
{ |
| 1042 |
objectMineTree.updateOffsetRelation(AutoGUITestCasesForm.this, objectMineTree.getLineOffsetRelation(), event.length, event.replacedText.length()); |
1042 |
objectMineTree.updateOffsetRelation(AutoGUITestCasesForm.this, objectMineTree.getLineOffsetRelation(), event.length, event.replacedText.length()); |
| 1043 |
} |
1043 |
} |
| 1044 |
|
1044 |
|
| 1045 |
} |
1045 |
} |
| 1046 |
|
1046 |
|
| 1047 |
public void performUndoRedoOperation(int lengthOfReplacedText, int lengthOfNewText) |
1047 |
public void performUndoRedoOperation(int lengthOfReplacedText, int lengthOfNewText) |
| 1048 |
{ |
1048 |
{ |
| 1049 |
logicalTreeRepresentaion.updateOffsetRelation(AutoGUITestCasesForm.this, objectMineTree.getLineOffsetRelation(), lengthOfReplacedText, lengthOfNewText); |
1049 |
logicalTreeRepresentaion.updateOffsetRelation(AutoGUITestCasesForm.this, objectMineTree.getLineOffsetRelation(), lengthOfReplacedText, lengthOfNewText); |
| 1050 |
} |
1050 |
} |
| 1051 |
|
1051 |
|
| 1052 |
|
1052 |
|
| 1053 |
public ISelection getSelection() |
1053 |
public ISelection getSelection() |
| 1054 |
{ |
1054 |
{ |
| 1055 |
return objectMineTree.getStructuredSelection(); |
1055 |
return objectMineTree.getStructuredSelection(); |
| 1056 |
} |
1056 |
} |
| 1057 |
|
1057 |
|
| 1058 |
|
1058 |
|
| 1059 |
|
1059 |
|
| 1060 |
public void deactivated() |
1060 |
public void deactivated() |
| 1061 |
{ |
1061 |
{ |
| 1062 |
/* Doesn't need to be implemented */ |
1062 |
/* Doesn't need to be implemented */ |
| 1063 |
} |
1063 |
} |
| 1064 |
|
1064 |
|
| 1065 |
|
1065 |
|
| 1066 |
|
1066 |
|
| 1067 |
public IUndoContext getUndoContext() |
1067 |
public IUndoContext getUndoContext() |
| 1068 |
{ |
1068 |
{ |
| 1069 |
return undoContext; |
1069 |
return undoContext; |
| 1070 |
} |
1070 |
} |
| 1071 |
|
1071 |
|
| 1072 |
|
1072 |
|
| 1073 |
public AutoGUIAbstractTreeStructure getTreeStructure() |
1073 |
public AutoGUIAbstractTreeStructure getTreeStructure() |
| 1074 |
{ |
1074 |
{ |
| 1075 |
return objectMineTree; |
1075 |
return objectMineTree; |
| 1076 |
} |
1076 |
} |
| 1077 |
} |
1077 |
} |
| 1078 |
|
1078 |
|
| 1079 |
public AutoGUIObjectMineTreeStructure getObjectMineTreeStruct() |
1079 |
public AutoGUIMacroObjectDescriptorMineTreeStructure getObjectMineTreeStruct() |
| 1080 |
{ |
1080 |
{ |
| 1081 |
return objectMineTree; |
1081 |
return objectMineTree; |
| 1082 |
} |
1082 |
} |
| 1083 |
|
1083 |
|
| 1084 |
|
1084 |
|
| 1085 |
public boolean updateTestProperty (String oldValue, String newValue, boolean isObjectMine) |
1085 |
public boolean updateTestProperty (String oldValue, String newValue, boolean isObjectMine) |
| 1086 |
{ |
1086 |
{ |
| 1087 |
if (oldValue == null && (newValue == null || newValue.length() <= 0)) |
1087 |
if (oldValue == null && (newValue == null || newValue.length() <= 0)) |
| 1088 |
return false; |
1088 |
return false; |
| 1089 |
|
1089 |
|
| 1090 |
|
1090 |
|
| 1091 |
if ((oldValue == null && newValue != null && newValue.length() > 0) || (oldValue != null && !oldValue.equals(newValue))) |
1091 |
if ((oldValue == null && newValue != null && newValue.length() > 0) || (oldValue != null && !oldValue.equals(newValue))) |
| 1092 |
{ |
1092 |
{ |
| 1093 |
if (isObjectMine) |
1093 |
if (isObjectMine) |
| 1094 |
{ |
1094 |
{ |
| 1095 |
HyadesUtil.setTestSuiteVariable(getTestSuite(), GlobalConstants.TEST_SUITE_PROPERTY_OBJECT_MINE, newValue); |
1095 |
HyadesUtil.setTestSuiteVariable(getTestSuite(), GlobalConstants.TEST_SUITE_PROPERTY_OBJECT_MINE, newValue); |
| 1096 |
} |
1096 |
} |
| 1097 |
else |
1097 |
else |
| 1098 |
{ |
1098 |
{ |
| 1099 |
testCasePropertyManager.addProperty(GUITestCaseProperties.MACRO_FRAGMENT, newValue); |
1099 |
testCasePropertyManager.addProperty(GUITestCaseProperties.MACRO_FRAGMENT, newValue); |
| 1100 |
} |
1100 |
} |
| 1101 |
markEditorDirty(); |
1101 |
markEditorDirty(); |
| 1102 |
} |
1102 |
} |
| 1103 |
|
1103 |
|
| 1104 |
return true; |
1104 |
return true; |
| 1105 |
} |
1105 |
} |
| 1106 |
/** |
1106 |
/** |
| 1107 |
* Entities that wish to register a modify listener with the macro text |
1107 |
* Entities that wish to register a modify listener with the macro text |
| 1108 |
* area must implement this interface. The macro content is dependent on |
1108 |
* area must implement this interface. The macro content is dependent on |
| 1109 |
* an item selection, hence the reason why this interface extends |
1109 |
* an item selection, hence the reason why this interface extends |
| 1110 |
* <code>ISelectionChangedListener</code> |
1110 |
* <code>ISelectionChangedListener</code> |
| 1111 |
* |
1111 |
* |
| 1112 |
* @author Ali Mehregani |
1112 |
* @author Ali Mehregani |
| 1113 |
*/ |
1113 |
*/ |
| 1114 |
public interface IMacroModifyListener extends ISelectionChangedListener |
1114 |
public interface IMacroModifyListener extends ISelectionChangedListener |
| 1115 |
{ |
1115 |
{ |
| 1116 |
/** |
1116 |
/** |
| 1117 |
* Invoked when the macro is modified. |
1117 |
* Invoked when the macro is modified. |
| 1118 |
* |
1118 |
* |
| 1119 |
* @param event The extended modify event. |
1119 |
* @param event The extended modify event. |
| 1120 |
*/ |
1120 |
*/ |
| 1121 |
public void macroModified(ExtendedModifyEvent event); |
1121 |
public void macroModified(ExtendedModifyEvent event); |
| 1122 |
|
1122 |
|
| 1123 |
|
1123 |
|
| 1124 |
/** |
1124 |
/** |
| 1125 |
* Returns the undo context for the macro text box |
1125 |
* Returns the undo context for the macro text box |
| 1126 |
* |
1126 |
* |
| 1127 |
* @return The undo context |
1127 |
* @return The undo context |
| 1128 |
*/ |
1128 |
*/ |
| 1129 |
public IUndoContext getUndoContext(); |
1129 |
public IUndoContext getUndoContext(); |
| 1130 |
|
1130 |
|
| 1131 |
|
1131 |
|
| 1132 |
/** |
1132 |
/** |
| 1133 |
* Returns the current selection of the tree |
1133 |
* Returns the current selection of the tree |
| 1134 |
* |
1134 |
* |
| 1135 |
* @return The selections |
1135 |
* @return The selections |
| 1136 |
*/ |
1136 |
*/ |
| 1137 |
public ISelection getSelection(); |
1137 |
public ISelection getSelection(); |
| 1138 |
|
1138 |
|
| 1139 |
|
1139 |
|
| 1140 |
/** |
1140 |
/** |
| 1141 |
* Invoked when there is a under/redo operation |
1141 |
* Invoked when there is a under/redo operation |
| 1142 |
* |
1142 |
* |
| 1143 |
* @param lengthOfReplacedText The length of the replaced text |
1143 |
* @param lengthOfReplacedText The length of the replaced text |
| 1144 |
* @param lengthOfNewText The length of the new text |
1144 |
* @param lengthOfNewText The length of the new text |
| 1145 |
*/ |
1145 |
*/ |
| 1146 |
public void performUndoRedoOperation (int lengthOfReplacedText, int lengthOfNewText); |
1146 |
public void performUndoRedoOperation (int lengthOfReplacedText, int lengthOfNewText); |
| 1147 |
|
1147 |
|
| 1148 |
|
1148 |
|
| 1149 |
/** |
1149 |
/** |
| 1150 |
* Invoked when this listener has been deactivated |
1150 |
* Invoked when this listener has been deactivated |
| 1151 |
*/ |
1151 |
*/ |
| 1152 |
public void deactivated (); |
1152 |
public void deactivated (); |
| 1153 |
|
1153 |
|
| 1154 |
|
1154 |
|
| 1155 |
/** |
1155 |
/** |
| 1156 |
* Returns the tree structure that belongs to this macro modify |
1156 |
* Returns the tree structure that belongs to this macro modify |
| 1157 |
* listener. |
1157 |
* listener. |
| 1158 |
* |
1158 |
* |
| 1159 |
* @return The tree structure owned by this listener. |
1159 |
* @return The tree structure owned by this listener. |
| 1160 |
*/ |
1160 |
*/ |
| 1161 |
public AutoGUIAbstractTreeStructure getTreeStructure(); |
1161 |
public AutoGUIAbstractTreeStructure getTreeStructure(); |
| 1162 |
} |
1162 |
} |
| 1163 |
|
1163 |
|
| 1164 |
|
1164 |
|
| 1165 |
/** |
1165 |
/** |
| 1166 |
* @return the logicalTreeRepresentaion |
1166 |
* @return the logicalTreeRepresentaion |
| 1167 |
*/ |
1167 |
*/ |
| 1168 |
public AutoGUITestCaseTreeStructure getLogicalTreeRepresentaion() |
1168 |
public AutoGUITestCaseTreeStructure getLogicalTreeRepresentaion() |
| 1169 |
{ |
1169 |
{ |
| 1170 |
return logicalTreeRepresentaion; |
1170 |
return logicalTreeRepresentaion; |
| 1171 |
} |
1171 |
} |
| 1172 |
|
1172 |
|
| 1173 |
/** |
1173 |
/** |
| 1174 |
* @return the logicalRepresentationListener |
1174 |
* @return the logicalRepresentationListener |
| 1175 |
*/ |
1175 |
*/ |
| 1176 |
public LogicalRepresentationListener getLogicalRepresentationListener() |
1176 |
public LogicalRepresentationListener getLogicalRepresentationListener() |
| 1177 |
{ |
1177 |
{ |
| 1178 |
return logicalRepresentationListener; |
1178 |
return logicalRepresentationListener; |
| 1179 |
} |
1179 |
} |
| 1180 |
|
1180 |
|
| 1181 |
/** |
1181 |
/** |
| 1182 |
* @return the form |
1182 |
* @return the form |
| 1183 |
*/ |
1183 |
*/ |
| 1184 |
public ScrolledForm getForm() |
1184 |
public ScrolledForm getForm() |
| 1185 |
{ |
1185 |
{ |
| 1186 |
return form; |
1186 |
return form; |
| 1187 |
} |
1187 |
} |
| 1188 |
|
1188 |
|
| 1189 |
|
1189 |
|
| 1190 |
/** |
1190 |
/** |
| 1191 |
* @return the sashForm |
1191 |
* @return the sashForm |
| 1192 |
*/ |
1192 |
*/ |
| 1193 |
public SashForm getSashForm() |
1193 |
public SashForm getSashForm() |
| 1194 |
{ |
1194 |
{ |
| 1195 |
return sashForm; |
1195 |
return sashForm; |
| 1196 |
} |
1196 |
} |
| 1197 |
|
1197 |
|
| 1198 |
|
1198 |
|
| 1199 |
/** |
1199 |
/** |
| 1200 |
* The root macro modify listener |
1200 |
* The root macro modify listener |
| 1201 |
* |
1201 |
* |
| 1202 |
* @author Ali Mehregani |
1202 |
* @author Ali Mehregani |
| 1203 |
*/ |
1203 |
*/ |
| 1204 |
private class RootMacroModifyListener implements ExtendedModifyListener |
1204 |
private class RootMacroModifyListener implements ExtendedModifyListener |
| 1205 |
{ |
1205 |
{ |
| 1206 |
private boolean enabled; |
1206 |
private boolean enabled; |
| 1207 |
|
1207 |
|
| 1208 |
public RootMacroModifyListener() |
1208 |
public RootMacroModifyListener() |
| 1209 |
{ |
1209 |
{ |
| 1210 |
enabled = true; |
1210 |
enabled = true; |
| 1211 |
} |
1211 |
} |
| 1212 |
|
1212 |
|
| 1213 |
public void modifyText(ExtendedModifyEvent event) |
1213 |
public void modifyText(ExtendedModifyEvent event) |
| 1214 |
{ |
1214 |
{ |
| 1215 |
if (!enabled) |
1215 |
if (!enabled) |
| 1216 |
return; |
1216 |
return; |
| 1217 |
|
1217 |
|
| 1218 |
if (activeMacroModifyListener != null) |
1218 |
if (activeMacroModifyListener != null) |
| 1219 |
activeMacroModifyListener.macroModified(event); |
1219 |
activeMacroModifyListener.macroModified(event); |
| 1220 |
|
1220 |
|
| 1221 |
if (!isOperationHistory) |
1221 |
if (!isOperationHistory) |
| 1222 |
return; |
1222 |
return; |
| 1223 |
|
1223 |
|
| 1224 |
int currentPosition = rawRepresentation.getSelection().x; |
1224 |
int currentPosition = rawRepresentation.getSelection().x; |
| 1225 |
String macro = rawRepresentation.getText(); |
1225 |
String macro = rawRepresentation.getText(); |
| 1226 |
IUndoContext context = getUndoContext(); |
1226 |
IUndoContext context = getUndoContext(); |
| 1227 |
int newTextStartInx = currentPosition - event.length; |
1227 |
int newTextStartInx = currentPosition - event.length; |
| 1228 |
|
1228 |
|
| 1229 |
if (context != null && newTextStartInx >= 0 && currentPosition <= macro.length()) |
1229 |
if (context != null && newTextStartInx >= 0 && currentPosition <= macro.length()) |
| 1230 |
{ |
1230 |
{ |
| 1231 |
linearOperationHistory.add(new UndoableTextOperation( |
1231 |
linearOperationHistory.add(new UndoableTextOperation( |
| 1232 |
context, |
1232 |
context, |
| 1233 |
currentPosition - event.length, /* The affected position */ |
1233 |
currentPosition - event.length, /* The affected position */ |
| 1234 |
event.length == 1 ? |
1234 |
event.length == 1 ? |
| 1235 |
String.valueOf(macro.charAt(newTextStartInx)) : |
1235 |
String.valueOf(macro.charAt(newTextStartInx)) : |
| 1236 |
macro.substring(newTextStartInx, newTextStartInx + event.length), /* The new text */ |
1236 |
macro.substring(newTextStartInx, newTextStartInx + event.length), /* The new text */ |
| 1237 |
event.replacedText /* The replaced text */ |
1237 |
event.replacedText /* The replaced text */ |
| 1238 |
)); |
1238 |
)); |
| 1239 |
} |
1239 |
} |
| 1240 |
|
1240 |
|
| 1241 |
IActionBars actionBar = AutoGUITestCasesForm.this.getEditorSite().getActionBars(); |
1241 |
IActionBars actionBar = AutoGUITestCasesForm.this.getEditorSite().getActionBars(); |
| 1242 |
if (actionBar != null) |
1242 |
if (actionBar != null) |
| 1243 |
{ |
1243 |
{ |
| 1244 |
undoAction.setEnabled(undoAction.isEnabled()); |
1244 |
undoAction.setEnabled(undoAction.isEnabled()); |
| 1245 |
redoAction.setEnabled(redoAction.isEnabled()); |
1245 |
redoAction.setEnabled(redoAction.isEnabled()); |
| 1246 |
actionBar.updateActionBars(); |
1246 |
actionBar.updateActionBars(); |
| 1247 |
} |
1247 |
} |
| 1248 |
} |
1248 |
} |
| 1249 |
|
1249 |
|
| 1250 |
|
1250 |
|
| 1251 |
public boolean isEnabled() |
1251 |
public boolean isEnabled() |
| 1252 |
{ |
1252 |
{ |
| 1253 |
return enabled; |
1253 |
return enabled; |
| 1254 |
} |
1254 |
} |
| 1255 |
|
1255 |
|
| 1256 |
public void setEnabled(boolean enabled) |
1256 |
public void setEnabled(boolean enabled) |
| 1257 |
{ |
1257 |
{ |
| 1258 |
this.enabled = enabled; |
1258 |
this.enabled = enabled; |
| 1259 |
} |
1259 |
} |
| 1260 |
} |
1260 |
} |
| 1261 |
|
1261 |
|
| 1262 |
|
1262 |
|
| 1263 |
/** |
1263 |
/** |
| 1264 |
* Represents an undoable operation that can be performed for the styled text |
1264 |
* Represents an undoable operation that can be performed for the styled text |
| 1265 |
* that displays the content macro. |
1265 |
* that displays the content macro. |
| 1266 |
* |
1266 |
* |
| 1267 |
* @author Ali Mehregani |
1267 |
* @author Ali Mehregani |
| 1268 |
*/ |
1268 |
*/ |
| 1269 |
private class UndoableTextOperation extends AbstractOperation |
1269 |
private class UndoableTextOperation extends AbstractOperation |
| 1270 |
{ |
1270 |
{ |
| 1271 |
/** The affected position indicates the position where the new text was added */ |
1271 |
/** The affected position indicates the position where the new text was added */ |
| 1272 |
private int affectedPosition; |
1272 |
private int affectedPosition; |
| 1273 |
|
1273 |
|
| 1274 |
/** The new text that was added */ |
1274 |
/** The new text that was added */ |
| 1275 |
private String newText; |
1275 |
private String newText; |
| 1276 |
|
1276 |
|
| 1277 |
/** The replaced text (can be "" or null) */ |
1277 |
/** The replaced text (can be "" or null) */ |
| 1278 |
private String replacedText; |
1278 |
private String replacedText; |
| 1279 |
|
1279 |
|
| 1280 |
/** If true, then this operation is undoable; otherwise it's redoable */ |
1280 |
/** If true, then this operation is undoable; otherwise it's redoable */ |
| 1281 |
private boolean undoable; |
1281 |
private boolean undoable; |
| 1282 |
|
1282 |
|
| 1283 |
/** |
1283 |
/** |
| 1284 |
* Constructor |
1284 |
* Constructor |
| 1285 |
* |
1285 |
* |
| 1286 |
* @param context The context of the operation |
1286 |
* @param context The context of the operation |
| 1287 |
* @param affectedPosition The affected position |
1287 |
* @param affectedPosition The affected position |
| 1288 |
* @param newText The new text added |
1288 |
* @param newText The new text added |
| 1289 |
* @param replacedText The replaced text (can be "" or null) |
1289 |
* @param replacedText The replaced text (can be "" or null) |
| 1290 |
*/ |
1290 |
*/ |
| 1291 |
public UndoableTextOperation(IUndoContext context, int affectedPosition, String newText, String replacedText) |
1291 |
public UndoableTextOperation(IUndoContext context, int affectedPosition, String newText, String replacedText) |
| 1292 |
{ |
1292 |
{ |
| 1293 |
super(AutoGUIMessages.AUTO_GUI_UNDOABLE_TEXT_OPERATION_LABEL); |
1293 |
super(AutoGUIMessages.AUTO_GUI_UNDOABLE_TEXT_OPERATION_LABEL); |
| 1294 |
super.addContext(context); |
1294 |
super.addContext(context); |
| 1295 |
this.affectedPosition = affectedPosition; |
1295 |
this.affectedPosition = affectedPosition; |
| 1296 |
this.newText = newText; |
1296 |
this.newText = newText; |
| 1297 |
if (replacedText == null) |
1297 |
if (replacedText == null) |
| 1298 |
this.replacedText = ""; |
1298 |
this.replacedText = ""; |
| 1299 |
else |
1299 |
else |
| 1300 |
this.replacedText = replacedText; |
1300 |
this.replacedText = replacedText; |
| 1301 |
|
1301 |
|
| 1302 |
/* All operations are initially undoable */ |
1302 |
/* All operations are initially undoable */ |
| 1303 |
this.undoable = true; |
1303 |
this.undoable = true; |
| 1304 |
} |
1304 |
} |
| 1305 |
|
1305 |
|
| 1306 |
|
1306 |
|
| 1307 |
public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException |
1307 |
public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException |
| 1308 |
{ |
1308 |
{ |
| 1309 |
/* Doesn't need to be implemented */ |
1309 |
/* Doesn't need to be implemented */ |
| 1310 |
return Status.OK_STATUS; |
1310 |
return Status.OK_STATUS; |
| 1311 |
} |
1311 |
} |
| 1312 |
|
1312 |
|
| 1313 |
|
1313 |
|
| 1314 |
/** |
1314 |
/** |
| 1315 |
* Redo this operation |
1315 |
* Redo this operation |
| 1316 |
*/ |
1316 |
*/ |
| 1317 |
public IStatus redo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException |
1317 |
public IStatus redo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException |
| 1318 |
{ |
1318 |
{ |
| 1319 |
return performUndoRedoOperation(); |
1319 |
return performUndoRedoOperation(); |
| 1320 |
} |
1320 |
} |
| 1321 |
|
1321 |
|
| 1322 |
/** |
1322 |
/** |
| 1323 |
* Undo this operation |
1323 |
* Undo this operation |
| 1324 |
*/ |
1324 |
*/ |
| 1325 |
public IStatus undo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException |
1325 |
public IStatus undo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException |
| 1326 |
{ |
1326 |
{ |
| 1327 |
return performUndoRedoOperation(); |
1327 |
return performUndoRedoOperation(); |
| 1328 |
} |
1328 |
} |
| 1329 |
|
1329 |
|
| 1330 |
private IStatus performUndoRedoOperation() |
1330 |
private IStatus performUndoRedoOperation() |
| 1331 |
{ |
1331 |
{ |
| 1332 |
undoable = !undoable; |
1332 |
undoable = !undoable; |
| 1333 |
int lengthOfNewText = newText.length(); |
1333 |
int lengthOfNewText = newText.length(); |
| 1334 |
int lengthOfReplacedText = replacedText.length(); |
1334 |
int lengthOfReplacedText = replacedText.length(); |
| 1335 |
|
1335 |
|
| 1336 |
isOperationHistory = false; |
1336 |
isOperationHistory = false; |
| 1337 |
rawRepresentation.replaceTextRange(affectedPosition, lengthOfNewText, replacedText); |
1337 |
rawRepresentation.replaceTextRange(affectedPosition, lengthOfNewText, replacedText); |
| 1338 |
isOperationHistory = true; |
1338 |
isOperationHistory = true; |
| 1339 |
|
1339 |
|
| 1340 |
rawRepresentation.setSelection(affectedPosition + lengthOfReplacedText); |
1340 |
rawRepresentation.setSelection(affectedPosition + lengthOfReplacedText); |
| 1341 |
/* Swap the replaced text and the new text so that the task can be undone/redone. */ |
1341 |
/* Swap the replaced text and the new text so that the task can be undone/redone. */ |
| 1342 |
String tmp = newText; |
1342 |
String tmp = newText; |
| 1343 |
newText = replacedText; |
1343 |
newText = replacedText; |
| 1344 |
replacedText = tmp; |
1344 |
replacedText = tmp; |
| 1345 |
|
1345 |
|
| 1346 |
if (activeMacroModifyListener != null) |
1346 |
if (activeMacroModifyListener != null) |
| 1347 |
activeMacroModifyListener.performUndoRedoOperation(lengthOfReplacedText, lengthOfNewText); |
1347 |
activeMacroModifyListener.performUndoRedoOperation(lengthOfReplacedText, lengthOfNewText); |
| 1348 |
return Status.OK_STATUS; |
1348 |
return Status.OK_STATUS; |
| 1349 |
} |
1349 |
} |
| 1350 |
|
1350 |
|
| 1351 |
|
1351 |
|
| 1352 |
/* |
1352 |
/* |
| 1353 |
* (non-Javadoc) |
1353 |
* (non-Javadoc) |
| 1354 |
* |
1354 |
* |
| 1355 |
* @see org.eclipse.core.commands.operations.IUndoableOperation#canRedo() |
1355 |
* @see org.eclipse.core.commands.operations.IUndoableOperation#canRedo() |
| 1356 |
* <p> Default implementation. Subclasses may override this method. |
1356 |
* <p> Default implementation. Subclasses may override this method. |
| 1357 |
* </p> |
1357 |
* </p> |
| 1358 |
*/ |
1358 |
*/ |
| 1359 |
public boolean canRedo() |
1359 |
public boolean canRedo() |
| 1360 |
{ |
1360 |
{ |
| 1361 |
return !undoable; |
1361 |
return !undoable; |
| 1362 |
} |
1362 |
} |
| 1363 |
|
1363 |
|
| 1364 |
/* |
1364 |
/* |
| 1365 |
* (non-Javadoc) |
1365 |
* (non-Javadoc) |
| 1366 |
* |
1366 |
* |
| 1367 |
* @see org.eclipse.core.commands.operations.IUndoableOperation#canUndo() |
1367 |
* @see org.eclipse.core.commands.operations.IUndoableOperation#canUndo() |
| 1368 |
* <p> Default implementation. Subclasses may override this method. |
1368 |
* <p> Default implementation. Subclasses may override this method. |
| 1369 |
* </p> |
1369 |
* </p> |
| 1370 |
*/ |
1370 |
*/ |
| 1371 |
public boolean canUndo() |
1371 |
public boolean canUndo() |
| 1372 |
{ |
1372 |
{ |
| 1373 |
return undoable; |
1373 |
return undoable; |
| 1374 |
} |
1374 |
} |
| 1375 |
|
1375 |
|
| 1376 |
} |
1376 |
} |
| 1377 |
|
1377 |
|
| 1378 |
|
1378 |
|
| 1379 |
/** |
1379 |
/** |
| 1380 |
* The undo context used for the styled text box that displays the |
1380 |
* The undo context used for the styled text box that displays the |
| 1381 |
* macro. |
1381 |
* macro. |
| 1382 |
* |
1382 |
* |
| 1383 |
* @author Ali Mehregani |
1383 |
* @author Ali Mehregani |
| 1384 |
*/ |
1384 |
*/ |
| 1385 |
private static class MacroUndoContext implements IUndoContext |
1385 |
private static class MacroUndoContext implements IUndoContext |
| 1386 |
{ |
1386 |
{ |
| 1387 |
/** Static global context id */ |
1387 |
/** Static global context id */ |
| 1388 |
private static String GLOBAL_CONTEXT_ID = "GLOBAL_CONTEXT_ID"; |
1388 |
private static String GLOBAL_CONTEXT_ID = "GLOBAL_CONTEXT_ID"; |
| 1389 |
|
1389 |
|
| 1390 |
/** The associated test case id */ |
1390 |
/** The associated test case id */ |
| 1391 |
private String id; |
1391 |
private String id; |
| 1392 |
|
1392 |
|
| 1393 |
public MacroUndoContext(String id) |
1393 |
public MacroUndoContext(String id) |
| 1394 |
{ |
1394 |
{ |
| 1395 |
this.id = id; |
1395 |
this.id = id; |
| 1396 |
} |
1396 |
} |
| 1397 |
|
1397 |
|
| 1398 |
public String getLabel() |
1398 |
public String getLabel() |
| 1399 |
{ |
1399 |
{ |
| 1400 |
return null; |
1400 |
return null; |
| 1401 |
} |
1401 |
} |
| 1402 |
|
1402 |
|
| 1403 |
|
1403 |
|
| 1404 |
public boolean matches(IUndoContext context) |
1404 |
public boolean matches(IUndoContext context) |
| 1405 |
{ |
1405 |
{ |
| 1406 |
return equals (context); |
1406 |
return equals (context); |
| 1407 |
} |
1407 |
} |
| 1408 |
|
1408 |
|
| 1409 |
public boolean equals (Object o) |
1409 |
public boolean equals (Object o) |
| 1410 |
{ |
1410 |
{ |
| 1411 |
if (!(o instanceof MacroUndoContext)) |
1411 |
if (!(o instanceof MacroUndoContext)) |
| 1412 |
return false; |
1412 |
return false; |
| 1413 |
return this.getId().equals(((MacroUndoContext)o).getId()); |
1413 |
return this.getId().equals(((MacroUndoContext)o).getId()); |
| 1414 |
} |
1414 |
} |
| 1415 |
|
1415 |
|
| 1416 |
private String getId() |
1416 |
private String getId() |
| 1417 |
{ |
1417 |
{ |
| 1418 |
return id; |
1418 |
return id; |
| 1419 |
} |
1419 |
} |
| 1420 |
|
1420 |
|
| 1421 |
} |
1421 |
} |
| 1422 |
|
1422 |
|
| 1423 |
/** |
1423 |
/** |
| 1424 |
* Extended properties on GUI test cases. |
1424 |
* Extended properties on GUI test cases. |
| 1425 |
*/ |
1425 |
*/ |
| 1426 |
public static class GUITestCaseProperties |
1426 |
public static class GUITestCaseProperties |
| 1427 |
{ |
1427 |
{ |
| 1428 |
public static final byte STARTING_PT = 0x00; |
1428 |
public static final byte STARTING_PT = 0x00; |
| 1429 |
public static final byte MACRO_FRAGMENT = 0x01; |
1429 |
public static final byte MACRO_FRAGMENT = 0x01; |
| 1430 |
public static final byte VERIFICATION_HOOKS = 0x02; |
1430 |
public static final byte VERIFICATION_HOOKS = 0x02; |
| 1431 |
|
1431 |
|
| 1432 |
/* The test case for which these properties belong to */ |
1432 |
/* The test case for which these properties belong to */ |
| 1433 |
private ITestCase testCase; |
1433 |
private ITestCase testCase; |
| 1434 |
|
1434 |
|
| 1435 |
/* The static target invocation used to retrieve the extended properties of a test case*/ |
1435 |
/* The static target invocation used to retrieve the extended properties of a test case*/ |
| 1436 |
private ITargetInvocation targetInvocation; |
1436 |
private ITargetInvocation targetInvocation; |
| 1437 |
|
1437 |
|
| 1438 |
public void setTestCase (ITestCase testCase) |
1438 |
public void setTestCase (ITestCase testCase) |
| 1439 |
{ |
1439 |
{ |
| 1440 |
this.testCase = testCase; |
1440 |
this.testCase = testCase; |
| 1441 |
} |
1441 |
} |
| 1442 |
|
1442 |
|
| 1443 |
public ITestCase getTestCase() |
1443 |
public ITestCase getTestCase() |
| 1444 |
{ |
1444 |
{ |
| 1445 |
return testCase; |
1445 |
return testCase; |
| 1446 |
} |
1446 |
} |
| 1447 |
|
1447 |
|
| 1448 |
|
1448 |
|
| 1449 |
public void addProperty (byte field, String value) |
1449 |
public void addProperty (byte field, String value) |
| 1450 |
{ |
1450 |
{ |
| 1451 |
targetInvocation = HyadesUtil.getTargetInvocation(testCase); |
1451 |
targetInvocation = HyadesUtil.getTargetInvocation(testCase); |
| 1452 |
|
1452 |
|
| 1453 |
if(targetInvocation == null) |
1453 |
if(targetInvocation == null) |
| 1454 |
{ |
1454 |
{ |
| 1455 |
targetInvocation = HyadesUtil.createTargetInvocation(testCase); |
1455 |
targetInvocation = HyadesUtil.createTargetInvocation(testCase); |
| 1456 |
} |
1456 |
} |
| 1457 |
|
1457 |
|
| 1458 |
IProperty property = getTestCaseProperty (field, true); |
1458 |
IProperty property = getTestCaseProperty (field, true); |
| 1459 |
property.setValue (value); |
1459 |
property.setValue (value); |
| 1460 |
} |
1460 |
} |
| 1461 |
|
1461 |
|
| 1462 |
|
1462 |
|
| 1463 |
public String getProperty (byte field) |
1463 |
public String getProperty (byte field) |
| 1464 |
{ |
1464 |
{ |
| 1465 |
targetInvocation = HyadesUtil.getTargetInvocation(testCase); |
1465 |
targetInvocation = HyadesUtil.getTargetInvocation(testCase); |
| 1466 |
IProperty prop = getTestCaseProperty (field, false); |
1466 |
IProperty prop = getTestCaseProperty (field, false); |
| 1467 |
String retValue = (prop == null ? null : prop.getValue()); |
1467 |
String retValue = (prop == null ? null : prop.getValue()); |
| 1468 |
|
1468 |
|
| 1469 |
return retValue; |
1469 |
return retValue; |
| 1470 |
} |
1470 |
} |
| 1471 |
|
1471 |
|
| 1472 |
private IProperty getTestCaseProperty (byte field, boolean doCreate) |
1472 |
private IProperty getTestCaseProperty (byte field, boolean doCreate) |
| 1473 |
{ |
1473 |
{ |
| 1474 |
if (targetInvocation == null) |
1474 |
if (targetInvocation == null) |
| 1475 |
return null; |
1475 |
return null; |
| 1476 |
|
1476 |
|
| 1477 |
IProperty property = null; |
1477 |
IProperty property = null; |
| 1478 |
|
1478 |
|
| 1479 |
/** |
1479 |
/** |
| 1480 |
* Look for the property |
1480 |
* Look for the property |
| 1481 |
*/ |
1481 |
*/ |
| 1482 |
for (Iterator i = targetInvocation.getActionProperties().getProperties().iterator(); i.hasNext();) |
1482 |
for (Iterator i = targetInvocation.getActionProperties().getProperties().iterator(); i.hasNext();) |
| 1483 |
{ |
1483 |
{ |
| 1484 |
IProperty prop = (IProperty)i.next(); |
1484 |
IProperty prop = (IProperty)i.next(); |
| 1485 |
if (prop.getName().equals(String.valueOf(field))) |
1485 |
if (prop.getName().equals(String.valueOf(field))) |
| 1486 |
{ |
1486 |
{ |
| 1487 |
property = prop; |
1487 |
property = prop; |
| 1488 |
break; |
1488 |
break; |
| 1489 |
} |
1489 |
} |
| 1490 |
} |
1490 |
} |
| 1491 |
|
1491 |
|
| 1492 |
/* Create the property if it can't be found */ |
1492 |
/* Create the property if it can't be found */ |
| 1493 |
if (property == null && doCreate) |
1493 |
if (property == null && doCreate) |
| 1494 |
{ |
1494 |
{ |
| 1495 |
property = HyadesFactory.INSTANCE.createProperty(); |
1495 |
property = HyadesFactory.INSTANCE.createProperty(); |
| 1496 |
property.setName(String.valueOf (field)); |
1496 |
property.setName(String.valueOf (field)); |
| 1497 |
targetInvocation.getActionProperties().getProperties().add(property); |
1497 |
targetInvocation.getActionProperties().getProperties().add(property); |
| 1498 |
} |
1498 |
} |
| 1499 |
|
1499 |
|
| 1500 |
return property; |
1500 |
return property; |
| 1501 |
} |
1501 |
} |
| 1502 |
} |
1502 |
} |
| 1503 |
|
1503 |
|
| 1504 |
|
1504 |
|
| 1505 |
/** |
1505 |
/** |
| 1506 |
* An expansion listener that is used to avoid having the editor display a vertical scroll |
1506 |
* An expansion listener that is used to avoid having the editor display a vertical scroll |
| 1507 |
* bar when the sections are expanded/collapsed. |
1507 |
* bar when the sections are expanded/collapsed. |
| 1508 |
*/ |
1508 |
*/ |
| 1509 |
private class ExpansionListener implements IExpansionListener |
1509 |
private class ExpansionListener implements IExpansionListener |
| 1510 |
{ |
1510 |
{ |
| 1511 |
private ISelection currentSelection; |
1511 |
private ISelection currentSelection; |
| 1512 |
|
1512 |
|
| 1513 |
public void expansionStateChanged(ExpansionEvent e) |
1513 |
public void expansionStateChanged(ExpansionEvent e) |
| 1514 |
{ |
1514 |
{ |
| 1515 |
logicalTreeRepresentaion.getTreeViewer().setSelection(currentSelection); |
1515 |
logicalTreeRepresentaion.getTreeViewer().setSelection(currentSelection); |
| 1516 |
} |
1516 |
} |
| 1517 |
|
1517 |
|
| 1518 |
public void expansionStateChanging(ExpansionEvent e) |
1518 |
public void expansionStateChanging(ExpansionEvent e) |
| 1519 |
{ |
1519 |
{ |
| 1520 |
AutoGUITestCasesForm.this.getForm().reflow(false); |
1520 |
AutoGUITestCasesForm.this.getForm().reflow(false); |
| 1521 |
/* If the common section is about to be expanded, then set the selection to |
1521 |
/* If the common section is about to be expanded, then set the selection to |
| 1522 |
* null so that we can avoid showing a vertical scroll in the editor. */ |
1522 |
* null so that we can avoid showing a vertical scroll in the editor. */ |
| 1523 |
final TreeViewer treeViewer = logicalTreeRepresentaion.getTreeViewer(); |
1523 |
final TreeViewer treeViewer = logicalTreeRepresentaion.getTreeViewer(); |
| 1524 |
currentSelection = treeViewer.getSelection(); |
1524 |
currentSelection = treeViewer.getSelection(); |
| 1525 |
treeViewer.setSelection(null); |
1525 |
treeViewer.setSelection(null); |
| 1526 |
} |
1526 |
} |
| 1527 |
} |
1527 |
} |
| 1528 |
|
1528 |
|
| 1529 |
|
1529 |
|
| 1530 |
/** |
1530 |
/** |
| 1531 |
* @see org.eclipse.ui.part.WorkbenchPart#getAdapter(java.lang.Class) |
1531 |
* @see org.eclipse.ui.part.WorkbenchPart#getAdapter(java.lang.Class) |
| 1532 |
*/ |
1532 |
*/ |
| 1533 |
public Object getAdapter(Class adapter) |
1533 |
public Object getAdapter(Class adapter) |
| 1534 |
{ |
1534 |
{ |
| 1535 |
if (adapter == IFindReplaceTarget.class) |
1535 |
if (adapter == IFindReplaceTarget.class) |
| 1536 |
{ |
1536 |
{ |
| 1537 |
if (macroFindReplaceTarget == null) |
1537 |
if (macroFindReplaceTarget == null) |
| 1538 |
macroFindReplaceTarget = new MacroFindReplaceTarget(rawRepresentation); |
1538 |
macroFindReplaceTarget = new MacroFindReplaceTarget(rawRepresentation); |
| 1539 |
return macroFindReplaceTarget; |
1539 |
return macroFindReplaceTarget; |
| 1540 |
} |
1540 |
} |
| 1541 |
|
1541 |
|
| 1542 |
return super.getAdapter(adapter); |
1542 |
return super.getAdapter(adapter); |
| 1543 |
} |
1543 |
} |
| 1544 |
|
1544 |
|
| 1545 |
/** |
1545 |
/** |
| 1546 |
* The Macro find/replace targe. This class is used to provide a target to the |
1546 |
* The Macro find/replace targe. This class is used to provide a target to the |
| 1547 |
* find/replace dialog. |
1547 |
* find/replace dialog. |
| 1548 |
* |
1548 |
* |
| 1549 |
* @author Ali Mehregani |
1549 |
* @author Ali Mehregani |
| 1550 |
*/ |
1550 |
*/ |
| 1551 |
public static class MacroFindReplaceTarget implements IFindReplaceTarget |
1551 |
public static class MacroFindReplaceTarget implements IFindReplaceTarget |
| 1552 |
{ |
1552 |
{ |
| 1553 |
/** The input */ |
1553 |
/** The input */ |
| 1554 |
private StyledText input; |
1554 |
private StyledText input; |
| 1555 |
|
1555 |
|
| 1556 |
public MacroFindReplaceTarget(StyledText input) |
1556 |
public MacroFindReplaceTarget(StyledText input) |
| 1557 |
{ |
1557 |
{ |
| 1558 |
this.input = input; |
1558 |
this.input = input; |
| 1559 |
} |
1559 |
} |
| 1560 |
|
1560 |
|
| 1561 |
public boolean canPerformFind() |
1561 |
public boolean canPerformFind() |
| 1562 |
{ |
1562 |
{ |
| 1563 |
return input != null; |
1563 |
return input != null; |
| 1564 |
} |
1564 |
} |
| 1565 |
|
1565 |
|
| 1566 |
public int findAndSelect(int widgetOffset, String findString, boolean searchForward, boolean caseSensitive, boolean wholeWord) |
1566 |
public int findAndSelect(int widgetOffset, String findString, boolean searchForward, boolean caseSensitive, boolean wholeWord) |
| 1567 |
{ |
1567 |
{ |
| 1568 |
String macro = input.getText(); |
1568 |
String macro = input.getText(); |
| 1569 |
macro = widgetOffset < 0 ? macro.substring(0) : searchForward ? macro.substring(widgetOffset) : macro.substring(0, widgetOffset); |
1569 |
macro = widgetOffset < 0 ? macro.substring(0) : searchForward ? macro.substring(widgetOffset) : macro.substring(0, widgetOffset); |
| 1570 |
char[] findStringChar = findString.toCharArray(); |
1570 |
char[] findStringChar = findString.toCharArray(); |
| 1571 |
int firstCharacterInx = -1; |
1571 |
int firstCharacterInx = -1; |
| 1572 |
char currentCharacter; |
1572 |
char currentCharacter; |
| 1573 |
|
1573 |
|
| 1574 |
|
1574 |
|
| 1575 |
if(searchForward) |
1575 |
if(searchForward) |
| 1576 |
{ |
1576 |
{ |
| 1577 |
for (int i = 0, macroLength = macro.length(); i < macroLength; i++) |
1577 |
for (int i = 0, macroLength = macro.length(); i < macroLength; i++) |
| 1578 |
{ |
1578 |
{ |
| 1579 |
currentCharacter = macro.charAt(i); |
1579 |
currentCharacter = macro.charAt(i); |
| 1580 |
firstCharacterInx = findFirstCharInx(currentCharacter, i, macro, findStringChar, searchForward, caseSensitive, wholeWord); |
1580 |
firstCharacterInx = findFirstCharInx(currentCharacter, i, macro, findStringChar, searchForward, caseSensitive, wholeWord); |
| 1581 |
firstCharacterInx = findSuccessiveCharacters(firstCharacterInx, findStringChar, macroLength, macro, i, 0, currentCharacter, searchForward, caseSensitive); |
1581 |
firstCharacterInx = findSuccessiveCharacters(firstCharacterInx, findStringChar, macroLength, macro, i, 0, currentCharacter, searchForward, caseSensitive); |
| 1582 |
|
1582 |
|
| 1583 |
if (firstCharacterInx != -1) |
1583 |
if (firstCharacterInx != -1) |
| 1584 |
{ |
1584 |
{ |
| 1585 |
widgetOffset = widgetOffset < 0 ? 0 : widgetOffset; |
1585 |
widgetOffset = widgetOffset < 0 ? 0 : widgetOffset; |
| 1586 |
input.setSelection( i + widgetOffset, i + findStringChar.length + widgetOffset ); |
1586 |
input.setSelection( i + widgetOffset, i + findStringChar.length + widgetOffset ); |
| 1587 |
return i; |
1587 |
return i; |
| 1588 |
} |
1588 |
} |
| 1589 |
} |
1589 |
} |
| 1590 |
} |
1590 |
} |
| 1591 |
|
1591 |
|
| 1592 |
else{ |
1592 |
else{ |
| 1593 |
// searching backward requires a different search (need to go match last character first and traversal is already based on widgetOffset |
1593 |
// searching backward requires a different search (need to go match last character first and traversal is already based on widgetOffset |
| 1594 |
// added for defect 171124 Liz D. |
1594 |
// added for defect 171124 Liz D. |
| 1595 |
|
1595 |
|
| 1596 |
for (int k = macro.length()-1, macroLength = macro.length(); k > 0; k--) |
1596 |
for (int k = macro.length()-1, macroLength = macro.length(); k > 0; k--) |
| 1597 |
{ |
1597 |
{ |
| 1598 |
currentCharacter = macro.charAt(k); |
1598 |
currentCharacter = macro.charAt(k); |
| 1599 |
int lastChar = findStringChar.length-1; |
1599 |
int lastChar = findStringChar.length-1; |
| 1600 |
firstCharacterInx = findFirstCharInx(currentCharacter, k, macro, findStringChar, searchForward, caseSensitive, wholeWord); |
1600 |
firstCharacterInx = findFirstCharInx(currentCharacter, k, macro, findStringChar, searchForward, caseSensitive, wholeWord); |
| 1601 |
firstCharacterInx = findSuccessiveCharacters(firstCharacterInx, findStringChar, macroLength, macro, k, lastChar, currentCharacter, searchForward, caseSensitive); |
1601 |
firstCharacterInx = findSuccessiveCharacters(firstCharacterInx, findStringChar, macroLength, macro, k, lastChar, currentCharacter, searchForward, caseSensitive); |
| 1602 |
|
1602 |
|
| 1603 |
if (firstCharacterInx != -1) |
1603 |
if (firstCharacterInx != -1) |
| 1604 |
{ |
1604 |
{ |
| 1605 |
k++; |
1605 |
k++; |
| 1606 |
input.setSelection(k , k - findStringChar.length ); |
1606 |
input.setSelection(k , k - findStringChar.length ); |
| 1607 |
return k; |
1607 |
return k; |
| 1608 |
} |
1608 |
} |
| 1609 |
} |
1609 |
} |
| 1610 |
} |
1610 |
} |
| 1611 |
|
1611 |
|
| 1612 |
|
1612 |
|
| 1613 |
return -1; |
1613 |
return -1; |
| 1614 |
} |
1614 |
} |
| 1615 |
|
1615 |
|
| 1616 |
private int findSuccessiveCharacters(int firstCharacterInx, char[] findStringChar, int macroLength, String macro, int macroInx, int lastChar, char currentCharacter, boolean searchForward, boolean caseSensitive) |
1616 |
private int findSuccessiveCharacters(int firstCharacterInx, char[] findStringChar, int macroLength, String macro, int macroInx, int lastChar, char currentCharacter, boolean searchForward, boolean caseSensitive) |
| 1617 |
{ |
1617 |
{ |
| 1618 |
for (int j = 1; firstCharacterInx != -1 && j < findStringChar.length; j++) |
1618 |
for (int j = 1; firstCharacterInx != -1 && j < findStringChar.length; j++) |
| 1619 |
{ |
1619 |
{ |
| 1620 |
if ((searchForward ? macroInx + j : macroInx - j) >= macroLength) |
1620 |
if ((searchForward ? macroInx + j : macroInx - j) >= macroLength) |
| 1621 |
{ |
1621 |
{ |
| 1622 |
firstCharacterInx = -1; |
1622 |
firstCharacterInx = -1; |
| 1623 |
break; |
1623 |
break; |
| 1624 |
} |
1624 |
} |
| 1625 |
currentCharacter = macro.charAt((searchForward ? macroInx + j : macroInx - j)); |
1625 |
currentCharacter = macro.charAt((searchForward ? macroInx + j : macroInx - j)); |
| 1626 |
if (currentCharacter != findStringChar[searchForward ? j : lastChar - j] && |
1626 |
if (currentCharacter != findStringChar[searchForward ? j : lastChar - j] && |
| 1627 |
(caseSensitive ? true : (currentCharacter <= 90 ? currentCharacter + 32 != findStringChar[searchForward ? j : lastChar - j] : currentCharacter - 32 != findStringChar[searchForward ? j : lastChar - j]))) |
1627 |
(caseSensitive ? true : (currentCharacter <= 90 ? currentCharacter + 32 != findStringChar[searchForward ? j : lastChar - j] : currentCharacter - 32 != findStringChar[searchForward ? j : lastChar - j]))) |
| 1628 |
{ |
1628 |
{ |
| 1629 |
firstCharacterInx = -1; |
1629 |
firstCharacterInx = -1; |
| 1630 |
break; |
1630 |
break; |
| 1631 |
} |
1631 |
} |
| 1632 |
} |
1632 |
} |
| 1633 |
|
1633 |
|
| 1634 |
return firstCharacterInx; |
1634 |
return firstCharacterInx; |
| 1635 |
} |
1635 |
} |
| 1636 |
|
1636 |
|
| 1637 |
private int findFirstCharInx(char currentCharacter, int i, String macro, char[] findStringChar, boolean searchForward, boolean caseSensitive, boolean wholeWord) |
1637 |
private int findFirstCharInx(char currentCharacter, int i, String macro, char[] findStringChar, boolean searchForward, boolean caseSensitive, boolean wholeWord) |
| 1638 |
{ |
1638 |
{ |
| 1639 |
if ((currentCharacter == findStringChar[searchForward ? 0 : findStringChar.length-1] || |
1639 |
if ((currentCharacter == findStringChar[searchForward ? 0 : findStringChar.length-1] || |
| 1640 |
(!caseSensitive && (currentCharacter <= 90 ? currentCharacter + 32 == findStringChar[0] : currentCharacter - 32 == findStringChar[0]))) && |
1640 |
(!caseSensitive && (currentCharacter <= 90 ? currentCharacter + 32 == findStringChar[0] : currentCharacter - 32 == findStringChar[0]))) && |
| 1641 |
(wholeWord ? macro.charAt(i - 1) == 32 && macro.charAt(i + findStringChar.length) == 32 : true)) |
1641 |
(wholeWord ? macro.charAt(i - 1) == 32 && macro.charAt(i + findStringChar.length) == 32 : true)) |
| 1642 |
{ |
1642 |
{ |
| 1643 |
return i; |
1643 |
return i; |
| 1644 |
} |
1644 |
} |
| 1645 |
|
1645 |
|
| 1646 |
return -1; |
1646 |
return -1; |
| 1647 |
} |
1647 |
} |
| 1648 |
|
1648 |
|
| 1649 |
public Point getSelection() |
1649 |
public Point getSelection() |
| 1650 |
{ |
1650 |
{ |
| 1651 |
Point selection = input.getSelection();; |
1651 |
Point selection = input.getSelection();; |
| 1652 |
return new Point (selection.x, selection.y - selection.x); |
1652 |
return new Point (selection.x, selection.y - selection.x); |
| 1653 |
} |
1653 |
} |
| 1654 |
|
1654 |
|
| 1655 |
public String getSelectionText() |
1655 |
public String getSelectionText() |
| 1656 |
{ |
1656 |
{ |
| 1657 |
Point selection = getSelection(); |
1657 |
Point selection = getSelection(); |
| 1658 |
return input.getText().substring(selection.x, selection.x + selection.y); |
1658 |
return input.getText().substring(selection.x, selection.x + selection.y); |
| 1659 |
} |
1659 |
} |
| 1660 |
|
1660 |
|
| 1661 |
public boolean isEditable() |
1661 |
public boolean isEditable() |
| 1662 |
{ |
1662 |
{ |
| 1663 |
return true; |
1663 |
return true; |
| 1664 |
} |
1664 |
} |
| 1665 |
|
1665 |
|
| 1666 |
public void replaceSelection(String text) |
1666 |
public void replaceSelection(String text) |
| 1667 |
{ |
1667 |
{ |
| 1668 |
if (input == null) |
1668 |
if (input == null) |
| 1669 |
return; |
1669 |
return; |
| 1670 |
|
1670 |
|
| 1671 |
Point selection = input.getSelection(); |
1671 |
Point selection = input.getSelection(); |
| 1672 |
input.replaceTextRange(selection.x, selection.y - selection.x, text); |
1672 |
input.replaceTextRange(selection.x, selection.y - selection.x, text); |
| 1673 |
} |
1673 |
} |
| 1674 |
} |
1674 |
} |
| 1675 |
|
1675 |
|
| 1676 |
private class UndoRedoAction extends Action |
1676 |
private class UndoRedoAction extends Action |
| 1677 |
{ |
1677 |
{ |
| 1678 |
private boolean undo; |
1678 |
private boolean undo; |
| 1679 |
public UndoRedoAction(boolean undo) |
1679 |
public UndoRedoAction(boolean undo) |
| 1680 |
{ |
1680 |
{ |
| 1681 |
this.undo = undo; |
1681 |
this.undo = undo; |
| 1682 |
} |
1682 |
} |
| 1683 |
|
1683 |
|
| 1684 |
public void run() |
1684 |
public void run() |
| 1685 |
{ |
1685 |
{ |
| 1686 |
try |
1686 |
try |
| 1687 |
{ |
1687 |
{ |
| 1688 |
if (undo) |
1688 |
if (undo) |
| 1689 |
{ |
1689 |
{ |
| 1690 |
linearOperationHistory.undo(getUndoContext(), new NullProgressMonitor(), null); |
1690 |
linearOperationHistory.undo(getUndoContext(), new NullProgressMonitor(), null); |
| 1691 |
} |
1691 |
} |
| 1692 |
else |
1692 |
else |
| 1693 |
{ |
1693 |
{ |
| 1694 |
linearOperationHistory.redo(getUndoContext(), new NullProgressMonitor(), null); |
1694 |
linearOperationHistory.redo(getUndoContext(), new NullProgressMonitor(), null); |
| 1695 |
} |
1695 |
} |
| 1696 |
|
1696 |
|
| 1697 |
IActionBars actionBar = AutoGUITestCasesForm.this.getEditorSite().getActionBars(); |
1697 |
IActionBars actionBar = AutoGUITestCasesForm.this.getEditorSite().getActionBars(); |
| 1698 |
if (actionBar != null) |
1698 |
if (actionBar != null) |
| 1699 |
{ |
1699 |
{ |
| 1700 |
undoAction.setEnabled(undoAction.isEnabled()); |
1700 |
undoAction.setEnabled(undoAction.isEnabled()); |
| 1701 |
redoAction.setEnabled(redoAction.isEnabled()); |
1701 |
redoAction.setEnabled(redoAction.isEnabled()); |
| 1702 |
actionBar.updateActionBars(); |
1702 |
actionBar.updateActionBars(); |
| 1703 |
} |
1703 |
} |
| 1704 |
} |
1704 |
} |
| 1705 |
catch (ExecutionException e) |
1705 |
catch (ExecutionException e) |
| 1706 |
{ |
1706 |
{ |
| 1707 |
/* Ignore the error */ |
1707 |
/* Ignore the error */ |
| 1708 |
} |
1708 |
} |
| 1709 |
} |
1709 |
} |
| 1710 |
|
1710 |
|
| 1711 |
public boolean isEnabled() |
1711 |
public boolean isEnabled() |
| 1712 |
{ |
1712 |
{ |
| 1713 |
try |
1713 |
try |
| 1714 |
{ |
1714 |
{ |
| 1715 |
return undo ? linearOperationHistory.canUndo(getUndoContext()) : linearOperationHistory.canRedo(getUndoContext()); |
1715 |
return undo ? linearOperationHistory.canUndo(getUndoContext()) : linearOperationHistory.canRedo(getUndoContext()); |
| 1716 |
} |
1716 |
} |
| 1717 |
catch (Exception e) |
1717 |
catch (Exception e) |
| 1718 |
{ |
1718 |
{ |
| 1719 |
return false; |
1719 |
return false; |
| 1720 |
} |
1720 |
} |
| 1721 |
} |
1721 |
} |
| 1722 |
} |
1722 |
} |
| 1723 |
|
1723 |
|
| 1724 |
/** |
1724 |
/** |
| 1725 |
* This needs to return true in order to enable the replace |
1725 |
* This needs to return true in order to enable the replace |
| 1726 |
* option of the the find dialog. |
1726 |
* option of the the find dialog. |
| 1727 |
*/ |
1727 |
*/ |
| 1728 |
public boolean isEditorInputModifiable() |
1728 |
public boolean isEditorInputModifiable() |
| 1729 |
{ |
1729 |
{ |
| 1730 |
return true; |
1730 |
return true; |
| 1731 |
} |
1731 |
} |
| 1732 |
|
1732 |
|
| 1733 |
|
1733 |
|
| 1734 |
public boolean validateEditorInputState() |
1734 |
public boolean validateEditorInputState() |
| 1735 |
{ |
1735 |
{ |
| 1736 |
return false; |
1736 |
return false; |
| 1737 |
} |
1737 |
} |
| 1738 |
} |
1738 |
} |