Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IEP-1252: Add MenuConfig menu option under ESP-IDF menu list #1052

Merged
merged 1 commit into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions bundles/com.espressif.idf.sdk.config.ui/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@
</reference>
</visibleWhen>
</command>
<command
commandId="com.espressif.idf.sdk.config.ui.command.menuConfig"
icon="icons/sdkconfig.png"
label="Menu Config"
style="push">
</command>
</menuContribution>
</extension>
<extension
Expand All @@ -48,6 +54,11 @@
id="com.espressif.idf.sdk.config.ui.command.setdefault"
name="%command.name">
</command>
<command
defaultHandler="com.espressif.idf.sdk.config.ui.OpenSdkConfigEditor"
id="com.espressif.idf.sdk.config.ui.command.menuConfig"
name="Open MenuConfig">
</command>
</extension>
<extension
point="org.eclipse.core.expressions.definitions">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ public class Messages extends NLS
public static String SDKConfigurationEditor_SDKConfiguration;
public static String SDKConfigurationEditor_StartingJSONConfigServer;
public static String SDKConfigurationEditor_UnableFindKConfigFile;
public static String SDKConfigFileNotFound_ErrorMessage;
public static String SDKConfigurationFileNotFound_Title;
static
{
// initialize resource bundle
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package com.espressif.idf.sdk.config.ui;

import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.handlers.HandlerUtil;
import org.eclipse.ui.ide.IDE;

public class OpenSdkConfigEditor extends AbstractHandler
{

private static final String SDKCONFIG_FILE_NAME = "sdkconfig";

@Override
public Object execute(ExecutionEvent event) throws ExecutionException
{
IWorkbenchPage page = HandlerUtil.getActiveWorkbenchWindow(event).getActivePage();
IProject project = getCurrentProject();
try
{
IFile sdkConfigFile = project.getFile(SDKCONFIG_FILE_NAME);
if (sdkConfigFile.exists())
{
IDE.openEditor(page, sdkConfigFile);
}
else
{
MessageDialog.openError(HandlerUtil.getActiveShell(event), Messages.SDKConfigurationFileNotFound_Title,
Messages.SDKConfigFileNotFound_ErrorMessage);
}
}
catch (CoreException e)
{
throw new ExecutionException("Error opening sdkconfig file", e);
}

return null;
}

/**
* Get the currently selected project in the workspace.
*/
private IProject getCurrentProject()
{
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
IProject[] projects = root.getProjects();
for (IProject project : projects)
{
if (project.isOpen() && project.getFile(SDKCONFIG_FILE_NAME).exists())
{
return project;
}
}
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,5 @@ SDKConfigurationEditor_SaveChanges=Do you want to save the changes in the Design
SDKConfigurationEditor_SDKConfiguration=SDK Configuration
SDKConfigurationEditor_StartingJSONConfigServer=Starting JSON Configuration Server
SDKConfigurationEditor_UnableFindKConfigFile=Unable to find kconfig_menus.json in the build config folder.\n
SDKConfigFileNotFound_ErrorMessage=No sdkconfig file found in the project.
SDKConfigurationFileNotFound_Title=sdkconfig missing
Loading