diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 958db9b21..0e78cc251 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,7 +25,7 @@ jobs: repository: espressif/esp-idf path: dependencies/idf-tools submodules: 'true' - ref: v4.4 + ref: release/v5.1 - name: Set up Python uses: actions/setup-python@v2 @@ -51,9 +51,12 @@ jobs: - name: Publish Test Reports if: ${{ always() }} - uses: scacap/action-surefire-report@v1 + uses: phoenix-actions/test-reporting@v12 with: - check_name: 'Linux Test Reports' + name: Linux Test Reports + path: + tests/*/*/*/TEST-*.xml + reporter: java-junit build_macos: runs-on: macos-latest diff --git a/.github/workflows/ci_windows.yml b/.github/workflows/ci_windows.yml index fcd0b6f83..b9ef1a859 100644 --- a/.github/workflows/ci_windows.yml +++ b/.github/workflows/ci_windows.yml @@ -24,7 +24,7 @@ jobs: repository: espressif/esp-idf path: dependencies/idf-tools submodules: 'true' - ref: v5.1 + ref: release/v5.1 - name: Set up Python uses: actions/setup-python@v2 diff --git a/FAQ.md b/FAQ.md index ab977ed42..152a6651f 100644 --- a/FAQ.md +++ b/FAQ.md @@ -40,6 +40,14 @@ Yes, you can create IDF CMake project using `File > New > Espressif IDF Project` Yes, you can import using Import Menu. `Import... > Espressif > Existing IDF Project` ## Where can I find the IDF installed tools in my system? Default directory is `$HOME/.espressif` for Linux/MacOS users or `%USER_PROFILE%.espressif` for Windows users +## Why am I getting timeout errors when Installing tools? +If you are getting errors when downloading or installing tools this can be due to some issue with the mirrors. You can try to set the mirrors in Eclipse `Preferences > Espressif` you will see two settings for Git and Pip Py Wheels please set these to proper mirror according to your region. Currently these two mirrors are available. +### Mirror for GIT (IDF_GITHUB_ASSETS) +- dl.espressif.com/github_assets (default) +- dl.espressif.cn/github_assets +### Mirror for python wheels (PIP_EXTRA_INDEX_URL) +- https://dl.espressif.com/pypi (default) +- https://dl.espressif.cn/pypi ## Deleted C/C++ build envrionment variables still appearing? - You need to uncheck the preference recorder. This can be performed by following. Eclipse `Preferences > Oomph > Setup Tasks > Preference Recorder` - Uncheck `Record into` diff --git a/NewAndNoteworthy/README.md b/NewAndNoteworthy/README.md deleted file mode 100644 index ef4a142b8..000000000 --- a/NewAndNoteworthy/README.md +++ /dev/null @@ -1 +0,0 @@ -Espressif-IDE Release Notes and New & Noteworthy diff --git a/README.md b/README.md index c83f60b81..1ab670bfe 100644 --- a/README.md +++ b/README.md @@ -877,7 +877,9 @@ Note this configuration changes where all the project build artifacts will be ge | IEP | Eclipse | Java | Installer | Description | | ------ | ------ | ------ |------ | ------ | -| IEP 2.11.0 | Eclipse 2023-03, Eclipse 2023-06, Eclipse 2023-09 |Java 17 and above | | +| IEP 2.12.1 | Eclipse 2023-03 to Eclipse 2023-12 |Java 17 and above |[espressif-ide-setup-2.12.1-with-esp-idf-5.2.exe](https://github.com/espressif/idf-installer/releases/download/espressif-ide-2.12.1-esp-idf-5.2/espressif-ide-setup-2.12.1-with-esp-idf-5.2.exe) | +| IEP 2.12.0 | Eclipse 2023-03, Eclipse 2023-06, Eclipse 2023-09 |Java 17 and above | [espressif-ide-setup-2.12.0-with-esp-idf-5.1.2](https://github.com/espressif/idf-installer/releases/download/espressif-ide-2.12.0-esp-idf-5.1.2/espressif-ide-setup-2.12.0-with-esp-idf-5.1.2.exe) | +| IEP 2.11.0 | Eclipse 2023-03, Eclipse 2023-06, Eclipse 2023-09 |Java 17 and above |[espressif-ide-setup-2.11.0-with-esp-idf-5.1.1.exe](https://github.com/espressif/idf-installer/releases/download/espressif-ide-2.11.0-esp-idf-5.1.1/espressif-ide-setup-2.11.0-with-esp-idf-5.1.1.exe) | | IEP 2.10.0 | Eclipse 2022-09,2022-12,2023-03 |Java 17 and above | [espressif-ide-setup-2.10.0-with-esp-idf-5.0.1.exe](https://github.com/espressif/idf-installer/releases/download/untagged-52aeb689780472c126c1/espressif-ide-setup-2.10.0-with-esp-idf-5.0.1.exe)| | IEP 2.9.1 | Eclipse 2022-09 and Eclipse 2022-12 |Java 17 and above | [espressif-ide-setup-2.9.0-with-esp-idf-5.0.1.exe](https://github.com/espressif/idf-installer/releases/download/espressif-ide-2.9.0-esp-idf-5.0.1/espressif-ide-setup-2.9.0-with-esp-idf-5.0.1.exe) | For Windows Users, it's recommended to use the Windows Offline Installer and upgrade to the latest IEP v2.9.1 plugin| | IEP 2.9.0 | Eclipse 2022-09 |Java 17 and above | [espressif-ide-setup-2.9.0-with-esp-idf-5.0.1.exe](https://github.com/espressif/idf-installer/releases/download/espressif-ide-2.9.0-esp-idf-5.0.1/espressif-ide-setup-2.9.0-with-esp-idf-5.0.1.exe) | For Windows, it's recommended to use the Windows Offline Installer| diff --git a/bundles/com.espressif.idf.branding/META-INF/MANIFEST.MF b/bundles/com.espressif.idf.branding/META-INF/MANIFEST.MF index 80f177fa1..5984c1959 100644 --- a/bundles/com.espressif.idf.branding/META-INF/MANIFEST.MF +++ b/bundles/com.espressif.idf.branding/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: com.espressif.idf.branding;singleton:=true -Bundle-Version: 2.12.0.qualifier +Bundle-Version: 2.13.0.qualifier Bundle-Vendor: %providerName Bundle-Localization: plugin Bundle-RequiredExecutionEnvironment: JavaSE-11 diff --git a/bundles/com.espressif.idf.core/src/com/espressif/idf/core/IDFConstants.java b/bundles/com.espressif.idf.core/src/com/espressif/idf/core/IDFConstants.java index f3d877216..f4ea59909 100644 --- a/bundles/com.espressif.idf.core/src/com/espressif/idf/core/IDFConstants.java +++ b/bundles/com.espressif.idf.core/src/com/espressif/idf/core/IDFConstants.java @@ -147,7 +147,7 @@ public interface IDFConstants String ESP_CORE_DUMP_FOLDER = "espcoredump"; //$NON-NLS-1$ - String ESP_CORE_DUMP_SCRIPT = "espcoredump.py"; + String ESP_CORE_DUMP_SCRIPT = "espcoredump.py"; //$NON-NLS-1$ /** * COMPONENT_FOLDER/esptool_py diff --git a/bundles/com.espressif.idf.core/src/com/espressif/idf/core/IDFCorePreferenceConstants.java b/bundles/com.espressif.idf.core/src/com/espressif/idf/core/IDFCorePreferenceConstants.java index 780e13a52..12ee97850 100644 --- a/bundles/com.espressif.idf.core/src/com/espressif/idf/core/IDFCorePreferenceConstants.java +++ b/bundles/com.espressif.idf.core/src/com/espressif/idf/core/IDFCorePreferenceConstants.java @@ -27,6 +27,10 @@ public class IDFCorePreferenceConstants public static final boolean CMAKE_CCACHE_DEFAULT_STATUS = true; public static final boolean AUTOMATE_BUILD_HINTS_DEFAULT_STATUS = true; public static final boolean HIDE_ERRORS_IDF_COMPONENTS_DEFAULT_STATUS = true; + public static final String IDF_GITHUB_ASSETS = "IDF_GITHUB_ASSETS"; //$NON-NLS-1$ + public static final String IDF_GITHUB_ASSETS_DEFAULT = "dl.espressif.com/github_assets"; //$NON-NLS-1$ + public static final String PIP_EXTRA_INDEX_URL = "PIP_EXTRA_INDEX_URL"; //$NON-NLS-1$ + public static final String PIP_EXTRA_INDEX_URL_DEFAULT = "https://dl.espressif.com/pypi"; //$NON-NLS-1$ /** * Returns the node in the preference in the given context. * diff --git a/bundles/com.espressif.idf.core/src/com/espressif/idf/core/build/IDFBuildConfiguration.java b/bundles/com.espressif.idf.core/src/com/espressif/idf/core/build/IDFBuildConfiguration.java index 9d3f53ccd..0448e487d 100644 --- a/bundles/com.espressif.idf.core/src/com/espressif/idf/core/build/IDFBuildConfiguration.java +++ b/bundles/com.espressif.idf.core/src/com/espressif/idf/core/build/IDFBuildConfiguration.java @@ -7,7 +7,7 @@ * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * + * * Contributors: * QNX - Initial API and implementation * kondal.kolipaka@espressif.com - ESP-IDF specific build configuration @@ -140,10 +140,12 @@ public class IDFBuildConfiguration extends CBuildConfiguration public boolean isProgressSet; private QualifiedName TIMESTAMP_COMPILE_COMMANDS_PROPERTY = new QualifiedName(null, "timestamp:compile_commands.json"); //$NON-NLS-1$ + private ILaunchConfiguration configuration; public IDFBuildConfiguration(IBuildConfiguration config, String name) throws CoreException { super(config, name); + this.configuration = LAUNCH_CONFIG_PROVIDER.getActiveLaunchConfiguration(); } public IDFBuildConfiguration(IBuildConfiguration config, String name, IToolChain toolChain) @@ -156,6 +158,14 @@ public IDFBuildConfiguration(IBuildConfiguration config, String name, IToolChain { super(config, name, toolChain, launchMode); this.toolChainFile = toolChainFile; + try + { + this.configuration = LAUNCH_CONFIG_PROVIDER.getActiveLaunchConfiguration(); + } + catch (CoreException e) + { + Logger.log(e); + } } @Override @@ -247,7 +257,6 @@ public String getProperty(String name) { try { - ILaunchConfiguration configuration = LAUNCH_CONFIG_PROVIDER.getActiveLaunchConfiguration(); if (configuration != null && configuration.getType().getIdentifier().equals(IDFLaunchConstants.DEBUG_LAUNCH_CONFIG_TYPE)) { @@ -639,7 +648,7 @@ private static String getIdfToolsPath() /** * Link build components(build_component_paths) from project_description.json to the project. - * + * * @param project * @throws Exception */ @@ -976,7 +985,7 @@ public void elementChanged(ElementChangedEvent event) /** * Processes the delta in order to detect whether one of the CMakeLists.txt files in the project has been modified * and saved by the user since the last build. - * + * * @return true to continue with delta processing, otherwise false */ private boolean processElementDelta(ICElementDelta delta) diff --git a/bundles/com.espressif.idf.sdk.config.core/src/com/espressif/idf/sdk/config/core/SDKConfigPropertyTester.java b/bundles/com.espressif.idf.sdk.config.core/src/com/espressif/idf/sdk/config/core/SDKConfigPropertyTester.java index 2aa540781..725ca0ffe 100644 --- a/bundles/com.espressif.idf.sdk.config.core/src/com/espressif/idf/sdk/config/core/SDKConfigPropertyTester.java +++ b/bundles/com.espressif.idf.sdk.config.core/src/com/espressif/idf/sdk/config/core/SDKConfigPropertyTester.java @@ -8,6 +8,7 @@ import org.eclipse.core.resources.IFile; import com.espressif.idf.core.IDFConstants; +import com.espressif.idf.core.util.StringUtil; /** * @author Kondal Kolipaka @@ -19,7 +20,9 @@ public class SDKConfigPropertyTester extends PropertyTester @Override public boolean test(Object receiver, String property, Object[] args, Object expectedValue) { - if (receiver instanceof IFile && ((IFile) receiver).getName().equals(IDFConstants.SDKCONFIG_FILE_NAME)) + boolean isIFile = receiver instanceof IFile; + String fileName = isIFile ? ((IFile) receiver).getName() : StringUtil.EMPTY; + if (fileName.startsWith(IDFConstants.SDKCONFIG_FILE_NAME)) { return true; } diff --git a/bundles/com.espressif.idf.sdk.config.core/src/com/espressif/idf/sdk/config/core/server/ConfigServerManager.java b/bundles/com.espressif.idf.sdk.config.core/src/com/espressif/idf/sdk/config/core/server/ConfigServerManager.java index 5b49e90f8..c258fa115 100644 --- a/bundles/com.espressif.idf.sdk.config.core/src/com/espressif/idf/sdk/config/core/server/ConfigServerManager.java +++ b/bundles/com.espressif.idf.sdk.config.core/src/com/espressif/idf/sdk/config/core/server/ConfigServerManager.java @@ -7,7 +7,9 @@ import java.io.IOException; import java.util.HashMap; import java.util.Map; +import java.util.Objects; +import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IProject; /** @@ -17,16 +19,17 @@ public class ConfigServerManager { public static ConfigServerManager INSTANCE = new ConfigServerManager(); - private Map jsonServermap = new HashMap(); + private Map jsonServermap = new HashMap(); public void clearAll() { jsonServermap.clear(); } - public void deleteServer(IProject project) + public void deleteServer(IProject project, IFile file) { - jsonServermap.remove(project); + ProjectFileMapKey projectFileMapKey = new ProjectFileMapKey(project, file); + jsonServermap.remove(projectFileMapKey); } /** @@ -34,16 +37,48 @@ public void deleteServer(IProject project) * @return * @throws IOException */ - public synchronized JsonConfigServer getServer(IProject project) throws IOException - { - JsonConfigServer jsonConfigServer = jsonServermap.get(project); + public synchronized JsonConfigServer getServer(final IProject project, final IFile file) throws IOException + { + ProjectFileMapKey projectFileMapKey = new ProjectFileMapKey(project, file); + + JsonConfigServer jsonConfigServer = jsonServermap.get(projectFileMapKey); if (jsonConfigServer == null) { - jsonConfigServer = new JsonConfigServer(project); - jsonServermap.put(project, jsonConfigServer); + jsonConfigServer = new JsonConfigServer(project, file); + jsonServermap.put(projectFileMapKey, jsonConfigServer); jsonConfigServer.start(); + return jsonConfigServer; } - + return jsonConfigServer; } + + + private class ProjectFileMapKey + { + private IProject project; + private IFile file; + + private ProjectFileMapKey(IProject project, IFile file) + { + this.file = file; + this.project = project; + } + + @Override + public boolean equals(Object o) + { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + ProjectFileMapKey that = (ProjectFileMapKey) o; + + return project.getName().equals(that.project.getName()) && file.getName().equals(that.file.getName()); + } + + @Override + public int hashCode() + { + return Objects.hash(project.getName(), file.getName()); + } + } } diff --git a/bundles/com.espressif.idf.sdk.config.core/src/com/espressif/idf/sdk/config/core/server/JsonConfigServer.java b/bundles/com.espressif.idf.sdk.config.core/src/com/espressif/idf/sdk/config/core/server/JsonConfigServer.java index db6e303b7..4033fa16e 100644 --- a/bundles/com.espressif.idf.sdk.config.core/src/com/espressif/idf/sdk/config/core/server/JsonConfigServer.java +++ b/bundles/com.espressif.idf.sdk.config.core/src/com/espressif/idf/sdk/config/core/server/JsonConfigServer.java @@ -4,8 +4,10 @@ *******************************************************************************/ package com.espressif.idf.sdk.config.core.server; +import java.io.BufferedReader; import java.io.File; import java.io.FileNotFoundException; +import java.io.FileReader; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; @@ -13,6 +15,7 @@ import java.util.List; import java.util.Map; +import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IProject; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; @@ -38,12 +41,15 @@ public class JsonConfigServer implements IMessagesHandlerNotifier private IProject project; private JsonConfigServerRunnable runnable; private JsonConfigOutput configOutput; + private Process process; + private IFile file; - public JsonConfigServer(IProject project) + public JsonConfigServer(IProject project, IFile file) { this.project = project; listeners = new ArrayList(); configOutput = new JsonConfigOutput(); + this.file = file; } @Override @@ -103,7 +109,7 @@ public void start() throws IOException try { arguments = new ArrayList(Arrays.asList(pythonPath, idfPythonScriptFile.getAbsolutePath(), "-B", //$NON-NLS-1$ - IDFUtil.getBuildDir(project), IDFConstants.CONF_SERVER_CMD)); + IDFUtil.getBuildDir(project), "-DSDKCONFIG=".concat(file.getName()), IDFConstants.CONF_SERVER_CMD)); //$NON-NLS-1$ } catch (CoreException e) { @@ -118,6 +124,7 @@ public void start() throws IOException } Map environment = processBuilder.environment(); environment.putAll(idfEnvMap); + environment.put("IDF_CCACHE_ENABLE", "false"); Logger.log(environment.toString()); @@ -134,11 +141,47 @@ public void start() throws IOException // redirect error stream to input stream processBuilder.redirectErrorStream(true); - - Process process = processBuilder.start(); - runnable = new JsonConfigServerRunnable(process, this); + String oldSdkconfigValue = StringUtil.EMPTY; + try + { + oldSdkconfigValue = getCmakeCacheSdkconfigValue(); + } + catch (CoreException e) + { + Logger.log(e); + } + process = processBuilder.start(); + runnable = new JsonConfigServerRunnable(process, this, project, oldSdkconfigValue); Thread t = new Thread(runnable); t.start(); + + } + + private String getCmakeCacheSdkconfigValue() throws CoreException + { + File cmakeCacheFile = new File(IDFUtil.getBuildDir(project).concat("/CMakeCache.txt")); + if (cmakeCacheFile.exists()) + { + try (BufferedReader reader = new BufferedReader(new FileReader(cmakeCacheFile))) + { + String line; + while ((line = reader.readLine()) != null) + { + // Check if the line starts with the specific prefix + if (line.startsWith("SDKCONFIG:UNINITIALIZED=")) //$NON-NLS-1$ + { + // Replace the line + return line; + } + } + } + catch (IOException e) + { + Logger.log(e); + } + } + + return StringUtil.EMPTY; } public IJsonConfigOutput getOutput(String response, boolean isUpdate) @@ -165,4 +208,8 @@ public void addConsole(MessageConsoleStream console) this.console = console; } + public boolean isAlive() + { + return runnable.isAlive(process); + } } diff --git a/bundles/com.espressif.idf.sdk.config.core/src/com/espressif/idf/sdk/config/core/server/JsonConfigServerRunnable.java b/bundles/com.espressif.idf.sdk.config.core/src/com/espressif/idf/sdk/config/core/server/JsonConfigServerRunnable.java index 31f17503f..ebb5eb566 100644 --- a/bundles/com.espressif.idf.sdk.config.core/src/com/espressif/idf/sdk/config/core/server/JsonConfigServerRunnable.java +++ b/bundles/com.espressif.idf.sdk.config.core/src/com/espressif/idf/sdk/config/core/server/JsonConfigServerRunnable.java @@ -5,6 +5,10 @@ package com.espressif.idf.sdk.config.core.server; +import java.io.BufferedReader; +import java.io.File; +import java.io.FileReader; +import java.io.FileWriter; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; @@ -13,11 +17,14 @@ import java.util.concurrent.TimeUnit; import java.util.function.Consumer; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.runtime.CoreException; import org.json.simple.JSONObject; import org.json.simple.parser.JSONParser; import org.json.simple.parser.ParseException; import com.espressif.idf.core.logging.Logger; +import com.espressif.idf.core.util.IDFUtil; import com.espressif.idf.core.util.StringUtil; import com.espressif.idf.sdk.config.core.IJsonServerConfig; import com.espressif.idf.sdk.config.core.SDKConfigCorePlugin; @@ -34,12 +41,15 @@ public class JsonConfigServerRunnable implements Runnable private InputStream out; private CommandType type; private Process process; - - public JsonConfigServerRunnable(Process process, JsonConfigServer configServer) + private IProject project; + private String oldSdkconfigValue; + + public JsonConfigServerRunnable(Process process, JsonConfigServer configServer, IProject project, String oldSdkconfigValue) { this.process = process; this.configServer = configServer; - + this.project = project; + this.oldSdkconfigValue = oldSdkconfigValue; } public void destory() @@ -74,15 +84,7 @@ public void executeCommand(String command, CommandType type) public boolean isAlive(Process p) { - try - { - p.exitValue(); - return false; - } - catch (IllegalThreadStateException e) - { - return true; - } + return p.isAlive(); } public void run() @@ -116,6 +118,17 @@ else if (no > 0) configServer.console.print(string); configServer.console.flush(); builder.append(string); + if (string.contains("Server running")) //$NON-NLS-1$ + { + try + { + replaceOldCmakeCache(); + } + catch (CoreException e) + { + Logger.log(e); + } + } } process.waitFor(100, TimeUnit.MILLISECONDS); @@ -136,7 +149,53 @@ else if (no > 0) } } + + private void replaceOldCmakeCache() throws CoreException + { + // SDKCONFIG:UNINITIALIZED= + + File cmakeCacheFile = new File(IDFUtil.getBuildDir(project).concat("/CMakeCache.txt")); //$NON-NLS-1$ + if (cmakeCacheFile.exists() && !StringUtil.isEmpty(oldSdkconfigValue)) + { + StringBuilder contentBuilder = new StringBuilder(); + String lineSeparator = System.lineSeparator(); + + try (BufferedReader reader = new BufferedReader(new FileReader(cmakeCacheFile))) + { + String line; + while ((line = reader.readLine()) != null) + { + // Check if the line starts with the specific prefix for sdkconfig + if (line.startsWith("SDKCONFIG:UNINITIALIZED=")) //$NON-NLS-1$ + { + // Replace the line + contentBuilder.append(oldSdkconfigValue).append(lineSeparator); + } + else + { + // Keep the line unchanged + contentBuilder.append(line).append(lineSeparator); + } + } + } + catch (IOException e) + { + Logger.log(e); + } + + // Write the modified content back to the file + try (PrintWriter writer = new PrintWriter(new FileWriter(cmakeCacheFile))) + { + writer.print(contentBuilder.toString()); + } + catch (IOException e) + { + Logger.log(e); + } + } + } + protected boolean isValidJson(String output) { String jsonOutput = new JsonConfigProcessor().getInitialOutput(output); diff --git a/bundles/com.espressif.idf.sdk.config.ui/plugin.xml b/bundles/com.espressif.idf.sdk.config.ui/plugin.xml index ed5bb2872..b7ec33f83 100644 --- a/bundles/com.espressif.idf.sdk.config.ui/plugin.xml +++ b/bundles/com.espressif.idf.sdk.config.ui/plugin.xml @@ -6,10 +6,12 @@ + + + + + + diff --git a/bundles/com.espressif.idf.sdk.config.ui/src/com/espressif/idf/sdk/config/ui/ConfigContentProvider.java b/bundles/com.espressif.idf.sdk.config.ui/src/com/espressif/idf/sdk/config/ui/ConfigContentProvider.java index 45aacaa30..474dca0af 100644 --- a/bundles/com.espressif.idf.sdk.config.ui/src/com/espressif/idf/sdk/config/ui/ConfigContentProvider.java +++ b/bundles/com.espressif.idf.sdk.config.ui/src/com/espressif/idf/sdk/config/ui/ConfigContentProvider.java @@ -8,6 +8,7 @@ import java.util.ArrayList; import java.util.List; +import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IProject; import org.eclipse.jface.viewers.TreeNodeContentProvider; import org.eclipse.jface.viewers.TreeViewer; @@ -29,10 +30,12 @@ public class ConfigContentProvider extends TreeNodeContentProvider private static Object[] EMPTY_ARRAY = new Object[0]; protected TreeViewer viewer; private IProject project; - - public ConfigContentProvider(IProject project) + private IFile file; + + public ConfigContentProvider(IProject project, IFile file) { this.project = project; + this.file = file; } /* @@ -90,7 +93,7 @@ public Object[] getChildren(Object parentElement) private List getMenuItems(List children) throws IOException { - JsonConfigServer configServer = ConfigServerManager.INSTANCE.getServer(project); + JsonConfigServer configServer = ConfigServerManager.INSTANCE.getServer(project, file); List menuList = new ArrayList(); for (KConfigMenuItem kConfigMenuItem : children) { diff --git a/bundles/com.espressif.idf.sdk.config.ui/src/com/espressif/idf/sdk/config/ui/LoadSdkConfigHandler.java b/bundles/com.espressif.idf.sdk.config.ui/src/com/espressif/idf/sdk/config/ui/LoadSdkConfigHandler.java index 203640188..77ea24815 100644 --- a/bundles/com.espressif.idf.sdk.config.ui/src/com/espressif/idf/sdk/config/ui/LoadSdkConfigHandler.java +++ b/bundles/com.espressif.idf.sdk.config.ui/src/com/espressif/idf/sdk/config/ui/LoadSdkConfigHandler.java @@ -4,12 +4,11 @@ *******************************************************************************/ package com.espressif.idf.sdk.config.ui; -import java.io.IOException; - import org.eclipse.core.commands.AbstractHandler; import org.eclipse.core.commands.ExecutionEvent; import org.eclipse.core.commands.ExecutionException; import org.eclipse.core.expressions.IEvaluationContext; +import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.IAdaptable; @@ -17,8 +16,6 @@ import org.eclipse.ui.IEditorInput; import org.eclipse.ui.IEditorPart; import org.eclipse.ui.IFileEditorInput; -import org.eclipse.ui.IPageLayout; -import org.eclipse.ui.ISelectionService; import org.eclipse.ui.ISources; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.PlatformUI; @@ -41,40 +38,38 @@ public class LoadSdkConfigHandler extends AbstractHandler public Object execute(ExecutionEvent event) throws ExecutionException { - // get the selected project - IResource project = getSelectedProject(IPageLayout.ID_PROJECT_EXPLORER); - if (project == null) + // get the selected resource + IResource resource = getSelectedResource((IEvaluationContext) event.getApplicationContext()); + if (resource == null) { - project = getSelectedResource((IEvaluationContext) event.getApplicationContext()); + return resource; } - - if (project == null) + + if (!(resource instanceof IFile)) { - return project; + return resource; } - - // get the active server instance for the project - if (project instanceof IProject) + + IProject project = resource.getProject(); + IFile file = (IFile) resource; + + try { - try - { - JsonConfigServer server = ConfigServerManager.INSTANCE.getServer((IProject) project); - // load changes - JSONObject jsonObject = new JSONObject(); - jsonObject.put(IJsonServerConfig.VERSION, 2); - jsonObject.put(IJsonServerConfig.LOAD, null); - String command = jsonObject.toJSONString(); - - // execute load command - server.execute(command, CommandType.LOAD); - } - catch (IOException e) - { - throw new ExecutionException(Messages.LoadSdkConfigHandler_ErrorLoadingJsonConfigServer, e); - } - + JsonConfigServer server = ConfigServerManager.INSTANCE.getServer(project, file); + // load changes + JSONObject jsonObject = new JSONObject(); + jsonObject.put(IJsonServerConfig.VERSION, 2); + jsonObject.put(IJsonServerConfig.LOAD, null); + String command = jsonObject.toJSONString(); + + // execute load command + server.execute(command, CommandType.LOAD); } - + catch (Exception e) + { + throw new ExecutionException(Messages.LoadSdkConfigHandler_ErrorLoadingJsonConfigServer, e); + } + return null; } @@ -114,25 +109,6 @@ public static IResource getSelectedResource(IEvaluationContext evaluationContext return null; } - private static IProject getSelectedProject(String viewID) - { - ISelectionService service = getActiveWorkbenchWindow().getSelectionService(); - IStructuredSelection structured = (IStructuredSelection) service.getSelection(viewID); - if (structured instanceof IStructuredSelection) - { - Object selectedObject = structured.getFirstElement(); - if (selectedObject instanceof IAdaptable) - { - IResource resource = ((IAdaptable) selectedObject).getAdapter(IResource.class); - if (resource != null) - { - return resource.getProject(); - } - } - } - return null; - } - public static IWorkbenchWindow getActiveWorkbenchWindow() { try diff --git a/bundles/com.espressif.idf.sdk.config.ui/src/com/espressif/idf/sdk/config/ui/SDKConfigurationEditor.java b/bundles/com.espressif.idf.sdk.config.ui/src/com/espressif/idf/sdk/config/ui/SDKConfigurationEditor.java index dc5f5510e..6c4775dad 100644 --- a/bundles/com.espressif.idf.sdk.config.ui/src/com/espressif/idf/sdk/config/ui/SDKConfigurationEditor.java +++ b/bundles/com.espressif.idf.sdk.config.ui/src/com/espressif/idf/sdk/config/ui/SDKConfigurationEditor.java @@ -57,6 +57,7 @@ import org.eclipse.ui.dialogs.PatternFilter; import org.eclipse.ui.editors.text.TextEditor; import org.eclipse.ui.ide.IDE; +import org.eclipse.ui.part.FileEditorInput; import org.eclipse.ui.part.MultiPageEditorPart; import org.eclipse.ui.progress.IProgressService; import org.eclipse.ui.texteditor.AbstractTextEditor; @@ -189,6 +190,8 @@ public void run() createErrorPage(errorMsg); return; } + + setPartName(getPartName() + " (" + getFile().getName() + ")"); //$NON-NLS-1$ //$NON-NLS-2$s // 3. Build the UI createDesignPage(); @@ -249,7 +252,7 @@ private void createDesignPage() treeViewer = transfersTree.getViewer(); // Create the tree viewer as a child of the composite parent - treeViewer.setContentProvider(new ConfigContentProvider(project)); + treeViewer.setContentProvider(new ConfigContentProvider(project, getFile())); treeViewer.setLabelProvider(new ConfigLabelProvider()); treeViewer.setUseHashlookup(true); @@ -335,6 +338,11 @@ private void createErrorPage(String errorMessage) setPageText(index, Messages.SDKConfigurationEditor_Design); } + + private IFile getFile() + { + return ((FileEditorInput) getEditorInput()).getFile(); + } /** * @return current project @@ -362,7 +370,7 @@ protected void initConfigServer(IProject project) throws IOException, ParseExcep MessageConsoleStream console = new IDFConsole().getConsoleStream("JSON Configuration Server Console", null, false); //$NON-NLS-1$ - configServer = ConfigServerManager.INSTANCE.getServer(project); + configServer = ConfigServerManager.INSTANCE.getServer(project, getFile()); // register the editor with the server to notify about the events configServer.addListener(this); @@ -444,7 +452,7 @@ public void dispose() { configServer.destroy(); } - ConfigServerManager.INSTANCE.deleteServer(project); + ConfigServerManager.INSTANCE.deleteServer(project, getFile()); super.dispose(); } diff --git a/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/LaunchBarListener.java b/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/LaunchBarListener.java index f929b7e9a..5d79ef522 100644 --- a/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/LaunchBarListener.java +++ b/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/LaunchBarListener.java @@ -119,6 +119,7 @@ private void update(String newTarget) { ILaunchBarUIManager uiManager = UIPlugin.getService(ILaunchBarUIManager.class); uiManager.openConfigurationEditor(launchBarManager.getActiveLaunchDescriptor()); + deleteBuildFolder(project, buildLocation); return; } } @@ -134,32 +135,7 @@ private void update(String newTarget) project.getName(), currentTarget, newTarget)); if (isDelete) { - IWorkspaceRunnable runnable = new IWorkspaceRunnable() - { - - @Override - public void run(IProgressMonitor monitor) throws CoreException - { - - monitor.beginTask("Deleting build folder...", 1); //$NON-NLS-1$ - Logger.log("Deleting build folder " + buildLocation.getAbsolutePath()); //$NON-NLS-1$ - deleteDirectory(buildLocation); - cleanSdkConfig(project); - project.refreshLocal(IResource.DEPTH_INFINITE, monitor); - } - - }; - - // run workspace job - try - { - ResourcesPlugin.getWorkspace().run(runnable, new NullProgressMonitor()); - } - catch (Exception e1) - { - Logger.log(IDFCorePlugin.getPlugin(), "Unable to delete the build folder", //$NON-NLS-1$ - e1); - } + deleteBuildFolder(project, buildLocation); } } } @@ -174,6 +150,36 @@ public void run(IProgressMonitor monitor) throws CoreException } } + private void deleteBuildFolder(IResource project, File buildLocation) + { + IWorkspaceRunnable runnable = new IWorkspaceRunnable() + { + + @Override + public void run(IProgressMonitor monitor) throws CoreException + { + + monitor.beginTask("Deleting build folder...", 1); //$NON-NLS-1$ + Logger.log("Deleting build folder " + buildLocation.getAbsolutePath()); //$NON-NLS-1$ + deleteDirectory(buildLocation); + cleanSdkConfig(project); + project.refreshLocal(IResource.DEPTH_INFINITE, monitor); + } + + }; + + // run workspace job + try + { + ResourcesPlugin.getWorkspace().run(runnable, new NullProgressMonitor()); + } + catch (Exception e1) + { + Logger.log(IDFCorePlugin.getPlugin(), "Unable to delete the build folder", //$NON-NLS-1$ + e1); + } + } + private boolean deleteDirectory(File directoryToBeDeleted) { File[] allContents = directoryToBeDeleted.listFiles(); diff --git a/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/messages.properties b/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/messages.properties index ff258ded8..1ab067fc1 100644 --- a/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/messages.properties +++ b/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/messages.properties @@ -1,3 +1,3 @@ LaunchBarListener_TargetChanged_Msg=Current target for the project {0} has changed from {1} to {2} in the launchbar, would you like to delete the "build" folder for the project? LaunchBarListener_TargetChanged_Title=IDF Launch Target Changed -LaunchBarListener_TargetDontMatch_Msg=The selected target {0} doesn''t match the target {1} for the JTAG flashing in {2}. Do you want to change the selected board in the configuration? \ No newline at end of file +LaunchBarListener_TargetDontMatch_Msg=The selected target {0} doesn''t match the target {1} for the JTAG flashing in {2}. Do you want to change the selected board in the configuration? The sdkconfig and the "build" folder will be cleared diff --git a/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/preferences/EspresssifPreferencesPage.java b/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/preferences/EspresssifPreferencesPage.java index f036e5ca0..e85e802f5 100644 --- a/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/preferences/EspresssifPreferencesPage.java +++ b/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/preferences/EspresssifPreferencesPage.java @@ -1,7 +1,6 @@ package com.espressif.idf.ui.preferences; import org.eclipse.core.runtime.preferences.InstanceScope; -import org.eclipse.embedcdt.ui.preferences.ScopedPreferenceStoreWithoutDefaults; import org.eclipse.jface.preference.PreferencePage; import org.eclipse.swt.SWT; import org.eclipse.swt.layout.GridData; @@ -14,10 +13,12 @@ import org.eclipse.swt.widgets.Text; import org.eclipse.ui.IWorkbench; import org.eclipse.ui.IWorkbenchPreferencePage; +import org.eclipse.ui.preferences.ScopedPreferenceStore; import com.espressif.idf.core.IDFCorePlugin; import com.espressif.idf.core.IDFCorePreferenceConstants; import com.espressif.idf.core.logging.Logger; +import com.espressif.idf.core.util.StringUtil; public class EspresssifPreferencesPage extends PreferencePage implements IWorkbenchPreferencePage { @@ -35,10 +36,13 @@ public class EspresssifPreferencesPage extends PreferencePage implements IWorkbe private Button automateHintsBtn; private Button hideErrorsOnIdfComponentsBtn; + private Text gitAssetsText; + private Text pythonWheelText; + public EspresssifPreferencesPage() { super(); - setPreferenceStore(new ScopedPreferenceStoreWithoutDefaults(InstanceScope.INSTANCE, IDFCorePlugin.PLUGIN_ID)); + setPreferenceStore(new ScopedPreferenceStore(InstanceScope.INSTANCE, IDFCorePlugin.PLUGIN_ID)); setDescription(Messages.EspresssifPreferencesPage_IDFSpecificPrefs); } @@ -70,9 +74,44 @@ protected Control createContents(Composite parent) addBuildSettings(mainComposite); + addToolsInstallationSettings(mainComposite); + return mainComposite; } + private void addToolsInstallationSettings(Composite mainComposite) + { + Group toolsInstallationGroup = new Group(mainComposite, SWT.SHADOW_ETCHED_IN); + toolsInstallationGroup.setText(Messages.EspressifPreferencesPage_ToolsInstallationGrpTxt); + toolsInstallationGroup.setLayout(new GridLayout(2, false)); + + Label githubAssetsLabel = new Label(toolsInstallationGroup, SWT.NONE); + githubAssetsLabel.setText(Messages.EspressifPreferencesPage_ToolsInstallationGitAssetUrlLabel); + gitAssetsText = new Text(toolsInstallationGroup, SWT.SINGLE | SWT.BORDER); + + Label pythonWheelsLabel = new Label(toolsInstallationGroup, SWT.NONE); + pythonWheelsLabel.setText(Messages.EspressifPreferencesPage_ToolsInstallationPythonPyWheelUrlLabel); + pythonWheelText = new Text(toolsInstallationGroup, SWT.SINGLE | SWT.NONE); + + GridData gitTextGridData = new GridData(SWT.FILL, SWT.CENTER, true, false); + gitTextGridData.widthHint = 200; + GridData pythonTextGridData = new GridData(SWT.FILL, SWT.CENTER, true, false); + pythonTextGridData.widthHint = 200; + gitAssetsText.setLayoutData(gitTextGridData); + pythonWheelText.setLayoutData(pythonTextGridData); + + String gitUrl = getPreferenceStore().getString(IDFCorePreferenceConstants.IDF_GITHUB_ASSETS); + String pyWheelUrl = getPreferenceStore().getString(IDFCorePreferenceConstants.PIP_EXTRA_INDEX_URL); + gitUrl = StringUtil.isEmpty(gitUrl) + ? getPreferenceStore().getDefaultString(IDFCorePreferenceConstants.IDF_GITHUB_ASSETS) + : gitUrl; + pyWheelUrl = StringUtil.isEmpty(pyWheelUrl) + ? getPreferenceStore().getDefaultString(IDFCorePreferenceConstants.PIP_EXTRA_INDEX_URL) + : pyWheelUrl; + gitAssetsText.setText(gitUrl); + pythonWheelText.setText(pyWheelUrl); + } + private void addBuildSettings(Composite mainComposite) { Group buildGroup = new Group(mainComposite, SWT.SHADOW_ETCHED_IN); @@ -171,6 +210,10 @@ public boolean performOk() { IDFCorePlugin.ERROR_MARKER_LISTENER.initialMarkerCleanup(); } + + getPreferenceStore().setValue(IDFCorePreferenceConstants.IDF_GITHUB_ASSETS, gitAssetsText.getText()); + + getPreferenceStore().setValue(IDFCorePreferenceConstants.PIP_EXTRA_INDEX_URL, pythonWheelText.getText()); } catch (Exception e) { @@ -192,6 +235,8 @@ protected void performDefaults() .setSelection(getPreferenceStore().getBoolean(IDFCorePreferenceConstants.AUTOMATE_BUILD_HINTS_STATUS)); hideErrorsOnIdfComponentsBtn .setSelection(getPreferenceStore().getBoolean(IDFCorePreferenceConstants.HIDE_ERRORS_IDF_COMPONENTS)); + gitAssetsText.setText(getPreferenceStore().getDefaultString(IDFCorePreferenceConstants.IDF_GITHUB_ASSETS)); + pythonWheelText.setText(getPreferenceStore().getDefaultString(IDFCorePreferenceConstants.PIP_EXTRA_INDEX_URL)); } private void initializeDefaults() @@ -205,5 +250,8 @@ private void initializeDefaults() IDFCorePreferenceConstants.AUTOMATE_BUILD_HINTS_DEFAULT_STATUS); getPreferenceStore().setDefault(IDFCorePreferenceConstants.HIDE_ERRORS_IDF_COMPONENTS, IDFCorePreferenceConstants.HIDE_ERRORS_IDF_COMPONENTS_DEFAULT_STATUS); + + getPreferenceStore().setDefault(IDFCorePreferenceConstants.IDF_GITHUB_ASSETS, IDFCorePreferenceConstants.IDF_GITHUB_ASSETS_DEFAULT); + getPreferenceStore().setDefault(IDFCorePreferenceConstants.PIP_EXTRA_INDEX_URL, IDFCorePreferenceConstants.PIP_EXTRA_INDEX_URL_DEFAULT); } } diff --git a/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/preferences/Messages.java b/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/preferences/Messages.java index 7cdef0978..5d81438b1 100644 --- a/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/preferences/Messages.java +++ b/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/preferences/Messages.java @@ -18,6 +18,9 @@ public class Messages extends NLS public static String SerialMonitorPage_GroupHeading; public static String EspresssifPreferencesPage_HideErrprOnIdfComponentsBtn; public static String EspresssifPreferencesPage_HideErrprOnIdfComponentsToolTip; + public static String EspressifPreferencesPage_ToolsInstallationGrpTxt; + public static String EspressifPreferencesPage_ToolsInstallationGitAssetUrlLabel; + public static String EspressifPreferencesPage_ToolsInstallationPythonPyWheelUrlLabel; static { diff --git a/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/preferences/messages.properties b/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/preferences/messages.properties index fb49bb1db..101521c7e 100644 --- a/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/preferences/messages.properties +++ b/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/preferences/messages.properties @@ -10,3 +10,6 @@ GDBServerTimeoutPage_TimeoutField=GDB server launch timeout(s) SerialMonitorPage_Field_NumberOfCharsInLine=Console Line Width (maximum characters): SerialMonitorPage_Field_NumberOfLines=Limit Console Output (number of lines): SerialMonitorPage_GroupHeading=Serial Monitor Setting +EspressifPreferencesPage_ToolsInstallationGrpTxt=Tools Installation +EspressifPreferencesPage_ToolsInstallationGitAssetUrlLabel=Mirror for GIT (IDF_GITHUB_ASSETS) +EspressifPreferencesPage_ToolsInstallationPythonPyWheelUrlLabel=Mirror for python wheels (PIP_EXTRA_INDEX_URL) diff --git a/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/update/AbstractToolsHandler.java b/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/update/AbstractToolsHandler.java index 0a915411b..454499415 100644 --- a/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/update/AbstractToolsHandler.java +++ b/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/update/AbstractToolsHandler.java @@ -8,7 +8,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.Map.Entry; import org.eclipse.core.commands.AbstractHandler; import org.eclipse.core.commands.ExecutionEvent; @@ -25,13 +24,12 @@ import org.eclipse.ui.console.MessageConsoleStream; import com.espressif.idf.core.IDFCorePlugin; +import com.espressif.idf.core.IDFCorePreferenceConstants; import com.espressif.idf.core.IDFEnvironmentVariables; import com.espressif.idf.core.ProcessBuilderFactory; import com.espressif.idf.core.SystemExecutableFinder; -import com.espressif.idf.core.Version; import com.espressif.idf.core.logging.Logger; import com.espressif.idf.core.util.IDFUtil; -import com.espressif.idf.core.util.PyWinRegistryReader; import com.espressif.idf.core.util.StringUtil; import com.espressif.idf.ui.IDFConsole; import com.espressif.idf.ui.InputStreamConsoleThread; @@ -122,25 +120,7 @@ protected void activateIDFConsoleView() protected String getPythonExecutablePath() { - // Get Python - if (Platform.OS_WIN32.equals(Platform.getOS())) - { - PyWinRegistryReader pyWinRegistryReader = new PyWinRegistryReader(); - pythonVersions = pyWinRegistryReader.getPythonVersions(); - if (pythonVersions.isEmpty()) - { - Logger.log("No Python installations found in the system."); //$NON-NLS-1$ - } - - pythonExecutablenPath = pythonVersions.entrySet().stream().filter( - e -> new Version(e.getKey().replaceAll("-.+", StringUtil.EMPTY)).compareTo(new Version("3.6")) >= 0) //$NON-NLS-1$ //$NON-NLS-2$ - .map(Entry::getValue).findAny().orElseGet(IDFUtil::getPythonExecutable); - - } - else - { - pythonExecutablenPath = IDFUtil.getPythonExecutable(); - } + pythonExecutablenPath = IDFUtil.getPythonExecutable(); return pythonExecutablenPath; } @@ -166,7 +146,17 @@ protected IStatus runCommand(List arguments, MessageConsoleStream consol Map environment = new HashMap<>(System.getenv()); Logger.log(environment.toString()); environment.put("PYTHONUNBUFFERED", "1"); //$NON-NLS-1$ //$NON-NLS-2$ - + + environment.put("IDF_GITHUB_ASSETS", //$NON-NLS-1$ + Platform.getPreferencesService().getString(IDFCorePlugin.PLUGIN_ID, + IDFCorePreferenceConstants.IDF_GITHUB_ASSETS, + IDFCorePreferenceConstants.IDF_GITHUB_ASSETS_DEFAULT, null)); + + environment.put("PIP_EXTRA_INDEX_URL", //$NON-NLS-1$ + Platform.getPreferencesService().getString(IDFCorePlugin.PLUGIN_ID, + IDFCorePreferenceConstants.PIP_EXTRA_INDEX_URL, + IDFCorePreferenceConstants.PIP_EXTRA_INDEX_URL_DEFAULT, null)); + if (gitExecutablePath != null) { addGitToEnvironment(environment, gitExecutablePath); 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 c9cc3ac93..35e3e2cb8 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 @@ -14,15 +14,24 @@ import org.eclipse.core.runtime.IStatus; 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.events.DisposeEvent; import org.eclipse.swt.events.DisposeListener; 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; @@ -48,6 +57,7 @@ @SuppressWarnings("restriction") public class NewIDFProjectWizard extends TemplateWizard { + private static final String NEW_LAUNCH_CONFIG_EDIT_PAGE = "NewLaunchConfigEditPage"; //$NON-NLS-1$ public static final String TARGET_SWITCH_JOB = "TARGET SWITCH JOB"; //$NON-NLS-1$ private NewProjectCreationWizardPage projectCreationWizardPage; @@ -72,16 +82,17 @@ public void addPages() super.addPages(); this.setWindowTitle(Messages.NewIDFProjectWizard_NewIDFProject); - + TemplatesManager templatesManager = new TemplatesManager(); ITemplateNode templateRoot = templatesManager.getTemplates(); - projectCreationWizardPage = new NewProjectCreationWizardPage(templateRoot, Messages.NewIDFProjectWizard_TemplatesHeader); + projectCreationWizardPage = new NewProjectCreationWizardPage(templateRoot, + Messages.NewIDFProjectWizard_TemplatesHeader); ITemplateNode templateNode = templatesManager.getTemplateNode(IDFConstants.DEFAULT_TEMPLATE_ID); if (templateNode != null) { projectCreationWizardPage.setInitialTemplateId(templateNode); } - + this.addPage(projectCreationWizardPage); } @@ -101,19 +112,61 @@ public boolean performFinish() selProvider.setSelection(new StructuredSelection(project)); } } + final String target = projectCreationWizardPage.getSelectedTarget(); this.getShell().addDisposeListener(new DisposeListener() { @Override - public void widgetDisposed(DisposeEvent e) + public void widgetDisposed(DisposeEvent event) { + ILaunchBarManager launchBarManager = UIPlugin.getService(ILaunchBarManager.class); TargetSwitchJob targetSwtichJob = new TargetSwitchJob(target); targetSwtichJob.schedule(); + try + { + ILaunchDescriptor desc = launchBarManager.getActiveLaunchDescriptor(); + createDefaultDebugConfig(); + launchBarManager.setActiveLaunchDescriptor(desc); + } + catch (CoreException e) + { + Logger.log(e); + } + } }); return performFinish; } - + + 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 + { + wizard.getWorkingCopy().doSave(); + } + catch (CoreException e) + { + Logger.log(e); + } + wizard.dispose(); + } + @Override protected IGenerator getGenerator() { @@ -126,7 +179,8 @@ protected IGenerator getGenerator() manifest = null; } - IDFProjectGenerator generator = new IDFProjectGenerator(manifest, selectedTemplate, true, projectCreationWizardPage.getSelectedTarget()); + IDFProjectGenerator generator = new IDFProjectGenerator(manifest, selectedTemplate, true, + projectCreationWizardPage.getSelectedTarget()); generator.setProjectName(projectCreationWizardPage.getProjectName()); if (!projectCreationWizardPage.useDefaults()) { @@ -135,11 +189,11 @@ protected IGenerator getGenerator() return generator; } - private class TargetSwitchJob extends Job { private ILaunchBarManager launchBarManager; private String target; + public TargetSwitchJob(String target) { super(TARGET_SWITCH_JOB); @@ -147,7 +201,6 @@ public TargetSwitchJob(String target) launchBarManager = UIPlugin.getService(ILaunchBarManager.class); } - private Job findInternalJob() { for (Job job : Job.getJobManager().find(null)) @@ -157,10 +210,9 @@ private Job findInternalJob() return job; } } - + return null; } - @Override protected IStatus run(IProgressMonitor monitor) @@ -177,7 +229,7 @@ protected IStatus run(IProgressMonitor monitor) Logger.log(e1); } } - + Display.getDefault().syncExec(() -> { ILaunchTarget launchTarget = findSuitableTargetForSelectedTargetString(); try @@ -187,13 +239,13 @@ protected IStatus run(IProgressMonitor monitor) catch (CoreException e) { Logger.log(e); - } + } }); - + return Status.OK_STATUS; - + } - + private ILaunchTarget findSuitableTargetForSelectedTargetString() { ILaunchTargetManager launchTargetManager = UIPlugin.getService(ILaunchTargetManager.class); @@ -202,14 +254,13 @@ private ILaunchTarget findSuitableTargetForSelectedTargetString() for (ILaunchTarget iLaunchTarget : targets) { - String idfTarget = iLaunchTarget.getAttribute(IDFLaunchConstants.ATTR_IDF_TARGET, - null); + String idfTarget = iLaunchTarget.getAttribute(IDFLaunchConstants.ATTR_IDF_TARGET, null); if (idfTarget.contentEquals(target)) { return iLaunchTarget; } } - + return null; } } diff --git a/bundles/com.espressif.idf.wokwi/bin/.gitignore b/bundles/com.espressif.idf.wokwi/bin/.gitignore deleted file mode 100644 index c2d9872a1..000000000 --- a/bundles/com.espressif.idf.wokwi/bin/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/com/ diff --git a/features/com.espressif.idf.feature/feature.xml b/features/com.espressif.idf.feature/feature.xml index b480700dd..8e55c6a57 100644 --- a/features/com.espressif.idf.feature/feature.xml +++ b/features/com.espressif.idf.feature/feature.xml @@ -2,7 +2,7 @@ diff --git a/releng/com.espressif.idf.configuration/pom.xml b/releng/com.espressif.idf.configuration/pom.xml index f0d83ea41..c1ea617e7 100644 --- a/releng/com.espressif.idf.configuration/pom.xml +++ b/releng/com.espressif.idf.configuration/pom.xml @@ -10,7 +10,7 @@ 3.0.4 ${tycho-version} UTF-8 - 2.12.0 + 2.13.0 diff --git a/releng/com.espressif.idf.product/idf.product b/releng/com.espressif.idf.product/idf.product index cbc91a1d3..b087df044 100644 --- a/releng/com.espressif.idf.product/idf.product +++ b/releng/com.espressif.idf.product/idf.product @@ -1,7 +1,7 @@ - + diff --git a/releng/com.espressif.idf.update/category.xml b/releng/com.espressif.idf.update/category.xml index 34f7ebb09..fa1599296 100644 --- a/releng/com.espressif.idf.update/category.xml +++ b/releng/com.espressif.idf.update/category.xml @@ -90,6 +90,9 @@ + + + ESP-IDF Eclipse Plugin for developing ESP32 based IoT applications diff --git a/tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectTest.java b/tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectTest.java index 4e8f6e8dc..84b61381f 100644 --- a/tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectTest.java +++ b/tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectTest.java @@ -153,19 +153,6 @@ public void givenNewProjectCreatedAndRenamedAfterThenProjectIsBuildSuccessfully( Fixture.thenConsoleShowsBuildSuccessful(); } - @Test - public void givenNewProjectCreatedBuiltAndThenRenamedThenProjectIsBuildSuccessfully() throws Exception - { - Fixture.givenNewEspressifIDFProjectIsSelected("EspressIf", "Espressif IDF Project"); - Fixture.givenProjectNameIs("NewProjectTest"); - Fixture.whenNewProjectIsSelected(); - Fixture.whenProjectIsBuiltUsingContextMenu(); - - Fixture.whenProjectIsRenamed("NewProjectTest2"); - Fixture.whenProjectIsBuiltUsingContextMenu(); - Fixture.thenConsoleShowsBuildSuccessful(); - } - @Test public void givenNewProjectCreatedDfuBuiltThenHasDfuBin() throws Exception {