diff --git a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/corebuild/LocalLaunchConfigurationTabGroup.java b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/corebuild/LocalLaunchConfigurationTabGroup.java index a77fe952a98..3636caa3d49 100644 --- a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/corebuild/LocalLaunchConfigurationTabGroup.java +++ b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/corebuild/LocalLaunchConfigurationTabGroup.java @@ -11,7 +11,7 @@ package org.eclipse.cdt.launch.internal.corebuild; import org.eclipse.cdt.launch.ui.CArgumentsTab; -import org.eclipse.cdt.launch.ui.corebuild.CoreBuildMainTab; +import org.eclipse.cdt.launch.ui.corebuild.CoreBuildMainTab2; import org.eclipse.cdt.launch.ui.corebuild.CoreBuildTab; import org.eclipse.debug.ui.AbstractLaunchConfigurationTabGroup; import org.eclipse.debug.ui.EnvironmentTab; @@ -22,7 +22,7 @@ public class LocalLaunchConfigurationTabGroup extends AbstractLaunchConfiguratio @Override public void createTabs(ILaunchConfigurationDialog dialog, String mode) { - ILaunchConfigurationTab mainTab = new CoreBuildMainTab(); + ILaunchConfigurationTab mainTab = new CoreBuildMainTab2(); ILaunchConfigurationTab buildTab = new CoreBuildTab(); ILaunchConfigurationTab argumentsTab = new CArgumentsTab(); ILaunchConfigurationTab environmentTab = new EnvironmentTab(); diff --git a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/CMainTab2.java b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/CMainTab2.java index ba7f9cda8e8..de2f6be5ada 100644 --- a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/CMainTab2.java +++ b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/CMainTab2.java @@ -93,7 +93,7 @@ public class CMainTab2 extends CAbstractMainTab { */ protected Combo fCoreTypeCombo; - private boolean fDontCheckProgram; + private boolean fDontCheckProgram = false; private final boolean fSpecifyCoreFile; private final boolean fIncludeBuildSettings; diff --git a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/corebuild/CoreBuildMainTab.java b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/corebuild/CoreBuildMainTab.java index 3ef4b9a7f6c..4097d0d0824 100644 --- a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/corebuild/CoreBuildMainTab.java +++ b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/corebuild/CoreBuildMainTab.java @@ -10,51 +10,73 @@ *******************************************************************************/ package org.eclipse.cdt.launch.ui.corebuild; -import org.eclipse.cdt.launch.internal.ui.LaunchMessages; -import org.eclipse.cdt.launch.ui.CMainTab2; +import org.eclipse.cdt.launch.internal.ui.LaunchUIPlugin; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.CoreException; import org.eclipse.debug.core.ILaunchConfiguration; +import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; +import org.eclipse.debug.ui.AbstractLaunchConfigurationTab; +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Text; /** * @since 9.1 */ -public class CoreBuildMainTab extends CMainTab2 { +public class CoreBuildMainTab extends AbstractLaunchConfigurationTab { + + private Text projectName; + + @Override + public void createControl(Composite parent) { + Composite comp = new Composite(parent, SWT.NONE); + comp.setLayout(new GridLayout()); + + Label label = new Label(comp, SWT.NONE); + label.setText("This launch configuration was automatically created."); + label.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); + + label = new Label(comp, SWT.NONE); + label.setText("Project:"); + + projectName = new Text(comp, SWT.READ_ONLY | SWT.BORDER); + projectName.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); + + setControl(comp); + } - /* - * A Core Build launch configuration is created immediately upon the Core Build project creation. - * It cannot be created by hand and it is not duplicatable and can't be renamed. - * The launch configuration is tied to the project. The project name may not be changed. - */ @Override - protected void createProjectGroup(Composite parent, int colSpan) { - super.createProjectGroup(parent, colSpan); - fProjText.setEnabled(false); - fProjButton.setVisible(false); + public void setDefaults(ILaunchConfigurationWorkingCopy configuration) { + // none } @Override - protected void createExeFileGroup(Composite parent, int colSpan) { - super.createExeFileGroup(parent, colSpan); - fProgText.setMessage(LaunchMessages.CoreBuildMainTab_Keep_empty_for_auto_selection); + public void initializeFrom(ILaunchConfiguration configuration) { + try { + for (IResource resource : configuration.getMappedResources()) { + if (resource instanceof IProject) { + projectName.setText(resource.getName()); + break; + } + } + } catch (CoreException e) { + LaunchUIPlugin.log(e.getStatus()); + } } - /* - * For Core Build projects the build configuration is hidden and it is selected - * via the LaunchBar Launch Mode. We remove the BuildConfigCombo. - */ @Override - protected void createBuildConfigCombo(Composite parent, int colspan) { - fBuildConfigCombo = null; + public void performApply(ILaunchConfigurationWorkingCopy configuration) { + // TODO Auto-generated method stub + } - /* - * Don't check the program name if it is empty. When the program name is empty the default - * CoreBuild binary is used. - */ @Override - public boolean isValid(ILaunchConfiguration config) { - String programName = fProgText.getText().trim(); - setDontCheckProgram(programName.isEmpty()); - return super.isValid(config); + public String getName() { + return "Main"; } + } diff --git a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/corebuild/CoreBuildMainTab2.java b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/corebuild/CoreBuildMainTab2.java new file mode 100644 index 00000000000..d41b8ef5c74 --- /dev/null +++ b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/corebuild/CoreBuildMainTab2.java @@ -0,0 +1,60 @@ +/******************************************************************************* + * Copyright (c) 2024 Intel corporation and others. + * + * This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + *******************************************************************************/ +package org.eclipse.cdt.launch.ui.corebuild; + +import org.eclipse.cdt.launch.internal.ui.LaunchMessages; +import org.eclipse.cdt.launch.ui.CMainTab2; +import org.eclipse.debug.core.ILaunchConfiguration; +import org.eclipse.swt.widgets.Composite; + +/** + * @since 10.4 + */ +public class CoreBuildMainTab2 extends CMainTab2 { + + /* + * A Core Build launch configuration is created immediately upon the Core Build project creation. + * It cannot be created by hand and it is not duplicatable and can't be renamed. + * The launch configuration is tied to the project. The project name may not be changed. + */ + @Override + protected void createProjectGroup(Composite parent, int colSpan) { + super.createProjectGroup(parent, colSpan); + fProjText.setEnabled(false); + fProjButton.setVisible(false); + } + + @Override + protected void createExeFileGroup(Composite parent, int colSpan) { + super.createExeFileGroup(parent, colSpan); + fProgText.setMessage(LaunchMessages.CoreBuildMainTab_Keep_empty_for_auto_selection); + } + + /* + * For Core Build projects the build configuration is hidden and it is selected + * via the LaunchBar Launch Mode. We remove the BuildConfigCombo. + */ + @Override + protected void createBuildConfigCombo(Composite parent, int colspan) { + fBuildConfigCombo = null; + } + + /* + * Don't check the program name if it is empty. When the program name is empty the default + * CoreBuild binary is used. + */ + @Override + public boolean isValid(ILaunchConfiguration config) { + String programName = fProgText.getText().trim(); + setDontCheckProgram(programName.isEmpty()); + return super.isValid(config); + } +} \ No newline at end of file