diff --git a/bundles/com.espressif.idf.sdk.config.ui/src/com/espressif/idf/sdk/config/ui/OpenSdkConfigEditor.java b/bundles/com.espressif.idf.sdk.config.ui/src/com/espressif/idf/sdk/config/ui/OpenSdkConfigEditor.java index 3cc59cca4..b6394541f 100644 --- a/bundles/com.espressif.idf.sdk.config.ui/src/com/espressif/idf/sdk/config/ui/OpenSdkConfigEditor.java +++ b/bundles/com.espressif.idf.sdk.config.ui/src/com/espressif/idf/sdk/config/ui/OpenSdkConfigEditor.java @@ -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 { @@ -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); @@ -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; - } -} \ No newline at end of file +}