-
Notifications
You must be signed in to change notification settings - Fork 133
IEP-1268: Welcome page closed when opening ESP-IDF Manager #1005
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -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 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -29,7 +30,7 @@ public Object execute(ExecutionEvent event) throws ExecutionException | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| launchEditor(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return null; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| private void launchEditor() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Display.getDefault().asyncExec(new Runnable() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -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
+42
to
+54
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 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
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -57,7 +72,7 @@ public void run() | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| private String toolSetConfigFilePath() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| IPath path = ResourcesPlugin.getWorkspace().getRoot().getLocation(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
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.