Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--launch/org.eclipse.cdt.launch/ChangeLog13
-rw-r--r--launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/AbstractCDebuggerTab.java4
-rw-r--r--launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/CoreFileCLaunchConfigurationTabGroup.java4
-rw-r--r--launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/LaunchUIPluginResources.properties10
-rw-r--r--launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/CDebuggerTab.java525
-rw-r--r--launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/CoreFileDebuggerTab.java124
-rw-r--r--launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/CorefileDebuggerTab.java206
7 files changed, 458 insertions, 428 deletions
diff --git a/launch/org.eclipse.cdt.launch/ChangeLog b/launch/org.eclipse.cdt.launch/ChangeLog
index 98c4f78b4f..5c4546acf4 100644
--- a/launch/org.eclipse.cdt.launch/ChangeLog
+++ b/launch/org.eclipse.cdt.launch/ChangeLog
@@ -1,3 +1,16 @@
+2004-08-23 Mikhail Khodjaiants
+ Changes in the "Debugger" tab of the launch configuration dialog.
+ Replaced the "Run in debugger/Attach to running process" radio button by
+ the "Attach to running process" check box.
+ Added the "Advanced" button that opens the "Advanced options" dialog.
+ The "Automatically track the values of variables" check box is moved to the dialog.
+ The "CoreFileDebuggerTab" class is implemented as an extension of "CDebuggerTab".
+ * LaunchUIPluginResources.properties
+ * AbstractCDebuggerTab.java
+ * CoreFileCLaunchConfigurationTabGroup.java
+ * CDebuggerTab.java
+ * CorefileDebuggerTab.java renamed to CoreFileDebuggerTab.java
+
2004-08-12 Mikhail Khodjaiants
Warning cleanup.
* CApplicationLaunchShortcut.java
diff --git a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/AbstractCDebuggerTab.java b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/AbstractCDebuggerTab.java
index f4fd0e25ec..655d191fbb 100644
--- a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/AbstractCDebuggerTab.java
+++ b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/AbstractCDebuggerTab.java
@@ -153,10 +153,6 @@ public abstract class AbstractCDebuggerTab extends CLaunchConfigurationTab {
LaunchUIPlugin.errorDialog(LaunchUIPlugin.getResourceString("AbstractCDebuggerTab.ErrorLoadingDebuggerPage"), e.getStatus()); //$NON-NLS-1$
}
setDynamicTab(tab);
- ICDebugConfiguration oldConfig = getDebugConfig();
- if ( oldConfig != null && oldConfig != debugConfig ) {
- setInitializeDefault(true);
- }
}
setDebugConfig(debugConfig);
if (getDynamicTab() == null) {
diff --git a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/CoreFileCLaunchConfigurationTabGroup.java b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/CoreFileCLaunchConfigurationTabGroup.java
index f06df0ea11..90f44e3bfc 100644
--- a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/CoreFileCLaunchConfigurationTabGroup.java
+++ b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/CoreFileCLaunchConfigurationTabGroup.java
@@ -13,7 +13,7 @@ package org.eclipse.cdt.launch.internal.ui;
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
import org.eclipse.cdt.launch.ui.CMainTab;
import org.eclipse.cdt.launch.ui.CSourceLookupTab;
-import org.eclipse.cdt.launch.ui.CorefileDebuggerTab;
+import org.eclipse.cdt.launch.ui.CoreFileDebuggerTab;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.debug.ui.AbstractLaunchConfigurationTabGroup;
import org.eclipse.debug.ui.CommonTab;
@@ -28,7 +28,7 @@ public class CoreFileCLaunchConfigurationTabGroup extends AbstractLaunchConfigur
public void createTabs(ILaunchConfigurationDialog dialog, String mode) {
ILaunchConfigurationTab[] tabs = new ILaunchConfigurationTab[] {
new CMainTab(),
- new CorefileDebuggerTab(),
+ new CoreFileDebuggerTab(),
new CSourceLookupTab(),
new CommonTab()
};
diff --git a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/LaunchUIPluginResources.properties b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/LaunchUIPluginResources.properties
index d2af8cae16..d8505d7cce 100644
--- a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/LaunchUIPluginResources.properties
+++ b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/LaunchUIPluginResources.properties
@@ -90,13 +90,15 @@ CMainTab.Search...=Searc&h...
CMainTab.Choose_program_to_run=Choose a &program to run:
CMainTab.Choose_program_to_run_from_NAME=Choose a program to run from {0}:
-CDebuggerTab.Run_program_in_debugger=Run program in debugger.
-CDebuggerTab.Attach_to_running_process=Attach to running process.
-CDebuggerTab.Stop_at_main_on_startup=Stop at main() on startup.
+CDebuggerTab.Attach_to_running_process=Attach to running process
+CDebuggerTab.Advanced_Options_Dialog_Title=Advanced Options
+CDebuggerTab.Stop_at_main_on_startup=Stop at main() on startup
CDebuggerTab.Automatically_track_values_of_variables=Automatically track the values of variables.
CDebuggerTab.Debugger_Options=Debugger Options
+CDebuggerTab.Mode_not_supported=Mode ''{0}'' is not supported by selected debugger
+CDebuggerTab.Advanced=Advanced...
CDebuggerTab.No_debugger_available=No debugger available
-CDebuggerTab.Select_Debug_mode=Select a Debug mode.
+CDebuggerTab.CPU_is_not_supported=The CPU is not supported by selected debugger.
CEnvironmentTab.Edit_Variable=Edit Variable
CEnvironmentTab.New_Variable=New Variable
diff --git a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/CDebuggerTab.java b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/CDebuggerTab.java
index 4017ec4a55..b4163c2885 100644
--- a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/CDebuggerTab.java
+++ b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/CDebuggerTab.java
@@ -10,19 +10,24 @@
***********************************************************************/
package org.eclipse.cdt.launch.ui;
+import java.text.MessageFormat;
import java.util.Arrays;
import java.util.Comparator;
-
+import java.util.HashMap;
+import java.util.Map;
import org.eclipse.cdt.core.model.IBinary;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.debug.core.CDebugCorePlugin;
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
import org.eclipse.cdt.debug.core.ICDebugConfiguration;
+import org.eclipse.cdt.debug.internal.ui.PixelConverter;
import org.eclipse.cdt.launch.internal.ui.AbstractCDebuggerTab;
import org.eclipse.cdt.launch.internal.ui.LaunchUIPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
@@ -33,295 +38,246 @@ import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.help.WorkbenchHelp;
public class CDebuggerTab extends AbstractCDebuggerTab {
- protected Combo fDCombo;
- protected Button fStopInMain;
- protected Button fAttachButton;
- protected Button fRunButton;
- protected Button fVarBookKeeping;
+ public class AdvancedDebuggerOptionsDialog extends Dialog {
- private final boolean DEFAULT_STOP_AT_MAIN = true;
- private boolean pageUpdated;
+ private Button fVarBookKeeping;
- public void createControl(Composite parent) {
- GridData gd;
+ private Map fAttributes;
- Composite comp = new Composite(parent, SWT.NONE);
- setControl(comp);
+ /**
+ * Constructor for AdvancedDebuggerOptionsDialog.
+ */
+ public AdvancedDebuggerOptionsDialog( Shell parentShell, Map attributes ) {
+ super( parentShell );
+ fAttributes = attributes;
+ }
- WorkbenchHelp.setHelp(getControl(), ICDTLaunchHelpContextIds.LAUNCH_CONFIGURATION_DIALOG_DEBBUGER_TAB);
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
+ */
+ protected Control createDialogArea( Composite parent ) {
+ Composite composite = (Composite)super.createDialogArea( parent );
+ fVarBookKeeping = new Button( composite, SWT.CHECK );
+ fVarBookKeeping.setText( LaunchUIPlugin.getResourceString( "CDebuggerTab.Automatically_track_values_of_variables" ) ); //$NON-NLS-1$
+ initialize();
+ return composite;
+ }
- GridLayout layout = new GridLayout(2, false);
- comp.setLayout(layout);
+ private Map getAttributes() {
+ return fAttributes;
+ }
- Composite comboComp = new Composite(comp, SWT.NONE);
- layout = new GridLayout(2, false);
- comboComp.setLayout(layout);
- Label dlabel = new Label(comboComp, SWT.NONE);
- dlabel.setText(LaunchUIPlugin.getResourceString("Launch.common.DebuggerColon")); //$NON-NLS-1$
- fDCombo = new Combo(comboComp, SWT.DROP_DOWN | SWT.READ_ONLY);
- fDCombo.addModifyListener(new ModifyListener() {
+ protected void okPressed() {
+ saveValues();
+ super.okPressed();
+ }
- public void modifyText(ModifyEvent e) {
- updateComboFromSelection();
- }
- });
-
- Composite radioComp = new Composite(comp, SWT.NONE);
- GridLayout radioLayout = new GridLayout(2, true);
- radioLayout.marginHeight = 0;
- radioLayout.marginWidth = 0;
- radioComp.setLayout(radioLayout);
- fRunButton = createRadioButton(radioComp, LaunchUIPlugin.getResourceString("CDebuggerTab.Run_program_in_debugger")); //$NON-NLS-1$
- fRunButton.addSelectionListener(new SelectionAdapter() {
-
- public void widgetSelected(SelectionEvent e) {
- if (fRunButton.getSelection() == true) {
- fStopInMain.setEnabled(true);
- } else {
- fStopInMain.setEnabled(false);
- }
- updateLaunchConfigurationDialog();
- }
- });
- fAttachButton = createRadioButton(radioComp, LaunchUIPlugin.getResourceString("CDebuggerTab.Attach_to_running_process")); //$NON-NLS-1$
- fAttachButton.addSelectionListener(new SelectionAdapter() {
+ private void initialize() {
+ Map attr = getAttributes();
+ Object varBookkeeping = attr.get( ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ENABLE_VARIABLE_BOOKKEEPING );
+ fVarBookKeeping.setSelection( ( varBookkeeping instanceof Boolean ) ? !((Boolean)varBookkeeping).booleanValue() : true );
+ }
- public void widgetSelected(SelectionEvent e) {
- updateLaunchConfigurationDialog();
- }
- });
+ private void saveValues() {
+ Map attr = getAttributes();
+ Boolean varBookkeeping = ( fVarBookKeeping.getSelection() ) ? Boolean.FALSE : Boolean.TRUE;
+ attr.put( ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ENABLE_VARIABLE_BOOKKEEPING, varBookkeeping );
+ updateLaunchConfigurationDialog();
+ }
- Composite optionComp = new Composite(comp, SWT.NONE);
- layout = new GridLayout(2, false);
- optionComp.setLayout(layout);
- gd = new GridData();
- gd.horizontalSpan = 2;
- optionComp.setLayoutData(gd);
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
+ */
+ protected void configureShell( Shell newShell ) {
+ super.configureShell( newShell );
+ newShell.setText( LaunchUIPlugin.getResourceString( "CDebuggerTab.Advanced_Options_Dialog_Title" ) ); //$NON-NLS-1$
+ }
- fStopInMain = new Button(optionComp, SWT.CHECK);
- fStopInMain.setText(LaunchUIPlugin.getResourceString("CDebuggerTab.Stop_at_main_on_startup")); //$NON-NLS-1$
- fStopInMain.addSelectionListener(new SelectionAdapter() {
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.window.Window#close()
+ */
+ public boolean close() {
+ fAttributes.clear();
+ return super.close();
+ }
+ }
- public void widgetSelected(SelectionEvent e) {
- updateLaunchConfigurationDialog();
- }
- });
+ protected Combo fDCombo;
+ protected Button fAdvancedButton;
+ protected Button fStopInMain;
+ protected Button fAttachButton;
- fVarBookKeeping = new Button(optionComp, SWT.CHECK);
- fVarBookKeeping.setText(LaunchUIPlugin.getResourceString("CDebuggerTab.Automatically_track_values_of_variables")); //$NON-NLS-1$
- fVarBookKeeping.addSelectionListener(new SelectionAdapter() {
+ private Map fAdvancedAttributes = new HashMap( 5 );
- public void widgetSelected(SelectionEvent e) {
- updateLaunchConfigurationDialog();
- }
- });
+ private boolean fPageUpdated;
- Group debuggerGroup = new Group(comp, SWT.SHADOW_ETCHED_IN);
- debuggerGroup.setText(LaunchUIPlugin.getResourceString("CDebuggerTab.Debugger_Options")); //$NON-NLS-1$
- setDynamicTabHolder(debuggerGroup);
- GridLayout tabHolderLayout = new GridLayout();
- tabHolderLayout.marginHeight = 0;
- tabHolderLayout.marginWidth = 0;
- tabHolderLayout.numColumns = 1;
- getDynamicTabHolder().setLayout(tabHolderLayout);
- gd = new GridData(GridData.FILL_BOTH);
- gd.horizontalSpan = 2;
- getDynamicTabHolder().setLayoutData(gd);
+ private boolean fIsInitializing = false;
+
+ public void createControl( Composite parent ) {
+ Composite comp = new Composite( parent, SWT.NONE );
+ setControl( comp );
+ WorkbenchHelp.setHelp( getControl(), ICDTLaunchHelpContextIds.LAUNCH_CONFIGURATION_DIALOG_DEBBUGER_TAB );
+ GridLayout layout = new GridLayout( 2, true );
+ comp.setLayout( layout );
+ GridData gd = new GridData();
+ gd.horizontalAlignment = GridData.FILL_HORIZONTAL;
+ gd.grabExcessHorizontalSpace = true;
+ comp.setLayoutData( gd );
+
+ createDebuggerCombo( comp );
+ createAttachButton( comp );
+ createOptionsComposite( comp );
+ createDebuggerGroup( comp );
}
- protected void loadDebuggerComboBox(ILaunchConfiguration config, String selection) {
+ protected void loadDebuggerComboBox( ILaunchConfiguration config, String selection ) {
ICDebugConfiguration[] debugConfigs;
- String configPlatform = getPlatform(config);
- String programCPU = ICDebugConfiguration.CPU_NATIVE;
- ICElement ce = getContext(config, configPlatform);
- if (ce instanceof IBinary) {
- IBinary bin = (IBinary) ce;
- programCPU = bin.getCPU();
- }
+ String configPlatform = getPlatform( config );
fDCombo.removeAll();
debugConfigs = CDebugCorePlugin.getDefault().getDebugConfigurations();
- Arrays.sort(debugConfigs, new Comparator() {
+ Arrays.sort( debugConfigs, new Comparator() {
- public int compare(Object o1, Object o2) {
- ICDebugConfiguration ic1 = (ICDebugConfiguration) o1;
- ICDebugConfiguration ic2 = (ICDebugConfiguration) o2;
- return ic1.getName().compareTo(ic2.getName());
+ public int compare( Object o1, Object o2 ) {
+ ICDebugConfiguration ic1 = (ICDebugConfiguration)o1;
+ ICDebugConfiguration ic2 = (ICDebugConfiguration)o2;
+ return ic1.getName().compareTo( ic2.getName() );
}
- });
- int x = 0;
+ } );
int selndx = -1;
- for (int i = 0; i < debugConfigs.length; i++) {
- if (debugConfigs[i].supportsMode(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN)
- || debugConfigs[i].supportsMode(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_ATTACH)) {
+ int x = 0;
+ for( int i = 0; i < debugConfigs.length; i++ ) {
+ if ( debugConfigs[i].supportsMode( ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN ) || debugConfigs[i].supportsMode( ICDTLaunchConfigurationConstants.DEBUGGER_MODE_ATTACH ) ) {
String debuggerPlatform = debugConfigs[i].getPlatform();
- if (debuggerPlatform.equalsIgnoreCase(configPlatform)
- || (debuggerPlatform.equalsIgnoreCase("*"))) { //$NON-NLS-1$
- if (debugConfigs[i].supportsCPU(programCPU)) {
- fDCombo.add(debugConfigs[i].getName());
- fDCombo.setData(Integer.toString(x), debugConfigs[i]);
- // select first exact matching debugger for platform or requested selection
- if ((selndx == -1 && debuggerPlatform.equalsIgnoreCase(configPlatform))
- || selection.equals(debugConfigs[i].getID())) {
- selndx = x;
- }
- x++;
+ if ( validatePlatform( config, debugConfigs[i] ) ) {
+ fDCombo.add( debugConfigs[i].getName() );
+ fDCombo.setData( Integer.toString( x ), debugConfigs[i] );
+ // select first exact matching debugger for platform or requested selection
+ if ( (selndx == -1 && debuggerPlatform.equalsIgnoreCase( configPlatform )) || selection.equals( debugConfigs[i].getID() ) ) {
+ selndx = x;
}
+ x++;
}
}
}
// if no selection meaning nothing in config the force initdefault on tab
- setInitializeDefault(selection.equals("") ? true : false); //$NON-NLS-1$
-
- pageUpdated = false;
- fDCombo.select(selndx == -1 ? 0 : selndx);
+ setInitializeDefault( selection.equals( "" ) ? true : false ); //$NON-NLS-1$
+ fPageUpdated = false;
+ fDCombo.select( selndx == -1 ? 0 : selndx );
//The behaviour is undefined for if the callbacks should be triggered for this,
//so force page update if needed.
- if (!pageUpdated) {
+ if ( !fPageUpdated ) {
updateComboFromSelection();
}
- pageUpdated = false;
- getControl().getParent().layout(true);
+ fPageUpdated = false;
+ getControl().getParent().layout( true );
}
protected void updateComboFromSelection() {
- pageUpdated = true;
+ fPageUpdated = true;
handleDebuggerChanged();
- ICDebugConfiguration debugConfig = getConfigForCurrentDebugger();
- if (debugConfig != null) {
- fRunButton.setEnabled(debugConfig.supportsMode(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN));
- fRunButton.setSelection(false);
- fAttachButton.setEnabled(debugConfig.supportsMode(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_ATTACH));
- fAttachButton.setSelection(false);
- try {
- String mode = getLaunchConfiguration().getAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE,
- ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN);
- if (mode.equals(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN) && fRunButton.isEnabled()) {
- fRunButton.setSelection(true);
- } else if (mode.equals(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_ATTACH) && fAttachButton.isEnabled()) {
- fAttachButton.setSelection(true);
- }
- if (fRunButton.getSelection() == true) {
- fStopInMain.setEnabled(true);
- } else {
- fStopInMain.setEnabled(false);
- }
- } catch (CoreException ex) {
- }
- }
+ initializeCommonControls( getLaunchConfigurationWorkingCopy() );
updateLaunchConfigurationDialog();
}
- public void setDefaults(ILaunchConfigurationWorkingCopy config) {
- super.setDefaults(config);
- config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN, DEFAULT_STOP_AT_MAIN);
- config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ENABLE_VARIABLE_BOOKKEEPING, false);
- config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE,
- ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN);
+ public void setDefaults( ILaunchConfigurationWorkingCopy config ) {
+ super.setDefaults( config );
+ config.setAttribute( ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN, ICDTLaunchConfigurationConstants.DEBUGGER_STOP_AT_MAIN_DEFAULT );
+ config.setAttribute( ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ENABLE_VARIABLE_BOOKKEEPING, false );
+ config.setAttribute( ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE, ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN );
}
- public void activated(ILaunchConfigurationWorkingCopy workingCopy) {
- super.activated(workingCopy);
+ public void initializeFrom( ILaunchConfiguration config ) {
+ setInitializing( true );
+ super.initializeFrom( config );
try {
- String id = workingCopy.getAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ID, ""); //$NON-NLS-1$
- loadDebuggerComboBox(workingCopy, id);
- } catch (CoreException e) {
+ String id = config.getAttribute( ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ID, "" ); //$NON-NLS-1$
+ loadDebuggerComboBox( config, id );
+ initializeCommonControls( config );
}
- }
-
- public void initializeFrom(ILaunchConfiguration config) {
- super.initializeFrom(config);
- try {
- String id = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ID, ""); //$NON-NLS-1$
- loadDebuggerComboBox(config, id);
- String mode = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE,
- ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN);
- if (mode.equals(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN)) {
- fRunButton.setSelection(true);
- fAttachButton.setSelection(false);
- } else if (mode.equals(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_ATTACH)) {
- fAttachButton.setSelection(true);
- fRunButton.setSelection(false);
- }
- if (config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN, DEFAULT_STOP_AT_MAIN) == true) {
- fStopInMain.setSelection(true);
- }
- if (config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ENABLE_VARIABLE_BOOKKEEPING, false) == false) {
- fVarBookKeeping.setSelection(true);
- }
- } catch (CoreException e) {
- return;
+ catch( CoreException e ) {
}
+ setInitializing( false );
}
- public void performApply(ILaunchConfigurationWorkingCopy config) {
- if (isValid(config)) {
- super.performApply(config);
- config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN, false);
- config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ENABLE_VARIABLE_BOOKKEEPING,
- !fVarBookKeeping.getSelection());
- if (fAttachButton.getSelection() == true) {
- config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE,
- ICDTLaunchConfigurationConstants.DEBUGGER_MODE_ATTACH);
- } else {
- config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN, fStopInMain.getSelection());
- config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE,
- ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN);
- }
+ public void performApply( ILaunchConfigurationWorkingCopy config ) {
+ super.performApply( config );
+ if ( fAttachButton.getSelection() ) {
+ config.setAttribute( ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE, ICDTLaunchConfigurationConstants.DEBUGGER_MODE_ATTACH );
+ }
+ else {
+ config.setAttribute( ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN, fStopInMain.getSelection() );
+ config.setAttribute( ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE, ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN );
}
+ applyAdvancedAttributes( config );
}
- public boolean isValid(ILaunchConfiguration config) {
- if (!validateDebuggerConfig(config)) {
- setErrorMessage(LaunchUIPlugin.getResourceString("CDebuggerTab.No_debugger_available")); //$NON-NLS-1$
+ public boolean isValid( ILaunchConfiguration config ) {
+ if ( !validateDebuggerConfig( config ) ) {
return false;
}
- if (super.isValid(config) == false) {
+ ICDebugConfiguration debugConfig = getDebugConfig();
+ if ( debugConfig == null ) {
+ setErrorMessage( LaunchUIPlugin.getResourceString( "CDebuggerTab.No_debugger_available" ) ); //$NON-NLS-1$
return false;
}
- if (!fRunButton.getSelection() && !fAttachButton.getSelection()) {
- setErrorMessage(LaunchUIPlugin.getResourceString("CDebuggerTab.Select_Debug_mode")); //$NON-NLS-1$
+ if ( fAttachButton != null ) {
+ String mode = ( fAttachButton.getSelection() ) ? ICDTLaunchConfigurationConstants.DEBUGGER_MODE_ATTACH : ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN;
+ if ( !debugConfig.supportsMode( mode ) ) {
+ setErrorMessage( MessageFormat.format( LaunchUIPlugin.getResourceString( "CDebuggerTab.Mode_not_supported" ), new String[] { mode } ) ); //$NON-NLS-1$
+ return false;
+ }
+ }
+ if ( super.isValid( config ) == false ) {
return false;
}
return true;
}
- private boolean validateDebuggerConfig(ILaunchConfiguration config) {
- ICElement ce = getContext(config, null);
- String projectPlatform = getPlatform(config);
+ protected boolean validatePlatform( ILaunchConfiguration config, ICDebugConfiguration debugConfig ) {
+ String configPlatform = getPlatform( config );
+ String debuggerPlatform = debugConfig.getPlatform();
+ return ( debuggerPlatform.equals( "*" ) || debuggerPlatform.equalsIgnoreCase( configPlatform ) ); //$NON-NLS-1$
+ }
+
+ protected boolean validateCPU( ILaunchConfiguration config, ICDebugConfiguration debugConfig ) {
+ ICElement ce = getContext( config, null );
String projectCPU = ICDebugConfiguration.CPU_NATIVE;
- if (ce != null) {
- if (ce instanceof IBinary) {
- IBinary bin = (IBinary) ce;
+ if ( ce != null ) {
+ if ( ce instanceof IBinary ) {
+ IBinary bin = (IBinary)ce;
projectCPU = bin.getCPU();
}
}
+ return debugConfig.supportsCPU( projectCPU );
+ }
+
+ protected boolean validateDebuggerConfig( ILaunchConfiguration config ) {
ICDebugConfiguration debugConfig = getDebugConfig();
- if (debugConfig == null) {
+ if ( debugConfig == null ) {
+ setErrorMessage( LaunchUIPlugin.getResourceString( "CDebuggerTab.No_debugger_available" ) ); //$NON-NLS-1$
return false;
}
- String debuggerPlatform = debugConfig.getPlatform();
- if (debuggerPlatform.equalsIgnoreCase(projectPlatform)
- || (debuggerPlatform.equalsIgnoreCase("*"))) { //$NON-NLS-1$
- if (debugConfig.supportsCPU(projectCPU)) {
- return true;
- }
+ if ( !validatePlatform( config, debugConfig ) || !validateCPU( config, debugConfig ) ) {
+ setErrorMessage( LaunchUIPlugin.getResourceString( "CDebuggerTab.CPU_is_not_supported" ) ); //$NON-NLS-1$
+ return false;
}
- return false;
+ return true;
}
/**
- * Return the class that implements <code>ILaunchConfigurationTab</code> that is registered against the debugger id of the
- * currently selected debugger.
+ * Return the class that implements <code>ILaunchConfigurationTab</code> that is registered against the debugger id of the currently selected debugger.
*/
protected ICDebugConfiguration getConfigForCurrentDebugger() {
int selectedIndex = fDCombo.getSelectionIndex();
- return (ICDebugConfiguration) fDCombo.getData(Integer.toString(selectedIndex));
+ return (ICDebugConfiguration)fDCombo.getData( Integer.toString( selectedIndex ) );
}
/**
@@ -331,4 +287,149 @@ public class CDebuggerTab extends AbstractCDebuggerTab {
super.updateLaunchConfigurationDialog();
}
+ protected void createDebuggerCombo( Composite parent ) {
+ Composite comboComp = new Composite( parent, SWT.NONE );
+ GridLayout layout = new GridLayout( 2, false );
+ comboComp.setLayout( layout );
+ Label dlabel = new Label( comboComp, SWT.NONE );
+ dlabel.setText( LaunchUIPlugin.getResourceString( "Launch.common.DebuggerColon" ) ); //$NON-NLS-1$
+ fDCombo = new Combo( comboComp, SWT.DROP_DOWN | SWT.READ_ONLY );
+ fDCombo.addModifyListener( new ModifyListener() {
+
+ public void modifyText( ModifyEvent e ) {
+ if ( !isInitializing() ) {
+ setInitializeDefault( true );
+ updateComboFromSelection();
+ }
+ }
+ } );
+ }
+
+ protected void createAttachButton( Composite parent ) {
+ Composite attachComp = new Composite( parent, SWT.NONE );
+ GridLayout attachLayout = new GridLayout();
+ attachLayout.marginHeight = 0;
+ attachLayout.marginWidth = 0;
+ attachComp.setLayout( attachLayout );
+ fAttachButton = createCheckButton( attachComp, LaunchUIPlugin.getResourceString( "CDebuggerTab.Attach_to_running_process" ) ); //$NON-NLS-1$
+ fAttachButton.addSelectionListener( new SelectionAdapter() {
+
+ public void widgetSelected( SelectionEvent e ) {
+ if ( !isInitializing() ) {
+ fStopInMain.setSelection( !fAttachButton.getSelection() );
+ fStopInMain.setEnabled( !fAttachButton.getSelection() );
+ updateLaunchConfigurationDialog();
+ }
+ }
+ } );
+ }
+
+ protected void createOptionsComposite( Composite parent ) {
+ Composite optionsComp = new Composite( parent, SWT.NONE );
+ GridLayout layout = new GridLayout( 2, true );
+ optionsComp.setLayout( layout );
+ optionsComp.setLayoutData( new GridData( GridData.FILL, GridData.CENTER, true, false, 2, 1 ) );
+
+ fStopInMain = createCheckButton( optionsComp, LaunchUIPlugin.getResourceString( "CDebuggerTab.Stop_at_main_on_startup" ) ); //$NON-NLS-1$
+ fStopInMain.addSelectionListener( new SelectionAdapter() {
+
+ public void widgetSelected( SelectionEvent e ) {
+ if ( !isInitializing() ) {
+ updateLaunchConfigurationDialog();
+ }
+ }
+ } );
+
+ fAdvancedButton = createPushButton( optionsComp, LaunchUIPlugin.getResourceString( "CDebuggerTab.Advanced" ), null ); //$NON-NLS-1$
+ GridData data = new GridData();
+ data.horizontalAlignment = GridData.END;
+ PixelConverter pc = new PixelConverter( parent );
+ data.widthHint = pc.convertHorizontalDLUsToPixels( IDialogConstants.BUTTON_WIDTH );
+ fAdvancedButton.setLayoutData( data );
+ fAdvancedButton.addSelectionListener( new SelectionAdapter() {
+
+ public void widgetSelected( SelectionEvent e ) {
+ Dialog dialog = new AdvancedDebuggerOptionsDialog( getShell(), getAdvancedAttributes() );
+ dialog.open();
+ }
+ } );
+ }
+
+ protected void createDebuggerGroup( Composite parent ) {
+ Group debuggerGroup = new Group( parent, SWT.SHADOW_ETCHED_IN );
+ debuggerGroup.setText( LaunchUIPlugin.getResourceString( "CDebuggerTab.Debugger_Options" ) ); //$NON-NLS-1$
+ setDynamicTabHolder( debuggerGroup );
+ GridLayout tabHolderLayout = new GridLayout();
+ tabHolderLayout.marginHeight = 0;
+ tabHolderLayout.marginWidth = 0;
+ tabHolderLayout.numColumns = 1;
+ getDynamicTabHolder().setLayout( tabHolderLayout );
+ GridData gd = new GridData( GridData.FILL_BOTH );
+ gd.horizontalSpan = 2;
+ getDynamicTabHolder().setLayoutData( gd );
+ }
+
+ protected Map getAdvancedAttributes() {
+ return fAdvancedAttributes;
+ }
+
+ private void initializeAdvancedAttributes( ILaunchConfiguration config ) {
+ Map attr = getAdvancedAttributes();
+ try {
+ Boolean varBookkeeping = ( config.getAttribute( ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ENABLE_VARIABLE_BOOKKEEPING, false ) ) ? Boolean.TRUE : Boolean.FALSE;
+ attr.put( ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ENABLE_VARIABLE_BOOKKEEPING, varBookkeeping );
+ }
+ catch( CoreException e ) {
+ }
+ }
+
+ private void applyAdvancedAttributes( ILaunchConfigurationWorkingCopy config ) {
+ Map attr = getAdvancedAttributes();
+ Object varBookkeeping = attr.get( ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ENABLE_VARIABLE_BOOKKEEPING );
+ if ( varBookkeeping instanceof Boolean )
+ config.setAttribute( ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ENABLE_VARIABLE_BOOKKEEPING, ((Boolean)varBookkeeping).booleanValue() );
+ }
+
+ protected Shell getShell() {
+ return super.getShell();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.ILaunchConfigurationTab#dispose()
+ */
+ public void dispose() {
+ getAdvancedAttributes().clear();
+ super.dispose();
+ }
+
+ protected void initializeCommonControls( ILaunchConfiguration config ) {
+ ICDebugConfiguration debugConfig = getConfigForCurrentDebugger();
+ try {
+ String mode = config.getAttribute( ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE, ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN );
+ fAttachButton.setEnabled( debugConfig != null && debugConfig.supportsMode( ICDTLaunchConfigurationConstants.DEBUGGER_MODE_ATTACH ) );
+ if ( fAttachButton.isEnabled() )
+ fAttachButton.setSelection( mode.equals( ICDTLaunchConfigurationConstants.DEBUGGER_MODE_ATTACH ) );
+ fStopInMain.setEnabled( debugConfig != null && !fAttachButton.getSelection() );
+ if ( fStopInMain.isEnabled() )
+ fStopInMain.setSelection( ( fAttachButton.getSelection() ) ? false : config.getAttribute( ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN, ICDTLaunchConfigurationConstants.DEBUGGER_STOP_AT_MAIN_DEFAULT ) );
+ initializeAdvancedAttributes( config );
+ }
+ catch( CoreException e ) {
+ }
+ }
+
+ protected boolean isInitializing() {
+ return fIsInitializing;
+ }
+
+ private void setInitializing( boolean isInitializing ) {
+ fIsInitializing = isInitializing;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.launch.internal.ui.AbstractCDebuggerTab#setInitializeDefault(boolean)
+ */
+ protected void setInitializeDefault( boolean init ) {
+ super.setInitializeDefault( init );
+ }
} \ No newline at end of file
diff --git a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/CoreFileDebuggerTab.java b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/CoreFileDebuggerTab.java
new file mode 100644
index 0000000000..0a0028e115
--- /dev/null
+++ b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/CoreFileDebuggerTab.java
@@ -0,0 +1,124 @@
+/**********************************************************************
+ * Copyright (c) 2004 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * QNX Software Systems - Initial API and implementation
+ ***********************************************************************/
+package org.eclipse.cdt.launch.ui;
+
+import java.util.Map;
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.ICDescriptor;
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.debug.core.CDebugCorePlugin;
+import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
+import org.eclipse.cdt.debug.core.ICDebugConfiguration;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.debug.ui.ILaunchConfigurationTab;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.help.WorkbenchHelp;
+
+public class CoreFileDebuggerTab extends CDebuggerTab {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.ILaunchConfigurationTab#createControl(org.eclipse.swt.widgets.Composite)
+ */
+ public void createControl( Composite parent ) {
+ Composite comp = new Composite( parent, SWT.NONE );
+ setControl( comp );
+ WorkbenchHelp.setHelp( getControl(), ICDTLaunchHelpContextIds.LAUNCH_CONFIGURATION_DIALOG_DEBBUGER_TAB );
+ GridLayout topLayout = new GridLayout( 2, false );
+ comp.setLayout( topLayout );
+ createDebuggerCombo( comp );
+ createDebuggerGroup( comp );
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.ILaunchConfigurationTab#setDefaults(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)
+ */
+ public void setDefaults( ILaunchConfigurationWorkingCopy config ) {
+ super.setDefaults( config );
+ config.setAttribute( ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE, ICDTLaunchConfigurationConstants.DEBUGGER_MODE_CORE );
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.launch.ui.CDebuggerTab#initializeCommonControls(org.eclipse.debug.core.ILaunchConfiguration)
+ */
+ protected void initializeCommonControls( ILaunchConfiguration config ) {
+ // no common controls for this tab
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.ILaunchConfigurationTab#performApply(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)
+ */
+ public void performApply( ILaunchConfigurationWorkingCopy config ) {
+ if ( getDebugConfig() != null ) {
+ config.setAttribute( ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ID, getDebugConfig().getID() );
+ ILaunchConfigurationTab dynamicTab = getDynamicTab();
+ if ( dynamicTab == null ) {
+ config.setAttribute( ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_SPECIFIC_ATTRS_MAP, (Map)null );
+ }
+ else {
+ dynamicTab.performApply( config );
+ }
+ }
+ }
+
+ protected void loadDebuggerComboBox( ILaunchConfiguration config, String selection ) {
+ fDCombo.removeAll();
+ ICDebugConfiguration[] debugConfigs = CDebugCorePlugin.getDefault().getDebugConfigurations();
+ String projectPlatform = getProjectPlatform( config );
+ int x = 0;
+ int selndx = -1;
+ for( int i = 0; i < debugConfigs.length; i++ ) {
+ if ( debugConfigs[i].supportsMode( ICDTLaunchConfigurationConstants.DEBUGGER_MODE_CORE ) ) {
+ if ( validatePlatform( config, debugConfigs[i] ) ) {
+ fDCombo.add( debugConfigs[i].getName() );
+ fDCombo.setData( Integer.toString( x ), debugConfigs[i] );
+ // select first exact matching debugger for platform or requested selection
+ String debuggerPlatform = debugConfigs[i].getPlatform();
+ if ( (selndx == -1 && debuggerPlatform.equalsIgnoreCase( projectPlatform )) || selection.equals( debugConfigs[i].getID() ) ) {
+ selndx = x;
+ }
+ x++;
+ }
+ }
+ }
+ // if no selection meaning nothing in config the force initdefault on tab
+ setInitializeDefault( selection.equals( "" ) ? true : false ); //$NON-NLS-1$
+ fDCombo.select( selndx == -1 ? 0 : selndx );
+ //The behaviour is undefined for if the callbacks should be triggered for this,
+ //so to avoid unnecessary confusion, we force an update.
+ handleDebuggerChanged();
+ getControl().getParent().layout( true );
+ }
+
+ protected boolean validatePlatform( ILaunchConfiguration config, ICDebugConfiguration debugConfig ) {
+ String projectPlatform = getProjectPlatform( config );
+ String debuggerPlatform = debugConfig.getPlatform();
+ return ( debuggerPlatform.equals( "*" ) || debuggerPlatform.equalsIgnoreCase( projectPlatform ) ); //$NON-NLS-1$
+ }
+
+ private String getProjectPlatform( ILaunchConfiguration config ) {
+ ICElement ce = getContext( config, null );
+ String projectPlatform = "*"; //$NON-NLS-1$
+ if ( ce != null ) {
+ try {
+ ICDescriptor descriptor = CCorePlugin.getDefault().getCProjectDescription( ce.getCProject().getProject(), false );
+ if ( descriptor != null ) {
+ projectPlatform = descriptor.getPlatform();
+ }
+ }
+ catch( Exception e ) {
+ }
+ }
+ return projectPlatform;
+ }
+}
diff --git a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/CorefileDebuggerTab.java b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/CorefileDebuggerTab.java
deleted file mode 100644
index 3521bae261..0000000000
--- a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/CorefileDebuggerTab.java
+++ /dev/null
@@ -1,206 +0,0 @@
-/**********************************************************************
- * Copyright (c) 2002 - 2004 QNX Software Systems and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * QNX Software Systems - Initial API and implementation
-***********************************************************************/
-package org.eclipse.cdt.launch.ui;
-
-import org.eclipse.cdt.core.CCorePlugin;
-import org.eclipse.cdt.core.ICDescriptor;
-import org.eclipse.cdt.core.model.IBinary;
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.debug.core.CDebugCorePlugin;
-import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
-import org.eclipse.cdt.debug.core.ICDebugConfiguration;
-import org.eclipse.cdt.launch.internal.ui.AbstractCDebuggerTab;
-import org.eclipse.cdt.launch.internal.ui.LaunchUIPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.debug.core.ILaunchConfiguration;
-import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Group;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.ui.help.WorkbenchHelp;
-
-public class CorefileDebuggerTab extends AbstractCDebuggerTab {
- protected Combo fDCombo;
-
- private boolean initializingComboBox = false;
-
- public void createControl(Composite parent) {
- Composite comp = new Composite(parent, SWT.NONE);
- setControl(comp);
-
- WorkbenchHelp.setHelp(getControl(), ICDTLaunchHelpContextIds.LAUNCH_CONFIGURATION_DIALOG_DEBBUGER_TAB);
-
- GridLayout topLayout = new GridLayout(2, false);
- comp.setLayout(topLayout);
- Label dlabel = new Label(comp, SWT.NONE);
- dlabel.setText(LaunchUIPlugin.getResourceString("Launch.common.DebuggerColon")); //$NON-NLS-1$
- fDCombo = new Combo(comp, SWT.DROP_DOWN | SWT.READ_ONLY);
- fDCombo.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- handleDebuggerChanged();
- }
- });
- Group debuggerGroup = new Group(comp, SWT.SHADOW_ETCHED_IN);
- debuggerGroup.setText(LaunchUIPlugin.getResourceString("CorefileDebuggerTab.Debugger_Options")); //$NON-NLS-1$
- setDynamicTabHolder(debuggerGroup);
- GridLayout tabHolderLayout = new GridLayout();
- tabHolderLayout.marginHeight = 0;
- tabHolderLayout.marginWidth = 0;
- tabHolderLayout.numColumns = 1;
- getDynamicTabHolder().setLayout(tabHolderLayout);
- GridData gd = new GridData(GridData.FILL_BOTH);
- gd.horizontalSpan = 2;
- getDynamicTabHolder().setLayoutData(gd);
- }
-
- protected void loadDebuggerComboBox(ILaunchConfiguration config, String selection) {
- if (initializingComboBox) {
- return;
- }
- initializingComboBox = true;
- ICDebugConfiguration[] debugConfigs;
- String configPlatform = getPlatform(config);
- ICElement ce = getContext(config, null);
- String projectPlatform = "*"; //$NON-NLS-1$
- String projectCPU = "*"; //$NON-NLS-1$
- if (ce != null) {
- try {
- ICDescriptor descriptor = CCorePlugin.getDefault().getCProjectDescription(ce.getCProject().getProject(), false);
- if (descriptor != null) {
- projectPlatform = descriptor.getPlatform();
- }
- IBinary bin = (IBinary) ce;
- projectCPU = bin.getCPU();
- } catch (Exception e) {
- }
- }
- fDCombo.removeAll();
- debugConfigs = CDebugCorePlugin.getDefault().getDebugConfigurations();
- int x = 0;
- int selndx = -1;
- for (int i = 0; i < debugConfigs.length; i++) {
- if (debugConfigs[i].supportsMode(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_CORE)) {
- String debuggerPlatform = debugConfigs[i].getPlatform();
- boolean platformMatch = configPlatform.equals(projectPlatform);
- if (debuggerPlatform.equalsIgnoreCase(projectPlatform) || (platformMatch && projectPlatform.equals("*"))) { //$NON-NLS-1$
- if (debugConfigs[i].supportsCPU(projectCPU)) {
- fDCombo.add(debugConfigs[i].getName());
- fDCombo.setData(Integer.toString(x), debugConfigs[i]);
- // select first exact matching debugger for platform or requested selection
- if ((selndx == -1 && debuggerPlatform.equalsIgnoreCase(projectPlatform))
- || selection.equals(debugConfigs[i].getID())) {
- selndx = x;
- }
- x++;
- }
- }
- }
- }
- // if no selection meaning nothing in config the force initdefault on tab
- setInitializeDefault(selection.equals("") ? true : false); //$NON-NLS-1$
-
- fDCombo.select(selndx == -1 ? 0 : selndx);
- //The behaviour is undefined for if the callbacks should be triggered for this,
- //so to avoid unnecessary confusion, we force an update.
- handleDebuggerChanged();
- getControl().getParent().layout(true);
- initializingComboBox = false;
- }
-
- public void activated(ILaunchConfigurationWorkingCopy workingCopy) {
- super.activated(workingCopy);
- try {
- String id = workingCopy.getAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ID, ""); //$NON-NLS-1$
- if (getDebugConfig() == null || !getDebugConfig().getID().equals(id) || !validateDebuggerConfig(workingCopy)) {
- loadDebuggerComboBox(workingCopy, id);
- }
- } catch (CoreException e) {
- }
- }
-
- public void initializeFrom(ILaunchConfiguration config) {
- super.initializeFrom(config);
- try {
- String id = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ID, ""); //$NON-NLS-1$
- loadDebuggerComboBox(config, id);
- } catch (CoreException e) {
- return;
- }
- }
-
- public void setDefaults(ILaunchConfigurationWorkingCopy config) {
- super.setDefaults(config);
- config.setAttribute(
- ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE,
- ICDTLaunchConfigurationConstants.DEBUGGER_MODE_CORE);
- }
-
- public boolean isValid(ILaunchConfiguration config) {
- if (!validateDebuggerConfig(config)) {
- setErrorMessage(LaunchUIPlugin.getResourceString("CorefileDebuggerTab.No_debugger_available")); //$NON-NLS-1$
- return false;
- }
- return super.isValid(config);
- }
-
- private boolean validateDebuggerConfig(ILaunchConfiguration config) {
- String platform = getPlatform(config);
- ICElement ce = getContext(config, null);
- String projectPlatform = "*"; //$NON-NLS-1$
- String projectCPU = "*"; //$NON-NLS-1$
- if (ce != null) {
- try {
- ICDescriptor descriptor = CCorePlugin.getDefault().getCProjectDescription(ce.getCProject().getProject(), false);
- if (descriptor != null) {
- projectPlatform = descriptor.getPlatform();
- }
- IBinary bin = (IBinary) ce;
- projectCPU = bin.getCPU();
- } catch (Exception e) {
- }
- }
- ICDebugConfiguration debugConfig = getDebugConfig();
- if (debugConfig == null) {
- return false;
- }
- String debuggerPlatform = debugConfig.getPlatform();
- boolean platformMatch = platform.equals(projectPlatform);
- if (debuggerPlatform.equalsIgnoreCase(projectPlatform) || (platformMatch && projectPlatform.equals("*"))) { //$NON-NLS-1$
- if (debugConfig.supportsCPU(projectCPU)) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * Return the class that implements <code>ILaunchConfigurationTab</code>
- * that is registered against the debugger id of the currently selected debugger.
- */
- protected ICDebugConfiguration getConfigForCurrentDebugger() {
- int selectedIndex = fDCombo.getSelectionIndex();
- return (ICDebugConfiguration) fDCombo.getData(Integer.toString(selectedIndex));
- }
-
- /**
- * @see org.eclipse.cdt.launch.internal.ui.AbstractCDebuggerTab#handleDebuggerChanged()
- */
- protected void handleDebuggerChanged() {
- super.handleDebuggerChanged();
- }
-
-}

Back to the top