debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/ui/ExecutablesTab.java
changeset 1384 10b788ab16fe
parent 746 df006c3379d5
child 1603 40a2929cde0d
equal deleted inserted replaced
1383:619a297ab336 1384:10b788ab16fe
   118 	private Button selectAllButton;
   118 	private Button selectAllButton;
   119 	private Button unselectAllButton;
   119 	private Button unselectAllButton;
   120 	private int targetingRule;
   120 	private int targetingRule;
   121 	private boolean supportsTargetAll;
   121 	private boolean supportsTargetAll;
   122 	private boolean disposed;
   122 	private boolean disposed;
   123 	private boolean wantsMainExecutable;
       
   124 	private List<ExeFileToDebug> executablesToTarget;
   123 	private List<ExeFileToDebug> executablesToTarget;
   125 
   124 
   126 	public ExecutablesTab(boolean supportsTargetAll) {
   125 	public ExecutablesTab(boolean supportsTargetAll) {
   127 		this.supportsTargetAll = supportsTargetAll;
   126 		this.supportsTargetAll = supportsTargetAll;
   128 		executablesToTarget = Collections.emptyList(); // avoid NPE if accessed before filled
   127 		executablesToTarget = Collections.emptyList(); // avoid NPE if accessed before filled
   144 		comp.setLayout(layout);
   143 		comp.setLayout(layout);
   145 
   144 
   146 		ExecutablesTabHeader header = new ExecutablesTabHeader(comp, SWT.NONE);
   145 		ExecutablesTabHeader header = new ExecutablesTabHeader(comp, SWT.NONE);
   147 		header.setLayoutData(new GridData(GridData.FILL_HORIZONTAL, GridData.FILL_VERTICAL, true, false, 3, 1));
   146 		header.setLayoutData(new GridData(GridData.FILL_HORIZONTAL, GridData.FILL_VERTICAL, true, false, 3, 1));
   148 
   147 
   149 		executablesBlock = new ExecutablesBlock(this, wantsMainExecutable);
   148 		executablesBlock = new ExecutablesBlock(this);
   150 		executablesBlock.createControl(comp);
   149 		executablesBlock.createControl(comp);
   151 		Control control = executablesBlock.getControl();
   150 		Control control = executablesBlock.getControl();
   152 		GridData data = new GridData(GridData.FILL_BOTH);
   151 		GridData data = new GridData(GridData.FILL_BOTH);
   153 		control.setLayoutData(data);
   152 		control.setLayoutData(data);
   154 
   153 
   219 	/* (non-Javadoc)
   218 	/* (non-Javadoc)
   220 	 * @see org.eclipse.debug.ui.ILaunchConfigurationTab#initializeFrom(org.eclipse.debug.core.ILaunchConfiguration)
   219 	 * @see org.eclipse.debug.ui.ILaunchConfigurationTab#initializeFrom(org.eclipse.debug.core.ILaunchConfiguration)
   221 	 */
   220 	 */
   222 	public void initializeFrom(ILaunchConfiguration configuration) {
   221 	public void initializeFrom(ILaunchConfiguration configuration) {
   223 		this.configuration = configuration;
   222 		this.configuration = configuration;
   224 		wantsMainExecutable = SettingsData.isStopModeConfiguration(configuration);
       
   225 		try {
   223 		try {
   226 			int targetingRule = configuration.getAttribute(SettingsData.LCS_ExecutableTargetingRule,
   224 			int targetingRule = configuration.getAttribute(SettingsData.LCS_ExecutableTargetingRule,
   227 					SettingsData.LCS_ExeTargetingRule_AllInSDK); //$NON-NLS-1$
   225 					SettingsData.LCS_ExeTargetingRule_AllInSDK); //$NON-NLS-1$
   228 			targetingRulesCombo.select(targetingRule);
   226 			targetingRulesCombo.select(targetingRule);
   229 			changeTargetingRule(targetingRule);
   227 			changeTargetingRule(targetingRule);
   270 		else
   268 		else
   271 			configuration.setAttribute(
   269 			configuration.setAttribute(
   272 					PreferenceConstants.J_PN_SymbolLoadingRule,
   270 					PreferenceConstants.J_PN_SymbolLoadingRule,
   273 					PreferenceConstants.J_PV_SymbolLoadingRule_Auto);
   271 					PreferenceConstants.J_PV_SymbolLoadingRule_Auto);
   274 		
   272 		
   275 		if (!wantsMainExecutable) {
   273 		// get the current program name because it needs to be set to some executable to target
   276 			// get the current program name because it needs to be set to some executable to target
   274 		String programName = null;
   277 			String programName = null;
   275 		try {
   278 			try {
   276 			programName = AbstractCLaunchDelegate.getProgramName(configuration);
   279 				programName = AbstractCLaunchDelegate.getProgramName(configuration);
   277 		} catch (CoreException e) {
   280 			} catch (CoreException e) {
   278 		}
   281 			}
   279 		
   282 			
   280 		// only do this when the current program name is not empty.  if it is, we'll be changing it
   283 			// only do this when the current program name is not empty.  if it is, we'll be changing it
   281 		// which causes the apply button to become enabled which is not expected behavior.  this will
   284 			// which causes the apply button to become enabled which is not expected behavior.  this will
   282 		// be called later if/when they do specify the main program, so we'll make sure then that it's
   285 			// be called later if/when they do specify the main program, so we'll make sure then that it's
   283 		// actually being targeted.
   286 			// actually being targeted.
   284 		if (programName != null && programName.length() > 0) {
   287 			if (programName != null && programName.length() > 0) {
   285 			boolean resetProgramName = true;
   288 				boolean resetProgramName = true;
   286 			// check to see if the current program name is one of the executables to target
   289 				// check to see if the current program name is one of the executables to target
   287 			for (ExeFileToDebug exeFileToDebug : executablesToTarget) {
       
   288 				if (exeFileToDebug.getExePath().equalsIgnoreCase(programName)) {
       
   289 					resetProgramName = false;
       
   290 					break;
       
   291 				}
       
   292 			}
       
   293 			if (resetProgramName) {
       
   294 				// ensure one of the enabled files to target is set as the program name
   290 				for (ExeFileToDebug exeFileToDebug : executablesToTarget) {
   295 				for (ExeFileToDebug exeFileToDebug : executablesToTarget) {
   291 					if (exeFileToDebug.getExePath().equalsIgnoreCase(programName)) {
   296 					if (exeFileToDebug.getEnabled()) {
   292 						resetProgramName = false;
   297 						configuration.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, exeFileToDebug.getExePath());
   293 						break;
   298 						break;
   294 					}
       
   295 				}
       
   296 				if (resetProgramName) {
       
   297 					// ensure one of the enabled files to target is set as the program name
       
   298 					for (ExeFileToDebug exeFileToDebug : executablesToTarget) {
       
   299 						if (exeFileToDebug.getEnabled()) {
       
   300 							configuration.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, exeFileToDebug.getExePath());
       
   301 							break;
       
   302 						}
       
   303 					}
   299 					}
   304 				}
   300 				}
   305 			}
   301 			}
   306 		}
   302 		}
   307 	}
   303 	}