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-1385 ESP-IDF:MenuConfig: feature uses any sdkconfig file if multiple projects open. #1096

Merged
merged 1 commit into from
Dec 13, 2024
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
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;

import com.espressif.idf.ui.EclipseUtil;

public class OpenSdkConfigEditor extends AbstractHandler
{

Expand All @@ -22,7 +22,7 @@ public class OpenSdkConfigEditor extends AbstractHandler
public Object execute(ExecutionEvent event) throws ExecutionException
{
IWorkbenchPage page = HandlerUtil.getActiveWorkbenchWindow(event).getActivePage();
IProject project = getCurrentProject();
IProject project = EclipseUtil.getSelectedProjectInExplorer();
try
{
IFile sdkConfigFile = project.getFile(SDKCONFIG_FILE_NAME);
Expand All @@ -43,21 +43,4 @@ public Object execute(ExecutionEvent event) throws ExecutionException

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;
}
}
}
Loading