Skip to content
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 @@ -10,16 +10,17 @@
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.ide.IDE;
import org.eclipse.ui.part.FileEditorInput;
import org.eclipse.ui.part.ViewPart;

import com.espressif.idf.core.logging.Logger;
import com.espressif.idf.core.tools.IToolsInstallationWizardConstants;
import com.espressif.idf.ui.handlers.EclipseHandler;
import com.espressif.idf.ui.tools.manager.ESPIDFManagerEditor;


public class ManageEspIdfVersionsHandler extends AbstractHandler
{

Expand All @@ -29,7 +30,7 @@ public Object execute(ExecutionEvent event) throws ExecutionException
launchEditor();
return null;
}

private void launchEditor()
{
Display.getDefault().asyncExec(new Runnable()
Expand All @@ -38,16 +39,30 @@ private void launchEditor()
public void run()
{
IWorkbenchWindow activeww = EclipseHandler.getActiveWorkbenchWindow();
if (activeww != null)
{
IWorkbenchPage page = activeww.getActivePage();
if (page != null)
{
ViewPart viewPart = (ViewPart) page.findView("org.eclipse.ui.internal.introview");
if (viewPart != null)
{
page.hideView(viewPart);
}
Comment on lines +47 to +51

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: ViewPart casting is not necessary here. We can use IViewPart instead of ViewPart. Also, we don't need if (viewPart != null), because it's a part of the page.hideView(IViewPart) method.


}
}
Comment on lines +42 to +54

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ensure robustness in UI manipulation.

The logic to hide the welcome page is implemented correctly. However, consider adding a type check before casting the view to ViewPart to avoid potential ClassCastException.

- ViewPart viewPart = (ViewPart) page.findView("org.eclipse.ui.internal.introview");
+ IViewPart viewPart = page.findView("org.eclipse.ui.internal.introview");
+ if (viewPart instanceof ViewPart) {
+     page.hideView((ViewPart)viewPart);
+ }
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if (activeww != null)
{
IWorkbenchPage page = activeww.getActivePage();
if (page != null)
{
ViewPart viewPart = (ViewPart) page.findView("org.eclipse.ui.internal.introview");
if (viewPart != null)
{
page.hideView(viewPart);
}
}
}
if (activeww != null)
{
IWorkbenchPage page = activeww.getActivePage();
if (page != null)
{
IViewPart viewPart = page.findView("org.eclipse.ui.internal.introview");
if (viewPart instanceof ViewPart)
{
page.hideView((ViewPart)viewPart);
}
}
}

try
{
File inputFile = new File(toolSetConfigFilePath());
if (!inputFile.exists())
{
inputFile.createNewFile();
}

IFile iFile = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(inputFile.getAbsolutePath()));


IFile iFile = ResourcesPlugin.getWorkspace().getRoot()
.getFile(new Path(inputFile.getAbsolutePath()));

IDE.openEditor(activeww.getActivePage(), new FileEditorInput(iFile), ESPIDFManagerEditor.EDITOR_ID);
}
catch (Exception e)
Expand All @@ -57,7 +72,7 @@ public void run()
}
});
}

private String toolSetConfigFilePath()
{
IPath path = ResourcesPlugin.getWorkspace().getRoot().getLocation();
Expand Down