Lines 10-15
Link Here
|
10 |
* Craig Setera (EclipseME) - Initial implementation |
10 |
* Craig Setera (EclipseME) - Initial implementation |
11 |
* Diego Sandin (Motorola) - Refactoring package name to follow eclipse |
11 |
* Diego Sandin (Motorola) - Refactoring package name to follow eclipse |
12 |
* standards |
12 |
* standards |
|
|
13 |
* Gang Ma (Sybase) - Add the functionality of warning user if |
14 |
* the base Eclipse debug settings is not correct |
13 |
*/ |
15 |
*/ |
14 |
package org.eclipse.mtj.ui.internal.launching; |
16 |
package org.eclipse.mtj.ui.internal.launching; |
15 |
|
17 |
|
Lines 24-29
Link Here
|
24 |
import org.eclipse.core.runtime.CoreException; |
26 |
import org.eclipse.core.runtime.CoreException; |
25 |
import org.eclipse.core.runtime.IProgressMonitor; |
27 |
import org.eclipse.core.runtime.IProgressMonitor; |
26 |
import org.eclipse.core.runtime.IStatus; |
28 |
import org.eclipse.core.runtime.IStatus; |
|
|
29 |
import org.eclipse.core.runtime.MultiStatus; |
30 |
import org.eclipse.core.runtime.Status; |
27 |
import org.eclipse.core.runtime.SubProgressMonitor; |
31 |
import org.eclipse.core.runtime.SubProgressMonitor; |
28 |
import org.eclipse.debug.core.DebugPlugin; |
32 |
import org.eclipse.debug.core.DebugPlugin; |
29 |
import org.eclipse.debug.core.ILaunchConfiguration; |
33 |
import org.eclipse.debug.core.ILaunchConfiguration; |
Lines 40-50
Link Here
|
40 |
import org.eclipse.jdt.core.IType; |
44 |
import org.eclipse.jdt.core.IType; |
41 |
import org.eclipse.jdt.core.JavaCore; |
45 |
import org.eclipse.jdt.core.JavaCore; |
42 |
import org.eclipse.jdt.core.JavaModelException; |
46 |
import org.eclipse.jdt.core.JavaModelException; |
|
|
47 |
import org.eclipse.jdt.debug.core.JDIDebugModel; |
48 |
import org.eclipse.jdt.debug.ui.JavaDebugUtils; |
49 |
import org.eclipse.jdt.internal.debug.ui.IJDIPreferencesConstants; |
43 |
import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants; |
50 |
import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants; |
44 |
import org.eclipse.jdt.ui.JavaElementLabelProvider; |
51 |
import org.eclipse.jdt.ui.JavaElementLabelProvider; |
45 |
import org.eclipse.jface.dialogs.ErrorDialog; |
52 |
import org.eclipse.jface.dialogs.ErrorDialog; |
|
|
53 |
import org.eclipse.jface.dialogs.IDialogConstants; |
46 |
import org.eclipse.jface.dialogs.ProgressMonitorDialog; |
54 |
import org.eclipse.jface.dialogs.ProgressMonitorDialog; |
47 |
import org.eclipse.jface.operation.IRunnableWithProgress; |
55 |
import org.eclipse.jface.operation.IRunnableWithProgress; |
|
|
56 |
import org.eclipse.jface.preference.IPreferenceStore; |
48 |
import org.eclipse.jface.viewers.ISelection; |
57 |
import org.eclipse.jface.viewers.ISelection; |
49 |
import org.eclipse.jface.viewers.IStructuredSelection; |
58 |
import org.eclipse.jface.viewers.IStructuredSelection; |
50 |
import org.eclipse.mtj.core.internal.MTJCorePlugin; |
59 |
import org.eclipse.mtj.core.internal.MTJCorePlugin; |
Lines 50-56
Link Here
|
50 |
import org.eclipse.mtj.core.internal.MTJCorePlugin; |
59 |
import org.eclipse.mtj.core.internal.MTJCorePlugin; |
51 |
import org.eclipse.mtj.core.internal.utils.Utils; |
60 |
import org.eclipse.mtj.core.internal.utils.Utils; |
52 |
import org.eclipse.mtj.core.launching.ILaunchConstants; |
61 |
import org.eclipse.mtj.core.launching.ILaunchConstants; |
|
|
62 |
import org.eclipse.mtj.ui.IMTJUIConstants; |
63 |
import org.eclipse.mtj.ui.MTJUIStrings; |
53 |
import org.eclipse.mtj.ui.internal.MTJUIPlugin; |
64 |
import org.eclipse.mtj.ui.internal.MTJUIPlugin; |
|
|
65 |
import org.eclipse.swt.SWT; |
66 |
import org.eclipse.swt.events.SelectionAdapter; |
67 |
import org.eclipse.swt.events.SelectionEvent; |
68 |
import org.eclipse.swt.layout.GridData; |
69 |
import org.eclipse.swt.widgets.Button; |
70 |
import org.eclipse.swt.widgets.Composite; |
71 |
import org.eclipse.swt.widgets.Control; |
54 |
import org.eclipse.swt.widgets.Shell; |
72 |
import org.eclipse.swt.widgets.Shell; |
55 |
import org.eclipse.ui.IEditorInput; |
73 |
import org.eclipse.ui.IEditorInput; |
56 |
import org.eclipse.ui.IEditorPart; |
74 |
import org.eclipse.ui.IEditorPart; |
Lines 57-62
Link Here
|
57 |
import org.eclipse.ui.IWorkbenchWindow; |
75 |
import org.eclipse.ui.IWorkbenchWindow; |
58 |
import org.eclipse.ui.dialogs.ElementListSelectionDialog; |
76 |
import org.eclipse.ui.dialogs.ElementListSelectionDialog; |
59 |
|
77 |
|
|
|
78 |
|
60 |
/** |
79 |
/** |
61 |
* Emulator launch shortcut implementation. |
80 |
* Emulator launch shortcut implementation. |
62 |
* |
81 |
* |
Lines 393-407
Link Here
|
393 |
} |
412 |
} |
394 |
|
413 |
|
395 |
if (type != null) { |
414 |
if (type != null) { |
396 |
ILaunchConfiguration config = findLaunchConfiguration(type, mode); |
415 |
// configure the debugger settings |
397 |
if (config != null) { |
416 |
configDebuggerSetting(mode); |
398 |
try { |
417 |
ILaunchConfiguration config = findLaunchConfiguration(type, mode); |
399 |
config.launch(mode, null); |
418 |
if (config != null) { |
400 |
} catch (CoreException e) { |
419 |
try { |
401 |
ErrorDialog.openError(getShell(), "Error Launching " |
420 |
config.launch(mode, null); |
402 |
+ config.getName(), e.getMessage(), e.getStatus()); |
421 |
} catch (CoreException e) { |
|
|
422 |
ErrorDialog.openError(getShell(), "Error Launching " |
423 |
+ config.getName(), e.getMessage(), e.getStatus()); |
424 |
} |
425 |
} |
426 |
|
427 |
} |
428 |
} |
429 |
|
430 |
/** |
431 |
* The preference key of debug setting warning, |
432 |
* if user select "don't warn me again", the preference will be stored. |
433 |
*/ |
434 |
public static final String PREF_DEBUGSETTING_WARNING = IMTJUIConstants.PLUGIN_ID+".debugSettingWarning"; |
435 |
/** |
436 |
* Debugger time out must be set more than 15000 |
437 |
*/ |
438 |
public static final int MIN_DEBUGGERTIMEOUT_SETTING = 15000; |
439 |
/** |
440 |
* Suspend execution on uncaught exception must not be checked |
441 |
*/ |
442 |
public static final boolean CORRECT_SUSPENDONUNCAUGHTEXP_SETTING = false; |
443 |
/** |
444 |
* Suspend execution on compilation errors must not be checked |
445 |
*/ |
446 |
public static final boolean CORRECT_SUSPENDONCOMPILEERR_SETTING = false; |
447 |
|
448 |
/** |
449 |
* configure the debug setting for user |
450 |
*/ |
451 |
private void configDebuggerSetting(String mode){ |
452 |
//only need to configure debugger setting while in debug mode |
453 |
if(!ILaunchManager.DEBUG_MODE.equalsIgnoreCase(mode)) |
454 |
return; |
455 |
IStatus debugSettingStatus = debugSettingSatisfied(); |
456 |
//only need to configure debugger setting while the setting is not satisfied |
457 |
if(debugSettingStatus.isOK()) |
458 |
return; |
459 |
|
460 |
String preferenceKey = PREF_DEBUGSETTING_WARNING; |
461 |
String debugWarningDesc = MTJUIPlugin.getDefault().getPreferenceStore().getString(preferenceKey); |
462 |
//if the user have ever checked "Don't warn me again",don't warn that |
463 |
if (ErrorDialogWithToggle.NO_WARING.equals(debugWarningDesc)){ |
464 |
return; |
465 |
} |
466 |
//show the warning dialog |
467 |
Shell shell = getShell(); |
468 |
ErrorDialogWithToggle dialog = new ErrorDialogWithToggle(shell, |
469 |
MTJUIStrings.getString("debugWarning.title"), null, |
470 |
debugSettingStatus, preferenceKey, MTJUIStrings |
471 |
.getString("debugWarning.toggleMessage"), |
472 |
MTJUIPlugin.getDefault().getPreferenceStore()); |
473 |
dialog.open(); |
474 |
|
475 |
boolean answer = (dialog.getReturnCode() == IDialogConstants.YES_ID); |
476 |
if(answer){ |
477 |
JDIDebugModel.getPreferences().setValue(JDIDebugModel.PREF_REQUEST_TIMEOUT, MIN_DEBUGGERTIMEOUT_SETTING); |
478 |
JavaDebugUtils.getPreferenceStore().setValue(IJDIPreferencesConstants.PREF_SUSPEND_ON_UNCAUGHT_EXCEPTIONS, CORRECT_SUSPENDONUNCAUGHTEXP_SETTING); |
479 |
JavaDebugUtils.getPreferenceStore().setValue(IJDIPreferencesConstants.PREF_SUSPEND_ON_COMPILATION_ERRORS, CORRECT_SUSPENDONCOMPILEERR_SETTING); |
480 |
|
481 |
} |
482 |
|
483 |
} |
484 |
|
485 |
/** |
486 |
* check if the debug setting is satisfied |
487 |
* if it is satisfied for debugging return status ok else return status warning. |
488 |
* @return IStatus |
489 |
*/ |
490 |
private IStatus debugSettingSatisfied(){ |
491 |
boolean suspendOnUnCaughtExp = JavaDebugUtils.getPreferenceStore().getBoolean(IJDIPreferencesConstants.PREF_SUSPEND_ON_UNCAUGHT_EXCEPTIONS); |
492 |
boolean suspendOnCompileErr = JavaDebugUtils.getPreferenceStore().getBoolean(IJDIPreferencesConstants.PREF_SUSPEND_ON_COMPILATION_ERRORS); |
493 |
int currReqTimeout = JDIDebugModel.getPreferences().getInt(JDIDebugModel.PREF_REQUEST_TIMEOUT); |
494 |
|
495 |
if (!suspendOnUnCaughtExp && !suspendOnCompileErr |
496 |
&& currReqTimeout >= MIN_DEBUGGERTIMEOUT_SETTING) { |
497 |
return new Status(IStatus.OK, IMTJUIConstants.PLUGIN_ID, ""); |
498 |
}else{ |
499 |
MultiStatus warningStatus = new MultiStatus(IMTJUIConstants.PLUGIN_ID,IStatus.WARNING,MTJUIStrings.getString("debugWarning.warningMessage"),null); |
500 |
|
501 |
if(suspendOnUnCaughtExp){ |
502 |
warningStatus.add(new Status(IStatus.WARNING, IMTJUIConstants.PLUGIN_ID, MTJUIStrings.getString("debugWarning.suspendOnUnCaughtExpWarning"))); |
503 |
} |
504 |
if(suspendOnCompileErr){ |
505 |
warningStatus.add(new Status(IStatus.WARNING, IMTJUIConstants.PLUGIN_ID, MTJUIStrings.getString("debugWarning.suspendOnCompileErrWarning"))); |
506 |
|
507 |
} |
508 |
if(currReqTimeout < MIN_DEBUGGERTIMEOUT_SETTING){ |
509 |
warningStatus.add(new Status(IStatus.WARNING, IMTJUIConstants.PLUGIN_ID, MTJUIStrings.getString("debugWarning.reqestTimeoutWarning",new Integer[]{MIN_DEBUGGERTIMEOUT_SETTING}))); |
510 |
} |
511 |
return warningStatus; |
512 |
} |
513 |
} |
514 |
/** |
515 |
* |
516 |
* this is a dialog with toggle message, "Yes" "No" and "Details" buttons. |
517 |
* @author gma |
518 |
* |
519 |
*/ |
520 |
class ErrorDialogWithToggle extends ErrorDialog { |
521 |
|
522 |
public static final String NO_WARING = "neverWaring"; |
523 |
|
524 |
/** |
525 |
* The selected state of the toggle. |
526 |
*/ |
527 |
private boolean toggleState; |
528 |
/** |
529 |
* The preference key which is set by the toggle button. |
530 |
* |
531 |
*/ |
532 |
private String fPreferenceKey= null; |
533 |
/** |
534 |
* The message displayed to the user, with the toggle button |
535 |
*/ |
536 |
private String fToggleMessage= null; |
537 |
private Button fToggleButton= null; |
538 |
/** |
539 |
* The preference store which will be affected by the toggle button |
540 |
*/ |
541 |
IPreferenceStore prefStore= null; |
542 |
|
543 |
public ErrorDialogWithToggle(Shell parentShell, String dialogTitle, String message, IStatus status, String preferenceKey, String toggleMessage, IPreferenceStore store) { |
544 |
super(parentShell, dialogTitle, message, status, IStatus.WARNING | IStatus.ERROR | IStatus.INFO); |
545 |
prefStore= store; |
546 |
fPreferenceKey= preferenceKey; |
547 |
fToggleMessage= toggleMessage; |
548 |
} |
549 |
|
550 |
protected Control createDialogArea(Composite parent) { |
551 |
Composite dialogComposite= (Composite) super.createDialogArea(parent); |
552 |
dialogComposite.setFont(parent.getFont()); |
553 |
setToggleButton(createCheckButton(dialogComposite, fToggleMessage)); |
554 |
applyDialogFont(dialogComposite); |
555 |
return dialogComposite; |
556 |
} |
557 |
|
558 |
/** |
559 |
* Creates a button with the given label and sets the default |
560 |
* configuration data. |
561 |
*/ |
562 |
private Button createCheckButton(Composite parent, String label) { |
563 |
final Button button= new Button(parent, SWT.CHECK | SWT.LEFT); |
564 |
button.setText(label); |
565 |
|
566 |
GridData data = new GridData(SWT.NONE); |
567 |
data.horizontalSpan= 2; |
568 |
data.horizontalAlignment= GridData.CENTER; |
569 |
button.setLayoutData(data); |
570 |
button.setFont(parent.getFont()); |
571 |
button.addSelectionListener(new SelectionAdapter() { |
572 |
|
573 |
public void widgetSelected(SelectionEvent e) { |
574 |
toggleState = button.getSelection(); |
575 |
} |
576 |
}); |
577 |
|
578 |
return button; |
579 |
} |
580 |
|
581 |
protected void buttonPressed(int buttonId) { |
582 |
|
583 |
if (buttonId != IDialogConstants.DETAILS_ID) { |
584 |
if(toggleState && prefStore != null && fPreferenceKey != null){ |
585 |
prefStore.setValue(fPreferenceKey, NO_WARING); |
403 |
} |
586 |
} |
|
|
587 |
setReturnCode(buttonId); |
588 |
close(); |
404 |
} |
589 |
} |
405 |
} |
590 |
super.buttonPressed(buttonId); |
|
|
591 |
} |
592 |
|
593 |
|
594 |
protected Button getToggleButton() { |
595 |
return fToggleButton; |
596 |
} |
597 |
|
598 |
protected void setToggleButton(Button button) { |
599 |
fToggleButton = button; |
600 |
} |
601 |
|
602 |
/** |
603 |
* @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite) |
604 |
*/ |
605 |
protected void createButtonsForButtonBar(Composite parent) { |
606 |
createButton(parent, IDialogConstants.YES_ID, IDialogConstants.YES_LABEL, |
607 |
true); |
608 |
createButton(parent, IDialogConstants.NO_ID, IDialogConstants.NO_LABEL, |
609 |
true); |
610 |
createDetailsButton(parent); |
611 |
|
612 |
getButton(IDialogConstants.YES_ID).setFocus(); |
613 |
} |
406 |
} |
614 |
} |
407 |
} |
615 |
} |