Skip to content

Commit

Permalink
updated code to close welcome page and isolated method (#1035)
Browse files Browse the repository at this point in the history
  • Loading branch information
alirana01 authored Aug 29, 2024
1 parent 18c992b commit 7a50c53
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.launchbar.core.ILaunchBarManager;
import org.eclipse.launchbar.core.target.ILaunchTarget;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.part.ViewPart;
import org.osgi.service.prefs.BackingStoreException;

import com.espressif.idf.core.IDFConstants;
Expand Down Expand Up @@ -813,4 +817,23 @@ public static String getIDFToolsPathFromPreferences()
IDFCorePreferenceConstants.IDF_TOOLS_PATH, IDFCorePreferenceConstants.IDF_TOOLS_PATH_DEFAULT, null);
return idfToolsPath;
}

public static void closeWelcomePage(IWorkbenchWindow activeww)
{
Display.getDefault().syncExec(()-> {
if (activeww != null)
{
IWorkbenchPage page = activeww.getActivePage();
if (page != null)
{
ViewPart viewPart = (ViewPart) page.findView("org.eclipse.ui.internal.introview"); //$NON-NLS-1$
if (viewPart != null)
{
page.hideView(viewPart);
}

}
}
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.PlatformUI;

import com.espressif.idf.core.util.IDFUtil;
import com.espressif.idf.ui.wizard.NewIDFProjectWizard;

/**
Expand All @@ -18,6 +19,7 @@ public class NewProjectHandler extends AbstractHandler
@Override
public Object execute(ExecutionEvent event) throws ExecutionException
{
IDFUtil.closeWelcomePage(EclipseHandler.getActiveWorkbenchWindow());
if (!NewProjectHandlerUtil.installToolsCheck())
{
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,13 @@
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.core.util.IDFUtil;
import com.espressif.idf.ui.handlers.EclipseHandler;
import com.espressif.idf.ui.tools.manager.ESPIDFManagerEditor;

Expand All @@ -39,19 +38,8 @@ 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);
}

}
}
IDFUtil.closeWelcomePage(activeww);

try
{
File inputFile = new File(toolSetConfigFilePath());
Expand All @@ -62,7 +50,6 @@ public void run()

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

IDE.openEditor(activeww.getActivePage(), new FileEditorInput(iFile), ESPIDFManagerEditor.EDITOR_ID);
}
catch (Exception e)
Expand Down

0 comments on commit 7a50c53

Please sign in to comment.