Skip to content
Merged
Show file tree
Hide file tree
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 @@ -7,7 +7,7 @@
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
*
* Contributors:
* QNX - Initial API and implementation
* kondal.kolipaka@espressif.com - ESP-IDF specific build configuration
Expand Down Expand Up @@ -140,10 +140,12 @@ public class IDFBuildConfiguration extends CBuildConfiguration
public boolean isProgressSet;
private QualifiedName TIMESTAMP_COMPILE_COMMANDS_PROPERTY = new QualifiedName(null,
"timestamp:compile_commands.json"); //$NON-NLS-1$
private ILaunchConfiguration configuration;

public IDFBuildConfiguration(IBuildConfiguration config, String name) throws CoreException
{
super(config, name);
this.configuration = LAUNCH_CONFIG_PROVIDER.getActiveLaunchConfiguration();
}

public IDFBuildConfiguration(IBuildConfiguration config, String name, IToolChain toolChain)
Expand All @@ -156,6 +158,14 @@ public IDFBuildConfiguration(IBuildConfiguration config, String name, IToolChain
{
super(config, name, toolChain, launchMode);
this.toolChainFile = toolChainFile;
try
{
this.configuration = LAUNCH_CONFIG_PROVIDER.getActiveLaunchConfiguration();
}
catch (CoreException e)
{
Logger.log(e);
}
}

@Override
Expand Down Expand Up @@ -247,7 +257,6 @@ public String getProperty(String name)
{
try
{
ILaunchConfiguration configuration = LAUNCH_CONFIG_PROVIDER.getActiveLaunchConfiguration();
if (configuration != null
&& configuration.getType().getIdentifier().equals(IDFLaunchConstants.DEBUG_LAUNCH_CONFIG_TYPE))
{
Expand Down Expand Up @@ -639,7 +648,7 @@ private static String getIdfToolsPath()

/**
* Link build components(build_component_paths) from project_description.json to the project.
*
*
* @param project
* @throws Exception
*/
Expand Down Expand Up @@ -976,7 +985,7 @@ public void elementChanged(ElementChangedEvent event)
/**
* Processes the delta in order to detect whether one of the CMakeLists.txt files in the project has been modified
* and saved by the user since the last build.
*
*
* @return <code>true</code> to continue with delta processing, otherwise <code>false</code>
*/
private boolean processElementDelta(ICElementDelta delta)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,24 @@
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunchConfigurationType;
import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.jface.dialogs.PageChangingEvent;
import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.launchbar.core.ILaunchBarManager;
import org.eclipse.launchbar.core.ILaunchDescriptor;
import org.eclipse.launchbar.core.target.ILaunchTarget;
import org.eclipse.launchbar.core.target.ILaunchTargetManager;
import org.eclipse.launchbar.ui.NewLaunchConfigWizard;
import org.eclipse.launchbar.ui.NewLaunchConfigWizardDialog;
import org.eclipse.launchbar.ui.internal.dialogs.NewLaunchConfigEditPage;
import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.tools.templates.core.IGenerator;
import org.eclipse.tools.templates.ui.TemplateWizard;
import org.eclipse.ui.IViewPart;
Expand All @@ -48,6 +57,7 @@
@SuppressWarnings("restriction")
public class NewIDFProjectWizard extends TemplateWizard
{
private static final String NEW_LAUNCH_CONFIG_EDIT_PAGE = "NewLaunchConfigEditPage"; //$NON-NLS-1$
public static final String TARGET_SWITCH_JOB = "TARGET SWITCH JOB"; //$NON-NLS-1$
private NewProjectCreationWizardPage projectCreationWizardPage;

Expand All @@ -72,16 +82,17 @@ public void addPages()
super.addPages();

this.setWindowTitle(Messages.NewIDFProjectWizard_NewIDFProject);

TemplatesManager templatesManager = new TemplatesManager();
ITemplateNode templateRoot = templatesManager.getTemplates();
projectCreationWizardPage = new NewProjectCreationWizardPage(templateRoot, Messages.NewIDFProjectWizard_TemplatesHeader);
projectCreationWizardPage = new NewProjectCreationWizardPage(templateRoot,
Messages.NewIDFProjectWizard_TemplatesHeader);
ITemplateNode templateNode = templatesManager.getTemplateNode(IDFConstants.DEFAULT_TEMPLATE_ID);
if (templateNode != null)
{
projectCreationWizardPage.setInitialTemplateId(templateNode);
}

this.addPage(projectCreationWizardPage);
}

Expand All @@ -101,19 +112,61 @@ public boolean performFinish()
selProvider.setSelection(new StructuredSelection(project));
}
}

final String target = projectCreationWizardPage.getSelectedTarget();
this.getShell().addDisposeListener(new DisposeListener()
{
@Override
public void widgetDisposed(DisposeEvent e)
public void widgetDisposed(DisposeEvent event)
{
ILaunchBarManager launchBarManager = UIPlugin.getService(ILaunchBarManager.class);
TargetSwitchJob targetSwtichJob = new TargetSwitchJob(target);
targetSwtichJob.schedule();
try
{
ILaunchDescriptor desc = launchBarManager.getActiveLaunchDescriptor();
createDefaultDebugConfig();
launchBarManager.setActiveLaunchDescriptor(desc);
}
catch (CoreException e)
{
Logger.log(e);
}

}
});
return performFinish;
}


private void createDefaultDebugConfig()
{
Shell activeShell = Display.getDefault().getActiveShell();

NewLaunchConfigWizard wizard = new NewLaunchConfigWizard();
WizardDialog dialog = new NewLaunchConfigWizardDialog(activeShell, wizard);
dialog.create();

NewLaunchConfigEditPage editPage = (NewLaunchConfigEditPage) wizard.getPage(NEW_LAUNCH_CONFIG_EDIT_PAGE);
ILaunchConfigurationType debugLaunchConfigType = DebugPlugin.getDefault().getLaunchManager()
.getLaunchConfigurationType(IDFLaunchConstants.DEBUG_LAUNCH_CONFIG_TYPE);
editPage.setLaunchConfigType(debugLaunchConfigType);

PageChangingEvent pageChangingEvent = new PageChangingEvent(wizard, wizard.getStartingPage(), editPage);
editPage.handlePageChanging(pageChangingEvent);

wizard.performFinish();

try
{
wizard.getWorkingCopy().doSave();
}
catch (CoreException e)
{
Logger.log(e);
}
wizard.dispose();
}
Comment thread
sigmaaa marked this conversation as resolved.

@Override
protected IGenerator getGenerator()
{
Expand All @@ -126,7 +179,8 @@ protected IGenerator getGenerator()
manifest = null;
}

IDFProjectGenerator generator = new IDFProjectGenerator(manifest, selectedTemplate, true, projectCreationWizardPage.getSelectedTarget());
IDFProjectGenerator generator = new IDFProjectGenerator(manifest, selectedTemplate, true,
projectCreationWizardPage.getSelectedTarget());
generator.setProjectName(projectCreationWizardPage.getProjectName());
if (!projectCreationWizardPage.useDefaults())
{
Expand All @@ -135,19 +189,18 @@ protected IGenerator getGenerator()
return generator;
}


private class TargetSwitchJob extends Job
{
private ILaunchBarManager launchBarManager;
private String target;

public TargetSwitchJob(String target)
{
super(TARGET_SWITCH_JOB);
this.target = target;
launchBarManager = UIPlugin.getService(ILaunchBarManager.class);
}


private Job findInternalJob()
{
for (Job job : Job.getJobManager().find(null))
Expand All @@ -157,10 +210,9 @@ private Job findInternalJob()
return job;
}
}

return null;
}


@Override
protected IStatus run(IProgressMonitor monitor)
Expand All @@ -177,7 +229,7 @@ protected IStatus run(IProgressMonitor monitor)
Logger.log(e1);
}
}

Display.getDefault().syncExec(() -> {
ILaunchTarget launchTarget = findSuitableTargetForSelectedTargetString();
try
Expand All @@ -187,13 +239,13 @@ protected IStatus run(IProgressMonitor monitor)
catch (CoreException e)
{
Logger.log(e);
}
}
});

return Status.OK_STATUS;

}

private ILaunchTarget findSuitableTargetForSelectedTargetString()
{
ILaunchTargetManager launchTargetManager = UIPlugin.getService(ILaunchTargetManager.class);
Expand All @@ -202,14 +254,13 @@ private ILaunchTarget findSuitableTargetForSelectedTargetString()

for (ILaunchTarget iLaunchTarget : targets)
{
String idfTarget = iLaunchTarget.getAttribute(IDFLaunchConstants.ATTR_IDF_TARGET,
null);
String idfTarget = iLaunchTarget.getAttribute(IDFLaunchConstants.ATTR_IDF_TARGET, null);
if (idfTarget.contentEquals(target))
{
return iLaunchTarget;
}
}

return null;
}
}
Expand Down
1 change: 0 additions & 1 deletion bundles/com.espressif.idf.wokwi/bin/.gitignore

This file was deleted.