Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 228747
Collapse All | Expand All

(-)src/org/eclipse/hyades/internal/execution/recorder/local/RecorderClient.java (-58 / +76 lines)
Lines 66-72 Link Here
66
 * This object is responsible for initiating the recorder session.  It constructs 
66
 * This object is responsible for initiating the recorder session.  It constructs 
67
 * all necessary object, create a Agent Controller Session, and initiates.  It also stay in scope
67
 * all necessary object, create a Agent Controller Session, and initiates.  It also stay in scope
68
 * with sub-classes to shut down all machinery after the recording is complete.
68
 * with sub-classes to shut down all machinery after the recording is complete.
69
 * @author Ernest Jessee
69
 * <p/>
70
 * 
71
 * 
72
 * @author  Ernest Jessee
73
 * @author  Paul E. Slauenwhite
74
 * @version May 6, 2008
75
 * @since   April 22, 2005
70
 */
76
 */
71
public class RecorderClient 
77
public class RecorderClient 
72
{	
78
{	
Lines 144-162 Link Here
144
	 * Recorder deployment directory
150
	 * Recorder deployment directory
145
	 */
151
	 */
146
	public final String RECORDER_DESTINATION_PATH="Recorder_Deploy";
152
	public final String RECORDER_DESTINATION_PATH="Recorder_Deploy";
147
	/** 
148
	 * This thread object is started by the RecorderClient and waits for a complete message to come from the Agent Controller 
149
	 * upon receiving this message, the scripts are generated if a script generator was specified.
150
	 * @author Ernest Jessee
151
	 */
152
	
153
	
153
	/**
154
	/**
154
	 * JAR containing the recorder framework
155
	 * JAR containing the recorder framework
155
	 */
156
	 */
156
	private final String RECORDER_JAR_NAME = "hexrecr.jar";
157
	private final String RECORDER_JAR_NAME = "hexrecr.jar";
157
	
158
	
158
	private class FinishCleanupAndGenTestThread extends Thread
159
	/**
159
	{
160
	 * This thread object is started by the RecorderClient and waits for a complete 
161
	 * message to come from the Agent Controller upon receiving this message, the 
162
	 * scripts are generated if a script generator was specified.
163
	 * <p/>
164
	 * 
165
	 * 
166
	 * @author  Ernest Jessee
167
	 * @author  Paul E. Slauenwhite
168
	 * @version May 6, 2008
169
	 * @since   April 22, 2005
170
	 */
171
	private class FinishCleanupAndGenTestThread extends Thread {
160
		
172
		
161
		/**
173
		/**
162
		 * the constructor
174
		 * the constructor
Lines 172-229 Link Here
172
		public void run()
184
		public void run()
173
		{				
185
		{				
174
			
186
			
175
			//wait for the dataProcessor to get a complete call
187
			try {
176
			while(!dataProcessorHelper.isRecordingComplete())
188
				
177
			{
189
				//wait for the dataProcessor to get a complete call
178
				delay(200);
190
				while(!dataProcessorHelper.isRecordingComplete())
179
			}		
191
				{
180
			if (helper != null)
192
					delay(200);
181
				helper.preStopRecording();
193
				}		
182
			try  {
194
				if (helper != null)
183
				stopApplication();
195
					helper.preStopRecording();
184
			} catch (Exception e) {}
196
				try  {
185
			if (helper != null)
197
					stopApplication();
186
				helper.postStopRecording();
198
				} catch (Exception e) {}
187
			//since we have the completion notification, we'll de-activate this recorder
199
				if (helper != null)
188
			theRecorder.setActive(false);
200
					helper.postStopRecording();
189
			
201
				//since we have the completion notification, we'll de-activate this recorder
190
			//and tell the user that the recorder is done.
202
				theRecorder.setActive(false);
191
			RecorderFactory.getInstance().controlMessage(theRecorder, IRecorderListenerFullFeedback.VIEW_MESSAGE,
203
				
192
					TestCorePluginResourceBundle.RecorderClient_RECORDING_COMPLETE_MESSAGE); 
204
				//and tell the user that the recorder is done.
193
205
				RecorderFactory.getInstance().controlMessage(theRecorder, IRecorderListenerFullFeedback.VIEW_MESSAGE,
194
			//now we need tdo seeif the user wants to generate the suite.  If he does, there will be a scriptgenID in the recorder object.
206
						TestCorePluginResourceBundle.RecorderClient_RECORDING_COMPLETE_MESSAGE); 
195
			//if he does not, the scriptgenid wil be -1.
207
	
196
		
208
				//now we need tdo seeif the user wants to generate the suite.  If he does, there will be a scriptgenID in the recorder object.
197
			
209
				//if he does not, the scriptgenid wil be -1.
198
			// First, write all Unwritten "CLOSE"   mdd
199
			
200
			//if we don't have a -1, then we'll kick off scriptgen
201
			if(!theRecorder.getScriptgenID().equalsIgnoreCase("-1")) //$NON-NLS-1$
202
			{
203
				//Testgen will cause TestHttp to be initialized.
204
				//if we testgen in a worker thread, when TestHttp is initialized, it will have no
205
				//concept of the current display (which it needs to load images)
206
				//Thus, we'll run this asynchronously in the UI thread
207
			}
208
			updateViewStatus(TestCorePluginResourceBundle.RecorderClient_STATUS_STOPPED);
209
			// bugzilla 139992 . check state of session before releasing it.
210
			// bugzilla 144444. Put session.release() back in mdd 06/01/2006
211
			session.release();
212
213
			//notify appropriate listeners to start test gen.
214
			
210
			
215
			Object[] objs = RecorderFactory.getInstance().getListenersForRecorder(theRecorder);
211
				
216
			for (int i = 0; i < objs.length; i++)
212
				// First, write all Unwritten "CLOSE"   mdd
217
			{
213
				
218
			    if (objs[i] instanceof MasterRecorderListener)
214
				//if we don't have a -1, then we'll kick off scriptgen
219
			    {
215
				if(!theRecorder.getScriptgenID().equalsIgnoreCase("-1")) //$NON-NLS-1$
220
			        ((MasterRecorderListener)objs[i]).startTestGen();
216
				{
221
			        break; //only start test gen once.  
217
					//Testgen will cause TestHttp to be initialized.
222
			    }
218
					//if we testgen in a worker thread, when TestHttp is initialized, it will have no
219
					//concept of the current display (which it needs to load images)
220
					//Thus, we'll run this asynchronously in the UI thread
221
				}
222
				updateViewStatus(TestCorePluginResourceBundle.RecorderClient_STATUS_STOPPED);
223
				// bugzilla 139992 . check state of session before releasing it.
224
				// bugzilla 144444. Put session.release() back in mdd 06/01/2006
225
				session.release();
226
	
227
				//notify appropriate listeners to start test gen.
228
				
229
				Object[] objs = RecorderFactory.getInstance().getListenersForRecorder(theRecorder);
230
				for (int i = 0; i < objs.length; i++)
231
				{
232
				    if (objs[i] instanceof MasterRecorderListener)
233
				    {
234
				        ((MasterRecorderListener)objs[i]).startTestGen();
235
				        break; //only start test gen once.  
236
				    }
237
				}
238
	
239
				if (helper != null)
240
					helper.cleanup();
241
			} 
242
			catch (Exception e) {
243
				TestCorePlugin.getDefault().logError(e);
223
			}
244
			}
224
225
			if (helper != null)
226
				helper.cleanup();
227
		}
245
		}
228
246
229
		private void delay(int miliseconds)
247
		private void delay(int miliseconds)
(-)src-recorder/org/eclipse/hyades/internal/execution/recorder/ui/views/RecorderControlView.java (-76 / +73 lines)
Lines 12-18 Link Here
12
package org.eclipse.hyades.internal.execution.recorder.ui.views;
12
package org.eclipse.hyades.internal.execution.recorder.ui.views;
13
13
14
import org.eclipse.core.resources.IResourceStatus;
14
import org.eclipse.core.resources.IResourceStatus;
15
import org.eclipse.core.resources.ResourcesPlugin;
16
import org.eclipse.core.runtime.Status;
15
import org.eclipse.core.runtime.Status;
17
import org.eclipse.hyades.execution.recorder.IRecorderListenerFullFeedback;
16
import org.eclipse.hyades.execution.recorder.IRecorderListenerFullFeedback;
18
import org.eclipse.hyades.internal.execution.recorder.ui.CopyAction;
17
import org.eclipse.hyades.internal.execution.recorder.ui.CopyAction;
Lines 22-28 Link Here
22
import org.eclipse.hyades.test.core.testgen.ITestgenListener;
21
import org.eclipse.hyades.test.core.testgen.ITestgenListener;
23
import org.eclipse.hyades.test.ui.UiPlugin;
22
import org.eclipse.hyades.test.ui.UiPlugin;
24
import org.eclipse.hyades.test.ui.internal.resources.UiPluginResourceBundle;
23
import org.eclipse.hyades.test.ui.internal.resources.UiPluginResourceBundle;
25
import org.eclipse.hyades.test.ui.internal.util.TestUIUtilities;
26
import org.eclipse.jface.action.GroupMarker;
24
import org.eclipse.jface.action.GroupMarker;
27
import org.eclipse.jface.action.ToolBarManager;
25
import org.eclipse.jface.action.ToolBarManager;
28
import org.eclipse.jface.dialogs.ErrorDialog;
26
import org.eclipse.jface.dialogs.ErrorDialog;
Lines 46-65 Link Here
46
import org.eclipse.swt.widgets.Menu;
44
import org.eclipse.swt.widgets.Menu;
47
import org.eclipse.swt.widgets.MenuItem;
45
import org.eclipse.swt.widgets.MenuItem;
48
import org.eclipse.swt.widgets.Text;
46
import org.eclipse.swt.widgets.Text;
49
import org.eclipse.ui.IWorkbenchPage;
47
import org.eclipse.ui.IWorkbenchPartSite;
50
import org.eclipse.ui.IWorkbenchWindow;
51
import org.eclipse.ui.PlatformUI;
48
import org.eclipse.ui.PlatformUI;
52
import org.eclipse.ui.actions.ActionFactory;
49
import org.eclipse.ui.actions.ActionFactory;
53
import org.eclipse.ui.part.ViewPart;
50
import org.eclipse.ui.part.ViewPart;
54
51
55
/**
52
/**
56
 * Recorder Control View for receiving feedback and controlling recorders during recording.
53
 * Recorder Control View for receiving feedback and controlling recorders during recording.
54
 * <p/>
57
 * 
55
 * 
58
 * 
56
 * 
59
 * @author  Ernest Jessee
57
 * @author  Ernest Jessee
60
 * @author  Paul E. Slauenwhite
58
 * @author  Paul E. Slauenwhite
61
 * @author  Paul Klicnik
59
 * @author  Paul Klicnik
62
 * @version April 9, 2008
60
 * @version May 6, 2008
63
 * @since   February 1, 2005
61
 * @since   February 1, 2005
64
 */
62
 */
65
public class RecorderControlView extends ViewPart implements ITestgenListener, IRecorderListenerFullFeedback 
63
public class RecorderControlView extends ViewPart implements ITestgenListener, IRecorderListenerFullFeedback 
Lines 80-88 Link Here
80
	private List statusList;
78
	private List statusList;
81
	
79
	
82
	/**
80
	/**
83
	 * the default instance
81
	 * Singleton instance of the Recorder Control View.
84
	 */
82
	 */
85
	public static RecorderControlView instance=null;
83
	public static RecorderControlView instance = null;
86
	
84
	
87
	/**
85
	/**
88
	 * Setup the clipboard   
86
	 * Setup the clipboard   
Lines 94-100 Link Here
94
	 */
92
	 */
95
	private CopyAction copyAction = null;
93
	private CopyAction copyAction = null;
96
	
94
	
97
		
98
	/**
95
	/**
99
	 * the view's ID
96
	 * the view's ID
100
	 */
97
	 */
Lines 207-221 Link Here
207
			copyAction.setEnabled( statusLines.length == 0 ? false : true );
204
			copyAction.setEnabled( statusLines.length == 0 ? false : true );
208
		}
205
		}
209
	}
206
	}
210
211
	/**
212
	 * method for acquiring the active IWorkbenchWindow 
213
	 * @return IWorkbenchWindow
214
	 */
215
	public static IWorkbenchWindow getActiveWorkbenchWindow() 
216
	{
217
		return PlatformUI.getWorkbench().getActiveWorkbenchWindow();
218
	}
219
	
207
	
220
	/**
208
	/**
221
	 * method which resets the contents of the Recorder Control View
209
	 * method which resets the contents of the Recorder Control View
Lines 227-273 Link Here
227
	}
215
	}
228
	
216
	
229
	/**
217
	/**
230
	 * returns the default instance of the recorder Control View.  Also changes the current perspective to the Test Perspective and creates
218
	 * Resolves the singleton instance of the Recorder Control View.
231
	 * the recorder control view if it has not previously been created.  
219
	 * <p/>
232
	 * @return RecorderControlView
220
	 * When the singleton instance is instantiated, the Recorder Control View
233
	 */
221
	 * is opened (if closed) and given focus in the active page of the active 
234
	public static RecorderControlView getInstance()
222
	 * workbench window.
235
	{
223
	 * <p/> 
236
224
	 * The Recorder Control View is given focus on subsequent calls after the 
237
		//Attempt to open the Test Perspective:
225
	 * singleton instance has been instantiated.
238
		TestUIUtilities.openTestPerspective();
226
	 * <p/> 
239
227
	 * 
240
		IWorkbenchWindow window = getActiveWorkbenchWindow();
228
	 * @return The singleton instance of the Recorder Control View.
229
	 */
230
	public static RecorderControlView getInstance(){
231
232
		if(instance == null){
233
			
234
			Display.getDefault().syncExec(new Runnable() {
235
236
				public void run() {
237
					
238
					try{
239
						instance = ((RecorderControlView)(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(ID)));
240
					}
241
					catch(Exception e){
241
242
242
		try
243
						UiPlugin.logError(e);
243
		{
244
			IWorkbenchPage page = window.getActivePage();
245
244
246
			if(instance == null){
245
						ErrorDialog.openError(Display.getDefault().getActiveShell(),
247
				instance = ((RecorderControlView)(page.showView(ID)));
246
								UiPluginResourceBundle.W_ERROR,
248
			}
247
								UiPluginResourceBundle.RecorderControlView_UNABLE_TO_CREATE_RECORDER_CONTROL_VIEW_ERROR_MSG, 
249
			else{
248
								new Status(Status.WARNING, UiPlugin.PLUGIN_ID, IResourceStatus.INTERNAL_ERROR, e.toString(), null));
250
				page.showView(ID);
249
					}
251
			}
250
				}
251
			});
252
		}
252
		}
253
		catch(Exception e)
254
		{
255
			String msg = UiPluginResourceBundle.RecorderControlView_UNABLE_TO_CREATE_RECORDER_CONTROL_VIEW_ERROR_MSG;                  
256
257
			Status err = new Status(Status.WARNING, ResourcesPlugin.PI_RESOURCES, IResourceStatus.INTERNAL_ERROR, e.toString(), null ); 
258
259
			ErrorDialog.openError(window.getShell(),
260
					msg,
261
					"", // no special message //$NON-NLS-1$
262
					err);
263
264
			UiPlugin.logError(e);
265
		}                               
266
253
267
		return instance;
254
		return instance;		
268
	}
255
	}
269
	
270
		
271
256
272
	/**
257
	/**
273
	 * asynchronously adds a message to the status box
258
	 * asynchronously adds a message to the status box
Lines 287-301 Link Here
287
	 */
272
	 */
288
	public void addMessage(final String message, boolean bSync)
273
	public void addMessage(final String message, boolean bSync)
289
	{
274
	{
290
		Runnable a =
275
		Runnable a = new Runnable(){
291
			new Runnable()
276
292
			{				
277
			public void run(){
293
				public void run()
278
294
				{
279
				if(!statusList.isDisposed()){					
280
281
					//Attempt to activate the singleton instance of the Recorder Control View:					
282
					if(instance != null){
283
284
						IWorkbenchPartSite workbenchPartSite = instance.getSite();
285
286
						if(workbenchPartSite != null){
287
							workbenchPartSite.getPage().activate(instance);
288
						}
289
					}
290
295
					statusList.add(message);
291
					statusList.add(message);
296
					statusList.setSelection(statusList.getItems().length-1);
292
					statusList.setSelection(statusList.getItems().length-1);
297
				}
293
				}
298
			};
294
			}
295
		};
299
 		if (bSync)
296
 		if (bSync)
300
			Display.getDefault().syncExec(a);
297
			Display.getDefault().syncExec(a);
301
		else
298
		else
Lines 309-327 Link Here
309
	 */
306
	 */
310
	public void setKBytesReceived(final int receivedKBytes)
307
	public void setKBytesReceived(final int receivedKBytes)
311
	{
308
	{
312
		Display.getDefault().asyncExec
309
		Display.getDefault().asyncExec(new Runnable(){
313
		(
310
314
			new Runnable()
311
			public void run(){
315
			{				
312
316
				public void run()
313
				if(!kBytesReceived.isDisposed()){
317
				{
318
					kBytesReceived.setText(String.valueOf(receivedKBytes));
314
					kBytesReceived.setText(String.valueOf(receivedKBytes));
319
				}
315
				}
320
			}
316
			}
321
	
317
		});
322
		);
323
	
324
	}
318
	}
319
	
325
	/**
320
	/**
326
	 * Sets text of the status text field
321
	 * Sets text of the status text field
327
	 * @param status
322
	 * @param status
Lines 392-404 Link Here
392
     * @see org.eclipse.hyades.internal.execution.recorder.IRecorderListener#updateStatus(java.lang.String)
387
     * @see org.eclipse.hyades.internal.execution.recorder.IRecorderListener#updateStatus(java.lang.String)
393
     */
388
     */
394
    public void updateStatus(final String str) {
389
    public void updateStatus(final String str) {
395
        if (Display.getDefault() != null)
390
        
396
        {
391
    	Display.getDefault().asyncExec(new Runnable() {
397
            Display.getDefault().asyncExec(new Runnable() {
392
398
                public void run() {
393
    		public void run() {
399
                    recStatus.setText(str);
394
400
                }
395
    			if(!recStatus.isDisposed()){
401
            });
396
    				recStatus.setText(str);
402
        }   
397
    			}
398
    		}
399
    	});
403
    }    
400
    }    
404
}
401
}
(-)src/org/eclipse/hyades/test/ui/internal/resources/messages.properties (-1 / +1 lines)
Lines 298-304 Link Here
298
RecorderUIUtility_INCORRECT_LAYOUT_MESSAGE_FORMAT_STRING=IWAT3036E Parent Composite does not have correct layout assigned ({0})
298
RecorderUIUtility_INCORRECT_LAYOUT_MESSAGE_FORMAT_STRING=IWAT3036E Parent Composite does not have correct layout assigned ({0})
299
StopRecordingAction_STOP_RECORDING_BUTTON_TOOLTIP=Stop Recording
299
StopRecordingAction_STOP_RECORDING_BUTTON_TOOLTIP=Stop Recording
300
RecorderControlView_KBYTES_RECEIVED_CONTROL_LABEL=KBytes Recorded:
300
RecorderControlView_KBYTES_RECEIVED_CONTROL_LABEL=KBytes Recorded:
301
RecorderControlView_UNABLE_TO_CREATE_RECORDER_CONTROL_VIEW_ERROR_MSG=IWAT3037E Unable to create recorder control view
301
RecorderControlView_UNABLE_TO_CREATE_RECORDER_CONTROL_VIEW_ERROR_MSG=IWAT3037E Unable to create the Recorder Control View.
302
RecorderControlView_STATUS_LABEL=Recorder Status:
302
RecorderControlView_STATUS_LABEL=Recorder Status:
303
303
304
#############################################################################################################
304
#############################################################################################################

Return to bug 228747