|
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 |
} |