debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/ui/SymbianExceptionsTab.java
branchRCL_2_4
changeset 583 0c45a379d354
equal deleted inserted replaced
581:3465427e6144 583:0c45a379d354
       
     1 package com.nokia.cdt.internal.debug.launch.ui;
       
     2 
       
     3 import org.eclipse.core.runtime.CoreException;
       
     4 import org.eclipse.debug.core.ILaunchConfiguration;
       
     5 import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
       
     6 import org.eclipse.debug.ui.AbstractLaunchConfigurationTab;
       
     7 import org.eclipse.jface.dialogs.Dialog;
       
     8 import org.eclipse.swt.SWT;
       
     9 import org.eclipse.swt.events.SelectionAdapter;
       
    10 import org.eclipse.swt.events.SelectionEvent;
       
    11 import org.eclipse.swt.graphics.Image;
       
    12 import org.eclipse.swt.layout.GridLayout;
       
    13 import org.eclipse.swt.widgets.Button;
       
    14 import org.eclipse.swt.widgets.Combo;
       
    15 import org.eclipse.swt.widgets.Composite;
       
    16 import org.eclipse.swt.widgets.Event;
       
    17 import org.eclipse.swt.widgets.Listener;
       
    18 import org.eclipse.ui.PlatformUI;
       
    19 
       
    20 import com.nokia.cdt.internal.debug.launch.LaunchPlugin;
       
    21 
       
    22 import cwdbg.PreferenceConstants;
       
    23 
       
    24 public class SymbianExceptionsTab extends AbstractLaunchConfigurationTab {
       
    25 
       
    26 	private Button panicCheckbox;
       
    27 	private Combo panicCombo;
       
    28 	private Button swExcCheckbox;
       
    29 	private Combo swExcCombo;
       
    30 	private Button hwExcCheckbox;
       
    31 	private Combo hwExcCombo;
       
    32 	
       
    33 	public void createControl(Composite parent) {
       
    34 		Composite comp = new Composite(parent, SWT.NONE);
       
    35 		setControl(comp);
       
    36 		
       
    37 		GridLayout layout = new GridLayout(2, true);
       
    38 		comp.setLayout(layout);
       
    39 		
       
    40 		panicCheckbox = new Button(comp, SWT.CHECK);
       
    41 		panicCheckbox.setText(Messages.getString("SymbianExceptionsTab.Panic")); //$NON-NLS-1$
       
    42 		panicCheckbox.setToolTipText(Messages.getString("SymbianExceptionsTab.PanicToolTip")); //$NON-NLS-1$
       
    43 		panicCheckbox.addSelectionListener(new SelectionAdapter() {
       
    44 			public void widgetSelected(SelectionEvent e) {
       
    45 				if (panicCombo != null) {
       
    46 					panicCombo.setEnabled(panicCheckbox.getSelection());
       
    47 					updateLaunchConfigurationDialog();
       
    48 				}
       
    49 			}
       
    50 		});
       
    51 
       
    52 		panicCombo = new Combo(comp, SWT.DROP_DOWN | SWT.READ_ONLY);
       
    53 		panicCombo.add(Messages.getString("SymbianExceptionsTab.DebugThreads")); //$NON-NLS-1$
       
    54 		panicCombo.add(Messages.getString("SymbianExceptionsTab.AnyThread")); //$NON-NLS-1$
       
    55 		panicCombo.select(0);
       
    56 		panicCombo.addListener(SWT.Selection, new Listener() {
       
    57 			public void handleEvent(Event e) {
       
    58 				updateLaunchConfigurationDialog();
       
    59 			}
       
    60 		});
       
    61 		
       
    62 		swExcCheckbox = new Button(comp, SWT.CHECK);
       
    63 		swExcCheckbox.setText(Messages.getString("SymbianExceptionsTab.SwExc")); //$NON-NLS-1$
       
    64 		swExcCheckbox.setToolTipText(Messages.getString("SymbianExceptionsTab.SwExcToolTip")); //$NON-NLS-1$
       
    65 		swExcCheckbox.addSelectionListener(new SelectionAdapter() {
       
    66 			public void widgetSelected(SelectionEvent e) {
       
    67 				if (swExcCombo != null) {
       
    68 					swExcCombo.setEnabled(swExcCheckbox.getSelection());
       
    69 					updateLaunchConfigurationDialog();
       
    70 				}
       
    71 			}
       
    72 		});
       
    73 
       
    74 		swExcCombo = new Combo(comp, SWT.DROP_DOWN | SWT.READ_ONLY);
       
    75 		swExcCombo.add(Messages.getString("SymbianExceptionsTab.DebugThreads")); //$NON-NLS-1$
       
    76 		swExcCombo.add(Messages.getString("SymbianExceptionsTab.AnyThread")); //$NON-NLS-1$
       
    77 		swExcCombo.select(0);
       
    78 		swExcCombo.addListener(SWT.Selection, new Listener() {
       
    79 			public void handleEvent(Event e) {
       
    80 				updateLaunchConfigurationDialog();
       
    81 			}
       
    82 		});
       
    83 
       
    84 		hwExcCheckbox = new Button(comp, SWT.CHECK);
       
    85 		hwExcCheckbox.setText(Messages.getString("SymbianExceptionsTab.HwExc")); //$NON-NLS-1$
       
    86 		hwExcCheckbox.setToolTipText(Messages.getString("SymbianExceptionsTab.HwExcToolTip")); //$NON-NLS-1$
       
    87 		hwExcCheckbox.addSelectionListener(new SelectionAdapter() {
       
    88 			public void widgetSelected(SelectionEvent e) {
       
    89 				if (hwExcCombo != null) {
       
    90 					hwExcCombo.setEnabled(hwExcCheckbox.getSelection());
       
    91 					updateLaunchConfigurationDialog();
       
    92 				}
       
    93 			}
       
    94 		});
       
    95 
       
    96 		hwExcCombo = new Combo(comp, SWT.DROP_DOWN | SWT.READ_ONLY);
       
    97 		hwExcCombo.add(Messages.getString("SymbianExceptionsTab.DebugThreads")); //$NON-NLS-1$
       
    98 		hwExcCombo.add(Messages.getString("SymbianExceptionsTab.AnyThread")); //$NON-NLS-1$
       
    99 		hwExcCombo.select(0);
       
   100 		hwExcCombo.addListener(SWT.Selection, new Listener() {
       
   101 			public void handleEvent(Event e) {
       
   102 				updateLaunchConfigurationDialog();
       
   103 			}
       
   104 		});
       
   105 
       
   106 		PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), LaunchTabHelpIds.STOP_MODE_EXCEPTIONS);
       
   107 		Dialog.applyDialogFont(parent);
       
   108 	}
       
   109 
       
   110 	public void initializeFrom(ILaunchConfiguration configuration) {
       
   111 		try {
       
   112 			panicCheckbox.setSelection(configuration.getAttribute(PreferenceConstants.J_PN_StopModeEnablePanics, true));
       
   113 			panicCombo.select(configuration.getAttribute(PreferenceConstants.J_PN_StopModeEnablePanicsForDebugThreadsOnly, true) ? 0 : 1);
       
   114 			panicCombo.setEnabled(panicCheckbox.getSelection());
       
   115 
       
   116 			swExcCheckbox.setSelection(configuration.getAttribute(PreferenceConstants.J_PN_StopModeEnableSwExcs, true));
       
   117 			swExcCombo.select(configuration.getAttribute(PreferenceConstants.J_PN_StopModeEnableSwExcsForDebugThreadsOnly, true) ? 0 : 1);
       
   118 			swExcCombo.setEnabled(swExcCheckbox.getSelection());
       
   119 
       
   120 			hwExcCheckbox.setSelection(configuration.getAttribute(PreferenceConstants.J_PN_StopModeEnableHwExcs, true));
       
   121 			hwExcCombo.select(configuration.getAttribute(PreferenceConstants.J_PN_StopModeEnableHwExcsForDebugThreadsOnly, true) ? 0 : 1);
       
   122 			hwExcCombo.setEnabled(hwExcCheckbox.getSelection());
       
   123 		} catch (CoreException e) {
       
   124 			LaunchPlugin.log(e);
       
   125 		}
       
   126 	}
       
   127 
       
   128 	public void performApply(ILaunchConfigurationWorkingCopy configuration) {
       
   129 		configuration.setAttribute(PreferenceConstants.J_PN_StopModeEnablePanics, panicCheckbox.getSelection());
       
   130 		configuration.setAttribute(PreferenceConstants.J_PN_StopModeEnablePanicsForDebugThreadsOnly, panicCombo.getSelectionIndex() == 0);
       
   131 
       
   132 		configuration.setAttribute(PreferenceConstants.J_PN_StopModeEnableSwExcs, swExcCheckbox.getSelection());
       
   133 		configuration.setAttribute(PreferenceConstants.J_PN_StopModeEnableSwExcsForDebugThreadsOnly, swExcCombo.getSelectionIndex() == 0);
       
   134 
       
   135 		configuration.setAttribute(PreferenceConstants.J_PN_StopModeEnableHwExcs, hwExcCheckbox.getSelection());
       
   136 		configuration.setAttribute(PreferenceConstants.J_PN_StopModeEnableHwExcsForDebugThreadsOnly, hwExcCombo.getSelectionIndex() == 0);
       
   137 	}
       
   138 
       
   139 	public void setDefaults(ILaunchConfigurationWorkingCopy configuration) {
       
   140 	}
       
   141 
       
   142 	public String getName() {
       
   143 		return Messages.getString("SymbianExceptionsTab.name"); //$NON-NLS-1$
       
   144 	}
       
   145 
       
   146 	public Image getImage() {
       
   147 		return LaunchImages.get(LaunchImages.IMG_VIEW_EXCEPTIONS_TAB);
       
   148 	}
       
   149 
       
   150 	@Override
       
   151 	public void activated(ILaunchConfigurationWorkingCopy workingCopy) {
       
   152 		super.activated(workingCopy);
       
   153 		
       
   154 		// forces page to get focus so that help works without having to select some control first.
       
   155 		getControl().setFocus();
       
   156 	}
       
   157 }