From 6d61c70ac46a304a1936fd3489c7e62889410973 Mon Sep 17 00:00:00 2001 From: Denys Almazov Date: Sat, 2 May 2026 13:04:58 +0300 Subject: [PATCH] feat: unify launch and debug configurations --- bundles/com.espressif.idf.core/plugin.xml | 1 + .../schema/launchDefaultsContributor.exsd | 102 ++++++++++++ .../core/util/ILaunchDefaultsContributor.java | 11 ++ .../plugin.xml | 149 +++++++++++++----- .../preferences/OpenOCDDefaultsInjector.java | 127 +++++++++++++++ .../plugin.xml | 2 +- .../core/IDFCoreLaunchConfigProvider.java | 50 +++++- .../plugin.xml | 78 ++++----- .../idf/ui/handlers/RunActionHandler.java | 128 +-------------- .../idf/ui/wizard/NewIDFProjectWizard.java | 41 ----- 10 files changed, 451 insertions(+), 238 deletions(-) create mode 100644 bundles/com.espressif.idf.core/schema/launchDefaultsContributor.exsd create mode 100644 bundles/com.espressif.idf.core/src/com/espressif/idf/core/util/ILaunchDefaultsContributor.java create mode 100644 bundles/com.espressif.idf.debug.gdbjtag.openocd/src/com/espressif/idf/debug/gdbjtag/openocd/preferences/OpenOCDDefaultsInjector.java diff --git a/bundles/com.espressif.idf.core/plugin.xml b/bundles/com.espressif.idf.core/plugin.xml index 669973799..402d97b4c 100644 --- a/bundles/com.espressif.idf.core/plugin.xml +++ b/bundles/com.espressif.idf.core/plugin.xml @@ -2,6 +2,7 @@ + + + + + + + + + [Enter description of this extension point.] + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + [Enter the first release in which this extension point appears.] + + + + + + + + + [Enter extension point usage example here.] + + + + + + + + + [Enter API information here.] + + + + + + + + + [Enter information about supplied implementation of this extension point.] + + + + + diff --git a/bundles/com.espressif.idf.core/src/com/espressif/idf/core/util/ILaunchDefaultsContributor.java b/bundles/com.espressif.idf.core/src/com/espressif/idf/core/util/ILaunchDefaultsContributor.java new file mode 100644 index 000000000..1a532265c --- /dev/null +++ b/bundles/com.espressif.idf.core/src/com/espressif/idf/core/util/ILaunchDefaultsContributor.java @@ -0,0 +1,11 @@ +package com.espressif.idf.core.util; + +import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; + +public interface ILaunchDefaultsContributor +{ + /** + * Applies plugin-specific default values to a newly created launch configuration. + */ + void applyDefaults(ILaunchConfigurationWorkingCopy wc); +} diff --git a/bundles/com.espressif.idf.debug.gdbjtag.openocd/plugin.xml b/bundles/com.espressif.idf.debug.gdbjtag.openocd/plugin.xml index 2fd06585f..098e628cb 100644 --- a/bundles/com.espressif.idf.debug.gdbjtag.openocd/plugin.xml +++ b/bundles/com.espressif.idf.debug.gdbjtag.openocd/plugin.xml @@ -14,14 +14,16 @@ --> + + + + - - - + + @@ -175,67 +187,130 @@ plugin="com.espressif.idf.debug.gdbjtag.openocd"> - + + + + + - - + + + - - + + + - - + + + + + - - + class="org.eclipse.debug.ui.CommonTab" + group="com.espressif.idf.debug.gdbjtag.openocd.launchConfigurationTabGroup" + id="org.eclipse.debug.ui.commonTab" + name="CommonTab"> + + + - - + + + + + - - + class="com.espressif.idf.debug.gdbjtag.openocd.ui.TabMain" + group="com.espressif.idf.launch.serial.ui.launchConfigurationTabGroup" + id="org.eclipse.cdt.cdi.launch.mainTab" + name="Main"> + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bundles/com.espressif.idf.debug.gdbjtag.openocd/src/com/espressif/idf/debug/gdbjtag/openocd/preferences/OpenOCDDefaultsInjector.java b/bundles/com.espressif.idf.debug.gdbjtag.openocd/src/com/espressif/idf/debug/gdbjtag/openocd/preferences/OpenOCDDefaultsInjector.java new file mode 100644 index 000000000..60129a8d9 --- /dev/null +++ b/bundles/com.espressif.idf.debug.gdbjtag.openocd/src/com/espressif/idf/debug/gdbjtag/openocd/preferences/OpenOCDDefaultsInjector.java @@ -0,0 +1,127 @@ +package com.espressif.idf.debug.gdbjtag.openocd.preferences; + +import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants; +import org.eclipse.cdt.debug.gdbjtag.core.IGDBJtagConstants; +import org.eclipse.cdt.dsf.gdb.IGDBLaunchConfigurationConstants; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.variables.VariablesPlugin; +import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; + +import com.espressif.idf.core.logging.Logger; +import com.espressif.idf.core.util.ILaunchDefaultsContributor; +import com.espressif.idf.debug.gdbjtag.openocd.Activator; +import com.espressif.idf.debug.gdbjtag.openocd.ConfigurationAttributes; +import com.espressif.idf.debug.gdbjtag.openocd.IIDFGDBJtagConstants; + +public class OpenOCDDefaultsInjector implements ILaunchDefaultsContributor +{ + + private static final String ESP_SVD_PATH = "esp_svd_path"; //$NON-NLS-1$ + + @Override + public void applyDefaults(ILaunchConfigurationWorkingCopy configuration) + { + + PersistentPreferences persistentPrefs = Activator.getInstance().getPersistentPreferences(); + + try + { + if (configuration.hasAttribute(ConfigurationAttributes.DO_START_GDB_SERVER)) + { + return; + } + } + catch (CoreException e) + { + Logger.log("Failed to check OpenOCD defaults guard", e); + } + + configuration.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, + DefaultPreferences.PROGRAM_APP_DEFAULT); + // --- 1. JTAG Device Setup --- + configuration.setAttribute(IGDBJtagConstants.ATTR_JTAG_DEVICE_ID, ConfigurationAttributes.JTAG_DEVICE); + + // --- 2. OpenOCD GDB Server Setup --- + configuration.setAttribute(ConfigurationAttributes.DO_START_GDB_SERVER, persistentPrefs.getGdbServerDoStart()); + configuration.setAttribute(ConfigurationAttributes.GDB_SERVER_EXECUTABLE, + persistentPrefs.getGdbServerExecutable()); + configuration.setAttribute(ConfigurationAttributes.GDB_SERVER_CONNECTION_ADDRESS, + DefaultPreferences.GDB_SERVER_CONNECTION_ADDRESS_DEFAULT); + configuration.setAttribute(ConfigurationAttributes.GDB_SERVER_GDB_PORT_NUMBER, + DefaultPreferences.GDB_SERVER_GDB_PORT_NUMBER_DEFAULT); + configuration.setAttribute(ConfigurationAttributes.GDB_SERVER_TELNET_PORT_NUMBER, + DefaultPreferences.GDB_SERVER_TELNET_PORT_NUMBER_DEFAULT); + configuration.setAttribute(ConfigurationAttributes.GDB_SERVER_TCL_PORT_NUMBER, + DefaultPreferences.GDB_SERVER_TCL_PORT_NUMBER_DEFAULT); + configuration.setAttribute(ConfigurationAttributes.GDB_SERVER_LOG, DefaultPreferences.GDB_SERVER_LOG_DEFAULT); + configuration.setAttribute(ConfigurationAttributes.DO_GDB_SERVER_ALLOCATE_CONSOLE, + DefaultPreferences.DO_GDB_SERVER_ALLOCATE_CONSOLE_DEFAULT); + configuration.setAttribute(ConfigurationAttributes.DO_GDB_SERVER_ALLOCATE_TELNET_CONSOLE, + DefaultPreferences.DO_GDB_SERVER_ALLOCATE_TELNET_CONSOLE_DEFAULT); + configuration.setAttribute(ConfigurationAttributes.GDB_SERVER_OTHER, + DefaultPreferences.GDB_SERVER_OTHER_DEFAULT); + + // --- 3. GDB Client Setup --- + configuration.setAttribute(IGDBJtagConstants.ATTR_USE_REMOTE_TARGET, + DefaultPreferences.USE_REMOTE_TARGET_DEFAULT); + configuration.setAttribute(IGDBLaunchConfigurationConstants.ATTR_DEBUG_NAME, + DefaultPreferences.GDB_CLIENT_EXECUTABLE_DYNAMIC_DEFAULT); + configuration.setAttribute(ConfigurationAttributes.GDB_CLIENT_OTHER_OPTIONS, + persistentPrefs.getGdbClientOtherOptions()); + configuration.setAttribute(ConfigurationAttributes.GDB_CLIENT_OTHER_COMMANDS, + persistentPrefs.getGdbClientCommands()); + + // --- 4. Thread List Setup --- + configuration.setAttribute(IGDBLaunchConfigurationConstants.ATTR_DEBUGGER_UPDATE_THREADLIST_ON_SUSPEND, + DefaultPreferences.UPDATE_THREAD_LIST_DEFAULT); + + // --- 5. SVD Target Setup --- + // Using the embedcdt ConfigurationAttributes explicitly to avoid namespace collision + configuration.setAttribute(org.eclipse.embedcdt.debug.gdbjtag.core.ConfigurationAttributes.SVD_PATH, + VariablesPlugin.getDefault().getStringVariableManager().generateVariableExpression(ESP_SVD_PATH, null)); + + // --- 6. Initialisation Commands (from TabStartup) --- + configuration.setAttribute(ConfigurationAttributes.DO_FIRST_RESET, persistentPrefs.getOpenOCDDoInitialReset()); + configuration.setAttribute(ConfigurationAttributes.FIRST_RESET_TYPE, persistentPrefs.getOpenOCDInitialResetType()); + configuration.setAttribute(ConfigurationAttributes.ENABLE_SEMIHOSTING, persistentPrefs.getOpenOCDEnableSemihosting()); + configuration.setAttribute(ConfigurationAttributes.OTHER_INIT_COMMANDS, persistentPrefs.getOpenOCDInitOther()); + + // --- 7. Load Image & Symbols (from TabStartup) --- + configuration.setAttribute(IGDBJtagConstants.ATTR_LOAD_IMAGE, IIDFGDBJtagConstants.DEFAULT_LOAD_IMAGE); + configuration.setAttribute(IGDBJtagConstants.ATTR_USE_PROJ_BINARY_FOR_IMAGE, IGDBJtagConstants.DEFAULT_USE_PROJ_BINARY_FOR_IMAGE); + configuration.setAttribute(IGDBJtagConstants.ATTR_USE_FILE_FOR_IMAGE, IGDBJtagConstants.DEFAULT_USE_FILE_FOR_IMAGE); + configuration.setAttribute(IGDBJtagConstants.ATTR_IMAGE_FILE_NAME, IGDBJtagConstants.DEFAULT_IMAGE_FILE_NAME); + configuration.setAttribute(IGDBJtagConstants.ATTR_IMAGE_OFFSET, IGDBJtagConstants.DEFAULT_IMAGE_OFFSET); + + configuration.setAttribute(IGDBJtagConstants.ATTR_LOAD_SYMBOLS, IGDBJtagConstants.DEFAULT_LOAD_SYMBOLS); + configuration.setAttribute(IGDBJtagConstants.ATTR_USE_PROJ_BINARY_FOR_SYMBOLS, IGDBJtagConstants.DEFAULT_USE_PROJ_BINARY_FOR_SYMBOLS); + configuration.setAttribute(IGDBJtagConstants.ATTR_USE_FILE_FOR_SYMBOLS, IGDBJtagConstants.DEFAULT_USE_FILE_FOR_SYMBOLS); + configuration.setAttribute(IGDBJtagConstants.ATTR_SYMBOLS_FILE_NAME, IGDBJtagConstants.DEFAULT_SYMBOLS_FILE_NAME); + configuration.setAttribute(IGDBJtagConstants.ATTR_SYMBOLS_OFFSET, IGDBJtagConstants.DEFAULT_SYMBOLS_OFFSET); + + // --- 8. Runtime Options & Run Commands (from TabStartup) --- + configuration.setAttribute(ConfigurationAttributes.DO_DEBUG_IN_RAM, persistentPrefs.getOpenOCDDebugInRam()); + configuration.setAttribute(ConfigurationAttributes.DO_SECOND_RESET, persistentPrefs.getOpenOCDDoPreRunReset()); + configuration.setAttribute(ConfigurationAttributes.SECOND_RESET_TYPE, persistentPrefs.getOpenOCDPreRunResetType()); + configuration.setAttribute(ConfigurationAttributes.OTHER_RUN_COMMANDS, persistentPrefs.getOpenOCDPreRunOther()); + + configuration.setAttribute(IGDBJtagConstants.ATTR_SET_PC_REGISTER, IGDBJtagConstants.DEFAULT_SET_PC_REGISTER); + configuration.setAttribute(IGDBJtagConstants.ATTR_PC_REGISTER, IGDBJtagConstants.DEFAULT_PC_REGISTER); + configuration.setAttribute(IGDBJtagConstants.ATTR_SET_STOP_AT, DefaultPreferences.DO_STOP_AT_DEFAULT); + configuration.setAttribute(IGDBJtagConstants.ATTR_STOP_AT, DefaultPreferences.STOP_AT_NAME_DEFAULT); + configuration.setAttribute(IGDBJtagConstants.ATTR_SET_RESUME, IGDBJtagConstants.DEFAULT_SET_RESUME); + configuration.setAttribute(ConfigurationAttributes.DO_CONTINUE, DefaultPreferences.DO_CONTINUE_DEFAULT); + + + configuration.setAttribute(ConfigurationAttributes.DO_START_GDB_CLIENT, + DefaultPreferences.DO_START_GDB_CLIENT_DEFAULT); + + configuration.setAttribute(IGDBJtagConstants.ATTR_IP_ADDRESS, "localhost"); + + configuration.setAttribute(IGDBJtagConstants.ATTR_PORT_NUMBER, + DefaultPreferences.GDB_SERVER_GDB_PORT_NUMBER_DEFAULT); + + configuration.setAttribute(ConfigurationAttributes.DO_FLASH_BEFORE_START, true); + configuration.setAttribute(ConfigurationAttributes.ENABLE_VERBOSE_OUTPUT, false); + } +} diff --git a/bundles/com.espressif.idf.launch.serial.core/plugin.xml b/bundles/com.espressif.idf.launch.serial.core/plugin.xml index e3699f1ea..02a20870d 100644 --- a/bundles/com.espressif.idf.launch.serial.core/plugin.xml +++ b/bundles/com.espressif.idf.launch.serial.core/plugin.xml @@ -35,7 +35,7 @@ diff --git a/bundles/com.espressif.idf.launch.serial.core/src/com/espressif/idf/launch/serial/core/IDFCoreLaunchConfigProvider.java b/bundles/com.espressif.idf.launch.serial.core/src/com/espressif/idf/launch/serial/core/IDFCoreLaunchConfigProvider.java index 769c2bbbd..1e1519fcc 100644 --- a/bundles/com.espressif.idf.launch.serial.core/src/com/espressif/idf/launch/serial/core/IDFCoreLaunchConfigProvider.java +++ b/bundles/com.espressif.idf.launch.serial.core/src/com/espressif/idf/launch/serial/core/IDFCoreLaunchConfigProvider.java @@ -8,6 +8,8 @@ import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.core.runtime.Platform; import org.eclipse.debug.core.DebugPlugin; import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; @@ -15,7 +17,9 @@ import org.eclipse.launchbar.core.target.ILaunchTarget; import com.espressif.idf.core.build.IDFLaunchConstants; +import com.espressif.idf.core.logging.Logger; import com.espressif.idf.core.util.IDFUtil; +import com.espressif.idf.core.util.ILaunchDefaultsContributor; import com.espressif.idf.core.util.LaunchUtil; public class IDFCoreLaunchConfigProvider extends CoreBuildGenericLaunchConfigProvider @@ -50,8 +54,50 @@ protected void populateLaunchConfiguration(ILaunchDescriptor descriptor, ILaunch // Set the project IProject project = descriptor.getAdapter(IProject.class); - workingCopy.setMappedResources(new IResource[] { project }); - workingCopy.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, project.getName()); + if (project != null && project.exists()) + { + workingCopy.setMappedResources(new IResource[] { project }); + workingCopy.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, project.getName()); + + org.eclipse.cdt.core.model.ICProject cProject = org.eclipse.cdt.core.CCorePlugin.getDefault().getCoreModel() + .create(project); + if (cProject != null && cProject.exists()) + { + org.eclipse.cdt.core.settings.model.ICProjectDescription projDes = org.eclipse.cdt.core.CCorePlugin + .getDefault().getProjectDescription(cProject.getProject()); + + if (projDes != null && projDes.getActiveConfiguration() != null) + { + String buildConfigID = projDes.getActiveConfiguration().getId(); + workingCopy.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_BUILD_CONFIG_ID, + buildConfigID); + } + } + + // 3. Ensure Build Before Launch is enabled + workingCopy.setAttribute(ICDTLaunchConfigurationConstants.ATTR_BUILD_BEFORE_LAUNCH, + ICDTLaunchConfigurationConstants.BUILD_BEFORE_LAUNCH_USE_WORKSPACE_SETTING); + } + + IConfigurationElement[] elements = Platform.getExtensionRegistry() + .getConfigurationElementsFor("com.espressif.idf.core.launchDefaultsContributor"); //$NON-NLS-1$ + + for (IConfigurationElement element : elements) + { + try + { + Object obj = element.createExecutableExtension("class"); //$NON-NLS-1$ + if (obj instanceof ILaunchDefaultsContributor launchDefaultsContributor) + { + launchDefaultsContributor.applyDefaults(workingCopy); + } + } + catch (CoreException e) + { + Logger.log(e); + } + } + workingCopy.doSave(); } diff --git a/bundles/com.espressif.idf.launch.serial.ui/plugin.xml b/bundles/com.espressif.idf.launch.serial.ui/plugin.xml index 31fce7ef1..46555427c 100644 --- a/bundles/com.espressif.idf.launch.serial.ui/plugin.xml +++ b/bundles/com.espressif.idf.launch.serial.ui/plugin.xml @@ -60,41 +60,47 @@ resolver="com.espressif.idf.launch.serial.ui.BuildFolderVariableResolver"> - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/handlers/RunActionHandler.java b/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/handlers/RunActionHandler.java index 2aa14522b..40c922f72 100644 --- a/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/handlers/RunActionHandler.java +++ b/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/handlers/RunActionHandler.java @@ -4,38 +4,23 @@ *******************************************************************************/ package com.espressif.idf.ui.handlers; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.stream.Stream; - import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants; import org.eclipse.core.commands.ExecutionEvent; import org.eclipse.core.commands.ExecutionException; import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; -import org.eclipse.debug.core.DebugPlugin; import org.eclipse.debug.core.ILaunchConfiguration; -import org.eclipse.debug.core.ILaunchManager; import org.eclipse.debug.core.ILaunchMode; import org.eclipse.debug.ui.DebugUITools; import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.window.Window; -import org.eclipse.jface.wizard.WizardDialog; import org.eclipse.launchbar.core.ILaunchBarManager; import org.eclipse.launchbar.ui.ILaunchBarUIManager; -import org.eclipse.launchbar.ui.NewLaunchConfigWizard; -import org.eclipse.launchbar.ui.NewLaunchConfigWizardDialog; import org.eclipse.launchbar.ui.internal.commands.LaunchActiveCommandHandler; import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Shell; import com.espressif.idf.core.build.IDFLaunchConstants; -import com.espressif.idf.core.logging.Logger; import com.espressif.idf.core.util.StringUtil; import com.espressif.idf.ui.UIPlugin; -import com.espressif.idf.ui.dialogs.SelectDebugConfigDialog; @SuppressWarnings("restriction") public class RunActionHandler extends LaunchActiveCommandHandler @@ -54,13 +39,10 @@ public Object execute(ExecutionEvent event) throws ExecutionException { return Status.OK_STATUS; } - - boolean isEspLaunchConfig = config.getType().getIdentifier() + boolean isUnifiedEspConfig = config.getType().getIdentifier() .contentEquals(IDFLaunchConstants.RUN_LAUNCH_CONFIG_TYPE); - boolean isEspDebugConfig = config.getType().getIdentifier() - .contentEquals(IDFLaunchConstants.DEBUG_LAUNCH_CONFIG_TYPE); - if (!isEspLaunchConfig && !isEspDebugConfig) + if (!isUnifiedEspConfig) { return super.execute(event); } @@ -70,7 +52,7 @@ public Object execute(ExecutionEvent event) throws ExecutionException { return Status.OK_STATUS; } - int returnCode = Window.OK; + String projectName = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, StringUtil.EMPTY); if (projectName.isBlank()) @@ -85,29 +67,10 @@ public Object execute(ExecutionEvent event) throws ExecutionException } return Status.CANCEL_STATUS; } - if (launchMode.getIdentifier().equals(ILaunchManager.DEBUG_MODE) && isEspLaunchConfig) - { - List suitableDescNames = findSuitableDescNames(projectName, - IDFLaunchConstants.DEBUG_LAUNCH_CONFIG_TYPE); - if (suitableDescNames.isEmpty()) - { - showMessage(Messages.DebugConfigurationNotFoundMsg); - return Status.CANCEL_STATUS; - } - returnCode = runActionBasedOnDescCount(launchBarManager, suitableDescNames); - } - else if (launchMode.getIdentifier().equals(ILaunchManager.RUN_MODE) && isEspDebugConfig) - { - List suitableDescNames = findSuitableDescNames(projectName, - IDFLaunchConstants.RUN_LAUNCH_CONFIG_TYPE); - returnCode = runActionBasedOnDescCount(launchBarManager, suitableDescNames); - } - if (returnCode == Window.OK) - { - launchBarManager.setActiveLaunchMode(launchMode); - config = launchBarManager.getActiveLaunchConfiguration(); - DebugUITools.launch(config, launchMode.getIdentifier()); - } + + launchBarManager.setActiveLaunchMode(launchMode); + config = launchBarManager.getActiveLaunchConfiguration(); + DebugUITools.launch(config, launchMode.getIdentifier()); return Status.OK_STATUS; } @@ -116,81 +79,4 @@ else if (launchMode.getIdentifier().equals(ILaunchManager.RUN_MODE) && isEspDebu return e.getStatus(); } } - - private int runActionBasedOnDescCount(ILaunchBarManager launchBarManager, List suitableDescNames) - throws CoreException - { - return suitableDescNames.size() == 1 - ? setLaunchBarWithFirstAppropriateDescriptor(launchBarManager, suitableDescNames) - : new SelectDebugConfigDialog(Display.getDefault().getActiveShell(), suitableDescNames).open(); - } - - private int setLaunchBarWithFirstAppropriateDescriptor(ILaunchBarManager launchBarManager, - List suitableDescNames) throws CoreException - { - Stream.of(launchBarManager.getLaunchDescriptors()) - .filter(desc -> desc.getName().equals(suitableDescNames.get(0))).findFirst().ifPresent(desc -> { - try - { - launchBarManager.setActiveLaunchDescriptor(desc); - } - catch (CoreException e) - { - Logger.log(e); - } - }); - return IStatus.OK; - } - - private List findSuitableDescNames(String projectName, String configType) - { - ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager(); - List configList = new ArrayList<>(); - try - { - configList = Arrays.asList( - launchManager.getLaunchConfigurations(launchManager.getLaunchConfigurationType(configType))); - - } - catch (CoreException e) - { - Logger.log(e); - } - return configList.stream().filter(config -> { - try - { - return config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, StringUtil.EMPTY) - .contentEquals(projectName); - } - catch (CoreException e) - { - Logger.log(e); - } - return false; - }).map(config -> config.getName()).toList(); - } - - private void showMessage(final String message) - { - Display.getDefault().asyncExec(() -> { - - Shell activeShell = Display.getDefault().getActiveShell(); - boolean isYes = MessageDialog.openQuestion(activeShell, Messages.MissingDebugConfigurationTitle, message); - if (isYes) - { - - NewLaunchConfigWizard wizard = new NewLaunchConfigWizard(); - WizardDialog dialog = new NewLaunchConfigWizardDialog(activeShell, wizard); - dialog.open(); - try - { - wizard.getWorkingCopy().doSave(); - } - catch (CoreException e) - { - Logger.log(e); - } - } - }); - } } diff --git a/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/wizard/NewIDFProjectWizard.java b/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/wizard/NewIDFProjectWizard.java index 88016b2d3..cc5ccc963 100644 --- a/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/wizard/NewIDFProjectWizard.java +++ b/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/wizard/NewIDFProjectWizard.java @@ -17,21 +17,14 @@ import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.jobs.Job; import org.eclipse.debug.core.DebugPlugin; -import org.eclipse.debug.core.ILaunchConfigurationType; import org.eclipse.jface.dialogs.IDialogSettings; -import org.eclipse.jface.dialogs.PageChangingEvent; import org.eclipse.jface.viewers.ISelectionProvider; import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.jface.wizard.WizardDialog; import org.eclipse.launchbar.core.ILaunchBarManager; import org.eclipse.launchbar.core.ILaunchDescriptor; import org.eclipse.launchbar.core.target.ILaunchTarget; import org.eclipse.launchbar.core.target.ILaunchTargetManager; -import org.eclipse.launchbar.ui.NewLaunchConfigWizard; -import org.eclipse.launchbar.ui.NewLaunchConfigWizardDialog; -import org.eclipse.launchbar.ui.internal.dialogs.NewLaunchConfigEditPage; import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Shell; import org.eclipse.tools.templates.core.IGenerator; import org.eclipse.tools.templates.ui.TemplateWizard; import org.eclipse.ui.IViewPart; @@ -150,8 +143,6 @@ public boolean performFinish() // this ensures that the configuration exists launchBarManager.getActiveLaunchConfiguration(); - - createDefaultDebugConfig(); launchBarManager.setActiveLaunchDescriptor(desc); } } @@ -205,38 +196,6 @@ private void updateClangFiles(IProject project) } } - private void createDefaultDebugConfig() - { - Shell activeShell = Display.getDefault().getActiveShell(); - - NewLaunchConfigWizard wizard = new NewLaunchConfigWizard(); - WizardDialog dialog = new NewLaunchConfigWizardDialog(activeShell, wizard); - dialog.create(); - - NewLaunchConfigEditPage editPage = (NewLaunchConfigEditPage) wizard.getPage(NEW_LAUNCH_CONFIG_EDIT_PAGE); - ILaunchConfigurationType debugLaunchConfigType = DebugPlugin.getDefault().getLaunchManager() - .getLaunchConfigurationType(IDFLaunchConstants.DEBUG_LAUNCH_CONFIG_TYPE); - editPage.setLaunchConfigType(debugLaunchConfigType); - - PageChangingEvent pageChangingEvent = new PageChangingEvent(wizard, wizard.getStartingPage(), editPage); - editPage.handlePageChanging(pageChangingEvent); - wizard.performFinish(); - - try - { - String originalName = wizard.getWorkingCopy().getName(); - int configPartIndex = originalName.lastIndexOf("Configuration"); //$NON-NLS-1$ - String debugConfigName = configPartIndex != -1 ? originalName.substring(0, configPartIndex) + "Debug" //$NON-NLS-1$ - : originalName; - wizard.getWorkingCopy().copy(debugConfigName).doSave(); - } - catch (CoreException e) - { - Logger.log(e); - } - wizard.dispose(); - } - @Override protected IGenerator getGenerator() {