1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-07 17:56:01 +02:00

abstract main tab: replace auto-config checkbox with combo item

as discussed on cdt-dev I am trying to make ui look better
and more generic by replacing 
"Select configuration using 'C/C++ Application'"
checkbox with Automatic selector.
Launch delegate or subclass on main page can control and override
behaivior of this ui control

This won't break API but it will break UI if subclasses were actually
doing something with original chechbox control 
(besides not creating it).

Change-Id: I36f20bf05ff19e1fd66782e2351f18edc7d507cc
Signed-off-by: Alena Laskavaia <elaskavaia.cdt@gmail.com>
Reviewed-on: https://git.eclipse.org/r/39619
Tested-by: Hudson CI
This commit is contained in:
Alena Laskavaia 2015-01-14 13:49:22 -05:00 committed by Elena Laskavaia
parent eb5d03de5c
commit 971176c83f
5 changed files with 154 additions and 128 deletions

View file

@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2 Bundle-ManifestVersion: 2
Bundle-Name: %pluginName Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.cdt.launch; singleton:=true Bundle-SymbolicName: org.eclipse.cdt.launch; singleton:=true
Bundle-Version: 7.1.0.qualifier Bundle-Version: 7.2.0.qualifier
Bundle-Activator: org.eclipse.cdt.launch.internal.ui.LaunchUIPlugin Bundle-Activator: org.eclipse.cdt.launch.internal.ui.LaunchUIPlugin
Bundle-Vendor: %providerName Bundle-Vendor: %providerName
Bundle-Localization: plugin Bundle-Localization: plugin

View file

@ -11,7 +11,7 @@
<relativePath>../../pom.xml</relativePath> <relativePath>../../pom.xml</relativePath>
</parent> </parent>
<version>7.1.0-SNAPSHOT</version> <version>7.2.0-SNAPSHOT</version>
<artifactId>org.eclipse.cdt.launch</artifactId> <artifactId>org.eclipse.cdt.launch</artifactId>
<packaging>eclipse-plugin</packaging> <packaging>eclipse-plugin</packaging>
</project> </project>

View file

@ -83,7 +83,10 @@ public class LaunchMessages extends NLS {
public static String CMainTab_Program_invalid_proj_path; public static String CMainTab_Program_invalid_proj_path;
public static String CMainTab_Build_Config; public static String CMainTab_Build_Config;
public static String CMainTab_Use_Active; public static String CMainTab_Use_Active;
public static String CMainTab_Use_Automatic;
public static String CMainTab_Build_Config_Active_tooltip;
public static String CMainTab_Build_Config_Auto; public static String CMainTab_Build_Config_Auto;
public static String CMainTab_Build_Config_Auto_tooltip;
public static String CMainTab_Configuration_name; public static String CMainTab_Configuration_name;
public static String CMainTab_Build_options; public static String CMainTab_Build_options;
public static String CMainTab_Disable_build_button_label; public static String CMainTab_Disable_build_button_label;

View file

@ -89,7 +89,10 @@ CMainTab_UseTerminal=Connect process input && output to a terminal.
CMainTab_Program_invalid_proj_path=Program specification is not a valid project-relative path. CMainTab_Program_invalid_proj_path=Program specification is not a valid project-relative path.
CMainTab_Build_Config=Build configuration: CMainTab_Build_Config=Build configuration:
CMainTab_Use_Active=Use Active CMainTab_Use_Active=Use Active
CMainTab_Use_Automatic=Select Automatically
CMainTab_Build_Config_Active_tooltip=Use active build configuration
CMainTab_Build_Config_Auto=Select configuration using 'C/C++ Application' CMainTab_Build_Config_Auto=Select configuration using 'C/C++ Application'
CMainTab_Build_Config_Auto_tooltip=Select build configuration based on the location of the application
#For CMainTab_Configuration_name: {0} - project name; {1} - configuration name #For CMainTab_Configuration_name: {0} - project name; {1} - configuration name
CMainTab_Configuration_name={0} {1} CMainTab_Configuration_name={0} {1}
CMainTab_Build_options=Build (if required) before launching CMainTab_Build_options=Build (if required) before launching

View file

@ -67,17 +67,25 @@ public abstract class CAbstractMainTab extends CLaunchConfigurationTab {
private static final String LAUNCHING_PREFERENCE_PAGE_ID = "org.eclipse.debug.ui.LaunchingPreferencePage"; //$NON-NLS-1$ private static final String LAUNCHING_PREFERENCE_PAGE_ID = "org.eclipse.debug.ui.LaunchingPreferencePage"; //$NON-NLS-1$
protected static final String EMPTY_STRING = ""; //$NON-NLS-1$ protected static final String EMPTY_STRING = ""; //$NON-NLS-1$
protected String filterPlatform = EMPTY_STRING; protected String filterPlatform = EMPTY_STRING;
/**
* @since 7.2
*/
protected static final String AUTO_CONFIG = "AUTO"; //$NON-NLS-1$
/** /**
* @since 6.0 * @since 6.0
*/ */
protected Combo fBuildConfigCombo; protected Combo fBuildConfigCombo;
/** @since 7.0*/ /**
* @since 7.0
* @deprecated This control won't be used anymore, combo will have addition item: Select Automatically
* */
protected Button fBuildConfigAuto; protected Button fBuildConfigAuto;
/** /**
* Indicates whether the user has clicked on the build config auto button * Indicates whether the user has clicked on the build config auto button Prevents causing a delta to the underlying launch
* Prevents causing a delta to the underlying launch configuration if the user hasn't touched this setting. * configuration if the user hasn't touched this setting.
*
* @since 7.0 * @since 7.0
* @deprecated
*/ */
protected boolean fBuildConfigAutoChanged; protected boolean fBuildConfigAutoChanged;
/** @since 6.1 */ /** @since 6.1 */
@ -92,11 +100,9 @@ public abstract class CAbstractMainTab extends CLaunchConfigurationTab {
protected Label fProjLabel; protected Label fProjLabel;
protected Text fProjText; protected Text fProjText;
protected Button fProjButton; protected Button fProjButton;
protected Label fProgLabel; protected Label fProgLabel;
protected Text fProgText; protected Text fProgText;
protected Button fSearchButton; protected Button fSearchButton;
// Core file UI widgets // Core file UI widgets
/** @since 2.0 */ /** @since 2.0 */
protected Label fCoreLabel; protected Label fCoreLabel;
@ -104,20 +110,18 @@ public abstract class CAbstractMainTab extends CLaunchConfigurationTab {
protected Text fCoreText; protected Text fCoreText;
/** @since 2.0 */ /** @since 2.0 */
protected Button fCoreButton; protected Button fCoreButton;
/** /**
* Name of most recently checked program; avoid constantly checking binary. * Name of most recently checked program; avoid constantly checking binary. See bug 277663.
* See bug 277663.
*/ */
protected String fPreviouslyCheckedProgram; protected String fPreviouslyCheckedProgram;
/** /**
* Validity result of most recently checked program; avoid constantly * Validity result of most recently checked program; avoid constantly checking binary. See bug 277663. N/A if
* checking binary. See bug 277663. N/A if fPreviouslyCheckedProgram = null; * fPreviouslyCheckedProgram = null;
*/ */
protected boolean fPreviouslyCheckedProgramIsValid; protected boolean fPreviouslyCheckedProgramIsValid;
/** /**
* Validity error message of most recently checked program; avoid constantly * Validity error message of most recently checked program; avoid constantly checking binary. See bug 277663. N/A if
* checking binary. See bug 277663. N/A if fPreviouslyCheckedProgram = null. * fPreviouslyCheckedProgram = null.
*/ */
protected String fPreviouslyCheckedProgramErrorMsg; protected String fPreviouslyCheckedProgramErrorMsg;
@ -140,13 +144,11 @@ public abstract class CAbstractMainTab extends CLaunchConfigurationTab {
GridData gd = new GridData(GridData.FILL_HORIZONTAL); GridData gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = colSpan; gd.horizontalSpan = colSpan;
projComp.setLayoutData(gd); projComp.setLayoutData(gd);
fProjLabel = new Label(projComp, SWT.NONE); fProjLabel = new Label(projComp, SWT.NONE);
fProjLabel.setText(LaunchMessages.CMainTab_ProjectColon); fProjLabel.setText(LaunchMessages.CMainTab_ProjectColon);
gd = new GridData(); gd = new GridData();
gd.horizontalSpan = 2; gd.horizontalSpan = 2;
fProjLabel.setLayoutData(gd); fProjLabel.setLayoutData(gd);
fProjText = new Text(projComp, SWT.SINGLE | SWT.BORDER); fProjText = new Text(projComp, SWT.SINGLE | SWT.BORDER);
gd = new GridData(GridData.FILL_HORIZONTAL); gd = new GridData(GridData.FILL_HORIZONTAL);
fProjText.setLayoutData(gd); fProjText.setLayoutData(gd);
@ -159,7 +161,6 @@ public abstract class CAbstractMainTab extends CLaunchConfigurationTab {
updateLaunchConfigurationDialog(); updateLaunchConfigurationDialog();
} }
}); });
fProjButton = createPushButton(projComp, LaunchMessages.Launch_common_Browse_1, null); fProjButton = createPushButton(projComp, LaunchMessages.Launch_common_Browse_1, null);
fProjButton.addSelectionListener(new SelectionAdapter() { fProjButton.addSelectionListener(new SelectionAdapter() {
@Override @Override
@ -171,8 +172,8 @@ public abstract class CAbstractMainTab extends CLaunchConfigurationTab {
} }
/** /**
* Return the ICProject corresponding to the project name in the project name text field, or * Return the ICProject corresponding to the project name in the project name text field, or null if the text does not match a
* null if the text does not match a project name. * project name.
*/ */
protected ICProject getCProject() { protected ICProject getCProject() {
String projectName = fProjText.getText().trim(); String projectName = fProjText.getText().trim();
@ -183,9 +184,8 @@ public abstract class CAbstractMainTab extends CLaunchConfigurationTab {
} }
/** /**
* Show a dialog that lets the user select a project. This in turn provides context for the main * Show a dialog that lets the user select a project. This in turn provides context for the main type, allowing the user to key
* type, allowing the user to key a main type name, or constraining the search for main types to * a main type name, or constraining the search for main types to the specified project.
* the specified project.
*/ */
protected void handleProjectButtonSelected() { protected void handleProjectButtonSelected() {
String currentProjectName = fProjText.getText(); String currentProjectName = fProjText.getText();
@ -193,7 +193,6 @@ public abstract class CAbstractMainTab extends CLaunchConfigurationTab {
if (project == null) { if (project == null) {
return; return;
} }
String projectName = project.getElementName(); String projectName = project.getElementName();
fProjText.setText(projectName); fProjText.setText(projectName);
if (currentProjectName.length() == 0) { if (currentProjectName.length() == 0) {
@ -211,7 +210,6 @@ public abstract class CAbstractMainTab extends CLaunchConfigurationTab {
protected ICProject[] getCProjects() throws CModelException { protected ICProject[] getCProjects() throws CModelException {
ICProject cproject[] = CoreModel.getDefault().getCModel().getCProjects(); ICProject cproject[] = CoreModel.getDefault().getCModel().getCProjects();
ArrayList<ICProject> list = new ArrayList<ICProject>(cproject.length); ArrayList<ICProject> list = new ArrayList<ICProject>(cproject.length);
for (int i = 0; i < cproject.length; i++) { for (int i = 0; i < cproject.length; i++) {
ICDescriptor cdesciptor = null; ICDescriptor cdesciptor = null;
try { try {
@ -234,19 +232,16 @@ public abstract class CAbstractMainTab extends CLaunchConfigurationTab {
} }
/** /**
* Realize a C Project selection dialog and return the first selected project, or null if there * Realize a C Project selection dialog and return the first selected project, or null if there was none.
* was none.
*/ */
protected ICProject chooseCProject() { protected ICProject chooseCProject() {
try { try {
ICProject[] projects = getCProjects(); ICProject[] projects = getCProjects();
ILabelProvider labelProvider = new CElementLabelProvider(); ILabelProvider labelProvider = new CElementLabelProvider();
ElementListSelectionDialog dialog = new ElementListSelectionDialog(getShell(), labelProvider); ElementListSelectionDialog dialog = new ElementListSelectionDialog(getShell(), labelProvider);
dialog.setTitle(LaunchMessages.CMainTab_Project_Selection); dialog.setTitle(LaunchMessages.CMainTab_Project_Selection);
dialog.setMessage(LaunchMessages.CMainTab_Choose_project_to_constrain_search_for_program); dialog.setMessage(LaunchMessages.CMainTab_Choose_project_to_constrain_search_for_program);
dialog.setElements(projects); dialog.setElements(projects);
ICProject cProject = getCProject(); ICProject cProject = getCProject();
if (cProject != null) { if (cProject != null) {
dialog.setInitialSelections(new Object[] { cProject }); dialog.setInitialSelections(new Object[] { cProject });
@ -265,36 +260,37 @@ public abstract class CAbstractMainTab extends CLaunchConfigurationTab {
*/ */
protected void updateBuildConfigCombo(String selectedConfigID) { protected void updateBuildConfigCombo(String selectedConfigID) {
if (fBuildConfigCombo != null) { if (fBuildConfigCombo != null) {
fBuildConfigCombo.setEnabled(!fBuildConfigAuto.getSelection());
fBuildConfigCombo.removeAll(); fBuildConfigCombo.removeAll();
int offset = 0;
fBuildConfigCombo.add(LaunchMessages.CMainTab_Use_Active); fBuildConfigCombo.add(LaunchMessages.CMainTab_Use_Active);
fBuildConfigCombo.setData("0", EMPTY_STRING); //$NON-NLS-1$ fBuildConfigCombo.setData(String.valueOf(offset), EMPTY_STRING);
fBuildConfigCombo.select(0); fBuildConfigCombo.select(offset);
offset++;
if (isAutoConfigSupported()) {
fBuildConfigCombo.add(LaunchMessages.CMainTab_Use_Automatic);
fBuildConfigCombo.setData(String.valueOf(offset), AUTO_CONFIG);
if (selectedConfigID.equals(AUTO_CONFIG)) {
fBuildConfigCombo.select(offset);
}
}
offset++;
ICProject cproject = getCProject(); ICProject cproject = getCProject();
if (cproject != null) { if (cproject != null) {
ICProjectDescription projDes = CDTPropertyManager.getProjectDescription(cproject.getProject()); ICProjectDescription projDes = CDTPropertyManager.getProjectDescription(cproject.getProject());
if (projDes != null) { if (projDes != null) {
// Find the config that should be automatically selected // Populate and select config
String autoConfigId = null;
if (fBuildConfigAuto.getSelection()) {
ICConfigurationDescription autoConfig = LaunchUtils.getBuildConfigByProgramPath(cproject.getProject(), fProgText.getText());
if (autoConfig != null)
autoConfigId = autoConfig.getId();
}
int selIndex = 0;
ICConfigurationDescription[] configurations = projDes.getConfigurations(); ICConfigurationDescription[] configurations = projDes.getConfigurations();
ICConfigurationDescription selectedConfig = projDes.getConfigurationById(selectedConfigID);
for (int i = 0; i < configurations.length; i++) { for (int i = 0; i < configurations.length; i++) {
String configName = configurations[i].getName(); String configName = configurations[i].getName();
String id = configurations[i].getId();
fBuildConfigCombo.add(configName); fBuildConfigCombo.add(configName);
fBuildConfigCombo.setData(Integer.toString(i + 1), configurations[i].getId()); int comboIndex = i + offset;
if (selectedConfig != null && selectedConfigID.equals(configurations[i].getId()) || fBuildConfigCombo.setData(String.valueOf(comboIndex), id);
fBuildConfigAuto.getSelection() && configurations[i].getId().equals(autoConfigId)) { if (id.equals(selectedConfigID)) {
selIndex = i + 1; fBuildConfigCombo.select(comboIndex);
} }
} }
fBuildConfigCombo.select(selIndex);
} }
} }
} }
@ -325,28 +321,13 @@ public abstract class CAbstractMainTab extends CLaunchConfigurationTab {
updateLaunchConfigurationDialog(); updateLaunchConfigurationDialog();
} }
}); });
new Label(comboComp, SWT.NONE).setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
fBuildConfigAuto = new Button(comboComp, SWT.CHECK); fBuildConfigAuto = new Button(comboComp, SWT.CHECK);
fBuildConfigAuto.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); GridData gd1 = new GridData(GridData.HORIZONTAL_ALIGN_END | GridData.GRAB_HORIZONTAL);
gd1.heightHint = 0;
gd1.horizontalSpan = 2;
fBuildConfigAuto.setLayoutData(gd1);
fBuildConfigAuto.setVisible(false);
fBuildConfigAuto.setText(LaunchMessages.CMainTab_Build_Config_Auto); fBuildConfigAuto.setText(LaunchMessages.CMainTab_Build_Config_Auto);
fBuildConfigAuto.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
fBuildConfigAutoChanged = true;
fBuildConfigCombo.setEnabled(false);
updateBuildConfigCombo(EMPTY_STRING);
updateLaunchConfigurationDialog();
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
fBuildConfigAutoChanged = true;
fBuildConfigCombo.setEnabled(true);
updateBuildConfigCombo(EMPTY_STRING);
updateLaunchConfigurationDialog();
}
});
} }
/** @since 6.1 */ /** @since 6.1 */
@ -362,42 +343,34 @@ public abstract class CAbstractMainTab extends CLaunchConfigurationTab {
buildGroup.setLayoutData(gridData); buildGroup.setLayoutData(gridData);
buildGroup.setLayout(gridLayout); buildGroup.setLayout(gridLayout);
buildGroup.setText(LaunchMessages.CMainTab_Build_options); buildGroup.setText(LaunchMessages.CMainTab_Build_options);
createBuildConfigCombo(buildGroup, 2); createBuildConfigCombo(buildGroup, 2);
fEnableBuildButton = new Button(buildGroup, SWT.RADIO); fEnableBuildButton = new Button(buildGroup, SWT.RADIO);
fEnableBuildButton.setText(LaunchMessages.CMainTab_Enable_build_button_label); fEnableBuildButton.setText(LaunchMessages.CMainTab_Enable_build_button_label);
fEnableBuildButton.setToolTipText(LaunchMessages.CMainTab_Enable_build_button_tooltip); fEnableBuildButton.setToolTipText(LaunchMessages.CMainTab_Enable_build_button_tooltip);
fEnableBuildButton.addSelectionListener(new SelectionAdapter() { fEnableBuildButton.addSelectionListener(new SelectionAdapter() {
@Override @Override
public void widgetSelected(SelectionEvent evt) { public void widgetSelected(SelectionEvent evt) {
updateLaunchConfigurationDialog(); updateLaunchConfigurationDialog();
} }
}); });
fDisableBuildButton = new Button(buildGroup, SWT.RADIO); fDisableBuildButton = new Button(buildGroup, SWT.RADIO);
fDisableBuildButton.setText(LaunchMessages.CMainTab_Disable_build_button_label); fDisableBuildButton.setText(LaunchMessages.CMainTab_Disable_build_button_label);
fDisableBuildButton.setToolTipText(LaunchMessages.CMainTab_Disable_build_button_tooltip); fDisableBuildButton.setToolTipText(LaunchMessages.CMainTab_Disable_build_button_tooltip);
fDisableBuildButton.addSelectionListener(new SelectionAdapter() { fDisableBuildButton.addSelectionListener(new SelectionAdapter() {
@Override @Override
public void widgetSelected(SelectionEvent evt) { public void widgetSelected(SelectionEvent evt) {
updateLaunchConfigurationDialog(); updateLaunchConfigurationDialog();
} }
}); });
fWorkspaceSettingsButton = new Button(buildGroup, SWT.RADIO); fWorkspaceSettingsButton = new Button(buildGroup, SWT.RADIO);
fWorkspaceSettingsButton.setText(LaunchMessages.CMainTab_Workspace_settings_button_label); fWorkspaceSettingsButton.setText(LaunchMessages.CMainTab_Workspace_settings_button_label);
fWorkspaceSettingsButton.setToolTipText(LaunchMessages.CMainTab_Workspace_settings_button_tooltip); fWorkspaceSettingsButton.setToolTipText(LaunchMessages.CMainTab_Workspace_settings_button_tooltip);
fWorkspaceSettingsButton.addSelectionListener(new SelectionAdapter() { fWorkspaceSettingsButton.addSelectionListener(new SelectionAdapter() {
@Override @Override
public void widgetSelected(SelectionEvent evt) { public void widgetSelected(SelectionEvent evt) {
updateLaunchConfigurationDialog(); updateLaunchConfigurationDialog();
} }
}); });
fWorkpsaceSettingsLink = new Link(buildGroup, SWT.NONE); fWorkpsaceSettingsLink = new Link(buildGroup, SWT.NONE);
fWorkpsaceSettingsLink.setText(LaunchMessages.CMainTab_Workspace_settings_link_label); fWorkpsaceSettingsLink.setText(LaunchMessages.CMainTab_Workspace_settings_link_label);
fWorkpsaceSettingsLink.addSelectionListener(new SelectionAdapter() { fWorkpsaceSettingsLink.addSelectionListener(new SelectionAdapter() {
@ -417,23 +390,23 @@ public abstract class CAbstractMainTab extends CLaunchConfigurationTab {
boolean configAuto = false; boolean configAuto = false;
int buildBeforeLaunchValue = ICDTLaunchConfigurationConstants.BUILD_BEFORE_LAUNCH_USE_WORKSPACE_SETTING; int buildBeforeLaunchValue = ICDTLaunchConfigurationConstants.BUILD_BEFORE_LAUNCH_USE_WORKSPACE_SETTING;
try { try {
buildBeforeLaunchValue = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_BUILD_BEFORE_LAUNCH, buildBeforeLaunchValue); buildBeforeLaunchValue = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_BUILD_BEFORE_LAUNCH,
buildBeforeLaunchValue);
configAuto = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_BUILD_CONFIG_AUTO, false); configAuto = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_BUILD_CONFIG_AUTO, false);
} catch (CoreException e) { } catch (CoreException e) {
LaunchUIPlugin.log(e); LaunchUIPlugin.log(e);
} }
if (fBuildConfigAuto != null) {
fBuildConfigAuto.setSelection(configAuto);
if (configAuto) if (configAuto)
updateBuildConfigCombo(EMPTY_STRING); updateBuildConfigCombo(AUTO_CONFIG);
} updateComboTooltip();
if (fDisableBuildButton != null) if (fDisableBuildButton != null)
fDisableBuildButton.setSelection(buildBeforeLaunchValue == ICDTLaunchConfigurationConstants.BUILD_BEFORE_LAUNCH_DISABLED); fDisableBuildButton
.setSelection(buildBeforeLaunchValue == ICDTLaunchConfigurationConstants.BUILD_BEFORE_LAUNCH_DISABLED);
if (fEnableBuildButton != null) if (fEnableBuildButton != null)
fEnableBuildButton.setSelection(buildBeforeLaunchValue == ICDTLaunchConfigurationConstants.BUILD_BEFORE_LAUNCH_ENABLED); fEnableBuildButton.setSelection(buildBeforeLaunchValue == ICDTLaunchConfigurationConstants.BUILD_BEFORE_LAUNCH_ENABLED);
if (fWorkspaceSettingsButton != null) if (fWorkspaceSettingsButton != null)
fWorkspaceSettingsButton.setSelection(buildBeforeLaunchValue == ICDTLaunchConfigurationConstants.BUILD_BEFORE_LAUNCH_USE_WORKSPACE_SETTING); fWorkspaceSettingsButton
.setSelection(buildBeforeLaunchValue == ICDTLaunchConfigurationConstants.BUILD_BEFORE_LAUNCH_USE_WORKSPACE_SETTING);
} }
/** /**
@ -472,7 +445,6 @@ public abstract class CAbstractMainTab extends CLaunchConfigurationTab {
updateLaunchConfigurationDialog(); updateLaunchConfigurationDialog();
} }
}); });
Button browseForCoreButton; Button browseForCoreButton;
browseForCoreButton = createPushButton(coreComp, LaunchMessages.Launch_common_Browse_3, null); browseForCoreButton = createPushButton(coreComp, LaunchMessages.Launch_common_Browse_3, null);
browseForCoreButton.addSelectionListener(new SelectionAdapter() { browseForCoreButton.addSelectionListener(new SelectionAdapter() {
@ -488,8 +460,9 @@ public abstract class CAbstractMainTab extends CLaunchConfigurationTab {
} }
/** /**
* This method is deprecated since LaunchUtils#getBinary(IProject, IPath) is too slow to be * This method is deprecated since LaunchUtils#getBinary(IProject, IPath) is too slow to be called on the UI thread. See
* called on the UI thread. See "https://bugs.eclipse.org/bugs/show_bug.cgi?id=328012". * "https://bugs.eclipse.org/bugs/show_bug.cgi?id=328012".
*
* @param project * @param project
* @param exePath * @param exePath
* @return * @return
@ -534,7 +507,6 @@ public abstract class CAbstractMainTab extends CLaunchConfigurationTab {
} }
} }
}); });
return ret[0]; return ret[0];
} }
@ -546,13 +518,15 @@ public abstract class CAbstractMainTab extends CLaunchConfigurationTab {
@Override @Override
public void performApply(ILaunchConfigurationWorkingCopy config) { public void performApply(ILaunchConfigurationWorkingCopy config) {
if (fBuildConfigCombo != null) { if (fBuildConfigCombo != null) {
config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_BUILD_CONFIG_ID, (String)fBuildConfigCombo.getData(Integer.toString(fBuildConfigCombo.getSelectionIndex()))); String configId = (String) fBuildConfigCombo.getData(Integer.toString(fBuildConfigCombo.getSelectionIndex()));
boolean auto = false;
if (configId.equals(AUTO_CONFIG)) {
auto = true;
configId = getAutoConfigId();
} }
config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_BUILD_CONFIG_ID, configId);
if (fBuildConfigAutoChanged && fBuildConfigAuto != null) { config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_BUILD_CONFIG_AUTO, auto);
config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_BUILD_CONFIG_AUTO, fBuildConfigAuto.getSelection());
} }
if (fDisableBuildButton != null) { if (fDisableBuildButton != null) {
int buildBeforeLaunchValue = ICDTLaunchConfigurationConstants.BUILD_BEFORE_LAUNCH_USE_WORKSPACE_SETTING; int buildBeforeLaunchValue = ICDTLaunchConfigurationConstants.BUILD_BEFORE_LAUNCH_USE_WORKSPACE_SETTING;
if (fDisableBuildButton.getSelection()) { if (fDisableBuildButton.getSelection()) {
@ -564,6 +538,37 @@ public abstract class CAbstractMainTab extends CLaunchConfigurationTab {
} }
} }
/**
* Calculate build config id based on selection of the binary. Subclasses may override.
*
* @return
* @since 7.2
*/
protected String getAutoConfigId() {
String data = null;
ICProject cproject = getCProject();
if (cproject != null) {
ICConfigurationDescription autoConfig = LaunchUtils.getBuildConfigByProgramPath(cproject.getProject(),
fProgText.getText());
if (autoConfig != null)
data = autoConfig.getId();
}
if (data == null)
data = EMPTY_STRING;
return data;
}
/**
* Either page wants Automatic selection in combo or not. Subclass should override
*
* @return true if panel support AUTO_CONFIG
* @since 7.2
*/
protected boolean isAutoConfigSupported() {
// original behavior was if this button is null it won't be shown and "supported"
return fBuildConfigAuto != null;
}
protected void updateProjectFromConfig(ILaunchConfiguration config) { protected void updateProjectFromConfig(ILaunchConfiguration config) {
String projectName = EMPTY_STRING; String projectName = EMPTY_STRING;
String configName = EMPTY_STRING; String configName = EMPTY_STRING;
@ -597,8 +602,23 @@ public abstract class CAbstractMainTab extends CLaunchConfigurationTab {
*/ */
@Override @Override
protected void updateLaunchConfigurationDialog() { protected void updateLaunchConfigurationDialog() {
if (fBuildConfigAuto != null && fBuildConfigAuto.getSelection()) updateComboTooltip();
updateBuildConfigCombo(EMPTY_STRING);
super.updateLaunchConfigurationDialog(); super.updateLaunchConfigurationDialog();
} }
/**
* @since 7.2
*/
protected void updateComboTooltip() {
if (fBuildConfigCombo != null) {
String configId = (String) fBuildConfigCombo.getData(Integer.toString(fBuildConfigCombo.getSelectionIndex()));
String tooltip = EMPTY_STRING;
if (configId.equals(AUTO_CONFIG)) {
tooltip = LaunchMessages.CMainTab_Build_Config_Auto_tooltip;
} else if (configId.equals(EMPTY_STRING)) {
tooltip = LaunchMessages.CMainTab_Build_Config_Active_tooltip;
}
fBuildConfigCombo.setToolTipText(tooltip);
}
}
} }